當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArrayObject::setIteratorClass方法代碼示例

本文整理匯總了PHP中ArrayObject::setIteratorClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayObject::setIteratorClass方法的具體用法?PHP ArrayObject::setIteratorClass怎麽用?PHP ArrayObject::setIteratorClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ArrayObject的用法示例。


在下文中一共展示了ArrayObject::setIteratorClass方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: verifyFieldRequirements

 /**
  * Verify that all required fields are populated
  *
  * @throws \Genesis\Exceptions\ErrorParameter
  */
 protected function verifyFieldRequirements()
 {
     if (isset($this->requiredFields)) {
         $this->requiredFields->setIteratorClass('RecursiveArrayIterator');
         $iterator = new \RecursiveIteratorIterator($this->requiredFields->getIterator());
         foreach ($iterator as $fieldName) {
             if (empty($this->{$fieldName})) {
                 throw new \Genesis\Exceptions\ErrorParameter(sprintf('Empty (null) required parameter: %s', $fieldName));
             }
         }
     }
 }
開發者ID:snehamalvankar,項目名稱:magento-ce-emp-plugin,代碼行數:17,代碼來源:Request.php

示例2: array

<?php

// Custom ArrayIterator (inherits from ArrayIterator)
class MyArrayIterator extends ArrayIterator
{
}
// Array of available fruits
$fruits = array("lemons" => 1, "oranges" => 4, "bananas" => 5, "apples" => 10);
$fruitsArrayObject = new ArrayObject($fruits);
// Set the iterator classname to the newly
$fruitsArrayObject->setIteratorClass('MyArrayIterator');
print_r($fruitsArrayObject->getIterator());
開發者ID:badlamer,項目名稱:hhvm,代碼行數:12,代碼來源:setIteratorClass.php

示例3: 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

示例4: setIteratorClass

 /**
  * @param string $className
  */
 public function setIteratorClass($className)
 {
     $this->data->setIteratorClass($className);
 }
開發者ID:awdn,項目名稱:vigilant-queue,代碼行數:7,代碼來源:PriorityHashQueue.php

示例5: 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

示例6: implode

        $args = func_get_args();
        echo "   In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
        return parent::current();
    }
    function next()
    {
        $args = func_get_args();
        echo "   In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
        return parent::next();
    }
    function key()
    {
        $args = func_get_args();
        echo "   In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
        return parent::key();
    }
}
$ao = new ArrayObject(array('a' => 1, 'b' => 2, 'c' => 3), 0, "MyIterator");
echo "--> Access using MyIterator:\n";
var_dump($ao->getIteratorClass());
var_dump($ao->getIterator());
foreach ($ao as $key => $value) {
    echo "  {$key}=>{$value}\n";
}
echo "\n\n--> Access using ArrayIterator:\n";
var_dump($ao->setIteratorClass("ArrayIterator"));
var_dump($ao->getIteratorClass());
var_dump($ao->getIterator());
foreach ($ao as $key => $value) {
    echo "{$key}=>{$value}\n";
}
開發者ID:gleamingthecube,項目名稱:php,代碼行數:31,代碼來源:ext_spl_tests_arrayObject_getIteratorClass_basic1.php

示例7: setIteratorClass

 /**
  * Implementation of ArrayObject::setIteratorClass().
  *
  * Sets the classname of the array iterator that is used by ::getIterator().
  *
  * No value is returned.
  *
  * @param string $iteratorClass
  */
 public function setIteratorClass($iteratorClass)
 {
     $this->arrayObject->setIteratorClass($iteratorClass);
 }
開發者ID:pbull,項目名稱:acquia-platform-cloud-data-model,代碼行數:13,代碼來源:ArrayObjectImplementationMethods.php

示例8: ArrayObject

<?php

try {
    $ao = new ArrayObject(array('a' => 1, 'b' => 2, 'c' => 3));
    $ao->setIteratorClass("nonExistentClass");
    foreach ($ao as $key => $value) {
        echo "  {$key}=>{$value}\n";
    }
} catch (Exception $e) {
    var_dump($e->getMessage());
}
try {
    $ao = new ArrayObject(array('a' => 1, 'b' => 2, 'c' => 3));
    $ao->setIteratorClass("stdClass");
    foreach ($ao as $key => $value) {
        echo "  {$key}=>{$value}\n";
    }
} catch (Exception $e) {
    var_dump($e->getMessage());
}
try {
    $ao = new ArrayObject(array('a' => 1, 'b' => 2, 'c' => 3), 0, "nonExistentClass");
    foreach ($ao as $key => $value) {
        echo "  {$key}=>{$value}\n";
    }
} catch (TypeError $e) {
    var_dump($e->getMessage());
}
try {
    $ao = new ArrayObject(array('a' => 1, 'b' => 2, 'c' => 3), 0, "stdClass");
    foreach ($ao as $key => $value) {
開發者ID:gleamingthecube,項目名稱:php,代碼行數:31,代碼來源:ext_spl_tests_arrayObject_setIteratorClass_error1.php


注:本文中的ArrayObject::setIteratorClass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。