xref: /PHP-Parser/test/code/parser/expr/nullsafe.test (revision a44faa63)
1Nullsafe operator
2-----
3<?php
4
5$a?->b;
6$a?->b($c);
7new $a?->b;
8"{$a?->b}";
9"$a?->b";
10-----
11array(
12    0: Stmt_Expression(
13        expr: Expr_NullsafePropertyFetch(
14            var: Expr_Variable(
15                name: a
16            )
17            name: Identifier(
18                name: b
19            )
20        )
21    )
22    1: Stmt_Expression(
23        expr: Expr_NullsafeMethodCall(
24            var: Expr_Variable(
25                name: a
26            )
27            name: Identifier(
28                name: b
29            )
30            args: array(
31                0: Arg(
32                    name: null
33                    value: Expr_Variable(
34                        name: c
35                    )
36                    byRef: false
37                    unpack: false
38                )
39            )
40        )
41    )
42    2: Stmt_Expression(
43        expr: Expr_New(
44            class: Expr_NullsafePropertyFetch(
45                var: Expr_Variable(
46                    name: a
47                )
48                name: Identifier(
49                    name: b
50                )
51            )
52            args: array(
53            )
54        )
55    )
56    3: Stmt_Expression(
57        expr: Scalar_InterpolatedString(
58            parts: array(
59                0: Expr_NullsafePropertyFetch(
60                    var: Expr_Variable(
61                        name: a
62                    )
63                    name: Identifier(
64                        name: b
65                    )
66                )
67            )
68        )
69    )
70    4: Stmt_Expression(
71        expr: Scalar_InterpolatedString(
72            parts: array(
73                0: Expr_NullsafePropertyFetch(
74                    var: Expr_Variable(
75                        name: a
76                    )
77                    name: Identifier(
78                        name: b
79                    )
80                )
81            )
82        )
83    )
84)
85