class SourceLocator

Resolves source-code locations for devtools: the caller frame of a share()/render() call, the line a prop key is defined on, the share() method body, and a route action's reflection. Pure lookup, no collector or request state.

Properties

protected array<string, null|array<int, string>> $fileCache

Methods

array|null
captureCallerSource()

Find the first caller frame outside of this package, the framework and vendor code.

string|null
frameworkDirectory()

Get the directory holding the framework packages, when this package is installed among them.

array|null
resolveShareSource(ReflectionMethod $reflection, string $key)

Resolve the source location of a shared prop key by scanning the share() method.

bool
methodBodyContains(ReflectionMethod $reflection, string $needle)

Determine if the method body contains the given text.

array|null
shareSourceFallback(ReflectionMethod $reflection)

Resolve the first plausible line of a share() method body, used as a fallback when a specific prop key line cannot be found.

array|null
readSourceLines(string|null $file)

Read the lines of the given source file.

int|null
findPropKeyLine(string $file, int $startLine, string $key, int|null $endLine = null)

Find the source line where a prop key is defined in an array literal.

array|null
resolveActionSource(string|null $action, mixed $uses = null)

Resolve the route action source location when possible.

reflectAction(string $action, mixed $uses)

Reflect a route action, covering closures, controller methods, array callables, and invokable controllers.

Details

at line 31
array|null captureCallerSource()

Find the first caller frame outside of this package, the framework and vendor code.

Return Value

array|null

at line 70
protected string|null frameworkDirectory()

Get the directory holding the framework packages, when this package is installed among them.

In the components repository or a path-linked checkout, framework frames such as facades, macros, the router and middleware are outside vendor and would be reported as the caller.

Return Value

string|null

at line 83
array|null resolveShareSource(ReflectionMethod $reflection, string $key)

Resolve the source location of a shared prop key by scanning the share() method.

Parameters

ReflectionMethod $reflection
string $key

Return Value

array|null

at line 115
bool methodBodyContains(ReflectionMethod $reflection, string $needle)

Determine if the method body contains the given text.

Parameters

ReflectionMethod $reflection
string $needle

Return Value

bool

at line 145
array|null shareSourceFallback(ReflectionMethod $reflection)

Resolve the first plausible line of a share() method body, used as a fallback when a specific prop key line cannot be found.

Parameters

ReflectionMethod $reflection

Return Value

array|null

at line 174
array|null readSourceLines(string|null $file)

Read the lines of the given source file.

Parameters

string|null $file

Return Value

array|null

at line 196
int|null findPropKeyLine(string $file, int $startLine, string $key, int|null $endLine = null)

Find the source line where a prop key is defined in an array literal.

Parameters

string $file
int $startLine
string $key
int|null $endLine

Return Value

int|null

at line 221
array|null resolveActionSource(string|null $action, mixed $uses = null)

Resolve the route action source location when possible.

Parameters

string|null $action
mixed $uses

Return Value

array|null

at line 251
static protected ReflectionFunctionAbstract|null reflectAction(string $action, mixed $uses)

Reflect a route action, covering closures, controller methods, array callables, and invokable controllers.

Parameters

string $action
mixed $uses

Return Value

ReflectionFunctionAbstract|null