roave/better-reflection
Enhanced PHP reflection for static analysis: reflect classes without loading them, from PHP code strings or closures, extract AST from functions/methods, and read type declarations and docblocks. Feature-rich but slower than native reflection.
Purely an ease-of-use API, the FindReflectionOnLine helper simplifies usage when you want to find a reflection on a
specific line. Usage is clean, as the class is an invokable class:
<?php
$finder = (new \Roave\BetterReflection\BetterReflection())->findReflectionsOnLine();
$reflection = $finder('path/to/my/file.php', 10);
The helper will return null if no reflection is found, or may return one of:
\Roave\BetterReflection\Reflection\ReflectionClass (for interfaces, classes, traits)\Roave\BetterReflection\Reflection\ReflectionMethod\Roave\BetterReflection\Reflection\ReflectionFunctionHow can I help you explore Laravel packages today?