comparison core/lib/Drupal/Component/ClassFinder/ClassFinder.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\Component\ClassFinder;
4
5 use Doctrine\Common\Reflection\ClassFinderInterface;
6
7 /**
8 * A Utility class that uses active autoloaders to find a file for a class.
9 */
10 class ClassFinder implements ClassFinderInterface {
11
12 /**
13 * {@inheritdoc}
14 */
15 public function findFile($class) {
16 $loaders = spl_autoload_functions();
17 foreach ($loaders as $loader) {
18 if (is_array($loader) && isset($loader[0]) && is_object($loader[0]) && method_exists($loader[0], 'findFile')) {
19 $file = call_user_func_array([$loader[0], 'findFile'], [$class]);
20 // Different implementations return different empty values. For example,
21 // \Composer\Autoload\ClassLoader::findFile() returns FALSE whilst
22 // \Doctrine\Common\Reflection\ClassFinderInterface::findFile()
23 // documents that a NULL should be returned.
24 if (!empty($file)) {
25 return $file;
26 }
27 }
28 }
29 return NULL;
30 }
31
32 }