SourceLocator
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
Find the first caller frame outside of this package, the framework and vendor code.
Get the directory holding the framework packages, when this package is installed among them.
Resolve the source location of a shared prop key by scanning the share() method.
Determine if the method body contains the given text.
Resolve the first plausible line of a share() method body, used as a fallback when a specific prop key line cannot be found.
Read the lines of the given source file.
Find the source line where a prop key is defined in an array literal.
Resolve the route action source location when possible.
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.
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.
at line 83
array|null
resolveShareSource(ReflectionMethod $reflection, string $key)
Resolve the source location of a shared prop key by scanning the share() method.
at line 115
bool
methodBodyContains(ReflectionMethod $reflection, string $needle)
Determine if the method body contains the given text.
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.
at line 174
array|null
readSourceLines(string|null $file)
Read the lines of the given source file.
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.
at line 221
array|null
resolveActionSource(string|null $action, mixed $uses = null)
Resolve the route action source location when possible.
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.