1--TEST--
2Test basic nullsafe property fetching
3--FILE--
4<?php
5
6class Foo {
7    public $bar = 'bar';
8
9    function qux() {
10        return 'qux';
11    }
12}
13
14$null = null;
15$foo = new Foo();
16
17var_dump(null?->bar);
18var_dump(null?->baz);
19var_dump(null?->qux());
20var_dump(null?->quux());
21
22var_dump($foo?->bar);
23var_dump($foo?->baz);
24var_dump($foo?->qux());
25try {
26    var_dump($foo?->quux());
27} catch (Throwable $e) {
28    var_dump($e->getMessage());
29}
30
31var_dump((new Foo)?->bar);
32var_dump((new Foo)?->baz);
33var_dump((new Foo)?->qux());
34try {
35    var_dump((new Foo)?->quux());
36} catch (Throwable $e) {
37    var_dump($e->getMessage());
38}
39
40?>
41--EXPECTF--
42NULL
43NULL
44NULL
45NULL
46string(3) "bar"
47
48Warning: Undefined property: Foo::$baz in %s.php on line 20
49NULL
50string(3) "qux"
51string(36) "Call to undefined method Foo::quux()"
52string(3) "bar"
53
54Warning: Undefined property: Foo::$baz in %s.php on line 29
55NULL
56string(3) "qux"
57string(36) "Call to undefined method Foo::quux()"
58