1--TEST--
2Test nullsafe in binary op
3--FILE--
4<?php
5
6function try_and_dump($fn) {
7    try {
8        var_dump($fn());
9    } catch (\Error $e) {
10        echo $e->getMessage() . "\n";
11    }
12}
13
14class Foo {
15    public function bar() {
16        echo "bar\n";
17    }
18}
19
20$foo = new Foo();
21$null = null;
22
23try_and_dump(fn() => $null?->null() + $null?->null());
24try_and_dump(fn() => $foo?->bar() + $null?->null());
25try_and_dump(fn() => $null?->null() + $foo?->bar());
26try_and_dump(fn() => $foo->bar() + $null?->null());
27try_and_dump(fn() => $null?->null() + $foo->bar());
28try_and_dump(fn() => $null?->null() + $null->null());
29try_and_dump(fn() => $null->null() + $null?->null());
30try_and_dump(fn() => ($foo?->bar() + $foo?->bar())?->baz());
31
32?>
33--EXPECT--
34int(0)
35bar
36int(0)
37bar
38int(0)
39bar
40int(0)
41bar
42int(0)
43Call to a member function null() on null
44Call to a member function null() on null
45bar
46bar
47Call to a member function baz() on int
48