/** * Fetch Next Token * * @return Token */ public function pop() { if ($token = $this->peeked) { $this->peeked = null; return $token; } $token = $this->generator->current(); $this->generator->next(); return $token; }
public function next() { if ($this->_currentGen) { return $this->_currentGen->next(); } return next($this->_records); }
/** * Rewind the Iterator to the first element * @see Iterator::rewind * @link http://php.net/manual/en/iterator.rewind.php */ public function rewind() { $this->generateGenerator(); if (is_callable($this->onRewind)) { call_user_func($this->onRewind); } if (defined('HHVM_VERSION')) { $this->generator->next(); } }
/** * {@inheritdoc} */ public function read($length) { $this->initializeBeforeRead(); if (!$this->generator->valid()) { return ''; } if ($this->resource->eof()) { $this->generator->next(); if (!$this->generator->valid()) { return ''; } $this->resource = $this->generator->current(); $this->resource->rewind(); } return $this->resource->fread($length); }
/** * Moves the generator on by one token. * * (It calls ->next() on the generator, look at the PHP doc) * * @see \Generator->next * * @return $this */ protected function nextToken() { $this->tokens->next(); return $this; }
/** * * @param int $n * @param \Generator $gen * * @return \Generator */ function take($n, Generator $gen) { while ($n-- > 0 && $gen->valid()) { (yield $gen->current()); $gen->next(); } }
public function next() { if (!$this->generator) { $this->rewind(); } $this->generator->next(); }
/** * @param \Generator $logs * * @return int */ protected function cntGeneratorLogs($logs) { $cnt = 0; while ($logs->valid()) { $cnt++; $logs->next(); } return $cnt; }
/** * Get next item */ public function next() { if ($this->generator) { $this->generator->next(); } }