blob: e32f1389400e43d2230516ead200946178d8b9ca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
--TEST--
SPL: ArrayObject/Iterator from IteratorAggregate
--FILE--
<?php
// This test also needs to exclude the protected and private variables
// since they cannot be accessed from the external object which iterates
// them.
class test implements IteratorAggregate
{
public $pub = "public";
protected $pro = "protected";
private $pri = "private";
function __construct()
{
$this->imp = "implicit";
}
function getIterator()
{
$it = new ArrayObject($this);
return $it->getIterator();
}
};
$test = new test;
$test->dyn = "dynamic";
print_r($test);
print_r($test->getIterator());
foreach($test as $key => $val)
{
echo "$key => $val\n";
}
?>
--EXPECT--
test Object
(
[pub] => public
[pro:protected] => protected
[pri:test:private] => private
[imp] => implicit
[dyn] => dynamic
)
ArrayIterator Object
(
[storage:ArrayIterator:private] => ArrayObject Object
(
[storage:ArrayObject:private] => test Object
(
[pub] => public
[pro:protected] => protected
[pri:test:private] => private
[imp] => implicit
[dyn] => dynamic
)
)
)
pub => public
imp => implicit
dyn => dynamic
|