# DebugValue

> Represents an arbitrary PHP value as JSON-safe tagged data.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Storage](/docs/extensions/debug-core/reference/storage/index.md) › DebugValue

| final readonly class | `PHPForge\Debug\Storage\DebugValue` |
| --- | --- |
| Implements | [`JsonSerializable`](https://www.php.net/manual/en/class.jsonserializable.php) |
| Source | [`src/Storage/DebugValue.php`](https://github.com/php-forge/debug-core/blob/main/src/Storage/DebugValue.php#L38) |

Represents an arbitrary PHP value as JSON-safe tagged data.

Hydration deliberately recreates this value object rather than executable objects, resources, or closures.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-className"></span>`$className` readonly constructor | `string\|null` | Captured object class or `null` for non-object values. Default: `null`. | `DebugValue` |
| <span id="property-entries"></span>`$entries` readonly constructor | `list<array{keyType: "int"\|"string", key: int\|string, value: self}>` | Captured child values. Default: `[]`. | `DebugValue` |
| <span id="property-reason"></span>`$reason` readonly constructor | `string\|null` | Truncation or unsupported-value reason, or `null` when not applicable. Default: `null`. | `DebugValue` |
| <span id="property-resourceType"></span>`$resourceType` readonly constructor | `string\|null` | Captured resource type or `null` for non-resource values. Default: `null`. | `DebugValue` |
| <span id="property-type"></span>`$type` readonly constructor | `string` | Tagged value type. | `DebugValue` |
| <span id="property-value"></span>`$value` readonly constructor | `bool\|float\|int\|string\|null` | Captured scalar value or display label. Default: `null`. | `DebugValue` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`capture()`](#method-capture) static | Captures an arbitrary PHP value as JSON-safe tagged data. | `DebugValue` |
| [`fromArray()`](#method-fromArray) static | Hydrates a tagged debug value from decoded JSON data. | `DebugValue` |
| [`jsonSerialize()`](#method-jsonSerialize) | Returns the tagged value for JSON serialization. | `DebugValue` |
| [`toDisplayEntries()`](#method-toDisplayEntries) | Returns the entries as a plain PHP array, keeping the key types captured from the original value. | `DebugValue` |
| [`toDisplayValue()`](#method-toDisplayValue) | Returns a safe PHP representation suitable for existing dump and table renderers. | `DebugValue` |

## Method details

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

```php
public static function capture(mixed $value): self
```

Captures an arbitrary PHP value as JSON-safe tagged data.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `mixed` | PHP value to capture. |

**Returns**

`self`: Tagged debug value.

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

```php
public static function fromArray(mixed $data, string $path = '$'): self
```

Hydrates a tagged debug value from decoded JSON data.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$data` | `mixed` | Decoded tagged value. |
| `$path` | `string` | Payload path used in hydration errors. |

**Returns**

`self`: Hydrated debug value.

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

```php
public function jsonSerialize(): array<string, mixed>
```

Returns the tagged value for JSON serialization.

**Returns**

`array<string, mixed>`: Tagged debug value payload.

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

```php
public function toDisplayEntries(): array<int|string, mixed>
```

Returns the entries as a plain PHP array, keeping the key types captured from the original value.

**Returns**

`array<int|string, mixed>`: Display-safe child values retaining captured key types.

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

```php
public function toDisplayValue(): mixed
```

Returns a safe PHP representation suitable for existing dump and table renderers.

**Returns**

`mixed`: Display-safe PHP value.