ondrejmirtes / better-reflection
Better Reflection - an improved code reflection API
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- jetbrains/phpstorm-stubs: dev-master#217ed9356d07ef89109d3cd7d8c5df10aab4b0d4
- nikic/php-parser: ^5.3.1
Requires (Dev)
- doctrine/coding-standard: ^12.0.0
- phpstan/phpstan: ^1.10.60
- phpstan/phpstan-phpunit: ^1.3.16
- phpunit/phpunit: ^11.4.3
- rector/rector: 0.14.3
Suggests
- composer/composer: Required to use the ComposerSourceLocator
Conflicts
- thecodingmachine/safe: <1.1.3
- 350.x-dev
- 6.43.x-dev
- 6.43.0.2
- 6.43.0.1
- 6.43.0.0
- 6.42.x-dev
- 6.42.0.11
- 6.42.0.10
- 6.42.0.9
- 6.42.0.8
- 6.42.0.7
- 6.42.0.6
- 6.42.0.5
- 6.42.0.4
- 6.42.0.3
- 6.42.0.2
- 6.42.0.1
- 6.42.0
- 6.41.0
- 6.40.0
- 6.39.0
- 6.38.0
- 6.37.0
- 6.36.0
- 6.35.0
- 6.34.0
- 6.33.0
- 6.32.0
- 6.31.0
- 6.30.0
- 6.29.0
- 6.28.0
- 6.27.0
- 6.26.0
- 6.25.x-dev
- 6.25.0.21
- 6.25.0.20
- 6.25.0.19
- 6.25.0.18
- 6.25.0.17
- 6.25.0.16
- 6.25.0.15
- 6.25.0.14
- 6.25.0.13
- 6.25.0.12
- 6.25.0.11
- 6.25.0.10
- 6.25.0.9
- 6.25.0.8
- 6.25.0.7
- 6.25.0.6
- 6.25.0.5
- 6.25.0.4
- 6.25.0.3
- 6.25.0.2
- 6.25.0.1
- 6.25.0
- 6.24.0
- 6.23.0
- 6.22.0
- 6.21.x-dev
- 6.21.0
- 6.20.0.1
- 6.20.0
- 6.19.0
- 6.18.0
- 6.17.x-dev
- 6.17.0
- 6.16.0
- 6.15.0
- 6.14.x-dev
- 6.14.0.8
- 6.14.0.7
- 6.14.0.6
- 6.14.0.5
- 6.14.0.4
- 6.14.0.3
- 6.14.0.2
- 6.14.0.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 4.3.46
- 4.3.45
- 4.3.44
- 4.3.43
- 4.3.42
- 4.3.41
- 4.3.40
- 4.3.39
- 4.3.38
- 4.3.37
- 4.3.36
- 4.3.35
- 4.3.34
- 4.3.33
- 4.3.32
- 4.3.31
- 4.3.30
- 4.3.29
- 4.3.28
- 4.3.27
- 4.3.26
- 4.3.25
- 4.3.24
- 4.3.23
- 4.3.22
- 4.3.21
- 4.3.20
- 4.3.19
- 4.3.18
- 4.3.17
- 4.3.16
- 4.3.15
- 4.3.14
- 4.3.13
- 4.3.12
- 4.3.11
- 4.3.10
- 4.3.9
- 4.3.8
- 4.3.7
- 4.3.6
- 4.3.5
- 4.3.4
- 4.3.3
- 4.3.2
- 4.3.1
- 4.3.0
- 4.2.16
- 4.2.15
- 4.2.14
- 4.2.13
- 4.2.12
- 4.2.11
- 4.2.10
- 4.2.9
- 4.2.8
- 4.2.7
- 4.2.6
- 4.2.5
- 4.2.4
- 4.2.3
- 4.2.2
- 4.2.1
- 4.2.0
- 4.1.0
- 4.0.1-RC1
- 4.0.0
- 3.5.6
- 3.5.5
- 3.5.4
- 3.5.3
- 3.5.2
- 3.5.1
- 3.5.0
- 3.4.0
- 3.3.0
- 3.2.x-dev
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.x-dev
- 3.0.0
- 2.0.2
- 2.0.1
- 2.0.0
- 1.2.0
- 1.1.0
- 1.0.1
- 1.0.0
- 0.1.0
- dev-CurloptFtpSsl
- dev-fix-enum
- dev-patch-1
- dev-6.1.x-opti
- dev-circular-failing-test
- dev-fix-phar-autoload
- dev-fix-union-null
- dev-memory-leak
- dev-failing-test
- dev-fix-enum-properties
- dev-fix-traits
- dev-fix-trait-method
- dev-enum-failing
- dev-legacy
- dev-generic-identifier-type
- dev-class-const-unpack
- dev-fix-name
- dev-phpstan
- dev-reproduce-574
- dev-reproduce-573
- dev-fix-cs
- dev-dependabot/composer/phpunit/phpunit-8.4.3
- dev-dependabot/composer/nikic/php-parser-4.3.0
- dev-implement-newInstanceArgs
This package is auto-updated.
Last update: 2024-11-19 19:32:57 UTC
README
Better Reflection is a reflection API that aims to improve and provide more features than PHP's built-in reflection API.
Why is it better?
- You can reflect on classes that are not already loaded, without loading them
- Ability to reflect on classes directly from a string of PHP code
- Reflecting directly on closures
- Ability to extract AST from methods and functions
- Ability to return AST representation of a class or function
- Fetch return type declaration and parameter type declarations in PHP 7 code
- Moar stuff coming soon!
Typically you would use Better Reflection for static analysis tooling. It can serve as a baseline to access type information (e.g. doc blocks, type declarations), method/function body AST fetching etc. for static analysis.
Better Reflection is NOT suited to runtime usage, since performance is much worse than PHP built-in reflection. If you do not want to do anything that native PHP reflection can't do, then just use native PHP reflection! The "Better" in Better Reflection refers to feature, not speed!
Be sure to read more in the feature documentation.
Installation
Require using composer:
composer require roave/better-reflection
Usage
<?php use Roave\BetterReflection\BetterReflection; $classInfo = (new BetterReflection()) ->reflector() ->reflectClass(\Foo\Bar\MyClass::class);
Documentation
Upgrading
Please refer to the Upgrade Documentation documentation to see what is required to upgrade your installed
BetterReflection
version.
Limitations
- PHP cannot autoload functions, therefore we cannot statically reflect functions
License
This package is released under the MIT license.
Contributing
If you wish to contribute to the project, please read the CONTRIBUTING notes.