xref: /PHP-8.2/Zend/tests/bug75573.phpt (revision f8d79582)
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 __construct()
10    {
11        $this->_stdObject = new stdClass;
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 &__get($property)
35    {
36        if (isset($this->settings) && isset($this->settings[$property])) {
37            $retval =& $this->settings[$property];
38            return $retval;
39        } else {
40            return parent::__get($property);
41        }
42    }
43}
44
45$b = new B();
46$b->settings = [ "foo" => "bar", "name" => "abc" ];
47var_dump($b->name);
48var_dump($b->settings);
49?>
50--EXPECTF--
51Notice: Only variable references should be returned by reference in %s on line %d
52string(3) "abc"
53array(2) {
54  ["foo"]=>
55  string(3) "bar"
56  ["name"]=>
57  string(3) "abc"
58}
59