1--TEST--
2Assign coalesce: All calls should be memoized
3--FILE--
4<?php
5class Foo {
6    public $prop;
7
8    public function foo() {
9        echo __METHOD__, "\n";
10        return $this;
11    }
12
13    public function bar() {
14        echo __METHOD__, "\n";
15        return 'prop';
16    }
17
18    public function __isset($name) {
19        echo __METHOD__, "\n";
20        return false;
21    }
22
23    public function __set($name, $value) {
24        echo __METHOD__, "\n";
25        var_dump($value);
26    }
27}
28
29function &foo() {
30    global $foo;
31    echo __FUNCTION__, "\n";
32    return $foo;
33}
34function bar() {
35    echo __FUNCTION__, "\n";
36}
37
38foo(bar())['bar'] ??= 42;
39var_dump($foo);
40
41$foo = new Foo();
42$foo->foo()->foo()->{$foo->bar()} ??= 42;
43var_dump($foo);
44$foo->foo()->baz ??= 42;
45
46?>
47--EXPECT--
48bar
49foo
50array(1) {
51  ["bar"]=>
52  int(42)
53}
54Foo::foo
55Foo::foo
56Foo::bar
57object(Foo)#1 (1) {
58  ["prop"]=>
59  int(42)
60}
61Foo::foo
62Foo::__isset
63Foo::__set
64int(42)
65