wyrihaximus / list-classes-in-directory
Allows you to list full qualified class names in directories and files.
Fund package maintenance!
WyriHaximus
Installs: 167 679
Dependents: 8
Suggesters: 0
Security: 0
Stars: 24
Watchers: 3
Forks: 3
Open Issues: 4
Requires
- php: ^8.2
- roave/better-reflection: ^6.5
Requires (Dev)
- wyrihaximus/test-utilities: ^6.0.9
- dev-master
- 1.7.0
- 1.6.0
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.0
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.0
- dev-dependabot/composer/symfony/process-7.1.7
- dev-dependabot/composer/symfony/validator-7.1.7
- dev-dependabot/add-v2-config-file
- dev-dependabot/composer/composer/composer-1.10.22
- dev-dependabot/composer/roave/better-reflection-4.3.0
- dev-appveyor-php-7.3
- dev-support-better-reflection-3-and-2-part-deux
- dev-support-better-reflection-3-and-2
This package is auto-updated.
Last update: 2024-12-06 16:16:43 UTC
README
Install
To install via Composer, use the command below, it will automatically detect the latest version and bind it with ^
.
composer require wyrihaximus/list-classes-in-directory
Usage
get a list of classes from multiple directories.
use function WyriHaximus\Lister; // $classes now contains a list of full qualified class names from 'src/' and 'tests/' $classes = Lister::classesInDirectories( __DIR__ . '/src', __DIR__ . '/tests' ); // use listInstantiatableClassesInDirectories() or listNonInstantiatableClassesInDirectories() to only consider classes that can actually be instantiated, or not. $instantiatableClasses = Lister::instantiatableClassesInDirectory( __DIR__ . '/src', __DIR__ . '/tests' ); $nonInstantiatableClasses = Lister::nonInstantiatableClassesInDirectory( __DIR__ . '/src', __DIR__ . '/tests' );
get a list of classes from one directory.
use function WyriHaximus\Lister; // $classes now contains a list of full qualified class names from __DIR__ $classes = Lister::classesInDirectory(__DIR__); // use listInstantiatableClassesInDirectory() or listNonInstantiatableClassesInDirectory() to only consider classes that can actually be instantiated, or not. $instantiatableClasses = Lister::instantiatableClassesInDirectory(__DIR__); $nonInstantiatableClasses = Lister::nonInstantiatableClassesInDirectory(__DIR__);
get a list of classes from multiple files.
use function WyriHaximus\Lister; // $classes now contains a list of full qualified class names from 'Bar.php' and 'Foo.php' $classes = Lister::classesInFiles( __DIR__ . '/Bar.php', __DIR__ . '/Foo.php' );
get a list of classes from one file.
use function WyriHaximus\Lister; // $classes now contains a list of full qualified class names from 'Foo.php' $classes = Lister::classesInFile(__DIR__.'/Foo.php');
Acknowledgement
This package is a shorthand function for using better reflection
and is based on one of the examples
.
License
The MIT License (MIT)
Copyright (c) 2024 Cees-Jan Kiewiet
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.