public function testCachingFileScannerWillUseSameInternalFileScannerWithMatchingFileNameAnAnnotationManagerObject() { CachingFileScanner::clearCache(); // single entry, based on file $cfs1 = new CachingFileScanner(__DIR__ . '/../TestAsset/BarClass.php'); $this->assertContains('ZendTest\\Code\\TestAsset\\BarClass', $cfs1->getClassNames()); $this->assertEquals(1, $this->getCacheCount($cfs1)); // ensure same class is used internally $cfs2 = new CachingFileScanner(__DIR__ . '/../TestAsset/BarClass.php'); $this->assertEquals(1, $this->getCacheCount($cfs2)); $this->assertSameInternalFileScanner($cfs1, $cfs2); // ensure $cfs3 = new CachingFileScanner(__DIR__ . '/../TestAsset/FooClass.php'); $this->assertEquals(2, $this->getCacheCount($cfs3)); $this->assertDifferentInternalFileScanner($cfs2, $cfs3); $annoManager = new AnnotationManager(); $cfs4 = new CachingFileScanner(__DIR__ . '/../TestAsset/FooClass.php', $annoManager); $this->assertEquals(3, $this->getCacheCount($cfs4)); $this->assertDifferentInternalFileScanner($cfs3, $cfs4); $cfs5 = new CachingFileScanner(__DIR__ . '/../TestAsset/FooClass.php', $annoManager); $this->assertEquals(3, $this->getCacheCount($cfs5)); $this->assertSameInternalFileScanner($cfs4, $cfs5); $cfs6 = new CachingFileScanner(__DIR__ . '/../TestAsset/BarClass.php', $annoManager); $this->assertEquals(4, $this->getCacheCount($cfs6)); $this->assertDifferentInternalFileScanner($cfs5, $cfs6); }
/** * This method does the work of "reflecting" the file * * Uses Zend\Code\Scanner\FileScanner to gather file information * * @return void */ protected function reflect() { $scanner = new CachingFileScanner($this->filePath); $this->docComment = $scanner->getDocComment(); $this->requiredFiles = $scanner->getIncludes(); $this->classes = $scanner->getClassNames(); $this->namespaces = $scanner->getNamespaces(); $this->uses = $scanner->getUses(); }