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


PHP ArrayObject::getIteratorClass方法代码示例

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


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

示例1: castArrayObject

 public static function castArrayObject(\ArrayObject $c, array $a, Stub $stub, $isNested)
 {
     $class = $stub->class;
     $flags = $c->getFlags();
     $b = array("~flag::STD_PROP_LIST" => (bool) ($flags & \ArrayObject::STD_PROP_LIST), "~flag::ARRAY_AS_PROPS" => (bool) ($flags & \ArrayObject::ARRAY_AS_PROPS), "~iteratorClass" => $c->getIteratorClass(), "~storage" => $c->getArrayCopy());
     if ($class === 'ArrayObject') {
         $a = $b;
     } else {
         if (!($flags & \ArrayObject::STD_PROP_LIST)) {
             $c->setFlags(\ArrayObject::STD_PROP_LIST);
             if ($a = (array) $c) {
                 $class = new \ReflectionClass($class);
                 foreach ($a as $k => $p) {
                     if (!isset($k[0]) || "" !== $k[0] && !$class->hasProperty($k)) {
                         unset($a[$k]);
                         $a["+" . $k] = $p;
                     }
                 }
             }
             $c->setFlags($flags);
         }
         $a += $b;
     }
     return $a;
 }
开发者ID:Chaireeee,项目名称:chaireeee,代码行数:25,代码来源:SplCaster.php

示例2: castArrayObject

 public static function castArrayObject(\ArrayObject $c, array $a, Stub $stub, $isNested)
 {
     $prefix = Caster::PREFIX_VIRTUAL;
     $class = $stub->class;
     $flags = $c->getFlags();
     $b = array($prefix . 'flag::STD_PROP_LIST' => (bool) ($flags & \ArrayObject::STD_PROP_LIST), $prefix . 'flag::ARRAY_AS_PROPS' => (bool) ($flags & \ArrayObject::ARRAY_AS_PROPS), $prefix . 'iteratorClass' => $c->getIteratorClass(), $prefix . 'storage' => $c->getArrayCopy());
     if ($class === 'ArrayObject') {
         $a = $b;
     } else {
         if (!($flags & \ArrayObject::STD_PROP_LIST)) {
             $c->setFlags(\ArrayObject::STD_PROP_LIST);
             $a = Caster::castObject($c, new \ReflectionClass($class));
             $c->setFlags($flags);
         }
         $a += $b;
     }
     return $a;
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:18,代码来源:SplCaster.php

示例3: makeUpper

<?php
// Custom ArrayIterator (inherits from ArrayIterator)
class MyArrayIterator extends ArrayIterator {
    
    public function makeUpper(){
        
    }
}
// Array of available fruits
$fruits = array("lemons" => 1, "oranges" => 4, "bananas" => 5, "apples" => 10);

$fruitsArrayObject = new ArrayObject($fruits);

// Get the current class name
$className = $fruitsArrayObject->getIteratorClass();
var_dump($className);

// Set new classname
$fruitsArrayObject->setIteratorClass('MyArrayIterator');

// Get the new iterator classname
$className = $fruitsArrayObject->getIteratorClass();
var_dump($className); 
?>
开发者ID:jestintab,项目名称:zendphp,代码行数:24,代码来源:spl-arrayobject-function-5.php

示例4: ArrayObject

<?php

// Copyright 2004-present Facebook. All Rights Reserved.
class MyIterator extends ArrayIterator
{
}
$a = new ArrayObject();
$a->foo = "hello";
$a->setIteratorClass('MyIterator');
var_dump($a->foo);
var_dump($a->getIteratorClass());
$ser = unserialize(serialize($a));
var_dump($ser->foo);
var_dump($ser->getIteratorClass());
开发者ID:afaltz,项目名称:hhvm,代码行数:14,代码来源:array_object.php

示例5: getIteratorClass

 /**
  * @return string
  */
 public function getIteratorClass()
 {
     return $this->data->getIteratorClass();
 }
开发者ID:awdn,项目名称:vigilant-queue,代码行数:7,代码来源:PriorityHashQueue.php

示例6: array

<?php

$ar = array(1, 2, array(31, 32, array(331)), 4);
foreach (new RecursiveIteratorIterator(new ArrayObject($ar, 0, "RecursiveArrayIterator")) as $v) {
    echo "{$v}\n";
}
$it = new ArrayObject($ar);
var_dump($it->getIteratorClass());
try {
    foreach (new RecursiveIteratorIterator(new ArrayObject($ar)) as $v) {
        echo "{$v}\n";
    }
} catch (InvalidArgumentException $e) {
    echo $e->getMessage() . "\n";
}
echo "===MANUAL===\n";
$it->setIteratorClass("RecursiveArrayIterator");
var_dump($it->getIteratorClass());
foreach (new RecursiveIteratorIterator($it) as $v) {
    echo "{$v}\n";
}
?>
===DONE===
开发者ID:gleamingthecube,项目名称:php,代码行数:23,代码来源:ext_spl_tests_iterator_024.php

示例7: getIteratorClass

 /**
  * Implementation of ArrayObject::getIteratorClass().
  *
  * Gets the class name of the array iterator that is used by
  * ArrayObject::getIterator().
  *
  * @return string
  */
 public function getIteratorClass()
 {
     return $this->arrayObject->getIteratorClass();
 }
开发者ID:pbull,项目名称:acquia-platform-cloud-data-model,代码行数:12,代码来源:ArrayObjectImplementationMethods.php


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