xref: /PHP-7.2/Zend/tests/bug75573.phpt (revision d4dee4a6)
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 initialize($properties = FALSE) {
10		$this->_stdObject = $properties ? (object) $properties : new stdClass();
11		parent::initialize();
12	}
13	function &__get($property)
14	{
15		if (isset($this->_stdObject->{$property})) {
16			$retval =& $this->_stdObject->{$property};
17			return $retval;
18		} else {
19			return NULL;
20		}
21	}
22	function &__set($property, $value)
23	{
24		return $this->_stdObject->{$property} = $value;
25	}
26	function __isset($property_name)
27	{
28		return isset($this->_stdObject->{$property_name});
29	}
30}
31
32class B extends A
33{
34	function initialize($properties = array())
35	{
36		parent::initialize($properties);
37	}
38	function &__get($property)
39	{
40		if (isset($this->settings) && isset($this->settings[$property])) {
41			$retval =& $this->settings[$property];
42			return $retval;
43		} else {
44			return parent::__get($property);
45		}
46	}
47}
48
49$b = new B();
50$b->settings = [ "foo" => "bar", "name" => "abc" ];
51var_dump($b->name);
52var_dump($b->settings);
53?>
54--EXPECTF--
55Warning: Creating default object from empty value in %sbug75573.php on line %d
56
57Notice: Only variable references should be returned by reference in %sbug75573.php on line %d
58string(3) "abc"
59array(2) {
60  ["foo"]=>
61  string(3) "bar"
62  ["name"]=>
63  string(3) "abc"
64}
65