コード例 #1
0
ファイル: Collection.php プロジェクト: KingNoosh/Teknik
 /**
  * Singleton method for this filter class.
  *
  * @return PHP_Depend_Code_Filter_Collection
  */
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new PHP_Depend_Code_Filter_Collection();
     }
     return self::$instance;
 }
コード例 #2
0
ファイル: CollectionTest.php プロジェクト: noelg/pdepend
 public function testCollectionClear()
 {
     $filter = PHP_Depend_Code_Filter_Collection::getInstance();
     $this->assertEquals(0, $filter->getIterator()->count());
     $filter->addFilter(new PHP_Depend_Code_Filter_Package(array()));
     $filter->addFilter(new PHP_Depend_Code_Filter_Package(array()));
     $this->assertEquals(2, $filter->getIterator()->count());
     $filter->clear();
     $this->assertEquals(0, $filter->getIterator()->count());
 }
コード例 #3
0
ファイル: ClassTest.php プロジェクト: rouffj/pdepend
 /**
  * testGetParentReturnsNullWhenParentIsFiltered
  *
  * @return void
  * @since 1.0.0
  */
 public function testGetParentReturnsNullWhenParentIsFiltered()
 {
     PHP_Depend_Code_Filter_Collection::getInstance()->setFilter(new PHP_Depend_Code_Filter_Package(array('org.pdepend.filter')));
     $class = $this->getFirstClassForTestCase();
     $this->assertNull($class->getParentClass());
 }
コード例 #4
0
ファイル: Depend.php プロジェクト: CobaltBlueDW/oddsandends
 /**
  * This method performs the analysing process of the parsed source files. It
  * creates the required analyzers for the registered listeners and then
  * applies them to the source tree.
  *
  * @return void
  */
 private function performAnalyzeProcess()
 {
     $analyzerLoader = $this->createAnalyzerLoader($this->options);
     $collection = PHP_Depend_Code_Filter_Collection::getInstance();
     $this->fireStartAnalyzeProcess();
     ini_set('xdebug.max_nesting_level', $this->configuration->parser->nesting);
     foreach ($analyzerLoader as $analyzer) {
         // Add filters if this analyzer is filter aware
         if ($analyzer instanceof PHP_Depend_Metrics_FilterAwareI) {
             $collection->setFilter($this->codeFilter);
         }
         $analyzer->analyze($this->builder->getPackages());
         // Remove filters if this analyzer is filter aware
         $collection->setFilter();
         foreach ($this->loggers as $logger) {
             $logger->log($analyzer);
         }
     }
     ini_restore('xdebug.max_nesting_level');
     $this->fireEndAnalyzeProcess();
 }
コード例 #5
0
 /**
  * Returns the parent class or <b>null</b> if this class has no parent.
  *
  * @return PHP_Depend_Code_Class
  */
 public function getParentClass()
 {
     // No parent? Stop here!
     if ($this->parentClassReference === null) {
         return null;
     }
     $parentClass = $this->parentClassReference->getType();
     if ($parentClass === $this) {
         throw new PHP_Depend_Code_Exceptions_RecursiveInheritanceException($this);
     }
     // Check parent against global filter
     $collection = PHP_Depend_Code_Filter_Collection::getInstance();
     if ($collection->accept($parentClass) === false) {
         return null;
     }
     return $parentClass;
 }
コード例 #6
0
ファイル: AnalyzerTest.php プロジェクト: KingNoosh/Teknik
 /**
  * Tests that the analyzer calculates the correct average hierarchy height.
  *
  * @return void
  */
 public function testAnalyzerCalculatesCorrectAHHValue()
 {
     $filter = PHP_Depend_Code_Filter_Collection::getInstance();
     $filter->setFilter(new PHP_Depend_Code_Filter_Package(array('library')));
     $packages = self::parseTestCaseSource(__METHOD__);
     $analyzer = new PHP_Depend_Metrics_Inheritance_Analyzer();
     $analyzer->analyze($packages);
     $project = $analyzer->getProjectMetrics();
     self::assertEquals(1, $project['ahh']);
 }
