private function getClasses($directory)
    {
        $classes = [];
        $directoryList = [];
        $includedFiles = [];

        $finder = new Finder();
        try {
            $finder->in($directory)->files()->name('*.php');
        } catch (\InvalidArgumentException $e) {
            return [[], []];
        }

        foreach ($finder as $file) {
            $directoryList[$file->getPath()] = true;
            $sourceFile = $file->getRealpath();
            if (!preg_match('(^phar:)i', $sourceFile)) {
                $sourceFile = realpath($sourceFile);
            }

            require_once $sourceFile;
            $includedFiles[$sourceFile] = true;
        }

        $declared = get_declared_classes();
        foreach ($declared as $className) {
            $reflectionClass = new \ReflectionClass($className);
            $sourceFile = $reflectionClass->getFileName();

            if ($reflectionClass->isAbstract()) {
                continue;
            }

            if (method_exists($reflectionClass, 'isAnonymous') && $reflectionClass->isAnonymous()) {
                continue;
            }

            if (isset($includedFiles[$sourceFile])) {
                $classes[$className] = true;
            }
        }

        return [array_keys($classes), $directoryList];
    }
private function getClasses($directory)
    {
        $classes = [];
        $directoryList = [];
        $includedFiles = [];

        $finder = new Finder();
        try {
            $finder->in($directory)->files()->name('*.php');
        } catch (\InvalidArgumentException $e) {
            return [[], []];
        }

        foreach ($finder as $file) {
            $directoryList[$file->getPath()] = true;
            $sourceFile = $file->getRealpath();
            if (!preg_match('(^phar:)i', $sourceFile)) {
                $sourceFile = realpath($sourceFile);
            }

            require_once $sourceFile;
            $includedFiles[$sourceFile] = true;
        }

        $declared = get_declared_classes();
        foreach ($declared as $className) {
            $reflectionClass = new \ReflectionClass($className);
            $sourceFile = $reflectionClass->getFileName();

            if ($reflectionClass->isAbstract()) {
                continue;
            }

            if (method_exists($reflectionClass, 'isAnonymous') && $reflectionClass->isAnonymous()) {
                continue;
            }

            if (isset($includedFiles[$sourceFile])) {
                $classes[$className] = true;
            }
        }

        return [array_keys($classes), $directoryList];
    }
private function getClasses ( $ directory ) { $ classes = [ ] ; $ directoryList = [ ] ; $ includedFiles = [ ] ; $ finder = new Finder ( ) ; try { $ finder -> in ( $ directory ) -> files ( ) -> name ( '*.php' ) ; } catch ( \ InvalidArgumentException $ e ) { return [ [ ] , [ ] ] ; } foreach ( $ finder as $ file ) { $ directoryList [ $ file -> getPath ( ) ] = true ; $ sourceFile = $ file -> getRealpath ( ) ; if ( ! preg_match ( '(^phar:)i' , $ sourceFile ) ) { $ sourceFile = realpath ( $ sourceFile ) ; } require_once $ sourceFile ; $ includedFiles [ $ sourceFile ] = true ; } $ declared = get_declared_classes ( ) ; foreach ( $ declared as $ className ) { $ reflectionClass = new \ ReflectionClass ( $ className ) ; $ sourceFile = $ reflectionClass -> getFileName ( ) ; if ( $ reflectionClass -> isAbstract ( ) ) { continue ; } if ( method_exists ( $ reflectionClass , 'isAnonymous' ) && $ reflectionClass -> isAnonymous ( ) ) { continue ; } if ( isset ( $ includedFiles [ $ sourceFile ] ) ) { $ classes [ $ className ] = true ; } } return [ array_keys ( $ classes ) , $ directoryList ] ; }
Gets the list of class names in the given directory.

@param string $directory

@return array
Gets the list of class names in the given directory .