ReflectionFile
Use Attraktiv\ReflectionFile
to retrieve a lot of information about class into the file., (*1)
, (*2)
Installation
You can install this lib using composer, (*3)
composer require funkyproject/reflection-file
or add the package to your composer.json
file directly, (*4)
Usage
use Funkyproject\ReflectionFIle;
$reflectionFile = new ReflectionFile($pathFileValid);
$reflectionFile->getName() // Namespace/ClassName
$instance = $reflectionFile->newInstance();
More information about methods are available on http://www.php.net/manual/en/class.reflectionclass.php, (*5)
If file not found, ReflectionFile
will throw a FileNotFoundException
, (*6)
If file is not a class, ReflectionFile will throw a ReflectionException
, (*7)
Tests
You can run the unit tests with the following command:, (*8)
$ cd path/to/ReflectionFile/
$ composer.phar install
$ phpunit