1--TEST--
2SPL: ArrayObject::getIteratorClass and ArrayObject::setIteratorClass basic functionality
3--FILE--
4<?php
5class MyIterator extends ArrayIterator {
6
7	function __construct() {
8	 	$args = func_get_args();
9		echo "   In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
10	}
11
12	function rewind() {
13		$args = func_get_args();
14		echo "   In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
15		return parent::rewind();
16	}
17
18	function valid() {
19		$args = func_get_args();
20		echo "   In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
21		return parent::valid();
22	}
23
24	function current() {
25		$args = func_get_args();
26		echo "   In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
27		return parent::current();
28	}
29
30	function next() {
31		$args = func_get_args();
32		echo "   In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
33		return parent::next();
34	}
35
36	function key() {
37		$args = func_get_args();
38		echo "   In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
39		return parent::key();
40	}
41}
42
43$ao = new ArrayObject(array('a'=>1,'b'=>2,'c'=>3), 0, "MyIterator");
44
45echo "--> Access using MyIterator:\n";
46var_dump($ao->getIteratorClass());
47var_dump($ao->getIterator());
48foreach($ao as $key=>$value) {
49	echo "  $key=>$value\n";
50}
51
52echo "\n\n--> Access using ArrayIterator:\n";
53var_dump($ao->setIteratorClass("ArrayIterator"));
54var_dump($ao->getIteratorClass());
55var_dump($ao->getIterator());
56foreach($ao as $key=>$value) {
57	echo "$key=>$value\n";
58}
59
60?>
61--EXPECTF--
62--> Access using MyIterator:
63string(10) "MyIterator"
64object(MyIterator)#2 (1) {
65  ["storage":"ArrayIterator":private]=>
66  object(ArrayObject)#1 (1) {
67    ["storage":"ArrayObject":private]=>
68    array(3) {
69      ["a"]=>
70      int(1)
71      ["b"]=>
72      int(2)
73      ["c"]=>
74      int(3)
75    }
76  }
77}
78   In MyIterator::rewind()
79   In MyIterator::valid()
80   In MyIterator::current()
81   In MyIterator::key()
82  a=>1
83   In MyIterator::next()
84   In MyIterator::valid()
85   In MyIterator::current()
86   In MyIterator::key()
87  b=>2
88   In MyIterator::next()
89   In MyIterator::valid()
90   In MyIterator::current()
91   In MyIterator::key()
92  c=>3
93   In MyIterator::next()
94   In MyIterator::valid()
95
96
97--> Access using ArrayIterator:
98NULL
99string(13) "ArrayIterator"
100object(ArrayIterator)#3 (1) {
101  ["storage":"ArrayIterator":private]=>
102  object(ArrayObject)#1 (1) {
103    ["storage":"ArrayObject":private]=>
104    array(3) {
105      ["a"]=>
106      int(1)
107      ["b"]=>
108      int(2)
109      ["c"]=>
110      int(3)
111    }
112  }
113}
114a=>1
115b=>2
116c=>3
117