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


PHP ArrayIterator::rewind方法代码示例

本文整理汇总了PHP中ArrayIterator::rewind方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayIterator::rewind方法的具体用法?PHP ArrayIterator::rewind怎么用?PHP ArrayIterator::rewind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArrayIterator的用法示例。


在下文中一共展示了ArrayIterator::rewind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rewind

 /**
  * @return void
  */
 public function rewind()
 {
     if ($this->items === null) {
         $this->items = new ArrayIterator($this->slideshow->getItems()->toArray());
     }
     return $this->items->rewind();
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:10,代码来源:MetaSlideshowItemList.php

示例2: search

 /**
  *
  * @param <type> $table
  * @param ArrayIterator $params
  * @return ArrayObject
  */
 public function search($table, ArrayIterator $params)
 {
     $this->searchParams = $params;
     $this->join();
     if ($table == "analysis") {
         $this->statements->remove("type_event");
     }
     $statement = "SELECT this_.* " . $this->selectAttributes() . " FROM {$table} this_ ";
     $statement .= $this->join();
     $i = 0;
     $this->searchParams->rewind();
     if ($this->searchParams->count() > 0 && !$this->searchParams->offsetExists('true')) {
         $statement .= " WHERE ";
     }
     while ($this->searchParams->valid()) {
         if ($this->statements->containsKey($this->searchParams->key())) {
             if ($i++ > 0) {
                 $statement .= " AND ";
             }
             $clause = $this->statements->get($this->searchParams->key());
             $statement .= str_replace(":" . $this->searchParams->key(), "'" . $this->searchParams->current() . "'", $clause['where']);
         }
         $this->searchParams->next();
     }
     return $this->getObject($statement . " ORDER BY this_.date DESC, this_.id DESC");
 }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:32,代码来源:SearchEngine.php

示例3: rewind

 public function rewind()
 {
     parent::rewind();
     if ($this->valid()) {
         $this->sum = parent::current();
     }
 }
开发者ID:jcsilkey,项目名称:CodeReviewSecurityRepo,代码行数:7,代码来源:RunningTotal1.php

示例4: zroneClassLoader

/**
 * 自动加载
 *
 * @param $className
 */
function zroneClassLoader($className)
{
    $path = array(str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Vendor/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "FrameWork/"), str_replace("\\", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR . "Application/"));
    if (isset($path) && is_array($path)) {
        $Iterator = new ArrayIterator($path);
        $Iterator->rewind();
        $pathString = "";
        while ($Iterator->valid()) {
            $pathString .= $Iterator->current() . ";";
            if ($Iterator->key() == count($path) - 1) {
                $pathString = rtrim($pathString, ";");
            }
            $Iterator->next();
        }
        set_include_path($pathString);
        spl_autoload_extensions(".php, .class.php");
        spl_autoload($className);
    } else {
        try {
            throw new Exception("<code style='color: red; font-size: 22px; display: block; text-align: center; height: 40px; line-height: 40px;'>I'm sorry, my dear! The FrameWork is Wrong……😫</code>");
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }
}
开发者ID:zrone,项目名称:apiDocument,代码行数:30,代码来源:zroneFrameWork.php

示例5: nextIterator

 /** @return php.Iterator */
 protected function nextIterator()
 {
     if ($this->source >= sizeof($this->sources)) {
         return null;
     }
     $src = $this->sources[$this->source];
     // Evaluate lazy supplier functions
     if ($src instanceof \Closure) {
         $src = $src();
     }
     if ($src instanceof \Iterator) {
         $it = $src;
     } else {
         if ($src instanceof \Traversable) {
             $it = new \IteratorIterator($src);
         } else {
             if ($src instanceof XPIterator) {
                 $it = new XPIteratorAdapter($src);
             } else {
                 if (is_array($src)) {
                     $it = new \ArrayIterator($src);
                 } else {
                     if (null === $src) {
                         $it = new \ArrayIterator([]);
                     } else {
                         throw new IllegalArgumentException('Expecting either an iterator, iterable, an array or NULL');
                     }
                 }
             }
         }
     }
     $this->source++;
     $it->rewind();
     return $it;
 }
开发者ID:xp-forge,项目名称:sequence,代码行数:36,代码来源:Iterators.class.php

示例6: rewind

 public function rewind()
 {
     parent::rewind();
     if (self::SKIP_FIRST_LINE & $this->getFlags()) {
         $this->next();
     }
 }
开发者ID:h4kuna,项目名称:iterators,代码行数:7,代码来源:TextIterator.php

示例7: find

 /**
  * @param string $collection
  * @param array  $query
  *
  * @return \Iterator
  */
 public function find($collection, array $query = [])
 {
     $cursor = $this->getDatabase()->selectCollection($collection)->find($query);
     $iterator = new \ArrayIterator($cursor);
     $iterator->rewind();
     return $iterator;
 }
开发者ID:respect,项目名称:structural,代码行数:13,代码来源:MongoDbDriver.php

示例8: testRetrievesAndCachesTargetData

 public function testRetrievesAndCachesTargetData()
 {
     $ctime = strtotime('January 1, 2013');
     $a = $this->getMockBuilder('SplFileinfo')->setMethods(array('getSize', 'getMTime', '__toString'))->disableOriginalConstructor()->getMock();
     $a->expects($this->any())->method('getSize')->will($this->returnValue(10));
     $a->expects($this->any())->method('getMTime')->will($this->returnValue($ctime));
     $a->expects($this->any())->method('__toString')->will($this->returnValue(''));
     $b = $this->getMockBuilder('SplFileinfo')->setMethods(array('getSize', 'getMTime', '__toString'))->disableOriginalConstructor()->getMock();
     $b->expects($this->any())->method('getSize')->will($this->returnValue(11));
     $b->expects($this->any())->method('getMTime')->will($this->returnValue($ctime));
     $a->expects($this->any())->method('__toString')->will($this->returnValue(''));
     $c = 0;
     $converter = $this->getMockBuilder('Aws\\S3\\Sync\\KeyConverter')->setMethods(array('convert'))->getMock();
     $converter->expects($this->any())->method('convert')->will($this->returnCallback(function () use(&$c) {
         if (++$c == 1) {
             return 'foo';
         } else {
             return 'bar';
         }
     }));
     $targetIterator = new \ArrayIterator(array($b, $a));
     $targetIterator->rewind();
     $changed = new ChangedFilesIterator($targetIterator, $targetIterator, $converter, $converter);
     $ref = new \ReflectionMethod($changed, 'getTargetData');
     $ref->setAccessible(true);
     $this->assertEquals(array(10, $ctime), $ref->invoke($changed, 'bar'));
     $this->assertEquals(array(11, $ctime), $ref->invoke($changed, 'foo'));
     $this->assertFalse($ref->invoke($changed, 'baz'));
 }
开发者ID:im286er,项目名称:ent,代码行数:29,代码来源:ChangedFilesIteratorTest.php

示例9: getAllAggregationColumns

 /**
  * @param string null|$aggKey
  * @return array
  */
 public function getAllAggregationColumns($aggKey = null)
 {
     if ($aggKey && isset($this->cachedColumns[$aggKey])) {
         return $this->cachedColumns[$aggKey];
     } elseif ($this->cachedColumns) {
         return $this->cachedColumns;
     }
     foreach (array_column($this->aggregationList, 'index') as $aggIndex) {
         $columns = [];
         $needSort = false;
         foreach ($this->arrayIterator as $current) {
             $aggrItem = $current[$aggIndex];
             if (isset($aggrItem['buckets'])) {
                 foreach ($aggrItem['buckets'] as $bucket) {
                     if (!in_array($bucket['key'], $columns)) {
                         $columns[] = $bucket['key'];
                         $needSort = true;
                     }
                 }
             } else {
                 $columns = array_keys($aggrItem);
                 break;
             }
         }
         $this->arrayIterator->rewind();
         if ($needSort) {
             sort($columns);
         }
         $this->cachedColumns[$aggIndex] = $columns;
     }
     return !is_null($aggKey) && isset($this->cachedColumns[$aggKey]) ? $this->cachedColumns[$aggKey] : $this->cachedColumns;
 }
开发者ID:anmoroz,项目名称:yii2-analytics,代码行数:36,代码来源:ViewHelperComponent.php

示例10: rewind

 public function rewind()
 {
     if ($this->iterator === null) {
         $pdo_fetch_mode = PDO::FETCH_ASSOC;
         switch ($this->fetch_mode) {
             case self::FETCH_NUM:
                 $pdo_fetch_mode = PDO::FETCH_NUM;
                 break;
             case self::FETCH_ASSOC:
             default:
                 $pdo_fetch_mode = PDO::FETCH_ASSOC;
                 break;
         }
         $this->iterator = new ArrayIterator($this->statement->fetchAll($pdo_fetch_mode));
     }
     $this->iterator->rewind();
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:17,代码来源:PDOSelectQueryResult.class.php

示例11: testRewindRestartsIteratorToBeginning

 public function testRewindRestartsIteratorToBeginning()
 {
     $iterator = new ArrayIterator(array('foo' => 'bar', 'oof' => 'rab'));
     $iterator->next();
     $iterator->rewind();
     $this->assertSame('foo', $iterator->key());
     $this->assertSame('bar', $iterator->current());
 }
开发者ID:nathanklick,项目名称:collections,代码行数:8,代码来源:ArrayIteratorTest.php

示例12: rewind

 /**
  * {@inheritdoc}
  */
 public function rewind()
 {
     if ($this->iterator) {
         $this->iterator->rewind();
         return;
     }
     $this->iterator = $this->collection->getIterator();
     $this->iterator->rewind();
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:12,代码来源:PropelCollectionSourceIterator.php

示例13: __construct

 public function __construct($arrToPrint)
 {
     $arrToPrint = (array) $arrToPrint;
     //构造一个循环迭代器
     $aArrIter = new \ArrayIterator($arrToPrint);
     $aArrIter->rewind();
     $this->aArrIter = new \InfiniteIterator($aArrIter);
     $this->aArrIter->rewind();
 }
开发者ID:JeCat,项目名称:framework,代码行数:9,代码来源:Cycle.php

示例14: average

 public function average(ArrayIterator $values)
 {
     $sum = 0;
     while ($values->valid()) {
         $sum += $values->current();
         $values->next();
     }
     $values->rewind();
     return round($sum / $values->count(), 2);
 }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:10,代码来源:Statistic.php

示例15: next

 /**
  * @inheritdoc
  */
 public function next()
 {
     $this->iterator->next();
     if ($this->autoloadEnabled && !$this->iterator->valid() && $this->paginator->hasMorePage()) {
         $this->paginator->incrPageNumber();
         /** @var Collection $newCollection */
         $newCollection = $this->adapter->map($this->subject, $this->context)->call($this->method, $this->criteria, $this->paginator);
         $this->iterator = new \ArrayIterator($newCollection->asArray(false));
         $this->iterator->rewind();
     }
 }
开发者ID:mehdi-ghezal,项目名称:sellsy-api,代码行数:14,代码来源:Collection.php


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