src/Loops/Application.php
public function definedClasses() {
        $loops = $this->getLoops();

        $cache = $loops->getService("cache");

        $key = "Loops-Application-definedClasses";

        if($cache->contains($key)) {
            return $cache->fetch($key);
        }

        $require = function($dir) use (&$require, &$classes) {
            foreach(scandir($dir) as $file) {
                if(substr($file, 0, 1) == '.') {
                    continue;
                }

                $filename = "$dir/$file";

                if(is_dir($filename)) {
                    $require($filename);
                }
                else {
                    require_once($filename);
                }
            }
        };

        $dirs = $this->include_dir;

        array_walk($dirs, $require);

        $classes = array_values(array_filter(get_declared_classes(), function($classname) use ($dirs, $cache) {
            $reflection = new ReflectionClass($classname);
            $filename = $reflection->getFileName();

            if(!$filename) {
                return FALSE;
            }

            if($this->enable_cached_autoload) {
                $key = "Loops-Application-autoload-$classname";
                $cache->save($key, $filename);
            }

            foreach($dirs as $dir) {
                if(substr($filename, 0, strlen($dir)) == $dir) {
                    return TRUE;
                }
            }

            return FALSE;
        }));

        $cache->save($key, $classes);

        return $classes;
    }
public function definedClasses() {
        $loops = $this->getLoops();

        $cache = $loops->getService("cache");

        $key = "Loops-Application-definedClasses";

        if($cache->contains($key)) {
            return $cache->fetch($key);
        }

        $require = function($dir) use (&$require, &$classes) {
            foreach(scandir($dir) as $file) {
                if(substr($file, 0, 1) == '.') {
                    continue;
                }

                $filename = "$dir/$file";

                if(is_dir($filename)) {
                    $require($filename);
                }
                else {
                    require_once($filename);
                }
            }
        };

        $dirs = $this->include_dir;

        array_walk($dirs, $require);

        $classes = array_values(array_filter(get_declared_classes(), function($classname) use ($dirs, $cache) {
            $reflection = new ReflectionClass($classname);
            $filename = $reflection->getFileName();

            if(!$filename) {
                return FALSE;
            }

            if($this->enable_cached_autoload) {
                $key = "Loops-Application-autoload-$classname";
                $cache->save($key, $filename);
            }

            foreach($dirs as $dir) {
                if(substr($filename, 0, strlen($dir)) == $dir) {
                    return TRUE;
                }
            }

            return FALSE;
        }));

        $cache->save($key, $classes);

        return $classes;
    }
public function definedClasses ( ) { $ loops = $ this -> getLoops ( ) ; $ cache = $ loops -> getService ( "cache" ) ; $ key = "Loops-Application-definedClasses" ; if ( $ cache -> contains ( $ key ) ) { return $ cache -> fetch ( $ key ) ; } $ require = function ( $ dir ) use ( & $ require , & $ classes ) { foreach ( scandir ( $ dir ) as $ file ) { if ( substr ( $ file , 0 , 1 ) == '.' ) { continue ; } $ filename = "$dir/$file" ; if ( is_dir ( $ filename ) ) { $ require ( $ filename ) ; } else { require_once ( $ filename ) ; } } } ; $ dirs = $ this -> include_dir ; array_walk ( $ dirs , $ require ) ; $ classes = array_values ( array_filter ( get_declared_classes ( ) , function ( $ classname ) use ( $ dirs , $ cache ) { $ reflection = new ReflectionClass ( $ classname ) ; $ filename = $ reflection -> getFileName ( ) ; if ( ! $ filename ) { return FALSE ; } if ( $ this -> enable_cached_autoload ) { $ key = "Loops-Application-autoload-$classname" ; $ cache -> save ( $ key , $ filename ) ; } foreach ( $ dirs as $ dir ) { if ( substr ( $ filename , 0 , strlen ( $ dir ) ) == $ dir ) { return TRUE ; } } return FALSE ; } ) ) ; $ cache -> save ( $ key , $ classes ) ; return $ classes ; }
Get a list of all classnames that are defined in the app directory

@return array<string> The list of all classes.
Get a list of all classnames that are defined in the app directory