1--TEST--
2SPL: RecursiveTreeIterator and IteratorAggregate
3--INI--
4error_reporting=E_ALL&~E_NOTICE
5--FILE--
6<?php
7
8$ary = array(
9	0 => array(
10		"a",
11		1,
12	),
13	"a" => array(
14		2,
15		"b",
16		3 => array(
17			4,
18			"c",
19		),
20		"3" => array(
21			4,
22			"c",
23		),
24	),
25);
26
27class RecursiveArrayIteratorAggregated implements IteratorAggregate {
28	public $it;
29	function __construct($it) {
30		$this->it = new RecursiveArrayIterator($it);
31	}
32	function getIterator() {
33		return $this->it;
34	}
35}
36
37$it = new RecursiveArrayIteratorAggregated($ary);
38echo "-- flags = BYPASS_KEY --\n";
39foreach(new RecursiveTreeIterator($it) as $k => $v) {
40	echo "[$k] => $v\n";
41}
42echo "-- flags = BYPASS_CURRENT --\n";
43foreach(new RecursiveTreeIterator($it, RecursiveTreeIterator::BYPASS_CURRENT) as $k => $v) {
44	echo "[$k] => $v\n";
45}
46echo "-- flags = BYPASS_KEY|BYPASS_KEY --\n";
47foreach(new RecursiveTreeIterator($it, RecursiveTreeIterator::BYPASS_CURRENT|RecursiveTreeIterator::BYPASS_KEY) as $k => $v) {
48	echo "[$k] => $v\n";
49}
50echo "-- flags = 0 --\n";
51foreach(new RecursiveTreeIterator($it, 0) as $k => $v) {
52	echo "[$k] => $v\n";
53}
54echo "-- flags = 0, caching_it_flags = CachingIterator::CATCH_GET_CHILD --\n";
55foreach(new RecursiveTreeIterator($it, 0, CachingIterator::CATCH_GET_CHILD) as $k => $v) {
56	echo "[$k] => $v\n";
57}
58
59?>
60===DONE===
61--EXPECT--
62-- flags = BYPASS_KEY --
63[0] => |-Array
64[0] => | |-a
65[1] => | \-1
66[a] => \-Array
67[0] =>   |-2
68[1] =>   |-b
69[3] =>   \-Array
70[0] =>     |-4
71[1] =>     \-c
72-- flags = BYPASS_CURRENT --
73[|-0] => Array
74[| |-0] => a
75[| \-1] => 1
76[\-a] => Array
77[  |-0] => 2
78[  |-1] => b
79[  \-3] => Array
80[    |-0] => 4
81[    \-1] => c
82-- flags = BYPASS_KEY|BYPASS_KEY --
83[0] => Array
84[0] => a
85[1] => 1
86[a] => Array
87[0] => 2
88[1] => b
89[3] => Array
90[0] => 4
91[1] => c
92-- flags = 0 --
93[|-0] => |-Array
94[| |-0] => | |-a
95[| \-1] => | \-1
96[\-a] => \-Array
97[  |-0] =>   |-2
98[  |-1] =>   |-b
99[  \-3] =>   \-Array
100[    |-0] =>     |-4
101[    \-1] =>     \-c
102-- flags = 0, caching_it_flags = CachingIterator::CATCH_GET_CHILD --
103[|-0] => |-Array
104[| |-0] => | |-a
105[| \-1] => | \-1
106[\-a] => \-Array
107[  |-0] =>   |-2
108[  |-1] =>   |-b
109[  \-3] =>   \-Array
110[    |-0] =>     |-4
111[    \-1] =>     \-c
112===DONE===
113