Created
April 2, 2019 12:03
-
-
Save asgrim/e2cd7aeb17c88bbd3ebafeeaa8041678 to your computer and use it in GitHub Desktop.
Get all the classes and functions in a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
use Roave\BetterReflection\BetterReflection; | |
use Roave\BetterReflection\Reflector\ClassReflector; | |
use Roave\BetterReflection\Reflector\FunctionReflector; | |
use Roave\BetterReflection\SourceLocator\Type\SingleFileSourceLocator; | |
$fileName = 'my-file-with-stuff.php'; | |
$sourceLocator = new SingleFileSourceLocator($fileName, (new BetterReflection())->astLocator()); | |
$classReflector = new ClassReflector($sourceLocator); | |
$allTheClasses = $classReflector->getAllClasses(); | |
$allTheFunctions = (new FunctionReflector($sourceLocator, $classReflector))->getAllFunctions(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment