2019-05-09 14:17:28 +02:00
|
|
|
Arrow Functions
|
|
|
|
-----
|
|
|
|
<?php
|
|
|
|
fn(bool $a) => $a;
|
|
|
|
fn($x = 42) => $x;
|
|
|
|
static fn(&$x) => $x;
|
|
|
|
fn&($x) => $x;
|
|
|
|
fn($x, ...$rest) => $rest;
|
|
|
|
fn(): int => $x;
|
|
|
|
-----
|
|
|
|
!!php7
|
|
|
|
array(
|
|
|
|
0: Stmt_Expression(
|
|
|
|
expr: Expr_ArrowFunction(
|
2020-09-13 21:01:17 +02:00
|
|
|
attrGroups: array(
|
|
|
|
)
|
2019-05-09 14:17:28 +02:00
|
|
|
static: false
|
|
|
|
byRef: false
|
|
|
|
params: array(
|
|
|
|
0: Param(
|
2020-09-13 21:01:17 +02:00
|
|
|
attrGroups: array(
|
|
|
|
)
|
2020-06-07 18:52:12 +02:00
|
|
|
flags: 0
|
2019-05-09 14:17:28 +02:00
|
|
|
type: Identifier(
|
|
|
|
name: bool
|
|
|
|
)
|
|
|
|
byRef: false
|
|
|
|
variadic: false
|
|
|
|
var: Expr_Variable(
|
|
|
|
name: a
|
|
|
|
)
|
|
|
|
default: null
|
|
|
|
)
|
|
|
|
)
|
|
|
|
returnType: null
|
|
|
|
expr: Expr_Variable(
|
|
|
|
name: a
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
1: Stmt_Expression(
|
|
|
|
expr: Expr_ArrowFunction(
|
2020-09-13 21:01:17 +02:00
|
|
|
attrGroups: array(
|
|
|
|
)
|
2019-05-09 14:17:28 +02:00
|
|
|
static: false
|
|
|
|
byRef: false
|
|
|
|
params: array(
|
|
|
|
0: Param(
|
2020-09-13 21:01:17 +02:00
|
|
|
attrGroups: array(
|
|
|
|
)
|
2020-06-07 18:52:12 +02:00
|
|
|
flags: 0
|
2019-05-09 14:17:28 +02:00
|
|
|
type: null
|
|
|
|
byRef: false
|
|
|
|
variadic: false
|
|
|
|
var: Expr_Variable(
|
|
|
|
name: x
|
|
|
|
)
|
|
|
|
default: Scalar_LNumber(
|
|
|
|
value: 42
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
returnType: null
|
|
|
|
expr: Expr_Variable(
|
|
|
|
name: x
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
2: Stmt_Expression(
|
|
|
|
expr: Expr_ArrowFunction(
|
2020-09-13 21:01:17 +02:00
|
|
|
attrGroups: array(
|
|
|
|
)
|
2019-05-09 14:17:28 +02:00
|
|
|
static: true
|
|
|
|
byRef: false
|
|
|
|
params: array(
|
|
|
|
0: Param(
|
2020-09-13 21:01:17 +02:00
|
|
|
attrGroups: array(
|
|
|
|
)
|
2020-06-07 18:52:12 +02:00
|
|
|
flags: 0
|
2019-05-09 14:17:28 +02:00
|
|
|
type: null
|
|
|
|
byRef: true
|
|
|
|
variadic: false
|
|
|
|
var: Expr_Variable(
|
|
|
|
name: x
|
|
|
|
)
|
|
|
|
default: null
|
|
|
|
)
|
|
|
|
)
|
|
|
|
returnType: null
|
|
|
|
expr: Expr_Variable(
|
|
|
|
name: x
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
3: Stmt_Expression(
|
|
|
|
expr: Expr_ArrowFunction(
|
2020-09-13 21:01:17 +02:00
|
|
|
attrGroups: array(
|
|
|
|
)
|
2019-05-09 14:17:28 +02:00
|
|
|
static: false
|
|
|
|
byRef: true
|
|
|
|
params: array(
|
|
|
|
0: Param(
|
2020-09-13 21:01:17 +02:00
|
|
|
attrGroups: array(
|
|
|
|
)
|
2020-06-07 18:52:12 +02:00
|
|
|
flags: 0
|
2019-05-09 14:17:28 +02:00
|
|
|
type: null
|
|
|
|
byRef: false
|
|
|
|
variadic: false
|
|
|
|
var: Expr_Variable(
|
|
|
|
name: x
|
|
|
|
)
|
|
|
|
default: null
|
|
|
|
)
|
|
|
|
)
|
|
|
|
returnType: null
|
|
|
|
expr: Expr_Variable(
|
|
|
|
name: x
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
4: Stmt_Expression(
|
|
|
|
expr: Expr_ArrowFunction(
|
2020-09-13 21:01:17 +02:00
|
|
|
attrGroups: array(
|
|
|
|
)
|
2019-05-09 14:17:28 +02:00
|
|
|
static: false
|
|
|
|
byRef: false
|
|
|
|
params: array(
|
|
|
|
0: Param(
|
2020-09-13 21:01:17 +02:00
|
|
|
attrGroups: array(
|
|
|
|
)
|
2020-06-07 18:52:12 +02:00
|
|
|
flags: 0
|
2019-05-09 14:17:28 +02:00
|
|
|
type: null
|
|
|
|
byRef: false
|
|
|
|
variadic: false
|
|
|
|
var: Expr_Variable(
|
|
|
|
name: x
|
|
|
|
)
|
|
|
|
default: null
|
|
|
|
)
|
|
|
|
1: Param(
|
2020-09-13 21:01:17 +02:00
|
|
|
attrGroups: array(
|
|
|
|
)
|
2020-06-07 18:52:12 +02:00
|
|
|
flags: 0
|
2019-05-09 14:17:28 +02:00
|
|
|
type: null
|
|
|
|
byRef: false
|
|
|
|
variadic: true
|
|
|
|
var: Expr_Variable(
|
|
|
|
name: rest
|
|
|
|
)
|
|
|
|
default: null
|
|
|
|
)
|
|
|
|
)
|
|
|
|
returnType: null
|
|
|
|
expr: Expr_Variable(
|
|
|
|
name: rest
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
5: Stmt_Expression(
|
|
|
|
expr: Expr_ArrowFunction(
|
2020-09-13 21:01:17 +02:00
|
|
|
attrGroups: array(
|
|
|
|
)
|
2019-05-09 14:17:28 +02:00
|
|
|
static: false
|
|
|
|
byRef: false
|
|
|
|
params: array(
|
|
|
|
)
|
|
|
|
returnType: Identifier(
|
|
|
|
name: int
|
|
|
|
)
|
|
|
|
expr: Expr_Variable(
|
|
|
|
name: x
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2020-06-07 18:52:12 +02:00
|
|
|
)
|