php5 test coverage

This commit is contained in:
z7zmey 2018-02-12 23:10:53 +02:00
parent 98b1698db7
commit b5e6d263f3
12 changed files with 2215 additions and 1797 deletions

22
diff
View File

@ -117,12 +117,16 @@
117 117
118 118
119 119
-120
121 121
-122
123 123
-124
125 125
126 126
127 127
128 128
-129
130 130
131 131
132 132
@ -138,16 +142,23 @@
142 142
143 143
144 144
-145
-146
147 147
148 148
149 149
-150
151 151
152 152
-153
154 154
-155
156 156
157 157
158 158
159 159
-160
-161
163 163
164 164
166 166
@ -369,17 +380,6 @@
528 528
-120
-122
-124
-129
-145
-146
-150
-153
-155
-160
-161
-162 -162
-165 -165
-177 -177

2686
log

File diff suppressed because it is too large Load Diff

View File

@ -65,7 +65,7 @@ func TestFunctionCallRelative(t *testing.T) {
} }
func TestFunctionFullyQualified(t *testing.T) { func TestFunctionFullyQualified(t *testing.T) {
src := `<? \foo();` src := `<? \foo([]);`
expected := &stmt.StmtList{ expected := &stmt.StmtList{
Stmts: []node.Node{ Stmts: []node.Node{
@ -76,7 +76,15 @@ func TestFunctionFullyQualified(t *testing.T) {
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
Arguments: []node.Node{}, Arguments: []node.Node{
&node.Argument{
Variadic: false,
IsReference: false,
Expr: &expr.ShortArray{
Items: []node.Node{},
},
},
},
}, },
}, },
}, },
@ -90,14 +98,22 @@ func TestFunctionFullyQualified(t *testing.T) {
} }
func TestFunctionCallVar(t *testing.T) { func TestFunctionCallVar(t *testing.T) {
src := `<? $foo();` src := `<? $foo(yield $a);`
expected := &stmt.StmtList{ expected := &stmt.StmtList{
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &expr.Variable{VarName: &node.Identifier{Value: "$foo"}}, Function: &expr.Variable{VarName: &node.Identifier{Value: "$foo"}},
Arguments: []node.Node{}, Arguments: []node.Node{
&node.Argument{
Variadic: false,
IsReference: false,
Expr: &expr.Yield{
Value: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
},
},
},
}, },
}, },
}, },

View File

@ -38,7 +38,7 @@ func TestDeclare(t *testing.T) {
} }
func TestDeclareStmts(t *testing.T) { func TestDeclareStmts(t *testing.T) {
src := `<? declare(ticks=1) {}` src := `<? declare(ticks=1, strict_types=1) {}`
expected := &stmt.StmtList{ expected := &stmt.StmtList{
Stmts: []node.Node{ Stmts: []node.Node{
@ -49,6 +49,11 @@ func TestDeclareStmts(t *testing.T) {
ConstantName: &node.Identifier{Value: "ticks"}, ConstantName: &node.Identifier{Value: "ticks"},
Expr: &scalar.Lnumber{Value: "1"}, Expr: &scalar.Lnumber{Value: "1"},
}, },
&stmt.Constant{
PhpDocComment: "",
ConstantName: &node.Identifier{Value: "strict_types"},
Expr: &scalar.Lnumber{Value: "1"},
},
}, },
Stmt: &stmt.StmtList{ Stmt: &stmt.StmtList{
Stmts: []node.Node{}, Stmts: []node.Node{},

View File

@ -1,11 +1,12 @@
package stmt_test package stmt_test
import ( import (
"github.com/z7zmey/php-parser/node/scalar"
"github.com/z7zmey/php-parser/node/name"
"bytes" "bytes"
"testing" "testing"
"github.com/z7zmey/php-parser/node/name"
"github.com/z7zmey/php-parser/node/scalar"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr" "github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/stmt" "github.com/z7zmey/php-parser/node/stmt"
@ -19,10 +20,10 @@ func TestSimpleFunction(t *testing.T) {
expected := &stmt.StmtList{ expected := &stmt.StmtList{
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Function{ &stmt.Function{
ReturnsRef: false, ReturnsRef: false,
PhpDocComment: "", PhpDocComment: "",
FunctionName: &node.Identifier{Value: "foo"}, FunctionName: &node.Identifier{Value: "foo"},
Stmts: []node.Node{}, Stmts: []node.Node{},
}, },
}, },
} }
@ -40,9 +41,9 @@ func TestFunctionReturn(t *testing.T) {
expected := &stmt.StmtList{ expected := &stmt.StmtList{
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Function{ &stmt.Function{
ReturnsRef: false, ReturnsRef: false,
PhpDocComment: "", PhpDocComment: "",
FunctionName: &node.Identifier{Value: "foo"}, FunctionName: &node.Identifier{Value: "foo"},
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Return{}, &stmt.Return{},
}, },
@ -58,14 +59,28 @@ func TestFunctionReturn(t *testing.T) {
} }
func TestFunctionReturnVar(t *testing.T) { func TestFunctionReturnVar(t *testing.T) {
src := `<? function foo() {return $a;}` src := `<? function foo(array $a, callable $b) {return $a;}`
expected := &stmt.StmtList{ expected := &stmt.StmtList{
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Function{ &stmt.Function{
ReturnsRef: false, ReturnsRef: false,
PhpDocComment: "", PhpDocComment: "",
FunctionName: &node.Identifier{Value: "foo"}, FunctionName: &node.Identifier{Value: "foo"},
Params: []node.Node{
&node.Parameter{
ByRef: false,
Variadic: false,
VariableType: &node.Identifier{Value: "array"},
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
},
&node.Parameter{
ByRef: false,
Variadic: false,
VariableType: &node.Identifier{Value: "callable"},
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
},
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Return{ &stmt.Return{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
@ -88,9 +103,9 @@ func TestRefFunction(t *testing.T) {
expected := &stmt.StmtList{ expected := &stmt.StmtList{
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Function{ &stmt.Function{
ReturnsRef: true, ReturnsRef: true,
PhpDocComment: "", PhpDocComment: "",
FunctionName: &node.Identifier{Value: "foo"}, FunctionName: &node.Identifier{Value: "foo"},
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Return{ &stmt.Return{
Expr: &scalar.Lnumber{Value: "1"}, Expr: &scalar.Lnumber{Value: "1"},
@ -113,9 +128,9 @@ func TestReturnTypeFunction(t *testing.T) {
expected := &stmt.StmtList{ expected := &stmt.StmtList{
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Function{ &stmt.Function{
ReturnsRef: true, ReturnsRef: true,
PhpDocComment: "", PhpDocComment: "",
FunctionName: &node.Identifier{Value: "foo"}, FunctionName: &node.Identifier{Value: "foo"},
ReturnType: &name.Name{ ReturnType: &name.Name{
Parts: []node.Node{ Parts: []node.Node{
&name.NamePart{Value: "void"}, &name.NamePart{Value: "void"},

View File

@ -3,10 +3,11 @@ package stmt_test
import ( import (
"bytes" "bytes"
"testing" "testing"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/stmt"
"github.com/z7zmey/php-parser/node/expr" "github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/name"
"github.com/z7zmey/php-parser/node/stmt"
"github.com/z7zmey/php-parser/php5" "github.com/z7zmey/php-parser/php5"
"github.com/z7zmey/php-parser/php7" "github.com/z7zmey/php-parser/php7"
) )
@ -32,7 +33,7 @@ func TestGlobal(t *testing.T) {
} }
func TestGlobalVars(t *testing.T) { func TestGlobalVars(t *testing.T) {
src := `<? global $a, $b;` src := `<? global $a, $b, $$c, ${foo()};`
expected := &stmt.StmtList{ expected := &stmt.StmtList{
Stmts: []node.Node{ Stmts: []node.Node{
@ -40,6 +41,17 @@ func TestGlobalVars(t *testing.T) {
Vars: []node.Node{ Vars: []node.Node{
&expr.Variable{VarName: &node.Identifier{Value: "$a"}}, &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
&expr.Variable{VarName: &node.Identifier{Value: "$b"}}, &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
&expr.Variable{VarName: &expr.Variable{VarName: &node.Identifier{Value: "$c"}}},
&expr.Variable{
VarName: &expr.FunctionCall{
Function: &name.Name{
Parts: []node.Node{
&name.NamePart{Value: "foo"},
},
},
Arguments: []node.Node{},
},
},
}, },
}, },
}, },

View File

@ -3,11 +3,11 @@ package stmt_test
import ( import (
"bytes" "bytes"
"testing" "testing"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr" "github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/stmt"
"github.com/z7zmey/php-parser/node/scalar" "github.com/z7zmey/php-parser/node/scalar"
"github.com/z7zmey/php-parser/node/stmt"
"github.com/z7zmey/php-parser/php5" "github.com/z7zmey/php-parser/php5"
"github.com/z7zmey/php-parser/php7" "github.com/z7zmey/php-parser/php7"
) )
@ -46,7 +46,33 @@ func TestStaticVars(t *testing.T) {
}, },
&stmt.StaticVar{ &stmt.StaticVar{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Expr: &scalar.Lnumber{Value: "1"}, Expr: &scalar.Lnumber{Value: "1"},
},
},
},
},
}
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
}
func TestStaticVars2(t *testing.T) {
src := `<? static $a = 1, $b;`
expected := &stmt.StmtList{
Stmts: []node.Node{
&stmt.Static{
Vars: []node.Node{
&stmt.StaticVar{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Expr: &scalar.Lnumber{Value: "1"},
},
&stmt.StaticVar{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
}, },
}, },
}, },

View File

@ -27,14 +27,14 @@ func TestAltSwitch(t *testing.T) {
Cond: &scalar.Lnumber{Value: "1"}, Cond: &scalar.Lnumber{Value: "1"},
Cases: []node.Node{ Cases: []node.Node{
&stmt.Case{ &stmt.Case{
Cond: &scalar.Lnumber{Value: "1"}, Cond: &scalar.Lnumber{Value: "1"},
Stmts: []node.Node{}, Stmts: []node.Node{},
}, },
&stmt.Default{ &stmt.Default{
Stmts: []node.Node{}, Stmts: []node.Node{},
}, },
&stmt.Case{ &stmt.Case{
Cond: &scalar.Lnumber{Value: "2"}, Cond: &scalar.Lnumber{Value: "2"},
Stmts: []node.Node{}, Stmts: []node.Node{},
}, },
}, },
@ -45,6 +45,38 @@ func TestAltSwitch(t *testing.T) {
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php") actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual) assertEqual(t, expected, actual)
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
}
func TestAltSwitchSemicolon(t *testing.T) {
src := `<?
switch (1) :;
case 1;
case 2;
endswitch;
`
expected := &stmt.StmtList{
Stmts: []node.Node{
&stmt.Switch{
Cond: &scalar.Lnumber{Value: "1"},
Cases: []node.Node{
&stmt.Case{
Cond: &scalar.Lnumber{Value: "1"},
Stmts: []node.Node{},
},
&stmt.Case{
Cond: &scalar.Lnumber{Value: "2"},
Stmts: []node.Node{},
},
},
},
},
}
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php") actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual) assertEqual(t, expected, actual)
@ -54,6 +86,43 @@ func TestSwitch(t *testing.T) {
src := `<? src := `<?
switch (1) { switch (1) {
case 1: break; case 1: break;
case 2: break;
}
`
expected := &stmt.StmtList{
Stmts: []node.Node{
&stmt.Switch{
Cond: &scalar.Lnumber{Value: "1"},
Cases: []node.Node{
&stmt.Case{
Cond: &scalar.Lnumber{Value: "1"},
Stmts: []node.Node{
&stmt.Break{},
},
},
&stmt.Case{
Cond: &scalar.Lnumber{Value: "2"},
Stmts: []node.Node{
&stmt.Break{},
},
},
},
},
},
}
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
}
func TestSwitchSemicolon(t *testing.T) {
src := `<?
switch (1) {;
case 1; break;
case 2; break; case 2; break;
} }
` `
@ -85,4 +154,4 @@ func TestSwitch(t *testing.T) {
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php") actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual) assertEqual(t, expected, actual)
} }

View File

@ -31,7 +31,6 @@ func TestBreakEmpty(t *testing.T) {
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php") actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual) assertEqual(t, expected, actual)
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php") actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual) assertEqual(t, expected, actual)
} }
@ -57,13 +56,12 @@ func TestBreakLight(t *testing.T) {
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php") actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual) assertEqual(t, expected, actual)
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php") actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual) assertEqual(t, expected, actual)
} }
func TestBreak(t *testing.T) { func TestBreak(t *testing.T) {
src := `<? while (1) { break(3); }` src := `<? while (1) : break(3); endwhile;`
expected := &stmt.StmtList{ expected := &stmt.StmtList{
Stmts: []node.Node{ Stmts: []node.Node{
@ -83,7 +81,6 @@ func TestBreak(t *testing.T) {
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php") actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual) assertEqual(t, expected, actual)
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php") actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual) assertEqual(t, expected, actual)
} }

File diff suppressed because it is too large Load Diff

View File

@ -668,7 +668,11 @@ unticked_statement:
comments.AddComments($$, $1.Comments()) comments.AddComments($$, $1.Comments())
} }
| yield_expr ';' | yield_expr ';'
{ fmt.Println("58"); $$ = $1 } {
fmt.Println("58"); $$ = stmt.NewExpression($1)
positions.AddPosition($$, positionBuilder.NewNodeTokenPosition($1, $2))
comments.AddComments($$, comments[$1])
}
| T_GLOBAL global_var_list ';' | T_GLOBAL global_var_list ';'
{ {
fmt.Println("59"); $$ = stmt.NewGlobal($2) fmt.Println("59"); $$ = stmt.NewGlobal($2)
@ -2276,41 +2280,25 @@ expr_without_variable:
yield_expr: yield_expr:
T_YIELD expr_without_variable T_YIELD expr_without_variable
{ {
yield := expr.NewYield(nil, $2) fmt.Println("307"); $$ = expr.NewYield(nil, $2)
positions.AddPosition(yield, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments(yield, $1.Comments())
fmt.Println("307"); $$ = stmt.NewExpression(yield)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2)) positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments()) comments.AddComments($$, $1.Comments())
} }
| T_YIELD variable | T_YIELD variable
{ {
yield := expr.NewYield(nil, $2) fmt.Println("308"); $$ = expr.NewYield(nil, $2)
positions.AddPosition(yield, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments(yield, $1.Comments())
fmt.Println("308"); $$ = stmt.NewExpression(yield)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2)) positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
comments.AddComments($$, $1.Comments()) comments.AddComments($$, $1.Comments())
} }
| T_YIELD expr T_DOUBLE_ARROW expr_without_variable | T_YIELD expr T_DOUBLE_ARROW expr_without_variable
{ {
yield := expr.NewYield($2, $4) fmt.Println("309"); $$ = expr.NewYield($2, $4)
positions.AddPosition(yield, positionBuilder.NewTokenNodePosition($1, $4))
comments.AddComments(yield, $1.Comments())
fmt.Println("309"); $$ = stmt.NewExpression(yield)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $4)) positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $4))
comments.AddComments($$, $1.Comments()) comments.AddComments($$, $1.Comments())
} }
| T_YIELD expr T_DOUBLE_ARROW variable | T_YIELD expr T_DOUBLE_ARROW variable
{ {
yield := expr.NewYield($2, $4) fmt.Println("310"); $$ = expr.NewYield($2, $4)
positions.AddPosition(yield, positionBuilder.NewTokenNodePosition($1, $4))
comments.AddComments(yield, $1.Comments())
fmt.Println("310"); $$ = stmt.NewExpression(yield)
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $4)) positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $4))
comments.AddComments($$, $1.Comments()) comments.AddComments($$, $1.Comments())
} }

View File

@ -102,7 +102,7 @@ CAD;
while (1) { break; } while (1) { break; }
while (1) { break 2; } while (1) { break 2; }
while (1) { break(3); } while (1) : break(3); endwhile;
class foo{ const FOO = 1, BAR = 2; } class foo{ const FOO = 1, BAR = 2; }
class foo{ function bar() {} } class foo{ function bar() {} }
class foo{ public static function &bar() {} } class foo{ public static function &bar() {} }
@ -117,7 +117,7 @@ CAD;
while (1) { continue 2; } while (1) { continue 2; }
while (1) { continue(3); } while (1) { continue(3); }
declare(ticks=1); declare(ticks=1);
declare(ticks=1) {} declare(ticks=1, strict_types=1) {}
declare(ticks=1): enddeclare; declare(ticks=1): enddeclare;
do {} while(1); do {} while(1);
echo $a, 1; echo $a, 1;
@ -140,10 +140,10 @@ CAD;
return $a; return $a;
} }
function foo() {return;} function foo(array $a, callable $b) {return;}
function &foo() {return 1;} function &foo() {return 1;}
function &foo() {} function &foo() {}
global $a, $b; global $a, $b, $$c, ${foo()};
a: a:
goto a; goto a;
__halt_compiler(); __halt_compiler();
@ -162,15 +162,26 @@ CAD;
class foo {var $a;} class foo {var $a;}
class foo {public static $a, $b = 1;} class foo {public static $a, $b = 1;}
static $a, $b = 1; static $a, $b = 1;
static $a = 1, $b;
switch (1) : switch (1) :
case 1: case 1:
default: default:
case 2:
endswitch;
switch (1) :;
case 1;
case 2; case 2;
endswitch; endswitch;
switch (1) { switch (1) {
case 1: break; case 1: break;
case 2: break;
}
switch (1) {;
case 1; break;
case 2; break; case 2; break;
} }
throw $e; throw $e;
@ -223,9 +234,9 @@ CAD;
die; die;
die($a); die($a);
foo(); foo();
namespace\foo(); namespace\foo(&$a);
\foo(); \foo([]);
$foo(); $foo(yield $a);
$a--; $a--;
$a++; $a++;
@ -794,6 +805,11 @@ CAD;
ConstantName: &node.Identifier{Value: "ticks"}, ConstantName: &node.Identifier{Value: "ticks"},
Expr: &scalar.Lnumber{Value: "1"}, Expr: &scalar.Lnumber{Value: "1"},
}, },
&stmt.Constant{
PhpDocComment: "",
ConstantName: &node.Identifier{Value: "strict_types"},
Expr: &scalar.Lnumber{Value: "1"},
},
}, },
Stmt: &stmt.StmtList{ Stmt: &stmt.StmtList{
Stmts: []node.Node{}, Stmts: []node.Node{},
@ -936,7 +952,7 @@ CAD;
ReturnsRef: false, ReturnsRef: false,
PhpDocComment: "", PhpDocComment: "",
FunctionName: &node.Identifier{Value: "foo"}, FunctionName: &node.Identifier{Value: "foo"},
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.HaltCompiler{}, &stmt.HaltCompiler{},
&stmt.Function{ &stmt.Function{
ReturnsRef: false, ReturnsRef: false,
@ -946,8 +962,8 @@ CAD;
}, },
&stmt.Class{ &stmt.Class{
PhpDocComment: "", PhpDocComment: "",
ClassName: &node.Identifier{Value: "Baz"}, ClassName: &node.Identifier{Value: "Baz"},
Stmts: []node.Node{}, Stmts: []node.Node{},
}, },
&stmt.Return{ &stmt.Return{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
@ -958,6 +974,20 @@ CAD;
ReturnsRef: false, ReturnsRef: false,
PhpDocComment: "", PhpDocComment: "",
FunctionName: &node.Identifier{Value: "foo"}, FunctionName: &node.Identifier{Value: "foo"},
Params: []node.Node{
&node.Parameter{
ByRef: false,
Variadic: false,
VariableType: &node.Identifier{Value: "array"},
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
},
&node.Parameter{
ByRef: false,
Variadic: false,
VariableType: &node.Identifier{Value: "callable"},
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
},
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Return{}, &stmt.Return{},
}, },
@ -982,6 +1012,17 @@ CAD;
Vars: []node.Node{ Vars: []node.Node{
&expr.Variable{VarName: &node.Identifier{Value: "$a"}}, &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
&expr.Variable{VarName: &node.Identifier{Value: "$b"}}, &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
&expr.Variable{VarName: &expr.Variable{VarName: &node.Identifier{Value: "$c"}}},
&expr.Variable{
VarName: &expr.FunctionCall{
Function: &name.Name{
Parts: []node.Node{
&name.NamePart{Value: "foo"},
},
},
Arguments: []node.Node{},
},
},
}, },
}, },
&stmt.Label{ &stmt.Label{
@ -1152,6 +1193,17 @@ CAD;
}, },
}, },
}, },
&stmt.Static{
Vars: []node.Node{
&stmt.StaticVar{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Expr: &scalar.Lnumber{Value: "1"},
},
&stmt.StaticVar{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
},
},
&stmt.Switch{ &stmt.Switch{
Cond: &scalar.Lnumber{Value: "1"}, Cond: &scalar.Lnumber{Value: "1"},
Cases: []node.Node{ Cases: []node.Node{
@ -1168,6 +1220,36 @@ CAD;
}, },
}, },
}, },
&stmt.Switch{
Cond: &scalar.Lnumber{Value: "1"},
Cases: []node.Node{
&stmt.Case{
Cond: &scalar.Lnumber{Value: "1"},
Stmts: []node.Node{},
},
&stmt.Case{
Cond: &scalar.Lnumber{Value: "2"},
Stmts: []node.Node{},
},
},
},
&stmt.Switch{
Cond: &scalar.Lnumber{Value: "1"},
Cases: []node.Node{
&stmt.Case{
Cond: &scalar.Lnumber{Value: "1"},
Stmts: []node.Node{
&stmt.Break{},
},
},
&stmt.Case{
Cond: &scalar.Lnumber{Value: "2"},
Stmts: []node.Node{
&stmt.Break{},
},
},
},
},
&stmt.Switch{ &stmt.Switch{
Cond: &scalar.Lnumber{Value: "1"}, Cond: &scalar.Lnumber{Value: "1"},
Cases: []node.Node{ Cases: []node.Node{
@ -1750,7 +1832,13 @@ CAD;
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
Arguments: []node.Node{}, Arguments: []node.Node{
&node.Argument{
Variadic: false,
IsReference: true,
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
},
},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
@ -1760,13 +1848,29 @@ CAD;
&name.NamePart{Value: "foo"}, &name.NamePart{Value: "foo"},
}, },
}, },
Arguments: []node.Node{}, Arguments: []node.Node{
&node.Argument{
Variadic: false,
IsReference: false,
Expr: &expr.ShortArray{
Items: []node.Node{},
},
},
},
}, },
}, },
&stmt.Expression{ &stmt.Expression{
Expr: &expr.FunctionCall{ Expr: &expr.FunctionCall{
Function: &expr.Variable{VarName: &node.Identifier{Value: "$foo"}}, Function: &expr.Variable{VarName: &node.Identifier{Value: "$foo"}},
Arguments: []node.Node{}, Arguments: []node.Node{
&node.Argument{
Variadic: false,
IsReference: false,
Expr: &expr.Yield{
Value: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
},
},
},
}, },
}, },
&stmt.Expression{ &stmt.Expression{