Skip to content
🔮 Better Reflection is a reflection API that aims to improve and provide more features than PHP's built-in reflection API.
Branch: master
Clone or download
asgrim Merge pull request #482 from kukulich/phpstorm-stubs
Removed wrong classes and functions from PHPStorm stubs map
Latest commit f86b8f9 Jun 12, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Removed wrong classes and functions from PHPStorm stubs map Jun 11, 2019
demo 'parsing-whole-directory' examples are referenced in check-demo.sh Sep 16, 2018
docs Usage example: reflecting sources from a `composer.json`-based project Apr 22, 2019
src Merge pull request #482 from kukulich/phpstorm-stubs Jun 12, 2019
test Make source stubber required parameter in EvaledCodeSourceLocator and… Jun 11, 2019
.gitattributes PhpInternalSourceLocator is not based on internal reflection anymore May 14, 2019
.gitignore Fixed .gitignore Apr 24, 2019
.scrutinizer.yml Added scrutinizer configs Jul 9, 2015
.travis.yml Merge pull request #474 from kukulich/php74 May 27, 2019
CONTRIBUTING.md Use HTTPS instead of HTTP Feb 14, 2018
LICENSE Happy new year Jan 2, 2017
README.md AppVeyor is dead, long live Travis Apr 22, 2019
UPGRADE.md Make source stubber required parameter in EvaledCodeSourceLocator and… Jun 11, 2019
composer.json Bump phpunit/phpunit from 8.1.5 to 8.1.6 Jun 1, 2019
composer.lock Bump phpunit/phpunit from 8.1.5 to 8.1.6 Jun 1, 2019
phpbench.json Introduced PHPBench with sample benchmark Sep 2, 2017
phpcs.xml.dist PhpInternalSourceLocator is not based on internal reflection anymore May 14, 2019
phpstan.neon Added ReflectionConstant May 20, 2019
phpunit.xml.dist Prefix namespaces with Roave Nov 30, 2016
psalm.xml PhpInternalSourceLocator is not based on internal reflection anymore May 14, 2019

README.md

Better Reflection

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version License

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
  • Better Reflection analyses the DocBlocks (using phpdocumentor/type-resolver)
  • 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
  • Change or remove PHP 7 parameter type and return type declarations from methods and functions
  • Change the body of a function or method to do something different
  • Moar stuff coming soon!

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())
    ->classReflector()
    ->reflect(\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.

You can’t perform that action at this time.