# EventInspection

> Immutable optional diagnostics; correlation identifies an observed scope, never a listener execution.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Panel](/docs/extensions/debug-core/reference/panel/index.md) › [Event](/docs/extensions/debug-core/reference/panel/event/index.md) › EventInspection

| final class | `PHPForge\Debug\Panel\Event\EventInspection` |
| --- | --- |
| Implements | [`PHPForge\Debug\Storage\PanelRow`](/docs/extensions/debug-core/reference/storage/panelrow/index.md) |
| Source | [`src/Panel/Event/EventInspection.php`](https://github.com/php-forge/debug-core/blob/main/src/Panel/Event/EventInspection.php#L17) |

Immutable optional diagnostics; correlation identifies an observed scope, never a listener execution.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`fromArray()`](#method-fromArray) static | Hydrates event diagnostics from decoded JSON data. | `EventInspection` |
| [`getClock()`](#method-getClock) | Returns the monotonic observation time. | `EventInspection` |
| [`getContext()`](#method-getContext) | Returns the selected context fields. | `EventInspection` |
| [`getContextStatus()`](#method-getContextStatus) | Returns the context capture state. | `EventInspection` |
| [`getDepth()`](#method-getDepth) | Returns the observed nesting depth. | `EventInspection` |
| [`getPairId()`](#method-getPairId) | Returns the request-local scope identity. | `EventInspection` |
| [`getPhase()`](#method-getPhase) | Returns the lifecycle marker. | `EventInspection` |
| [`getTrace()`](#method-getTrace) | Returns the captured source frames. | `EventInspection` |
| [`getTraceStatus()`](#method-getTraceStatus) | Returns the trace capture state. | `EventInspection` |
| [`jsonSerialize()`](#method-jsonSerialize) | Returns the diagnostics for JSON serialization. | `EventInspection` |
| [`withContext()`](#method-withContext) | Returns a copy with selected context and its capture state replaced together. | `EventInspection` |
| [`withLifecycle()`](#method-withLifecycle) | Returns a copy with the complete observed lifecycle correlation replaced. | `EventInspection` |
| [`withTrace()`](#method-withTrace) | Returns a copy with the source trace and its capture state replaced together. | `EventInspection` |

## Method details

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

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

Hydrates event diagnostics from decoded JSON data.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$data` | `mixed` | Decoded event diagnostics payload. |
| `$path` | `string` | Payload path used in hydration errors. |

**Returns**

`self`: Hydrated event diagnostics.

**Throws**

- [`PHPForge\Debug\Storage\HydrationException`](/docs/extensions/debug-core/reference/storage/hydrationexception/index.md): When a value exceeds its bound or a capture state is unknown.

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

```php
public function getClock(): float|null
```

Returns the monotonic observation time.

**Returns**

`float|null`: Observation time in seconds, or `null` when no clock reading was captured.

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

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

Returns the selected context fields.

**Returns**

`array<string, string>`: Explicit adapter-selected scalar fields.

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

```php
public function getContextStatus(): string
```

Returns the context capture state.

**Returns**

`string`: One of `disabled`, `captured`, `unsupported`, or `failed`.

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

```php
public function getDepth(): int
```

Returns the observed nesting depth.

**Returns**

`int`: Nesting depth of the scope the event belongs to.

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

```php
public function getPairId(): int|null
```

Returns the request-local scope identity.

**Returns**

`int|null`: Scope identity correlating lifecycle markers, or `null` when none was observed.

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

```php
public function getPhase(): string
```

Returns the lifecycle marker.

**Returns**

`string`: `enter`, `leave`, or empty for ordinary events.

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

```php
public function getTrace(): list<string>
```

Returns the captured source frames.

**Returns**

`list<string>`: Argument-free source frames.

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

```php
public function getTraceStatus(): string
```

Returns the trace capture state.

**Returns**

`string`: One of `disabled`, `captured`, or `failed`.

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

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

Returns the diagnostics for JSON serialization.

**Returns**

`array<string, mixed>`: Serialized context, trace, capture states, and lifecycle correlation.

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

```php
public function withContext(array<string, string> $context, string $contextStatus): self
```

Returns a copy with selected context and its capture state replaced together.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$context` | `array<string, string>` | Explicit adapter-selected scalar fields, not an object dump. |
| `$contextStatus` | `string` | One of `disabled`, `captured`, `unsupported`, or `failed`. |

**Returns**

`self`: Diagnostics with the context and its capture state applied.

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

```php
public function withLifecycle(int|null $pairId, string $phase, int $depth, float|null $clock): self
```

Returns a copy with the complete observed lifecycle correlation replaced.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$pairId` | `int\|null` | Request-local scope identity; `null` means no correlation was observed. |
| `$phase` | `string` | Empty for ordinary events; `enter` or `leave` for lifecycle markers. |
| `$depth` | `int` | Observed nesting depth. |
| `$clock` | `float\|null` | Monotonic observation time in seconds, not a wall-clock timestamp. |

**Returns**

`self`: Diagnostics with the lifecycle correlation applied.

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

```php
public function withTrace(list<string> $trace, string $traceStatus): self
```

Returns a copy with the source trace and its capture state replaced together.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$trace` | `list<string>` | Argument-free source frames. |
| `$traceStatus` | `string` | One of `disabled`, `captured`, or `failed`. |

**Returns**

`self`: Diagnostics with the trace and its capture state applied.