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