當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。