Download the PHP package delolmo/class-finder without Composer
On this page you can find all versions of the php package delolmo/class-finder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download delolmo/class-finder
More information about delolmo/class-finder
Files in delolmo/class-finder
Package class-finder
Short Description Find the instantiable PHP classes in a directory, optionally filtered by parent class or interface.
License MIT
Homepage https://github.com/delolmo/class-finder
Informations about the package class-finder
delolmo/class-finder
Find the instantiable classes declared in a directory, optionally narrowed to the subclasses or implementations of a given type.
Requirements
- PHP ~8.4.27 || ^8.5.12
Installation
Usage
Both methods return a list of class names. findByClassName() is typed with a template, so static analysers know $handlers is a list<class-string<HandlerInterface>>.
Filtering the files
The constructor takes an optional Symfony\Component\Finder\Finder to use as a template. Every search runs on a fresh copy of it, so its filters apply to every call while the directories of one call never leak into the next:
A custom PhpParser\Parser can be passed as the second argument.
What is found
- Every named class a file declares, several per file included.
- Only instantiable classes: abstract classes, classes with a non-public constructor, interfaces, traits and enums are left out.
- Only autoloadable classes. Checking this runs the autoloader, which loads the file: scan only directories whose files are safe to include.
- Files that cannot be read or do not parse are skipped.
All versions of class-finder with dependencies
nikic/php-parser Version ^5.9
symfony/finder Version ^7.4 || ^8.0