php-parser/test/code/parser/expr/closure.test

174 lines
4.1 KiB
Plaintext
Raw Normal View History

2011-11-27 11:20:35 +01:00
Closures
-----
<?php
function($a) { $a; };
function($a) use($b) {};
function() use($a, &$b) {};
function &($a) {};
static function() {};
function($a) : array {};
function() use($a) : \Foo\Bar {};
2011-11-27 11:20:35 +01:00
-----
array(
2017-01-19 22:25:22 +01:00
0: Stmt_Expression(
expr: Expr_Closure(
static: false
byRef: false
params: array(
0: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
2017-01-19 23:23:38 +01:00
name: a
)
2017-01-19 22:25:22 +01:00
default: null
)
2011-11-27 11:20:35 +01:00
)
2017-01-19 22:25:22 +01:00
uses: array(
)
returnType: null
stmts: array(
0: Stmt_Expression(
expr: Expr_Variable(
name: a
)
)
2011-11-27 11:20:35 +01:00
)
)
)
2017-01-19 22:25:22 +01:00
1: Stmt_Expression(
expr: Expr_Closure(
static: false
byRef: false
params: array(
0: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
2017-01-19 23:23:38 +01:00
name: a
)
2017-01-19 22:25:22 +01:00
default: null
)
2011-11-27 11:20:35 +01:00
)
2017-01-19 22:25:22 +01:00
uses: array(
0: Expr_ClosureUse(
2017-01-19 23:23:38 +01:00
var: Expr_Variable(
name: b
)
2017-01-19 22:25:22 +01:00
byRef: false
)
)
returnType: null
stmts: array(
2011-11-27 11:20:35 +01:00
)
)
)
2017-01-19 22:25:22 +01:00
2: Stmt_Expression(
expr: Expr_Closure(
static: false
byRef: false
params: array(
2011-11-27 11:20:35 +01:00
)
2017-01-19 22:25:22 +01:00
uses: array(
0: Expr_ClosureUse(
2017-01-19 23:23:38 +01:00
var: Expr_Variable(
name: a
)
2017-01-19 22:25:22 +01:00
byRef: false
)
1: Expr_ClosureUse(
2017-01-19 23:23:38 +01:00
var: Expr_Variable(
name: b
)
2017-01-19 22:25:22 +01:00
byRef: true
)
)
returnType: null
stmts: array(
2011-11-27 11:20:35 +01:00
)
)
)
2017-01-19 22:25:22 +01:00
3: Stmt_Expression(
expr: Expr_Closure(
static: false
byRef: true
params: array(
0: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
2017-01-19 23:23:38 +01:00
name: a
)
2017-01-19 22:25:22 +01:00
default: null
)
)
uses: array(
)
returnType: null
stmts: array(
2011-11-27 11:20:35 +01:00
)
)
)
2017-01-19 22:25:22 +01:00
4: Stmt_Expression(
expr: Expr_Closure(
static: true
byRef: false
params: array(
)
uses: array(
)
returnType: null
stmts: array(
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
5: Stmt_Expression(
expr: Expr_Closure(
static: false
byRef: false
params: array(
0: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
2017-01-19 23:23:38 +01:00
name: a
)
2017-01-19 22:25:22 +01:00
default: null
)
)
uses: array(
)
returnType: array
stmts: array(
)
)
)
2017-01-19 22:25:22 +01:00
6: Stmt_Expression(
expr: Expr_Closure(
static: false
byRef: false
params: array(
)
2017-01-19 22:25:22 +01:00
uses: array(
0: Expr_ClosureUse(
2017-01-19 23:23:38 +01:00
var: Expr_Variable(
name: a
)
2017-01-19 22:25:22 +01:00
byRef: false
)
)
returnType: Name_FullyQualified(
parts: array(
0: Foo
1: Bar
)
)
stmts: array(
)
)
)
2017-01-19 22:25:22 +01:00
)