public static function classes(array $options = []) {
		$defaults = ['group' => 'classes', 'file' => null];
		$options += $defaults;

		$list = get_declared_classes();
		$files = get_included_files();
		$classes = [];

		if ($file = $options['file']) {
			$loaded = static::_instance('collection', ['data' => array_map(
				function($class) { return new ReflectionClass($class); }, $list
			)]);
			$classFiles = $loaded->getFileName();

			if (in_array($file, $files) && !in_array($file, $classFiles)) {
				return [];
			}
			if (!in_array($file, $classFiles)) {
				include $file;
				$list = array_diff(get_declared_classes(), $list);
			} else {
				$filter = function($class) use ($file) { return $class->getFileName() === $file; };
				$list = $loaded->find($filter)->map(function ($class) {
					return $class->getName() ?: $class->name;
				}, ['collect' => false]);
			}
		}

		foreach ($list as $class) {
			$inspector = new ReflectionClass($class);

			if ($options['group'] === 'classes') {
				$inspector->getFileName() ? $classes[$class] = $inspector->getFileName() : null;
			} elseif ($options['group'] === 'files') {
				$classes[$inspector->getFileName()][] = $inspector;
			}
		}
		return $classes;
	}
public static function classes(array $options = []) {
		$defaults = ['group' => 'classes', 'file' => null];
		$options += $defaults;

		$list = get_declared_classes();
		$files = get_included_files();
		$classes = [];

		if ($file = $options['file']) {
			$loaded = static::_instance('collection', ['data' => array_map(
				function($class) { return new ReflectionClass($class); }, $list
			)]);
			$classFiles = $loaded->getFileName();

			if (in_array($file, $files) && !in_array($file, $classFiles)) {
				return [];
			}
			if (!in_array($file, $classFiles)) {
				include $file;
				$list = array_diff(get_declared_classes(), $list);
			} else {
				$filter = function($class) use ($file) { return $class->getFileName() === $file; };
				$list = $loaded->find($filter)->map(function ($class) {
					return $class->getName() ?: $class->name;
				}, ['collect' => false]);
			}
		}

		foreach ($list as $class) {
			$inspector = new ReflectionClass($class);

			if ($options['group'] === 'classes') {
				$inspector->getFileName() ? $classes[$class] = $inspector->getFileName() : null;
			} elseif ($options['group'] === 'files') {
				$classes[$inspector->getFileName()][] = $inspector;
			}
		}
		return $classes;
	}
public static function classes ( array $ options = [ ] ) { $ defaults = [ 'group' => 'classes' , 'file' => null ] ; $ options += $ defaults ; $ list = get_declared_classes ( ) ; $ files = get_included_files ( ) ; $ classes = [ ] ; if ( $ file = $ options [ 'file' ] ) { $ loaded = static :: _instance ( 'collection' , [ 'data' => array_map ( function ( $ class ) { return new ReflectionClass ( $ class ) ; } , $ list ) ] ) ; $ classFiles = $ loaded -> getFileName ( ) ; if ( in_array ( $ file , $ files ) && ! in_array ( $ file , $ classFiles ) ) { return [ ] ; } if ( ! in_array ( $ file , $ classFiles ) ) { include $ file ; $ list = array_diff ( get_declared_classes ( ) , $ list ) ; } else { $ filter = function ( $ class ) use ( $ file ) { return $ class -> getFileName ( ) === $ file ; } ; $ list = $ loaded -> find ( $ filter ) -> map ( function ( $ class ) { return $ class -> getName ( ) ? : $ class -> name ; } , [ 'collect' => false ] ) ; } } foreach ( $ list as $ class ) { $ inspector = new ReflectionClass ( $ class ) ; if ( $ options [ 'group' ] === 'classes' ) { $ inspector -> getFileName ( ) ? $ classes [ $ class ] = $ inspector -> getFileName ( ) : null ; } elseif ( $ options [ 'group' ] === 'files' ) { $ classes [ $ inspector -> getFileName ( ) ] [ ] = $ inspector ; } } return $ classes ; }
Gets an array of classes and their corresponding definition files, or examines a file and
returns the classes it defines.

@param array $options Option consists of:
- `'group'`: Can be `classes` for grouping by class name or `files` for grouping by
filename.
- `'file': Valid file path for inspecting the containing classes.
@return array Associative of classes and their corresponding definition files
Gets an array of classes and their corresponding definition files or examines a file and returns the classes it defines .