public function next() { parent::next(); $this->currentResult = $this->nextResult; if ($this->hasNext()) { $this->nextResult = $this->handleItem($this->getInnerIterator()->current()); } }
/** @test */ public function testMainFunctionality() { $count = 0; $it = new CachingIterator(new MapIterator(new ArrayIterator(range(0, 10)), function ($i) use(&$count) { $count += 1; return $i; })); $it->rewind(); $this->assertEquals(0, $count); $it->valid(); $this->assertEquals(0, $it->current()); $it->valid(); $it->next(); $this->assertEquals(1, $it->current()); $this->assertEquals(1, $it->current()); $this->assertEquals(1, $it->current()); $it->valid(); $it->next(); $this->assertEquals(2, $it->current()); $this->assertEquals(3, $count); }
function next() { if ($this->hasChildren = $this->it->hasChildren()) { try { $child = $this->it->getChildren(); if (!$this->ref) { //TODO: // $this->ref = new ReflectionClass($this); } //$this->getChildren = $ref->newInstance($child, $this->flags); } catch (Exception $e) { if (!$this->flags & self::CATCH_GET_CHILD) { throw $e; } $this->hasChildren = false; $this->getChildren = NULL; } } else { $this->getChildren = NULL; } parent::next(); }
/** * Forwards to the next element. * @return void */ public function next() { parent::next(); if (parent::valid()) { $this->counter++; } }
public function next() { $this->prev = $this->current(); $this->prevKey = $this->key(); parent::next(); }
public function test_London_getTransitions() { $test = $this->europeLondon(); $trans = $test->getTransitions(); $first = $trans[0]; $this->assertEquals($first->getDateTimeBefore(), LocalDateTime::of(1847, 12, 1, 0, 0)); $this->assertEquals($first->getOffsetBefore(), ZoneOffset::ofHoursMinutesSeconds(0, -1, -15)); $this->assertEquals($first->getOffsetAfter(), self::$OFFSET_ZERO); $spring1916 = $trans[1]; $this->assertEquals($spring1916->getDateTimeBefore(), LocalDateTime::of(1916, 5, 21, 2, 0)); $this->assertEquals($spring1916->getOffsetBefore(), self::$OFFSET_ZERO); $this->assertEquals($spring1916->getOffsetAfter(), self::$OFFSET_PONE); $autumn1916 = $trans[2]; $this->assertEquals($autumn1916->getDateTimeBefore(), LocalDateTime::of(1916, 10, 1, 3, 0)); $this->assertEquals($autumn1916->getOffsetBefore(), self::$OFFSET_PONE); $this->assertEquals($autumn1916->getOffsetAfter(), self::$OFFSET_ZERO); $zot = null; $it = new \CachingIterator(new \ArrayIterator($trans)); while ($it->hasNext()) { $it->next(); $zot = $it->current(); if ($zot->getDateTimeBefore()->getYear() === 1990) { break; } } $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1990, 3, 25, 1, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_ZERO); $it->next(); $zot = $it->current(); $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1990, 10, 28, 2, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_PONE); $it->next(); $zot = $it->current(); $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1991, 3, 31, 1, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_ZERO); $it->next(); $zot = $it->current(); $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1991, 10, 27, 2, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_PONE); $it->next(); $zot = $it->current(); $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1992, 3, 29, 1, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_ZERO); $it->next(); $zot = $it->current(); $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1992, 10, 25, 2, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_PONE); $it->next(); $zot = $it->current(); $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1993, 3, 28, 1, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_ZERO); $it->next(); $zot = $it->current(); $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1993, 10, 24, 2, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_PONE); $it->next(); $zot = $it->current(); $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1994, 3, 27, 1, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_ZERO); $it->next(); $zot = $it->current(); $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1994, 10, 23, 2, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_PONE); $it->next(); $zot = $it->current(); $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1995, 3, 26, 1, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_ZERO); $it->next(); $zot = $it->current(); $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1995, 10, 22, 2, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_PONE); $it->next(); $zot = $it->current(); $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1996, 3, 31, 1, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_ZERO); $it->next(); $zot = $it->current(); $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1996, 10, 27, 2, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_PONE); $it->next(); $zot = $it->current(); $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1997, 3, 30, 1, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_ZERO); $it->next(); $zot = $it->current(); $this->assertEquals($zot->getDateTimeBefore(), LocalDateTime::of(1997, 10, 26, 2, 0)); $this->assertEquals($zot->getOffsetBefore(), self::$OFFSET_PONE); $this->assertEquals($it->hasNext(), false); }
<?php $data = array('Mela', 'Pera', 'Kiwi', 'Banana', 'Pompelmo'); $it = new ArrayIterator($data); $iterator = new CachingIterator($it); for ($iterator->rewind(); $iterator->valid(); $iterator->next()) { echo $iterator, PHP_EOL; }
public function next() { $this->isCurrentChildrenCacheValid = false; return parent::next(); }
private function parseMonth(\CachingIterator $s) { $s->next(); $month = $s->current(); if ($m = preg_match(self::$MONTH, $month, $mr)) { for ($moy = 1; $moy < 13 && $moy < count($mr); $moy++) { if ($mr[$moy] !== '') { return Month::of($moy); } } } throw new IllegalArgumentException("Unknown month: " . $month); }
Nette\NotSupportedException('Iterator is not countable.');}}function next(){parent::next();if(parent::valid()){$this->counter++;}}function