PHP code example of jerowork / file-class-reflector
1. Go to this page and download the library: Download jerowork/file-class-reflector library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jerowork / file-class-reflector example snippets
use Jerowork\FileClassReflector\NikicParser\NikicParserClassReflectorFactory;
// Create a new ClassReflector instance directly via a static factory method
$reflector = NikicParserClassReflectorFactory::createInstance();
// Add necessary directories and/or files and reflect
$reflector
->addDirectory(__DIR__ . '/some/directory')
->reflect();
// Get all \ReflectionClass found in files
$classes = $reflector->getClasses();
use Jerowork\FileClassReflector\FileFinder\RegexIterator\RegexIteratorFileFinder;
use Jerowork\FileClassReflector\NikicParser\NikicParserClassReflectorFactory;
use PhpParser\NodeTraverser;
use PhpParser\ParserFactory;
// Create the factory
$factory = new NikicParserClassReflectorFactory(
new RegexIteratorFileFinder(),
(new ParserFactory())->create(ParserFactory::PREFER_PHP7),
new NodeTraverser(),
);
// Create a new ClassReflector instance
$reflector = $factory->create();
// ...
use Jerowork\FileClassReflector\ClassReflectorFactory;
use Jerowork\FileClassReflector\FileFinder\FileFinder;
use Jerowork\FileClassReflector\FileFinder\RegexIterator\RegexIteratorFileFinder;
use Jerowork\FileClassReflector\NikicParser\NikicParserClassReflectorFactory;
use PhpParser\NodeTraverser;
use PhpParser\ParserFactory;
use Psr\Container\ContainerInterface;
return [
ClassReflectorFactory::class => static function (ContainerInterface $container): ClassReflectorFactory {
return new NikicParserClassReflectorFactory(
new RegexIteratorFileFinder(),
(new ParserFactory())->create(ParserFactory::PREFER_PHP7),
new NodeTraverser(),
);
},
FileFinder::class => static fn (): FileFinder => new RegexIteratorFileFinder(),
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.