summaryrefslogtreecommitdiff
path: root/ext/spl/tests/array_007.phpt
blob: 3e74e00da4c9b6ea16ecf880074638eaa6fca7a4 (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
--TEST--
SPL: ArrayObject/Iterator from IteratorAggregate
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip"; ?>
--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";
}

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
test Object
(
    [pub] => public
    [pro:protected] => protected
    [pri:private] => private
    [imp] => implicit
    [dyn] => dynamic
)
ArrayIterator Object
(
    [pub] => public
    [pro:protected] => protected
    [pri:private] => private
    [imp] => implicit
    [dyn] => dynamic
)
pub => public
imp => implicit
dyn => dynamic
===DONE===