public function discover()
    {
        $classes = [];

        foreach ($this->doFileSearch() as $file) {
            $classinfo = $this->parse($file);
            $classname = $classinfo['class'];
            $classpath = $file->getRealPath() ?: "$classname.php";

            if (!empty($this->searchMatches)) {
                foreach ($this->searchMatches as $type => $value) {
                    if (!isset($classinfo[$type])) {
                        continue;
                    }
                    $instances = !is_array($classinfo[$type])
                        ? [$classinfo[$type]]
                        : $classinfo[$type];

                    $matches = array_intersect($value, $instances);

                    if (empty($matches)) {
                        continue;
                    }

                    $classes[$classpath] = $classname;
                }
            } else {
                $classes[$classpath] = $classname;
            }
        }

        $this->requireClasses($classes);

        return $classes;
    }
public function discover()
    {
        $classes = [];

        foreach ($this->doFileSearch() as $file) {
            $classinfo = $this->parse($file);
            $classname = $classinfo['class'];
            $classpath = $file->getRealPath() ?: "$classname.php";

            if (!empty($this->searchMatches)) {
                foreach ($this->searchMatches as $type => $value) {
                    if (!isset($classinfo[$type])) {
                        continue;
                    }
                    $instances = !is_array($classinfo[$type])
                        ? [$classinfo[$type]]
                        : $classinfo[$type];

                    $matches = array_intersect($value, $instances);

                    if (empty($matches)) {
                        continue;
                    }

                    $classes[$classpath] = $classname;
                }
            } else {
                $classes[$classpath] = $classname;
            }
        }

        $this->requireClasses($classes);

        return $classes;
    }
public function discover ( ) { $ classes = [ ] ; foreach ( $ this -> doFileSearch ( ) as $ file ) { $ classinfo = $ this -> parse ( $ file ) ; $ classname = $ classinfo [ 'class' ] ; $ classpath = $ file -> getRealPath ( ) ? : "$classname.php" ; if ( ! empty ( $ this -> searchMatches ) ) { foreach ( $ this -> searchMatches as $ type => $ value ) { if ( ! isset ( $ classinfo [ $ type ] ) ) { continue ; } $ instances = ! is_array ( $ classinfo [ $ type ] ) ? [ $ classinfo [ $ type ] ] : $ classinfo [ $ type ] ; $ matches = array_intersect ( $ value , $ instances ) ; if ( empty ( $ matches ) ) { continue ; } $ classes [ $ classpath ] = $ classname ; } } else { $ classes [ $ classpath ] = $ classname ; } } $ this -> requireClasses ( $ classes ) ; return $ classes ; }
Discover PHP classed based on searching criteria.

@return array
An array of class namespaces keyed by the PHP file path.
Discover PHP classed based on searching criteria .