当前位置: 首页>>代码示例>>PHP>>正文


PHP Iterator::valid方法代码示例

本文整理汇总了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();
     }
 }
开发者ID:indigophp,项目名称:iterators,代码行数:10,代码来源:LazyAppendIterator.php

示例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;
 }
开发者ID:artoscopus,项目名称:command,代码行数:33,代码来源:CommandToRequestIterator.php

示例3: valid

 private function valid()
 {
     if (!$this->data->valid()) {
         $this->rewind();
     }
     return TRUE;
 }
开发者ID:h4kuna,项目名称:iterators,代码行数:7,代码来源:ArrayRound.php

示例4: next

 /**
  * {@inheritdoc}
  */
 public function next()
 {
     $this->neighbour->next();
     if (!$this->neighbour->valid()) {
         $this->neighbour->rewind();
         parent::next();
     }
 }
开发者ID:th3n3rd,项目名称:cartesian-product,代码行数:11,代码来源:Set.php

示例5: valid

	public function valid(){
		if ($this->isFirstValidCall === true){
			$this->innerHasItems = $this->innerIterator->valid();
			$this->isFirstValidCall = false;
			return true;
		}
		return $this->innerIterator->valid();
	}
开发者ID:gpanda,项目名称:security-scan-tool,代码行数:8,代码来源:DefaultIterator.php

示例6: next

 public function next()
 {
     $this->currentIt->next();
     if ($this->state === 1 && !$this->currentIt->valid()) {
         $this->currentIt = $this->it2;
         $this->state = 2;
     }
 }
开发者ID:ugochimbo,项目名称:collections,代码行数:8,代码来源:LazyConcatIterator.php

示例7: memo

 private function memo()
 {
     if (!$this->it->valid()) {
         return;
     }
     array_push($this->cache, array($this->it->key(), $this->it->current()));
     $this->cacheSize++;
 }
开发者ID:gunjiro,项目名称:ginq,代码行数:8,代码来源:MemoizeIterator.php

示例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);
     }
 }
开发者ID:gunjiro,项目名称:ginq,代码行数:9,代码来源:EachIterator.php

示例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);
     }
 }
开发者ID:gunjiro,项目名称:ginq,代码行数:9,代码来源:SelectIterator.php

示例10: valid

 public function valid()
 {
     if (!parent::valid()) {
         if ($this->source->valid()) {
             $this->append($this->transform($this->source->current()));
         }
     }
     return parent::valid();
 }
开发者ID:bugadani,项目名称:monad,代码行数:9,代码来源:ArrayCallbackIterator.php

示例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;
     }
 }
开发者ID:win10calendar,项目名称:3rdparty,代码行数:13,代码来源:IteratorDirectory.php

示例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;
     }
 }
开发者ID:ngangchill,项目名称:FileClient,代码行数:17,代码来源:AbstractFileIterator.php

示例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;
 }
开发者ID:devhelp,项目名称:resource-core,代码行数:14,代码来源:ResourceCollector.php

示例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();
     }
 }
开发者ID:evaneos,项目名称:berthe,代码行数:11,代码来源:BufferedIterator.php

示例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;
 }
开发者ID:wearebase,项目名称:base-core,代码行数:11,代码来源:CachingIterator.php


注:本文中的Iterator::valid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。