src/Core/CommandCollector.php
private function getAllClassesFromPhpFile($pathToPhpFile)
    {
        $classesBefore = get_declared_classes();
        try {
            require_once $pathToPhpFile;
        } catch (\Throwable $exception) {
            print "Can not add Command $pathToPhpFile:\n";
            print $exception->getMessage() . "\n";
        }
        $classesAfter = get_declared_classes();
        $newClasses = array_diff($classesAfter, $classesBefore);
        if(count($newClasses) > 1) {
            //try to find the correct class name to use
            //this avoids warnings when module developer use there own command base class, that is not instantiable
            $name = basename($pathToPhpFile,'.php');
            foreach ($newClasses as $newClass) {
                if ($newClass == $name){
                    return [$newClass];
                }
            }
        }

        return $newClasses;
    }
private function getAllClassesFromPhpFile($pathToPhpFile)
    {
        $classesBefore = get_declared_classes();
        try {
            require_once $pathToPhpFile;
        } catch (\Throwable $exception) {
            print "Can not add Command $pathToPhpFile:\n";
            print $exception->getMessage() . "\n";
        }
        $classesAfter = get_declared_classes();
        $newClasses = array_diff($classesAfter, $classesBefore);
        if(count($newClasses) > 1) {
            //try to find the correct class name to use
            //this avoids warnings when module developer use there own command base class, that is not instantiable
            $name = basename($pathToPhpFile,'.php');
            foreach ($newClasses as $newClass) {
                if ($newClass == $name){
                    return [$newClass];
                }
            }
        }

        return $newClasses;
    }
private function getAllClassesFromPhpFile ( $ pathToPhpFile ) { $ classesBefore = get_declared_classes ( ) ; try { require_once $ pathToPhpFile ; } catch ( \ Throwable $ exception ) { print "Can not add Command $pathToPhpFile:\n" ; print $ exception -> getMessage ( ) . "\n" ; } $ classesAfter = get_declared_classes ( ) ; $ newClasses = array_diff ( $ classesAfter , $ classesBefore ) ; if ( count ( $ newClasses ) > 1 ) { //try to find the correct class name to use //this avoids warnings when module developer use there own command base class, that is not instantiable $ name = basename ( $ pathToPhpFile , '.php' ) ; foreach ( $ newClasses as $ newClass ) { if ( $ newClass == $ name ) { return [ $ newClass ] ; } } } return $ newClasses ; }
Get list of defined classes from given PHP file.

@param string $pathToPhpFile

@return string[]
Get list of defined classes from given PHP file .