xref: /PHP-Parser/test/code/parser/expr/uvs/misc.test (revision a44faa63)
1Uniform variable syntax in PHP 7 (misc)
2-----
3<?php
4
5"string"->length();
6"foo$bar"[0];
7"foo$bar"->length();
8(clone $obj)->b[0](1);
9[0, 1][0] = 1;
10-----
11array(
12    0: Stmt_Expression(
13        expr: Expr_MethodCall(
14            var: Scalar_String(
15                value: string
16            )
17            name: Identifier(
18                name: length
19            )
20            args: array(
21            )
22        )
23    )
24    1: Stmt_Expression(
25        expr: Expr_ArrayDimFetch(
26            var: Scalar_InterpolatedString(
27                parts: array(
28                    0: InterpolatedStringPart(
29                        value: foo
30                    )
31                    1: Expr_Variable(
32                        name: bar
33                    )
34                )
35            )
36            dim: Scalar_Int(
37                value: 0
38            )
39        )
40    )
41    2: Stmt_Expression(
42        expr: Expr_MethodCall(
43            var: Scalar_InterpolatedString(
44                parts: array(
45                    0: InterpolatedStringPart(
46                        value: foo
47                    )
48                    1: Expr_Variable(
49                        name: bar
50                    )
51                )
52            )
53            name: Identifier(
54                name: length
55            )
56            args: array(
57            )
58        )
59    )
60    3: Stmt_Expression(
61        expr: Expr_FuncCall(
62            name: Expr_ArrayDimFetch(
63                var: Expr_PropertyFetch(
64                    var: Expr_Clone(
65                        expr: Expr_Variable(
66                            name: obj
67                        )
68                    )
69                    name: Identifier(
70                        name: b
71                    )
72                )
73                dim: Scalar_Int(
74                    value: 0
75                )
76            )
77            args: array(
78                0: Arg(
79                    name: null
80                    value: Scalar_Int(
81                        value: 1
82                    )
83                    byRef: false
84                    unpack: false
85                )
86            )
87        )
88    )
89    4: Stmt_Expression(
90        expr: Expr_Assign(
91            var: Expr_ArrayDimFetch(
92                var: Expr_Array(
93                    items: array(
94                        0: ArrayItem(
95                            key: null
96                            value: Scalar_Int(
97                                value: 0
98                            )
99                            byRef: false
100                            unpack: false
101                        )
102                        1: ArrayItem(
103                            key: null
104                            value: Scalar_Int(
105                                value: 1
106                            )
107                            byRef: false
108                            unpack: false
109                        )
110                    )
111                )
112                dim: Scalar_Int(
113                    value: 0
114                )
115            )
116            expr: Scalar_Int(
117                value: 1
118            )
119        )
120    )
121)
122