public static function getClasses($namespace, $conditions = [])
	{
		self::_setupRoot();

		$namespace = explode('\\', trim($namespace, '\\'));
		
		$composerNamespaces = self::getComposerNamespaces();
		$searchPaths = [];
		
		// for each Composer namespace, assess whether it may contain the namespace $namespace.
		foreach ( $composerNamespaces as $ns => $paths )
		{
			$nsTrimmed = explode('\\', trim($ns, '\\'));
			for ( $i = min(count($nsTrimmed), count($namespace)); $i > 0; $i-- ) {
				if ( array_slice($nsTrimmed, 0, $i) === array_slice($namespace, 0, $i) ) {
					$searchPaths[] = [
							'prefix' => $nsTrimmed
							, 'paths' => $paths
						];
					
					continue;
				}
			}
		}
		
		// $searchPaths now contains a list of PSR-4 namespaces we must search for
		// classes under the namespace $namespace.
		
		// FIXME crawling everything under the sun is potentially very time-consuming. It would make a lot of
		// sense to be able to generate a cache classes specifying what interfaces each class implements, etc.
		
		$result = [];
		foreach ( $searchPaths as $pathspec ) {
			foreach ( $pathspec['paths'] as $path ) {
				// Determine the path under which the namespace we are searching for will exist for this pathspace
				$path = $path
						. DIRECTORY_SEPARATOR
						. implode(DIRECTORY_SEPARATOR, array_slice($namespace, count($pathspec['prefix'])));
						
				$prefix = count($pathspec['prefix']) > count($namespace) ? implode('\\', $pathspec['prefix']) : implode('\\', $namespace);
						
				// if that path exists, go ahead and search it for class files and append them to the result.
				if ( is_dir($path) ) {
					$result = array_merge($result, self::searchPath($prefix, rtrim($path, DIRECTORY_SEPARATOR), $conditions));
				}
			}
		}
		
		return $result;
	}
public static function getClasses($namespace, $conditions = [])
	{
		self::_setupRoot();

		$namespace = explode('\\', trim($namespace, '\\'));
		
		$composerNamespaces = self::getComposerNamespaces();
		$searchPaths = [];
		
		// for each Composer namespace, assess whether it may contain the namespace $namespace.
		foreach ( $composerNamespaces as $ns => $paths )
		{
			$nsTrimmed = explode('\\', trim($ns, '\\'));
			for ( $i = min(count($nsTrimmed), count($namespace)); $i > 0; $i-- ) {
				if ( array_slice($nsTrimmed, 0, $i) === array_slice($namespace, 0, $i) ) {
					$searchPaths[] = [
							'prefix' => $nsTrimmed
							, 'paths' => $paths
						];
					
					continue;
				}
			}
		}
		
		// $searchPaths now contains a list of PSR-4 namespaces we must search for
		// classes under the namespace $namespace.
		
		// FIXME crawling everything under the sun is potentially very time-consuming. It would make a lot of
		// sense to be able to generate a cache classes specifying what interfaces each class implements, etc.
		
		$result = [];
		foreach ( $searchPaths as $pathspec ) {
			foreach ( $pathspec['paths'] as $path ) {
				// Determine the path under which the namespace we are searching for will exist for this pathspace
				$path = $path
						. DIRECTORY_SEPARATOR
						. implode(DIRECTORY_SEPARATOR, array_slice($namespace, count($pathspec['prefix'])));
						
				$prefix = count($pathspec['prefix']) > count($namespace) ? implode('\\', $pathspec['prefix']) : implode('\\', $namespace);
						
				// if that path exists, go ahead and search it for class files and append them to the result.
				if ( is_dir($path) ) {
					$result = array_merge($result, self::searchPath($prefix, rtrim($path, DIRECTORY_SEPARATOR), $conditions));
				}
			}
		}
		
		return $result;
	}
public static function getClasses ( $ namespace , $ conditions = [ ] ) { self :: _setupRoot ( ) ; $ namespace = explode ( '\\' , trim ( $ namespace , '\\' ) ) ; $ composerNamespaces = self :: getComposerNamespaces ( ) ; $ searchPaths = [ ] ; // for each Composer namespace, assess whether it may contain the namespace $namespace. foreach ( $ composerNamespaces as $ ns => $ paths ) { $ nsTrimmed = explode ( '\\' , trim ( $ ns , '\\' ) ) ; for ( $ i = min ( count ( $ nsTrimmed ) , count ( $ namespace ) ) ; $ i > 0 ; $ i -- ) { if ( array_slice ( $ nsTrimmed , 0 , $ i ) === array_slice ( $ namespace , 0 , $ i ) ) { $ searchPaths [ ] = [ 'prefix' => $ nsTrimmed , 'paths' => $ paths ] ; continue ; } } } // $searchPaths now contains a list of PSR-4 namespaces we must search for // classes under the namespace $namespace. // FIXME crawling everything under the sun is potentially very time-consuming. It would make a lot of // sense to be able to generate a cache classes specifying what interfaces each class implements, etc. $ result = [ ] ; foreach ( $ searchPaths as $ pathspec ) { foreach ( $ pathspec [ 'paths' ] as $ path ) { // Determine the path under which the namespace we are searching for will exist for this pathspace $ path = $ path . DIRECTORY_SEPARATOR . implode ( DIRECTORY_SEPARATOR , array_slice ( $ namespace , count ( $ pathspec [ 'prefix' ] ) ) ) ; $ prefix = count ( $ pathspec [ 'prefix' ] ) > count ( $ namespace ) ? implode ( '\\' , $ pathspec [ 'prefix' ] ) : implode ( '\\' , $ namespace ) ; // if that path exists, go ahead and search it for class files and append them to the result. if ( is_dir ( $ path ) ) { $ result = array_merge ( $ result , self :: searchPath ( $ prefix , rtrim ( $ path , DIRECTORY_SEPARATOR ) , $ conditions ) ) ; } } } return $ result ; }
Return a list of classes under a given namespace. It is an error to enumerate the root namespace.
@param string Namespace name. Trailing backslash may be omitted.
@param Limiting rules. An array of constraints on the returned results. Currently
the only supported constraints are "implements" (string - class name) and "abstract"
(boolean).
Use it: [ ['implements' => 'Some\Interface', 'abstract' => false] ]
@return array
@static
Return a list of classes under a given namespace . It is an error to enumerate the root namespace .