Skip to content

Commit d1ee4b4

Browse files
committed
- Commite manually if not conatined in bunch commit
1 parent 7d918fa commit d1ee4b4

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

ext/spl/tests/array_009a.phpt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
SPL: ArrayIterator implementing RecursiveIterator
3+
--SKIPIF--
4+
<?php if (!extension_loaded("spl")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
8+
class MyRecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
9+
{
10+
function hasChildren()
11+
{
12+
return is_array($this->current());
13+
}
14+
15+
function getChildren()
16+
{
17+
return new MyRecursiveArrayIterator($this->current());
18+
}
19+
}
20+
21+
$array = array(1, 2 => array(21, 22 => array(221, 222), 23 => array(231)), 3);
22+
23+
$dir = new RecursiveIteratorIterator(new MyRecursiveArrayIterator($array), RecursiveIteratorIterator::LEAVES_ONLY);
24+
25+
foreach ($dir as $file) {
26+
print "$file\n";
27+
}
28+
29+
?>
30+
===DONE===
31+
<?php exit(0); ?>
32+
--EXPECT--
33+
1
34+
21
35+
221
36+
222
37+
231
38+
3
39+
===DONE===

ext/spl/tests/iterator_024.phpt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--TEST--
2+
SPL: RecursiveIteratorIterator with custom iterator class
3+
--FILE--
4+
<?php
5+
6+
$ar = array(1, 2, array(31, 32, array(331)), 4);
7+
8+
foreach(new RecursiveIteratorIterator(new ArrayObject($ar, 0, "RecursiveArrayIterator")) as $v) echo "$v\n";
9+
10+
$it = new ArrayObject($ar);
11+
var_dump($it->getIteratorClass());
12+
13+
try
14+
{
15+
foreach(new RecursiveIteratorIterator(new ArrayObject($ar)) as $v) echo "$v\n";
16+
}
17+
catch (InvalidArgumentException $e)
18+
{
19+
echo $e->getMessage() . "\n";
20+
}
21+
22+
echo "===MANUAL===\n";
23+
24+
$it->setIteratorClass("RecursiveArrayIterator");
25+
var_dump($it->getIteratorClass());
26+
foreach(new RecursiveIteratorIterator($it) as $v) echo "$v\n";
27+
28+
29+
?>
30+
===DONE===
31+
<?php exit(0); ?>
32+
--EXPECT--
33+
1
34+
2
35+
31
36+
32
37+
331
38+
4
39+
string(13) "ArrayIterator"
40+
An instance of RecursiveIterator or IteratorAggregate creating it is required
41+
===MANUAL===
42+
string(22) "RecursiveArrayIterator"
43+
1
44+
2
45+
31
46+
32
47+
331
48+
4
49+
===DONE===

0 commit comments

Comments
 (0)