PHP code example of lighth7015 / runtime-class-info

1. Go to this page and download the library: Download lighth7015/runtime-class-info 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/ */

    

lighth7015 / runtime-class-info example snippets


use function WyriHaximus\listClassesInDirectories;
use function WyriHaximus\listInstantiatableClassesInDirectories;
use function WyriHaximus\listNonInstantiatableClassesInDirectories;

// $classes now contains a list of full qualified class names from 'src/' and 'tests/'
$classes = listClassesInDirectories(
    __DIR__ . '/src',
    __DIR__ . '/tests'
);


// use listInstantiatableClassesInDirectories() or listNonInstantiatableClassesInDirectories() to only consider classes that can actually be instantiated, or not.
$instantiatableClasses = listInstantiatableClassesInDirectory(
    __DIR__ . '/src', 
    __DIR__ . '/tests'
);
$nonInstantiatableClasses = listNonInstantiatableClassesInDirectory(
    __DIR__ . '/src', 
    __DIR__ . '/tests'
);

use function WyriHaximus\listClassesInDirectory;
use function WyriHaximus\listInstantiatableClassesInDirectory;
use function WyriHaximus\listNonInstantiatableClassesInDirectory;

// $classes now contains a list of full qualified class names from __DIR__
$classes = listClassesInDirectory(__DIR__);

// use listInstantiatableClassesInDirectory() or listNonInstantiatableClassesInDirectory() to only consider classes that can actually be instantiated, or not.
$instantiatableClasses = listInstantiatableClassesInDirectory(__DIR__);
$nonInstantiatableClasses = listNonInstantiatableClassesInDirectory(__DIR__);


use function WyriHaximus\listClassesInFiles;

// $classes now contains a list of full qualified class names from 'Bar.php' and 'Foo.php'
$classes = listClassesInFiles(
    __DIR__ . '/Bar.php',
    __DIR__ . '/Foo.php'
);

use function WyriHaximus\listClassesInFile;

// $classes now contains a list of full qualified class names from 'Foo.php'
$classes = listClassesInFile(__DIR__.'/Foo.php');