Collector
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
Set the source location of the render call.
Set the source locations of the shared prop keys.
Set the route that rendered the page.
Set which top-level prop keys came from shared props.
Record a prop's Inertia wrapper type, defer group, and extended metadata.
Store the route action and resolve its source location.
Store the resolved file path of the frontend component.
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.
Scan the render source file to find the line number of each non-shared prop key.
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.
Determine if the prop carries metadata beyond its default shape.
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).
Cast the resolved props to plain arrays and scalars so recorded values match the JSON the client received.
Assemble the final devtools metadata array.
Details
at line 44
__construct(string $component, SourceLocator $sourceLocator)
Create a new collector instance.
at line 51
void
setRenderSource(string|null $file, int|null $line)
Set the source location of the render call.
at line 63
void
setShareSources(array $sources)
Set the source locations of the shared prop keys.
at line 71
void
setRoute(string|null $name, string $uri, string $method)
Set the route that rendered the page.
at line 85
void
setSharedKeys(array $keys)
Set which top-level prop keys came from shared props.
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.
at line 145
void
setRouteAction(string|null $action, mixed $uses = null)
Store the route action and resolve its source location.
at line 159
void
setComponentPath(string|null $path)
Store the resolved file path of the frontend component.
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.
at line 180
protected void
resolveRenderPropLines()
Scan the render source file to find the line number of each non-shared prop key.
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.
at line 230
protected bool
propHasMetadata(array $meta)
Determine if the prop carries metadata beyond its default shape.
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).
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.
at line 286
array
build()
Assemble the final devtools metadata array.