Пример #1
0
 /**
  * Get an array of loaded file names in order of loading.
  *
  * @return array
  */
 public function getFilenames()
 {
     $files = array();
     foreach ($this->classList->getClasses() as $class) {
         // Push interfaces before classes if not already loaded
         try {
             $r = new \ReflectionClass($class);
             foreach ($r->getInterfaces() as $inf) {
                 $name = $inf->getFileName();
                 if ($name && !in_array($name, $files)) {
                     $files[] = $name;
                 }
             }
             if (!in_array($r->getFileName(), $files)) {
                 $files[] = $r->getFileName();
             }
         } catch (\ReflectionException $e) {
             // We ignore all exceptions related to reflection,
             // because in some cases class can't exists. This
             // can be if you use in your code constuctions like
             //
             // if (class_exists('SomeClass')) { // <-- here will trigger autoload
             //      class SomeSuperClass extends SomeClass {
             //      }
             // }
             //
             // We ignore all problems with classes, interfaces and
             // traits.
         }
     }
     return $files;
 }
 /**
  * Loads the given class, interface or trait.
  *
  * We'll return true if it was loaded.
  *
  * @param string $class
  *
  * @return bool|null
  */
 public function loadClass($class)
 {
     foreach (spl_autoload_functions() as $func) {
         if (is_array($func) && $func[0] === $this) {
             continue;
         }
         $this->classList->push($class);
         if (call_user_func($func, $class)) {
             break;
         }
     }
     $this->classList->next();
     return true;
 }
Пример #3
0
 /**
  * Get an array of loaded file names in order of loading.
  *
  * @return array
  */
 public function getFilenames()
 {
     $files = [];
     foreach ($this->classList->getClasses() as $class) {
         // Push interfaces before classes if not already loaded
         try {
             $r = new \ReflectionClass($class);
             foreach ($r->getInterfaces() as $inf) {
                 $name = $inf->getFileName();
                 if ($name && !in_array($name, $files)) {
                     $files[] = $name;
                 }
             }
             if (!in_array($r->getFileName(), $files)) {
                 $files[] = $r->getFileName();
             }
         } catch (\ReflectionException $e) {
             // We ignore all exceptions related to reflection because in
             // some cases class doesn't need to exist. We're ignoring all
             // problems with classes, interfaces and traits.
         }
     }
     return $files;
 }