A PHP reflection API that improves upon the native one with features like reflecting on unloaded classes and extracting ASTs.
Better Reflection is a PHP library that provides an enhanced reflection API with more features than PHP's built-in reflection. It allows developers to inspect classes, functions, and closures without loading them, extract abstract syntax trees, and access detailed type information for static analysis purposes.
PHP developers building static analysis tools, code generators, IDE plugins, or any tool requiring deep introspection of PHP code without execution.
Developers choose Better Reflection over the native PHP reflection API because it offers advanced capabilities like reflecting on unloaded classes, analyzing code from strings, and extracting ASTs, which are essential for static analysis and development tooling.
:crystal_ball: Better Reflection is a reflection API that aims to improve and provide more features than PHP's built-in reflection API.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows analysis of classes without loading them into memory, essential for static analysis tools that inspect codebases without execution.
Provides access to abstract syntax trees from methods, functions, and closures, enabling deep code inspection and manipulation for tooling.
Fetches detailed type declarations including PHP 7+ features, improving the accuracy of static analysis and code generation.
Can reflect on closures and parse classes directly from PHP code strings, offering flexibility for various analysis scenarios.
Significantly slower than PHP's native reflection API, making it impractical for performance-sensitive runtime applications, as admitted in the README.
Cannot statically reflect on functions due to PHP's autoloading limitations, restricting its use in function-centric analysis tools, as noted in the limitations section.
Requires familiarity with advanced reflection concepts and ASTs, which may pose a steep learning curve for developers new to static analysis, despite detailed documentation.