Пример #1
0
 /**
  * @param \PHP\Manipulator\TokenContainer\Iterator $iterator
  */
 protected function _setPreviousTokenValueToOneSpace(Iterator $iterator)
 {
     $token = $iterator->current();
     $iterator->previous();
     $iterator->current()->setValue(' ');
     $iterator->update($token);
 }
Пример #2
0
 /**
  * @covers \PHP\Manipulator\TokenContainer\Iterator::update
  */
 public function testUpdateWithSeek()
 {
     $container = $this->getTestContainerWithHoles();
     $iterator = new Iterator($container);
     $iterator->seekToToken($container[5]);
     $this->assertSame($iterator->current(), $container[5]);
     $iterator->update($container[5]);
     $this->assertSame($iterator->current(), $container[5]);
 }
Пример #3
0
 /**
  * @param \PHP\Manipulator\TokenContainer\Iterator $iterator
  * @param \Closure $closure
  * @return \PHP\Manipulator\Token
  */
 public function getNextMatchingToken(Iterator $iterator, \Closure $closure)
 {
     $token = $iterator->current();
     $foundToken = null;
     while ($iterator->valid()) {
         $currentToken = $iterator->current();
         if ($closure($currentToken)) {
             $foundToken = $currentToken;
             break;
         }
         $iterator->next();
     }
     $iterator->update($token);
     return $foundToken;
 }