コード例 #1
0
 /**
  * Returns a node iterator with all implemented interfaces.
  *
  * @return PHP_Depend_Code_NodeIterator
  * @since 0.9.5
  */
 public function getInterfaces()
 {
     $stack = array($this);
     if ($this->parentClassReference !== null) {
         array_unshift($stack, $this->parentClassReference->getType());
     }
     $parents = array();
     $interfaces = array();
     while (($top = array_pop($stack)) !== null) {
         foreach ($top->interfaceReferences as $interfaceReference) {
             $interface = $interfaceReference->getType();
             if (in_array($interface, $interfaces, true) === true) {
                 continue;
             }
             $interfaces[] = $interface;
             $stack[] = $interface;
         }
         if ($top->parentClassReference !== null) {
             $class = $top->parentClassReference->getType();
             if (!in_array($class, $parents, true)) {
                 $stack[] = $class;
                 $parents[] = $class;
             }
         }
     }
     return new PHP_Depend_Code_NodeIterator($interfaces);
 }
コード例 #2
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;
 }
コード例 #3
0
 /**
  * Returns a node iterator with all implemented interfaces.
  *
  * @return PHP_Depend_Code_NodeIterator
  * @since 0.9.5
  */
 public function getInterfaces()
 {
     $interfaces = array();
     foreach ($this->interfaceReferences as $interfaceReference) {
         $interface = $interfaceReference->getType();
         if (in_array($interface, $interfaces, true) === true) {
             continue;
         }
         $interfaces[] = $interface;
         foreach ($interface->getInterfaces() as $parentInterface) {
             if (in_array($parentInterface, $interfaces, true) === false) {
                 $interfaces[] = $parentInterface;
             }
         }
     }
     if ($this->parentClassReference === null) {
         return new PHP_Depend_Code_NodeIterator($interfaces);
     }
     $parentClass = $this->parentClassReference->getType();
     foreach ($parentClass->getInterfaces() as $interface) {
         $interfaces[] = $interface;
     }
     return new PHP_Depend_Code_NodeIterator($interfaces);
 }
コード例 #4
0
ファイル: ASTClassReferenceTest.php プロジェクト: kingsj/core
 /**
  * testGetTypeCachesReturnValueOfBuilderContextGetClass
  *
  * @return void
  * @group pdepend
  * @group pdepend::ast
  * @group unittest
  */
 public function testGetTypeCachesReturnValueOfBuilderContextGetClass()
 {
     $context = $this->getBuilderContextMock();
     $context->expects($this->exactly(1))->method('getClass')->with($this->equalTo(__CLASS__))->will($this->returnValue($this));
     $reference = new PHP_Depend_Code_ASTClassReference($context, __CLASS__);
     $reference->getType();
 }