本文整理汇总了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;
}
示例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;
}
示例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);
?>
示例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());
示例5: getIteratorClass
/**
* @return string
*/
public function getIteratorClass()
{
return $this->data->getIteratorClass();
}
示例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===
示例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();
}