Adds the ability to reverse-engineer classes, interfaces, functions, constants, namespaces, traits and more.
PHP Reflect is a library that adds the ability to reverse-engineer classes, interfaces, functions, constants, namespaces, traits and more.
Both were distributed as source code (install via composer) and a PHAR version that bundles all dependencies in a single file.
Follow development on the official Blog.
Have a look on branch 2.6 for previous stable API 2.0
You can either :
download the phar version 3.1.1
install via packagist the current source dev-master or the stable version 3.1.1
The documentation for PHP Reflect 3.1 is available in English to read it online or download to read it later (multiple formats).
AsciiDoc source code are available on
docs folder of the repository.
Contributions to source code and its documentation are always welcome.
As developper, I’m always happy when I have the more informations as possible to check and find out issues. This is the reason why I’ve created a PHPUnit TestSuite Listener for compatible PSR-3 Loggers.
And recently, for the php-compatinfo project, I’ve wrote a new PHPUnit ResultPrinter class, that is based on PSR-3 logger concept. You can learn more on this post in the CompatInfo’s blog.
If you want to use it, then :
install all the components via Composer
$ php composer.phar require --dev bartlett/php-reflect
phpunit.xmlfile with at least following contents :
<?xml version="1.0" encoding="UTF-8"?> <phpunit backupGlobals="true" backupStaticAttributes="false" bootstrap="tests/bootstrap.dev.php" colors="true" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnRisky="false" stopOnSkipped="false" verbose="true" printerClass="Bartlett\Tests\Reflect\ResultPrinter" > <filter> <whitelist> <directory suffix=".php">src/</directory> </whitelist> </filter> <testsuites> <testsuite name="Reflect Test Suite"> <directory suffix="Test.php">tests/</directory> </testsuite> </testsuites> </phpunit>
configure the PSR-3 logger in
tests\MonologConsoleLogger.php, if you want to change some behaviors.
phpunit-phpreflect-php<PHP_VERSION_ID>.logand log events corresponding to PHPUnit mode (
--debug) to the console. Note If you’ve a Growl client installed and running, you will be notified at end of tests run. Output look like
PHPUnit 4.6.6 by Sebastian Bergmann and contributors. Configuration read from C:\home\github\php-reflect\phpunit.xml Reflect Test Suite: Test suite started with 122 tests Bartlett\Tests\Reflect\Analyser\AnalyserManagerTest: Test suite started with 8 tests Bartlett\Tests\Reflect\Analyser\AnalyserManagerTest: Test suite ended. Results OK. Tests: 8, Assertions: 8 Bartlett\Tests\Reflect\EnvironmentTest: Test suite started with 8 tests Bartlett\Tests\Reflect\EnvironmentTest: Test suite ended. Results OK. Tests: 8, Assertions: 11 Bartlett\Tests\Reflect\Model\ClassModelTest: Test suite started with 31 tests Test 'testIterateableClassByInheritance' is incomplete. Not yet fully implemented (FIXME) Test 'testSubclassOfInterface' is incomplete. Not yet fully implemented (FIXME) Test 'testSubclassOfClass' is incomplete. Not yet fully implemented (FIXME) Bartlett\Tests\Reflect\Model\ClassModelTest: Test suite ended. Results OK. Tests: 28, Assertions: 28, Incomplete: 3 Bartlett\Tests\Reflect\Model\ConstantModelTest: Test suite started with 11 tests Bartlett\Tests\Reflect\Model\ConstantModelTest: Test suite ended. Results OK. Tests: 11, Assertions: 11 Bartlett\Tests\Reflect\Model\FunctionModelTest: Test suite started with 15 tests Bartlett\Tests\Reflect\Model\FunctionModelTest: Test suite ended. Results OK. Tests: 15, Assertions: 15 Bartlett\Tests\Reflect\Model\IssueTest: Test suite started with 1 tests Bartlett\Tests\Reflect\Model\IssueTest: Test suite ended. Results OK. Tests: 1, Assertions: 2 Bartlett\Tests\Reflect\Model\MethodModelTest: Test suite started with 19 tests Bartlett\Tests\Reflect\Model\MethodModelTest: Test suite ended. Results OK. Tests: 19, Assertions: 19 Bartlett\Tests\Reflect\Model\ParameterModelTest: Test suite started with 18 tests Bartlett\Tests\Reflect\Model\ParameterModelTest: Test suite ended. Results OK. Tests: 18, Assertions: 18 Bartlett\Tests\Reflect\Model\PropertyModelTest: Test suite started with 11 tests Bartlett\Tests\Reflect\Model\PropertyModelTest: Test suite ended. Results OK. Tests: 11, Assertions: 11 Reflect Test Suite: Test suite ended. Results OK. Tests: 119, Assertions: 123, Incomplete: 3 Time: 2.94 seconds, Memory: 14.75Mb Results OK. Tests: 122, Assertions: 123, Incomplete: 3