Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Roave/BetterReflection
:crystal_ball: Better Reflection is a reflection API that aims to improve and provide more features than PHP's built-in reflection API.
https://github.com/Roave/BetterReflection
hacktoberfest
Last synced: 3 months ago
JSON representation
:crystal_ball: Better Reflection is a reflection API that aims to improve and provide more features than PHP's built-in reflection API.
- Host: GitHub
- URL: https://github.com/Roave/BetterReflection
- Owner: Roave
- License: mit
- Created: 2015-06-04T11:02:42.000Z (over 9 years ago)
- Default Branch: 6.37.x
- Last Pushed: 2024-05-22T11:40:14.000Z (6 months ago)
- Last Synced: 2024-05-22T17:36:17.719Z (6 months ago)
- Topics: hacktoberfest
- Language: PHP
- Homepage:
- Size: 7.31 MB
- Stars: 1,159
- Watchers: 29
- Forks: 129
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-php - Better Reflection - AST-based reflection library that allows analysis and manipulation of code (Table of Contents / Code Analysis)
- awesome-php-cn - Better Reflection - 基于ast的反射库,允许分析和 代码操作 (目录 / 代码分析 Code Analysis)
- awesome-projects - Better Reflection - AST-based reflection library that allows analysis and manipulation of code (PHP / Code Analysis)
- php-awesome - BetterReflection - 基于AST的反射库,允许分析操作代码 (类库 / 代码检查/静态分析)
- awesome-php - Better Reflection - AST-based reflection library that allows analysis and manipulation of code (Table of Contents / Code Analysis)
README
Better Reflection
=================[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FRoave%2FBetterReflection%2F6.6.x)](https://dashboard.stryker-mutator.io/reports/github.com/Roave/BetterReflection/6.6.x)
[![Type Coverage](https://shepherd.dev/github/Roave/BetterReflection/coverage.svg)](https://shepherd.dev/github/Roave/BetterReflection)
[![Latest Stable Version](https://poser.pugx.org/roave/better-reflection/v/stable)](https://packagist.org/packages/roave/better-reflection)
[![License](https://poser.pugx.org/roave/better-reflection/license)](https://packagist.org/packages/roave/better-reflection)Better Reflection is a reflection API that aims to improve and provide more features than PHP's built-in
[reflection API](https://php.net/manual/en/book.reflection.php).## 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](docs/features.md).
## Installation
Require using composer:
```shell
composer require roave/better-reflection
```## Usage
```php
reflector()
->reflectClass(\Foo\Bar\MyClass::class);
```## Documentation
* [Compatibility with core Reflection API](docs/compatibility.md)
* [Basic usage instructions](docs/usage.md)
* [Using types](docs/types.md)
* [The features](docs/features.md)
* [Test suite](https://github.com/Roave/BetterReflection/blob/master/test/README.md)## Upgrading
Please refer to the [Upgrade Documentation](UPGRADE.md) 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](LICENSE).
## Contributing
If you wish to contribute to the project, please read the [CONTRIBUTING notes](CONTRIBUTING.md).