xref: /PHP-7.3/Zend/tests/bug37667.phpt (revision 610c7fbe)
1--TEST--
2Bug #37667 (Object is not added into array returned by __get)
3--FILE--
4<?php
5
6class Test
7{
8	protected $property = array('foo' => 'bar');
9
10	function __get($name)
11	{
12		return $this->property;
13	}
14}
15
16$obj = new Test;
17
18var_dump($obj->property['foo']);
19var_dump($obj->property[2]);
20
21var_dump($obj);
22
23$obj->property[] = 1;
24$obj->property[] = 2;
25
26var_dump($obj);
27
28?>
29===DONE===
30--EXPECTF--
31string(3) "bar"
32
33Notice: Undefined offset: 2 in %sbug37667.php on line 16
34NULL
35object(Test)#%d (1) {
36  ["property":protected]=>
37  array(1) {
38    ["foo"]=>
39    string(3) "bar"
40  }
41}
42
43Notice: Indirect modification of overloaded property Test::$property has no effect in %sbug37667.php on line 20
44
45Notice: Indirect modification of overloaded property Test::$property has no effect in %sbug37667.php on line 21
46object(Test)#%d (1) {
47  ["property":protected]=>
48  array(1) {
49    ["foo"]=>
50    string(3) "bar"
51  }
52}
53===DONE===
54