xref: /PHP-Parser/test/code/parser/expr/uvs/new.test (revision beba9c52)
1UVS new expressions
2-----
3<?php
4new $className;
5new $array['className'];
6new $obj->className;
7new Test::$className;
8new $test::$className;
9new $weird[0]->foo::$className;
10-----
11array(
12    0: Stmt_Expression(
13        expr: Expr_New(
14            class: Expr_Variable(
15                name: className
16            )
17            args: array(
18            )
19        )
20    )
21    1: Stmt_Expression(
22        expr: Expr_New(
23            class: Expr_ArrayDimFetch(
24                var: Expr_Variable(
25                    name: array
26                )
27                dim: Scalar_String(
28                    value: className
29                )
30            )
31            args: array(
32            )
33        )
34    )
35    2: Stmt_Expression(
36        expr: Expr_New(
37            class: Expr_PropertyFetch(
38                var: Expr_Variable(
39                    name: obj
40                )
41                name: Identifier(
42                    name: className
43                )
44            )
45            args: array(
46            )
47        )
48    )
49    3: Stmt_Expression(
50        expr: Expr_New(
51            class: Expr_StaticPropertyFetch(
52                class: Name(
53                    name: Test
54                )
55                name: VarLikeIdentifier(
56                    name: className
57                )
58            )
59            args: array(
60            )
61        )
62    )
63    4: Stmt_Expression(
64        expr: Expr_New(
65            class: Expr_StaticPropertyFetch(
66                class: Expr_Variable(
67                    name: test
68                )
69                name: VarLikeIdentifier(
70                    name: className
71                )
72            )
73            args: array(
74            )
75        )
76    )
77    5: Stmt_Expression(
78        expr: Expr_New(
79            class: Expr_StaticPropertyFetch(
80                class: Expr_PropertyFetch(
81                    var: Expr_ArrayDimFetch(
82                        var: Expr_Variable(
83                            name: weird
84                        )
85                        dim: Scalar_Int(
86                            value: 0
87                        )
88                    )
89                    name: Identifier(
90                        name: foo
91                    )
92                )
93                name: VarLikeIdentifier(
94                    name: className
95                )
96            )
97            args: array(
98            )
99        )
100    )
101)
102