/** * {@inheritdoc} */ public function rewind() { if (!$this->iterator) { $this->initIterator(); } $this->iterator->rewind(); }
private function valid() { if (!$this->data->valid()) { $this->rewind(); } return TRUE; }
/** * Lazily append the next iterator to the chain */ private function lazyAppend() { if (!parent::valid() and $this->iterators->valid()) { $this->append($this->iterators->current()); $this->iterators->next(); } }
private function getCurrentIterator() { if (null === $this->currentIterator) { $this->currentIterator = $this->mainIterator->current(); } return $this->currentIterator; }
/** * {@inheritdoc} */ public final function rewind() { if (null === $this->iterator) { throw new \LogicException('Internal iterator is missing.'); } $this->iterator->rewind(); }
/** * {@inheritdoc} */ protected function doMatch($name, \Iterator $subject, $expected, $elementNumber) { $actual = $subject->current(); if ($expected !== $actual) { throw new FailureException(sprintf('Element #%d was expected to be %s, but %s was given.', $elementNumber, $this->presenter->presentValue($expected), $this->presenter->presentValue($actual))); } }
/** * Rewind the Iterator to the first element. * * @link http://php.net/manual/en/iterator.rewind.php * @since 5.0.0 */ public function rewind() { if (null === $this->iterator) { throw new \LogicException('Missing internal iterator.'); } $this->iterator->rewind(); }
public function getChildren() { $children = new self($this->iterator->getChildren(), []); $children->excludedDirs = $this->excludedDirs; $children->excludedPattern = $this->excludedPattern; return $children; }
private function advanceElementIterator(\Iterator $element) { $element->next(); if (!$element->valid()) { next($this->fields); } }
/** * {@inheritdoc} */ public function rewind() { if (!$this->iterableResult) { $this->iterableResult = new \ArrayIterator($this->getDataFromService()); } $this->iterableResult->rewind(); }
/** * Builds the index for the given collection * * @param DatabaseInterface|\Iterator $database * @return $this */ public function indexDatabase($database) { // Clear the map $this->map = array(); /** @var SplFixedArray $collection */ $collection = null; if ($database instanceof DatabaseRawDataInterface) { $collection = $database->getRawData(); } if ($database instanceof SplFixedArray) { // Use the fixed array as is } elseif (is_array($database)) { $collection = SplFixedArray::fromArray($database); } elseif ($database instanceof \Iterator) { $collection = SplFixedArray::fromArray(iterator_to_array($database)); } else { throw new InvalidIndexException(sprintf('Can not build index of argument of type %s', is_object($database) ? get_class($database) : gettype($database))); } $position = 0; $count = $collection->getSize(); if ($count > 0) { do { $tempEntry = DocumentUtility::assertDocumentIdentifier($database[$position]); $this->addEntryWithPosition($tempEntry, $position); } while (++$position < $count); } }
protected function checkStemmer(Stemmer $stemmer, \Iterator $words, \Iterator $stems) { foreach ($words as $word) { $stem = $stems->current(); $this->assertEquals($stemmer->stem($word), $stem, "The stem for '{$word}' should be '{$stem}' not '{$stemmer->stem($word)}'"); $stems->next(); } }
/** * */ function foo(Iterator $param) { if ($param->valid()) { echo 'valid'; } else { echo 'invalid'; } }
public function valid(){ if ($this->isFirstValidCall === true){ $this->innerHasItems = $this->innerIterator->valid(); $this->isFirstValidCall = false; return true; } return $this->innerIterator->valid(); }
public static function baa(Iterator $param) { if ($param->valid()) { echo 'valid'; } else { echo 'invalid'; } }
/** * {@inheritdoc} */ public function getIterator() { if ($this->sortedIterator === null) { $this->sortedIterator = new \ArrayIterator($this->enumerable()->toArray(true)); $this->sortedIterator->uasort($this->comparator()); } return $this->sortedIterator; }
private function memo() { if (!$this->it->valid()) { return; } array_push($this->cache, array($this->it->key(), $this->it->current())); $this->cacheSize++; }
/** * Initializes the iterator */ protected function initializeIterator() { $this->iterator = $this->createIterator(); if ($this->batchMode) { $this->iterator = new \ArrayIterator(array(iterator_to_array($this->iterator))); } $this->iterator->rewind(); }
private function fetch() { if ($this->it->valid()) { $this->v = $this->it->current(); $this->k = $this->it->key(); $fn = $this->fn; $fn($this->v, $this->k); } }
/** * @param \Iterator $cursor * * @return array */ public function fetch(\Iterator $cursor) { $data = []; if ($cursor->valid()) { $data = $cursor->current(); $cursor->next(); } return $data; }
private function fetch() { if ($this->it->valid()) { $v = $this->it->current(); $k = $this->it->key(); $this->v = $this->valueSelector->select($v, $k); $this->k = $this->keySelector->select($v, $k); } }
public function fetch($fetchMode = null) { if (!$this->currentIterator) { $this->currentIterator = $this->getIterator(); } $data = $this->currentIterator->current(); $this->currentIterator->next(); return $data; }
/** * {@inheritdoc} */ protected function doMatch($name, \Iterator $subject, $expected, $elementNumber) { list($expectedKey, $expectedValue) = $this->castArgumentToKeyValueTuple($expected); $actualKey = $subject->key(); $actualValue = $subject->current(); if ($expectedKey !== $actualKey || $expectedValue !== $actualValue) { throw new FailureException(sprintf('Element #%d was expected to have key %s with value %s, but key %s with value %s was given.', $elementNumber, $this->presenter->presentValue($expectedKey), $this->presenter->presentValue($expectedValue), $this->presenter->presentValue($actualKey), $this->presenter->presentValue($actualValue))); } }
/** * ( excerpt from http://php.net/manual/en/appenditerator.append.php ) * * Appends an iterator. * * @it mixed The iterator to append. * * @return mixed No value is returned. */ function append(\Iterator $it) { $it->rewind(); $this->iterators->append($it); // if we will start at $it and $it is empty, advance our position past if ($this->iterators->current() === $it && !$it->valid()) { $this->iterators->next(); } }
public function valid() { if (!parent::valid()) { if ($this->source->valid()) { $this->append($this->transform($this->source->current())); } } return parent::valid(); }
/** * @param $limit * @return Resource[] */ public function collect($limit = -1) { $resources = array(); while ($limit && $this->iterator->valid()) { $resources[] = $this->iterator->current(); $this->iterator->next(); $limit--; } return $resources; }
/** * {@inheritdoc} */ public function rewind() { if (!$this->iterableResult) { $this->iterableResult = new \SimpleXMLIterator(file_get_contents($this->filename)); if ($this->xpath) { $this->iterableResult = new \ArrayIterator($this->iterableResult->xpath($this->xpath)); } } $this->iterableResult->rewind(); }
protected function fetch() { $this->buffer = array(); for ($i = 0; $i < $this->chunkSize; $i++) { if (!$this->it->valid()) { return; } array_push($this->buffer, $this->it->current()); $this->it->next(); } }
public function valid() { if ($this->usingCache) { return isset($this->array[$this->position]); } $valid = $this->innerIterator->valid(); if (!$valid) { $this->usingCache = true; } return $valid; }
function iterateList(Iterator $i) { foreach ($i as $entry) { if ($i->hasChildren() && !ignore($entry)) { iterateList($i->getChildren()); } else { if (substr($entry, -4, 4) == '.php') { checkFile($entry); } } } }