# PrintRParser

> Parses the output of print_r($value, true) for an array, object, or enum into a PHPForge\Debug\Panel\Log\DumpNode tree.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Panel](/docs/extensions/debug-core/reference/panel/index.md) › [Log](/docs/extensions/debug-core/reference/panel/log/index.md) › PrintRParser

| final class | `PHPForge\Debug\Panel\Log\PrintRParser` |
| --- | --- |
| Source | [`src/Panel/Log/PrintRParser.php`](https://github.com/php-forge/debug-core/blob/main/src/Panel/Log/PrintRParser.php#L27) |

Parses the output of `print_r($value, true)` for an array, object, or enum into a [`DumpNode`](/docs/extensions/debug-core/reference/panel/log/dumpnode/index.md) tree.

Only the root header may carry free text before it, such as `Request: Array`. Any other deviation from the
`print_r()` layout, or an exceeded bound, yields `null`; the parser never throws.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`parse()`](#method-parse) static | Parses a `print_r()` dump of an array, object, or enum. | `PrintRParser` |

## Constants

| Constant | Value | Description | Defined by |
| --- | --- | --- | --- |
| <span id="const-MAX_BYTES"></span>`MAX_BYTES` | `262144` | Maximum size of a parsed message, in bytes, shared with [`PhpExportTokenizer`](/docs/extensions/debug-core/reference/panel/log/phpexporttokenizer/index.md). | `PrintRParser` |
| <span id="const-MAX_DEPTH"></span>`MAX_DEPTH` | `32` | Maximum nesting level of blocks, the root block included, shared with the export classes and [`DumpNode`](/docs/extensions/debug-core/reference/panel/log/dumpnode/index.md). | `PrintRParser` |
| <span id="const-MAX_NODES"></span>`MAX_NODES` | `5000` | Maximum number of values, the root block included, shared with [`PhpExportParser`](/docs/extensions/debug-core/reference/panel/log/phpexportparser/index.md) and [`DumpNode`](/docs/extensions/debug-core/reference/panel/log/dumpnode/index.md). | `PrintRParser` |

## Method details

### parse() <span id="method-parse"></span>

```php
public static function parse(string $message): PHPForge\Debug\Panel\Log\DumpNode|null
```

Parses a `print_r()` dump of an array, object, or enum.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$message` | `string` |  |

**Returns**

[`DumpNode`](/docs/extensions/debug-core/reference/panel/log/dumpnode/index.md)`|null`: Root block, with the free text preceding its header as [`DumpNode::$text`](/docs/extensions/debug-core/reference/panel/log/dumpnode/index.md#property-text), or `null` for an unsupported message.