Example #1
0
 /**
  * testCurrentReturnsFalseWhenNoMoreElementExists
  *
  * @return void
  * @covers PHP_Depend_Code_NodeIterator
  * @group pdepend
  * @group pdepend::code
  * @group unittest
  */
 public function testCurrentReturnsFalseWhenNoMoreElementExists()
 {
     $iterator = new PHP_Depend_Code_NodeIterator(array());
     $this->assertFalse($iterator->current());
 }
Example #2
0
 /**
  * Returns an iterator with all method/function parameters.
  *
  * <b>NOTE:</b> All node iterators return an alphabetic ordered list of
  * nodes. Use the {@link PHP_Depend_Code_Parameter::getPosition()} for the
  * correct parameter position.
  *
  * @return PHP_Depend_Code_NodeIterator
  */
 public function getParameters()
 {
     if ($this->_parameters === null) {
         $this->_initParameters();
     }
     $this->_parameters->rewind();
     return $this->_parameters;
 }
 /**
  * Constructs a new reference iterator instance.
  *
  * @param array(PHP_Depend_Code_ASTClassOrInterfaceReference) $references List
  *        of references to concrete type instances.
  */
 public function __construct(array $references)
 {
     parent::__construct($this->createClassesAndInterfaces($references));
 }
Example #4
0
 /**
  * Tests that the iterator returns the node name as key.
  *
  * @return void
  */
 public function testNodeIteratorLoopWithKey()
 {
     $names = array('clazz', 'func', 'method', 'pkg');
     $nodes = array(new PHP_Depend_Code_Class('clazz', 0, 'clazz.php'), new PHP_Depend_Code_Function('func', 0), new PHP_Depend_Code_Method('method', 0), new PHP_Depend_Code_Package('pkg'));
     $it = new PHP_Depend_Code_NodeIterator($nodes);
     for ($i = 0, $it->rewind(); $it->valid(); ++$i, $it->next()) {
         $this->assertSame($nodes[$i], $it->current());
         $this->assertEquals($names[$i], $it->key());
     }
 }