当前位置: 首页>>代码示例>>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;未经允许,请勿转载。