Example #1
0
 /**
  * {@inheritDoc}
  *
  * This has been lifted pretty much wholesale from Doctrine ORM, so credit where credit is due.
  * @see Doctrine\Common\Persistence\Mapping\Driver\AnnotationDriver
  */
 public function getAllClassNames()
 {
     if (!$this->paths) {
         throw Exception::pathsRequired();
     }
     $classes = array();
     $includedFiles = array();
     foreach ($this->paths as $path) {
         if (!is_dir($path)) {
             throw Exception::invalidPath($path);
         }
         $iterator = new \RegexIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY), '/^.+\\.php$/i', \RecursiveRegexIterator::GET_MATCH);
         foreach ($iterator as $file) {
             $sourceFile = realpath($file[0]);
             require_once $sourceFile;
             $includedFiles[] = $sourceFile;
         }
     }
     $declared = get_declared_classes();
     foreach ($declared as $className) {
         $rc = new \ReflectionClass($className);
         $sourceFile = $rc->getFileName();
         if (in_array($sourceFile, $includedFiles) && $this->isService($className)) {
             $classes[] = $className;
         }
     }
     return $classes;
 }