the whole shebang

This commit is contained in:
2014-11-25 16:42:40 +01:00
parent 7f74c0613e
commit ab1334c0cf
3686 changed files with 496409 additions and 1 deletions

View File

@@ -0,0 +1,37 @@
Return and pass by ref
-----
<?php
function a(&$b) {}
function &a($b) {}
-----
array(
0: Stmt_Function(
byRef: false
params: array(
0: Param(
name: b
default: null
type: null
byRef: true
)
)
stmts: array(
)
name: a
)
1: Stmt_Function(
byRef: true
params: array(
0: Param(
name: b
default: null
type: null
byRef: false
)
)
stmts: array(
)
name: a
)
)

View File

@@ -0,0 +1,32 @@
Conditional function definition
-----
<?php
if (true) {
function A() {}
}
-----
array(
0: Stmt_If(
stmts: array(
0: Stmt_Function(
byRef: false
params: array(
)
stmts: array(
)
name: A
)
)
elseifs: array(
)
else: null
cond: Expr_ConstFetch(
name: Name(
parts: array(
0: true
)
)
)
)
)

View File

@@ -0,0 +1,138 @@
Default values (static scalar tests)
-----
<?php
function a(
$b = null,
$c = 'foo',
$d = A::B,
$f = +1,
$g = -1.0,
$h = array(),
$i = [],
$j = ['foo'],
$k = ['foo', 'bar' => 'baz']
) {}
-----
array(
0: Stmt_Function(
byRef: false
params: array(
0: Param(
name: b
default: Expr_ConstFetch(
name: Name(
parts: array(
0: null
)
)
)
type: null
byRef: false
)
1: Param(
name: c
default: Scalar_String(
value: foo
)
type: null
byRef: false
)
2: Param(
name: d
default: Expr_ClassConstFetch(
class: Name(
parts: array(
0: A
)
)
name: B
)
type: null
byRef: false
)
3: Param(
name: f
default: Expr_UnaryPlus(
expr: Scalar_LNumber(
value: 1
)
)
type: null
byRef: false
)
4: Param(
name: g
default: Expr_UnaryMinus(
expr: Scalar_DNumber(
value: 1
)
)
type: null
byRef: false
)
5: Param(
name: h
default: Expr_Array(
items: array(
)
)
type: null
byRef: false
)
6: Param(
name: i
default: Expr_Array(
items: array(
)
)
type: null
byRef: false
)
7: Param(
name: j
default: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_String(
value: foo
)
byRef: false
)
)
)
type: null
byRef: false
)
8: Param(
name: k
default: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_String(
value: foo
)
byRef: false
)
1: Expr_ArrayItem(
key: Scalar_String(
value: bar
)
value: Scalar_String(
value: baz
)
byRef: false
)
)
)
type: null
byRef: false
)
)
stmts: array(
)
name: a
)
)

View File

@@ -0,0 +1,227 @@
Generators (yield expression
-----
<?php
function gen() {
// statements
yield;
yield $value;
yield $key => $value;
// expressions
$data = yield;
$data = (yield $value);
$data = (yield $key => $value);
// yield in language constructs with their own parentheses
if (yield $foo); elseif (yield $foo);
if (yield $foo): elseif (yield $foo): endif;
while (yield $foo);
do {} while (yield $foo);
switch (yield $foo) {}
die(yield $foo);
// yield in function calls
func(yield $foo);
$foo->func(yield $foo);
new Foo(yield $foo);
}
-----
array(
0: Stmt_Function(
byRef: false
params: array(
)
stmts: array(
0: Expr_Yield(
key: null
value: null
)
1: Expr_Yield(
key: null
value: Expr_Variable(
name: value
)
)
2: Expr_Yield(
key: Expr_Variable(
name: key
)
value: Expr_Variable(
name: value
)
)
3: Expr_Assign(
var: Expr_Variable(
name: data
)
expr: Expr_Yield(
key: null
value: null
)
)
4: Expr_Assign(
var: Expr_Variable(
name: data
)
expr: Expr_Yield(
key: null
value: Expr_Variable(
name: value
)
)
)
5: Expr_Assign(
var: Expr_Variable(
name: data
)
expr: Expr_Yield(
key: Expr_Variable(
name: key
)
value: Expr_Variable(
name: value
)
)
)
6: Stmt_If(
stmts: array(
)
elseifs: array(
0: Stmt_ElseIf(
cond: Expr_Yield(
key: null
value: Expr_Variable(
name: foo
)
)
stmts: array(
)
)
)
else: null
cond: Expr_Yield(
key: null
value: Expr_Variable(
name: foo
)
)
)
7: Stmt_If(
stmts: array(
)
elseifs: array(
0: Stmt_ElseIf(
cond: Expr_Yield(
key: null
value: Expr_Variable(
name: foo
)
)
stmts: array(
)
)
)
else: null
cond: Expr_Yield(
key: null
value: Expr_Variable(
name: foo
)
)
)
8: Stmt_While(
cond: Expr_Yield(
key: null
value: Expr_Variable(
name: foo
)
)
stmts: array(
)
)
9: Stmt_Do(
cond: Expr_Yield(
key: null
value: Expr_Variable(
name: foo
)
)
stmts: array(
)
)
10: Stmt_Switch(
cond: Expr_Yield(
key: null
value: Expr_Variable(
name: foo
)
)
cases: array(
)
)
11: Expr_Exit(
expr: Expr_Yield(
key: null
value: Expr_Variable(
name: foo
)
)
)
12: Expr_FuncCall(
name: Name(
parts: array(
0: func
)
)
args: array(
0: Arg(
value: Expr_Yield(
key: null
value: Expr_Variable(
name: foo
)
)
byRef: false
)
)
)
13: Expr_MethodCall(
var: Expr_Variable(
name: foo
)
name: func
args: array(
0: Arg(
value: Expr_Yield(
key: null
value: Expr_Variable(
name: foo
)
)
byRef: false
)
)
)
14: Expr_New(
class: Name(
parts: array(
0: Foo
)
)
args: array(
0: Arg(
value: Expr_Yield(
key: null
value: Expr_Variable(
name: foo
)
)
byRef: false
)
)
)
)
name: gen
)
)

View File

@@ -0,0 +1,50 @@
Special function variables
-----
<?php
function a() {
global $a, ${'b'}, $$c;
static $c, $d = 'e';
}
-----
array(
0: Stmt_Function(
byRef: false
params: array(
)
stmts: array(
0: Stmt_Global(
vars: array(
0: Expr_Variable(
name: a
)
1: Expr_Variable(
name: Scalar_String(
value: b
)
)
2: Expr_Variable(
name: Expr_Variable(
name: c
)
)
)
)
1: Stmt_Static(
vars: array(
0: Stmt_StaticVar(
name: c
default: null
)
1: Stmt_StaticVar(
name: d
default: Scalar_String(
value: e
)
)
)
)
)
name: a
)
)

View File

@@ -0,0 +1,44 @@
Type hints
-----
<?php
function a($b, array $c, callable $d, E $f) {}
-----
array(
0: Stmt_Function(
byRef: false
params: array(
0: Param(
name: b
default: null
type: null
byRef: false
)
1: Param(
name: c
default: null
type: array
byRef: false
)
2: Param(
name: d
default: null
type: callable
byRef: false
)
3: Param(
name: f
default: null
type: Name(
parts: array(
0: E
)
)
byRef: false
)
)
stmts: array(
)
name: a
)
)