class Collector

Properties

protected array<array-key, array<string, mixed>> $props
protected null|array{file: string, line: int} $renderSource
protected array<string, array{file: string, line: int}> $shareSources
protected null|array{name: null|string, uri: string, method: string} $route
protected array<int, string> $sharedKeys
protected string|null $routeAction
protected null|array{file: string, line: int} $actionSource
protected string|null $componentPath
protected array<string, mixed> $resolvedProps

The resolved page props, kept nested so values may be plucked per prop path.

Methods

__construct(string $component, SourceLocator $sourceLocator)

Create a new collector instance.

void
setRenderSource(string|null $file, int|null $line)

Set the source location of the render call.

void
setShareSources(array $sources)

Set the source locations of the shared prop keys.

void
setRoute(string|null $name, string $uri, string $method)

Set the route that rendered the page.

void
setSharedKeys(array $keys)

Set which top-level prop keys came from shared props.

void
addProp(string $path, PropType|null $inertiaType = null, string|null $deferGroup = null, bool $reset = false, bool $once = false, bool $live = false, string|null $mergeDirection = null, bool $deepMerge = false, bool $rescued = false)

Record a prop's Inertia wrapper type, defer group, and extended metadata.

void
setRouteAction(string|null $action, mixed $uses = null)

Store the route action and resolve its source location.

void
setComponentPath(string|null $path)

Store the resolved file path of the frontend component.

void
setResolvedProps(array $props)

Store the resolved page props. Values are plucked per prop path when the entry is built, so no work is spent flattening props that get pruned.

void
resolveRenderPropLines()

Scan the render source file to find the line number of each non-shared prop key.

array
pruneProps()

Drop deep prop paths that carry no devtools metadata. Every top-level prop is kept so nothing disappears from the tree; nested values are rendered from the recorded prop values rather than one metadata row per leaf.

bool
propHasMetadata(array $meta)

Determine if the prop carries metadata beyond its default shape.

array
extractPropValues(array $paths)

Pluck the value backing each metadata node. Nested objects are stored once under their prop path rather than duplicated as the parent object and every exploded child path (e.g. auth.user alongside auth.user.id, auth.user.name).

array
normalizePropValues(array $props)

Cast the resolved props to plain arrays and scalars so recorded values match the JSON the client received.

array
build()

Assemble the final devtools metadata array.

Details

at line 44
__construct(string $component, SourceLocator $sourceLocator)

Create a new collector instance.

Parameters

string $component
SourceLocator $sourceLocator

at line 51
void setRenderSource(string|null $file, int|null $line)

Set the source location of the render call.

Parameters

string|null $file
int|null $line

Return Value

void

at line 63
void setShareSources(array $sources)

Set the source locations of the shared prop keys.

Parameters

array $sources

Return Value

void

at line 71
void setRoute(string|null $name, string $uri, string $method)

Set the route that rendered the page.

Parameters

string|null $name
string $uri
string $method

Return Value

void

at line 85
void setSharedKeys(array $keys)

Set which top-level prop keys came from shared props.

Parameters

array $keys

Return Value

void

at line 93
void addProp(string $path, PropType|null $inertiaType = null, string|null $deferGroup = null, bool $reset = false, bool $once = false, bool $live = false, string|null $mergeDirection = null, bool $deepMerge = false, bool $rescued = false)

Record a prop's Inertia wrapper type, defer group, and extended metadata.

Parameters

string $path
PropType|null $inertiaType
string|null $deferGroup
bool $reset
bool $once
bool $live
string|null $mergeDirection
bool $deepMerge
bool $rescued

Return Value

void

at line 145
void setRouteAction(string|null $action, mixed $uses = null)

Store the route action and resolve its source location.

Parameters

string|null $action
mixed $uses

Return Value

void

at line 159
void setComponentPath(string|null $path)

Store the resolved file path of the frontend component.

Parameters

string|null $path

Return Value

void

at line 172
void setResolvedProps(array $props)

Store the resolved page props. Values are plucked per prop path when the entry is built, so no work is spent flattening props that get pruned.

Parameters

array $props

Return Value

void

at line 180
protected void resolveRenderPropLines()

Scan the render source file to find the line number of each non-shared prop key.

Return Value

void

at line 218
protected array pruneProps()

Drop deep prop paths that carry no devtools metadata. Every top-level prop is kept so nothing disappears from the tree; nested values are rendered from the recorded prop values rather than one metadata row per leaf.

Return Value

array

at line 230
protected bool propHasMetadata(array $meta)

Determine if the prop carries metadata beyond its default shape.

Parameters

array $meta

Return Value

bool

at line 245
protected array extractPropValues(array $paths)

Pluck the value backing each metadata node. Nested objects are stored once under their prop path rather than duplicated as the parent object and every exploded child path (e.g. auth.user alongside auth.user.id, auth.user.name).

Parameters

array $paths

Return Value

array

at line 270
protected array normalizePropValues(array $props)

Cast the resolved props to plain arrays and scalars so recorded values match the JSON the client received.

Parameters

array $props

Return Value

array

at line 286
array build()

Assemble the final devtools metadata array.

Return Value

array