コード例 #7
0
ファイル: AbstractTest.php プロジェクト: JohnMurray/VulnScan
 /**
  * Resets the global iterator filter.
  *
  * @return void
  */
 protected function tearDown()
 {
     PHP_Depend_Code_Filter_Collection::getInstance()->setFilter();
     $this->_clearRunResources();
     parent::tearDown();
 }
コード例 #8
0
ファイル: NodeIterator.php プロジェクト: JohnMurray/VulnScan
 /**
  * Constructs a new node iterator from the given {@link PHP_Depend_Code_NodeI}
  * node array.
  *
  * @param array(PHP_Depend_Code_NodeI) $nodes List of code nodes.
  *
  * @throws RuntimeException If the array contains something different from
  *                          a {@link PHP_Depend_Code_NodeI} object.
  */
 public function __construct(array $nodes)
 {
     $filter = PHP_Depend_Code_Filter_Collection::getInstance();
     $nodeKeys = array();
     foreach ($nodes as $node) {
         $uuid = $node->getUUID();
         if (!isset($nodeKeys[$uuid]) && $filter->accept($node)) {
             $nodeKeys[$uuid] = $uuid;
             $this->_nodes[] = $node;
             ++$this->_count;
         }
     }
 }
コード例 #9
0
ファイル: CollectionTest.php プロジェクト: KingNoosh/Teknik
 /**
  * testAcceptsCallsNestedFilterWhenSet
  *
  * @return void
  */
 public function testAcceptsCallsNestedFilterWhenSet()
 {
     $class = new PHP_Depend_Code_Class(__CLASS__);
     $filter = $this->getMock('PHP_Depend_Code_FilterI');
     $filter->expects($this->once())->method('accept')->with($this->equalTo($class));
     $collection = new PHP_Depend_Code_Filter_Collection();
     $collection->setFilter($filter);
     $collection->accept($class);
 }
コード例 #10
0
 /**
  * Returns the parent class or <b>null</b> if this class has no parent.
  *
  * @return PHP_Depend_Code_Class
  */
 public function getParentClass()
 {
     // No parent? Stop here!
     if ($this->_parentClassReference === null) {
         return null;
     }
     $parentClass = $this->_parentClassReference->getType();
     // Check parent against global filter
     $collection = PHP_Depend_Code_Filter_Collection::getInstance();
     if ($collection->accept($parentClass) === false) {
         return null;
     }
     // Parent is valid, so return
     return $parentClass;
 }
コード例 #11
0
ファイル: XmlTest.php プロジェクト: noelg/pdepend
 /**
  * Removes the temporary log files.
  *
  * @return void
  */
 protected function tearDown()
 {
     // Clear filter collection
     $collection = PHP_Depend_Code_Filter_Collection::getInstance();
     $collection->clear();
     @unlink($this->resultFile);
     parent::tearDown();
 }
コード例 #12
0
ファイル: Depend.php プロジェクト: noelg/pdepend
 /**
  * This method performs the analysing process of the parsed source files. It
  * creates the required analyzers for the registered listeners and then
  * applies them to the source tree.
  *
  * @return void
  */
 private function _performAnalyzeProcess()
 {
     $analyzerLoader = $this->_createAnalyzerLoader($this->_options);
     $collection = PHP_Depend_Code_Filter_Collection::getInstance();
     $this->fireStartAnalyzeProcess();
     foreach ($analyzerLoader as $analyzer) {
         // Add filters if this analyzer is filter aware
         if ($analyzer instanceof PHP_Depend_Metrics_FilterAwareI) {
             $collection->addFilter($this->_codeFilter);
         }
         $analyzer->analyze($this->_builder->getPackages());
         // Remove filters if this analyzer is filter aware
         if ($analyzer instanceof PHP_Depend_Metrics_FilterAwareI) {
             $collection->removeFilter($this->_codeFilter);
         }
         foreach ($this->_loggers as $logger) {
             $logger->log($analyzer);
         }
     }
     $this->fireEndAnalyzeProcess();
 }