xref: /PHP-7.4/Zend/tests/bug75573.phpt (revision a9e66678)
1--TEST--
2Bug #75573 (Segmentation fault in 7.1.12 and 7.0.26)
3--FILE--
4<?php
5
6class A
7{
8	var $_stdObject;
9	function &__get($property)
10	{
11		if (isset($this->_stdObject->{$property})) {
12			$retval =& $this->_stdObject->{$property};
13			return $retval;
14		} else {
15			return NULL;
16		}
17	}
18	function &__set($property, $value)
19	{
20		return $this->_stdObject->{$property} = $value;
21	}
22	function __isset($property_name)
23	{
24		return isset($this->_stdObject->{$property_name});
25	}
26}
27
28class B extends A
29{
30	function &__get($property)
31	{
32		if (isset($this->settings) && isset($this->settings[$property])) {
33			$retval =& $this->settings[$property];
34			return $retval;
35		} else {
36			return parent::__get($property);
37		}
38	}
39}
40
41$b = new B();
42$b->settings = [ "foo" => "bar", "name" => "abc" ];
43var_dump($b->name);
44var_dump($b->settings);
45?>
46--EXPECTF--
47Warning: Creating default object from empty value in %sbug75573.php on line %d
48
49Notice: Only variable references should be returned by reference in %sbug75573.php on line %d
50string(3) "abc"
51array(2) {
52  ["foo"]=>
53  string(3) "bar"
54  ["name"]=>
55  string(3) "abc"
56}
57