예제 #1
0
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     $finder = $this;
     $finder->setReader(new AnnotationReader())->files()->name('*.php')->filter(function (\SplFileInfo $file) use($finder) {
         try {
             $fileInspector = new FileInspector($file->getPathname());
             $classInspector = $fileInspector->getClassInspector($finder->getReader());
             foreach ($finder->getContainsAtLeastOneOf() as $annotation) {
                 if ($classInspector->containsClassAnnotation($annotation) || $classInspector->containsMethodAnnotation($annotation) || $classInspector->containsPropertyAnnotation($annotation)) {
                     return true;
                 }
             }
         } catch (AnnotationScannerException $ex) {
             return false;
         }
         return false;
     });
 }
 public function getIterator()
 {
     $result = array();
     $finder = new SymfonyFinder();
     $finder->files()->name('*.php')->in($this->path)->exclude($this->exclude);
     /** @var SplFileInfo $file */
     foreach ($finder as $file) {
         try {
             $fileInspector = new FileInspector($file->getPathname());
             $classInspector = $fileInspector->getClassInspector($this->reader);
             foreach ($this->annotations as $annotation) {
                 if ($classInspector->containsClassAnnotation($annotation) || $classInspector->containsMethodAnnotation($annotation) || $classInspector->containsPropertyAnnotation($annotation)) {
                     $result[] = new ClassFileInfo($file, $classInspector);
                     break;
                 }
             }
         } catch (AnnotationScannerException $ex) {
             continue;
         }
     }
     return new \ArrayIterator($result);
 }
 public function testGetNamespace()
 {
     $this->assertEquals($this->fixtureNamespace, $this->fileInspector->getNamespace());
 }