本文整理汇总了PHP中Iterator::current方法的典型用法代码示例。如果您正苦于以下问题:PHP Iterator::current方法的具体用法?PHP Iterator::current怎么用?PHP Iterator::current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Iterator
的用法示例。
在下文中一共展示了Iterator::current方法的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: current
public function current(){
if ($this->innerHasItems === true){
return $this->innerIterator->current();
} else {
return $this->defaultValue;
}
}
示例3: current
/**
* {@inheritdoc}
*/
public function current()
{
if (!$this->iterableResult) {
$this->rewind();
}
return $this->iterableResult->current();
}
示例4: getCurrentIterator
private function getCurrentIterator()
{
if (null === $this->currentIterator) {
$this->currentIterator = $this->mainIterator->current();
}
return $this->currentIterator;
}
示例5: subscribe
/**
* @param ObserverInterface $observer
* @param SchedulerInterface|null $scheduler
* @return \Rx\Disposable\CompositeDisposable|\Rx\DisposableInterface
*/
public function subscribe(ObserverInterface $observer, SchedulerInterface $scheduler = null)
{
$scheduler = $scheduler ?: new ImmediateScheduler();
$key = 0;
return $scheduler->scheduleRecursive(function ($reschedule) use(&$observer, &$key) {
try {
//HHVM requires you to call next() before current()
if (defined('HHVM_VERSION')) {
$this->items->next();
$key = $this->items->key();
}
if (null === $key) {
$observer->onCompleted();
return;
}
$current = $this->items->current();
$observer->onNext($current);
if (!defined('HHVM_VERSION')) {
$this->items->next();
$key = $this->items->key();
}
$reschedule();
} catch (\Exception $e) {
$observer->onError($e);
}
});
}
示例6: 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;
}
示例7: current
public function current()
{
if (!$this->usingCache) {
$this->array[$this->position] = $this->innerIterator->current();
}
return $this->array[$this->position];
}
示例8: current
/**
* @return Mixed|null Returns null if out of range
*/
public function current()
{
if (!$this->baseIterator->valid()) {
return null;
// out of range
}
return call_user_func_array($this->vCallback, array($this->baseIterator->current()));
}
示例9: current
/**
* Returns the current element.
*
* @return \SplFileInfo
*
* @throws FileSystemException If called after the last element has been returned.
*/
public function current()
{
try {
return $this->iterator->current();
} catch (\RuntimeException $e) {
throw FileSystemException::wrap($e);
}
}
示例10: memo
private function memo()
{
if (!$this->it->valid()) {
return;
}
array_push($this->cache, array($this->it->key(), $this->it->current()));
$this->cacheSize++;
}
示例11: 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);
}
}
示例12: 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);
}
}
示例13: fetch
public function fetch($fetchMode = null)
{
if (!$this->currentIterator) {
$this->currentIterator = $this->getIterator();
}
$data = $this->currentIterator->current();
$this->currentIterator->next();
return $data;
}
示例14: current
public function current()
{
if ($this->projectionNeeded) {
$projection = $this->projection;
$this->current = $projection($this->innerIterator->current(), $this->innerIterator->key(), $this->innerIterator);
$this->projectionNeeded = false;
}
return $this->current;
}
示例15: current
public function current()
{
$current = $this->iterator->current();
$fileCrate = new \HQ\ErrorMonitorinq\FileCrate();
$fileCrate->name = $current["Key"];
$fileCrate->size = $current["Size"];
$fileCrate->lastModified = new \DateTime($current["LastModified"]);
return $fileCrate;
}