alex-oleshkevich / classnames
A missing class name extractor from PHP files.
Installs: 27 324
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=5.4
Requires (Dev)
This package is auto-updated.
Last update: 2024-10-24 17:40:33 UTC
README
This library extracts entity names from php files.
Supports plain classes, multiple entity per file, classes within curly namespaces, etc.
Installation
composer install alex-oleshkevich/classnames
Example
$extractor = new \ClassNames\ClassNames; $classes = $extractor->getClassNames('/path/to/file.php'); // or $interfaces = $extractor->getInterfaceNames('/path/to/file.php'); // or $traits = $extractor->getTraitNames('/path/to/file.php');
All functions listed above return a plain array of found entities.
// file "/path/to/file.php" namespace TestAsset { class Asset {} class Asset2 {} } $extractor = new \ClassNames\ClassNames; $classes = $extractor->getClassNames('/path/to/file.php'); print_r($classes); /** * Array * ( * [0] => TestAsset\Asset * [1] => TestAsset\Asset2 * ) */