xref: /PHP-8.0/Zend/tests/bug72813.phpt (revision 782352c5)
1--TEST--
2Bug #72813 (Segfault with __get returned by ref)
3--FILE--
4<?php
5class Test
6{
7    private $props = ['a' => 'text', 'b' => 1];
8
9    public function &__get($prop)
10    {
11        return $this->props[$prop];
12    }
13
14    public function __set($prop, $value)
15    {
16        if ($prop === 'b') $value = [$value];
17        $this->props[$prop] = $value;
18    }
19
20    public function getProperties()
21    {
22        return [$this->props];
23    }
24}
25
26$obj = new Test;
27$obj->b = $obj->b;
28print_r($obj->getProperties());
29?>
30--EXPECT--
31Array
32(
33    [0] => Array
34        (
35            [a] => text
36            [b] => Array
37                (
38                    [0] => 1
39                )
40
41        )
42
43)
44