本文整理汇总了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();
}
示例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");
}
示例3: rewind
public function rewind()
{
parent::rewind();
if ($this->valid()) {
$this->sum = parent::current();
}
}
示例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();
}
}
}
示例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;
}
示例6: rewind
public function rewind()
{
parent::rewind();
if (self::SKIP_FIRST_LINE & $this->getFlags()) {
$this->next();
}
}
示例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;
}
示例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'));
}
示例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;
}
示例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();
}
示例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());
}
示例12: rewind
/**
* {@inheritdoc}
*/
public function rewind()
{
if ($this->iterator) {
$this->iterator->rewind();
return;
}
$this->iterator = $this->collection->getIterator();
$this->iterator->rewind();
}
示例13: __construct
public function __construct($arrToPrint)
{
$arrToPrint = (array) $arrToPrint;
//构造一个循环迭代器
$aArrIter = new \ArrayIterator($arrToPrint);
$aArrIter->rewind();
$this->aArrIter = new \InfiniteIterator($aArrIter);
$this->aArrIter->rewind();
}
示例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);
}
示例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();
}
}