1Fixup for precedence and some special syntax
2-----
3<?php
4$a ** $b  *  $c;
5$a  +  $b * $c;
6$a * $b  +  $c;
7$a  ?  $b  :  $c;
8($a ** $b)  *  $c;
9( $a ** $b )  *  $c;
10!$a = $b;
11-----
12// Parens necessary
13$stmts[0]->expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b'));
14// The parens here are "correct", because add is left assoc
15$stmts[1]->expr->right = new Expr\BinaryOp\Plus(new Expr\Variable('b'), new Expr\Variable('c'));
16// No parens necessary
17$stmts[2]->expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b'));
18// Parens for RHS not strictly necessary due to assign speciality
19$stmts[3]->expr->cond = new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b'));
20$stmts[3]->expr->if = new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b'));
21$stmts[3]->expr->else = new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b'));
22// Already has parens
23$stmts[4]->expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b'));
24$stmts[5]->expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b'));
25-----
26<?php
27($a + $b)  *  $c;
28$a  +  ($b + $c);
29$a + $b  +  $c;
30($a = $b)  ?  $a = $b  :  ($a = $b);
31($a + $b)  *  $c;
32( $a + $b )  *  $c;
33!$a = $b;
34-----
35<?php
36foo ();
37foo ();
38$foo -> bar;
39$foo -> bar;
40$foo -> bar;
41$foo -> bar;
42$foo -> bar;
43self :: $foo;
44self :: $foo;
45new Foo();
46$x instanceof Foo;
47Foo :: bar;
48Foo :: $bar;
49Foo :: bar();
50Foo :: bar;
51-----
52$stmts[0]->expr->name = new Expr\Variable('a');
53$stmts[1]->expr->name = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b'));
54$stmts[2]->expr->var = new Expr\Variable('bar');
55$stmts[3]->expr->var = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b'));
56$stmts[4]->expr->name = new Node\Identifier('foo');
57// In this case the braces are not strictly necessary. However, on PHP 5 they may be required
58// depending on where the property fetch node itself occurs.
59$stmts[5]->expr->name = new Expr\Variable('bar');
60$stmts[6]->expr->name = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b'));
61$stmts[7]->expr->name = new Node\VarLikeIdentifier('bar');
62$stmts[8]->expr->name = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b'));
63$stmts[9]->expr->class = new Scalar\String_('Foo');
64$stmts[10]->expr->class = new Scalar\String_('Foo');
65$stmts[11]->expr->class = new Expr\ConstFetch(new Node\Name('FOO'));
66$stmts[12]->expr->class = new Expr\ConstFetch(new Node\Name('FOO'));
67$stmts[13]->expr->class = new Expr\ConstFetch(new Node\Name('FOO'));
68$stmts[14]->expr->name = new Expr\Variable('bar');
69-----
70<?php
71$a ();
72($a . $b) ();
73$bar -> bar;
74($a . $b) -> bar;
75$foo -> foo;
76$foo -> {$bar};
77$foo -> {$a . $b};
78self :: $bar;
79self :: ${$a . $b};
80new ('Foo')();
81$x instanceof ('Foo');
82(FOO) :: bar;
83(FOO) :: $bar;
84(FOO) :: bar();
85Foo :: {$bar};
86