本文整理汇总了PHP中Iterator::valid方法的典型用法代码示例。如果您正苦于以下问题:PHP Iterator::valid方法的具体用法?PHP Iterator::valid怎么用?PHP Iterator::valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Iterator
的用法示例。
在下文中一共展示了Iterator::valid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lazyAppend
/**
* 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();
}
}
示例2: valid
public function valid()
{
get_next:
// Return true if this function has already been called for iteration.
if ($this->currentRequest) {
return true;
}
// Return false if we are at the end of the provided commands iterator.
if (!$this->commands->valid()) {
return false;
}
$command = $this->commands->current();
if (!$command instanceof CommandInterface) {
throw new \RuntimeException('All commands provided to the ' . __CLASS__ . ' must implement GuzzleHttp\\Command\\CommandInterface.' . ' Encountered a ' . Core::describeType($command) . ' value.');
}
$command->setFuture('lazy');
$this->attachListeners($command, $this->eventListeners);
// Prevent transfer exceptions from throwing.
$command->getEmitter()->on('process', function (ProcessEvent $e) {
if ($e->getException()) {
$e->setResult(null);
}
}, RequestEvents::LATE);
$builder = $this->requestBuilder;
$result = $builder($command);
// Skip commands that were intercepted with a result.
if (isset($result['result'])) {
$this->commands->next();
goto get_next;
}
$this->currentRequest = $result['request'];
return true;
}
示例3: valid
private function valid()
{
if (!$this->data->valid()) {
$this->rewind();
}
return TRUE;
}
示例4: next
/**
* {@inheritdoc}
*/
public function next()
{
$this->neighbour->next();
if (!$this->neighbour->valid()) {
$this->neighbour->rewind();
parent::next();
}
}
示例5: valid
public function valid(){
if ($this->isFirstValidCall === true){
$this->innerHasItems = $this->innerIterator->valid();
$this->isFirstValidCall = false;
return true;
}
return $this->innerIterator->valid();
}
示例6: next
public function next()
{
$this->currentIt->next();
if ($this->state === 1 && !$this->currentIt->valid()) {
$this->currentIt = $this->it2;
$this->state = 2;
}
}
示例7: memo
private function memo()
{
if (!$this->it->valid()) {
return;
}
array_push($this->cache, array($this->it->key(), $this->it->current()));
$this->cacheSize++;
}
示例8: fetch
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);
}
}
示例9: fetch
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);
}
}
示例10: valid
public function valid()
{
if (!parent::valid()) {
if ($this->source->valid()) {
$this->append($this->transform($this->source->current()));
}
}
return parent::valid();
}
示例11: dir_readdir
/**
* @return string
*/
public function dir_readdir()
{
if ($this->iterator->valid()) {
$result = $this->iterator->current();
$this->iterator->next();
return $result;
} else {
return false;
}
}
示例12: initSuspended
/**
* Initialize isSuspended.
*
* Called in walk() method.
*
* @return void
*/
protected function initSuspended()
{
if ($this->lineHandler instanceof \IteratorIterator) {
$this->isSuspended = $this->lineHandler->getInnerIterator()->valid();
} elseif ($this->lineHandler instanceof \Iterator) {
$this->isSuspended = $this->lineHandler->valid();
} else {
$this->isSuspended = false;
}
}
示例13: collect
/**
* @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;
}
示例14: fetch
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();
}
}
示例15: valid
public function valid()
{
if ($this->usingCache) {
return isset($this->array[$this->position]);
}
$valid = $this->innerIterator->valid();
if (!$valid) {
$this->usingCache = true;
}
return $valid;
}