Add Composer autoloading functions and PHPStan for testing

This commit is contained in:
Alex Cabal 2019-02-26 13:03:45 -06:00
parent e198c4db65
commit f5d7d4e02a
1518 changed files with 169063 additions and 30 deletions

View file

@ -0,0 +1,39 @@
Adding property type
-----
<?php
class A
{
public $a
= 1;
}
-----
$stmts[0]->stmts[0]->type = new Node\Identifier('string');
-----
<?php
class A
{
public string $a
= 1;
}
-----
<?php
class A
{
public
$b;
}
-----
$stmts[0]->stmts[0]->type = new Node\Identifier('int');
-----
<?php
class A
{
public
int $b;
}

View file

@ -0,0 +1,28 @@
Anonymous classes
-----
<?php
new class
($x)
extends X
{ };
-----
$new = $stmts[0]->expr;
$new->class->extends = null;
$new->args[] = new Expr\Variable('y');
-----
<?php
new class
($x, $y)
{ };
-----
<?php
new class
{};
-----
// Ignore name assigned to anon class
$new = $stmts[0]->expr;
$new->class->name = new Node\Identifier('Anon1');
-----
<?php
new class
{};

View file

@ -0,0 +1,190 @@
abc1
-----
<?php
echo
1
+
2
+
3;
-----
$stmts[0]->exprs[0]->left->right->value = 42;
-----
<?php
echo
1
+
42
+
3;
-----
<?php
function foo($a)
{ return $a; }
-----
$stmts[0]->name = new Node\Identifier('bar');
-----
<?php
function bar($a)
{ return $a; }
-----
<?php
function
foo() {
call(
$bar
);
}
-----
// This triggers a fallback
$stmts[0]->byRef = true;
-----
<?php
function &foo()
{
call(
$bar
);
}
-----
<?php
function
foo() {
echo "Start
End";
}
-----
// This triggers a fallback
$stmts[0]->byRef = true;
-----
<?php
function &foo()
{
echo "Start
End";
}
-----
<?php
function test() {
call1(
$bar
);
}
call2(
$foo
);
-----
$tmp = $stmts[0]->stmts[0];
$stmts[0]->stmts[0] = $stmts[1];
$stmts[1] = $tmp;
-----
<?php
function test() {
call2(
$foo
);
}
call1(
$bar
);
-----
<?php
x;
function test() {
call1(
$bar
);
}
call2(
$foo
);
-----
$tmp = $stmts[1]->stmts[0];
$stmts[1]->stmts[0] = $stmts[2];
$stmts[2] = $tmp;
// Same test, but also removing first statement, triggering fallback
array_splice($stmts, 0, 1, []);
-----
<?php
function test() {
call2(
$foo
);
}
call1(
$bar
);
-----
<?php
echo 1;
-----
$stmts[0] = new Stmt\Expression(
new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b')));
-----
<?php
$a = $b;
-----
<?php
echo$a;
-----
$stmts[0]->exprs[0] = new Expr\ConstFetch(new Node\Name('C'));
-----
<?php
echo C;
-----
<?php
function foo() {
foo();
/*
* bar
*/
baz();
}
{
$x;
}
-----
$tmp = $stmts[0];
$stmts[0] = $stmts[1];
$stmts[1] = $tmp;
/* TODO This used to do two replacement operations, but with the node list diffing this is a
* remove, keep, add (which probably makes more sense). As such, this currently triggers a
* fallback. */
-----
<?php
$x;
function foo() {
foo();
/*
* bar
*/
baz();
}
-----
<?php
echo "${foo}bar";
echo "${foo['baz']}bar";
-----
$stmts[0]->exprs[0]->parts[0] = new Expr\Variable('bar');
$stmts[1]->exprs[0]->parts[0] = new Expr\Variable('bar');
-----
<?php
echo "{$bar}bar";
echo "{$bar}bar";
-----
<?php
[$a
,$b
,
,] = $b;
-----
/* Nothing */
-----
<?php
[$a
,$b
,
,] = $b;

View file

@ -0,0 +1,29 @@
It may be necessary to convert a single statement into a block
-----
<?php
if
($a) $b;
-----
// TODO Avoid fallback
$stmts[0]->stmts[] = new Stmt\Expression(new Expr\Variable('c'));
-----
<?php
if ($a) {
$b;
$c;
}
-----
<?php
if
($a) {$b;}
-----
$stmts[0]->stmts[] = new Stmt\Expression(new Expr\Variable('c'));
-----
<?php
if
($a) {$b;
$c;}

View file

@ -0,0 +1,52 @@
Comment changes
-----
<?php
// Test
foo();
-----
$stmts[0]->setAttribute('comments', []);
-----
<?php
foo();
-----
<?php
$foo;
/* bar */
$baz;
-----
$comments = $stmts[1]->getComments();
$comments[] = new Comment("// foo");
$stmts[1]->setAttribute('comments', $comments);
-----
<?php
$foo;
/* bar */
// foo
$baz;
-----
<?php
class Test {
/**
* @expectedException \FooException
*/
public function test() {
// some code
}
}
-----
$method = $stmts[0]->stmts[0];
$method->setAttribute('comments', [new Comment\Doc("/**\n *\n */")]);
-----
<?php
class Test {
/**
*
*/
public function test() {
// some code
}
}

View file

@ -0,0 +1,67 @@
Fixup for precedence and some special syntax
-----
<?php
$a ** $b * $c;
$a + $b * $c;
$a * $b + $c;
$a ? $b : $c;
($a ** $b) * $c;
( $a ** $b ) * $c;
!$a = $b;
-----
// Parens necessary
$stmts[0]->expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b'));
// The parens here are "correct", because add is left assoc
$stmts[1]->expr->right = new Expr\BinaryOp\Plus(new Expr\Variable('b'), new Expr\Variable('c'));
// No parens necessary
$stmts[2]->expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b'));
// Parens for RHS not strictly necessary due to assign speciality
$stmts[3]->expr->cond = new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b'));
$stmts[3]->expr->if = new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b'));
$stmts[3]->expr->else = new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b'));
// Already has parens
$stmts[4]->expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b'));
$stmts[5]->expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b'));
-----
<?php
($a + $b) * $c;
$a + ($b + $c);
$a + $b + $c;
($a = $b) ? $a = $b : ($a = $b);
($a + $b) * $c;
( $a + $b ) * $c;
!$a = $b;
-----
<?php
foo ();
foo ();
$foo -> bar;
$foo -> bar;
$foo -> bar;
$foo -> bar;
$foo -> bar;
self :: $foo;
self :: $foo;
-----
$stmts[0]->expr->name = new Expr\Variable('a');
$stmts[1]->expr->name = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b'));
$stmts[2]->expr->var = new Expr\Variable('bar');
$stmts[3]->expr->var = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b'));
$stmts[4]->expr->name = new Node\Identifier('foo');
// In this case the braces are not strictly necessary. However, on PHP 5 they may be required
// depending on where the property fetch node itself occurs.
$stmts[5]->expr->name = new Expr\Variable('bar');
$stmts[6]->expr->name = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b'));
$stmts[7]->expr->name = new Node\VarLikeIdentifier('bar');
$stmts[8]->expr->name = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b'));
-----
<?php
$a ();
($a . $b) ();
$bar -> bar;
($a . $b) -> bar;
$foo -> foo;
$foo -> {$bar};
$foo -> {$a . $b};
self :: $bar;
self :: ${$a . $b};

View file

@ -0,0 +1,54 @@
Handling of inline HTML
-----
<?php
function test() {
?>Foo<?php
}
-----
$stmts[0]->setAttribute('origNode', null);
-----
<?php
function test()
{
?>Foo<?php
}
-----
<?php
function test() {
foo();
?>Bar<?php
baz();
}
-----
// TODO Fix broken result
$stmts[0]->stmts[2] = $stmts[0]->stmts[1];
-----
<?php
function test() {
foo();
?>Bar<?php
Bar
}
-----
<?php
function test() {
foo();
?>Bar<?php
baz();
}
-----
// TODO Fix broken result
$stmts[0]->stmts[1] = $stmts[0]->stmts[2];
-----
<?php
function test() {
foo();<?php
baz();
baz();
}

View file

@ -0,0 +1,176 @@
Insertion of a nullable node
-----
<?php
// TODO: The result spacing isn't always optimal. We may want to skip whitespace in some cases.
function
foo(
$x,
&$y
)
{}
$foo
[
];
[
$value
];
function
()
{};
$x
?
:
$y;
yield
$v ;
yield ;
break
;
continue
;
return
;
class
X
{
public
function y()
{}
private
$x
;
}
foreach (
$x
as
$y
) {}
static
$var
;
try {
} catch (X
$y) {
}
if ($cond) { // Foo
} elseif ($cond2) { // Bar
}
-----
$stmts[0]->returnType = new Node\Name('Foo');
$stmts[0]->params[0]->type = new Node\Identifier('int');
$stmts[0]->params[1]->type = new Node\Identifier('array');
$stmts[0]->params[1]->default = new Expr\ConstFetch(new Node\Name('null'));
$stmts[1]->expr->dim = new Expr\Variable('a');
$stmts[2]->expr->items[0]->key = new Scalar\String_('X');
$stmts[3]->expr->returnType = new Node\Name('Bar');
$stmts[4]->expr->if = new Expr\Variable('z');
$stmts[5]->expr->key = new Expr\Variable('k');
$stmts[6]->expr->value = new Expr\Variable('v');
$stmts[7]->num = new Scalar\LNumber(2);
$stmts[8]->num = new Scalar\LNumber(2);
$stmts[9]->expr = new Expr\Variable('x');
$stmts[10]->extends = new Node\Name\FullyQualified('Bar');
$stmts[10]->stmts[0]->returnType = new Node\Name('Y');
$stmts[10]->stmts[1]->props[0]->default = new Scalar\DNumber(42.0);
$stmts[11]->keyVar = new Expr\Variable('z');
$stmts[12]->vars[0]->default = new Scalar\String_('abc');
$stmts[13]->finally = new Stmt\Finally_([]);
$stmts[14]->else = new Stmt\Else_([]);
-----
<?php
// TODO: The result spacing isn't always optimal. We may want to skip whitespace in some cases.
function
foo(
int $x,
array &$y = null
) : Foo
{}
$foo
[$a
];
[
'X' => $value
];
function
() : Bar
{};
$x
? $z
:
$y;
yield
$k => $v ;
yield $v ;
break 2
;
continue 2
;
return $x
;
class
X extends \Bar
{
public
function y() : Y
{}
private
$x = 42.0
;
}
foreach (
$x
as
$z => $y
) {}
static
$var = 'abc'
;
try {
} catch (X
$y) {
} finally {
}
if ($cond) { // Foo
} elseif ($cond2) { // Bar
} else {
}
-----
<?php
namespace
{ echo 42; }
-----
$stmts[0]->name = new Node\Name('Foo');
-----
<?php
namespace Foo
{ echo 42; }

View file

@ -0,0 +1,312 @@
Insertion into list nodes
-----
<?php
$foo;
$bar;
-----
$stmts[] = new Stmt\Expression(new Expr\Variable('baz'));
-----
<?php
$foo;
$bar;
$baz;
-----
<?php
function test() {
$foo;
$bar;
}
-----
$stmts[0]->stmts[] = new Stmt\Expression(new Expr\Variable('baz'));
-----
<?php
function test() {
$foo;
$bar;
$baz;
}
-----
<?php
function test(Foo $param1) {}
-----
$stmts[0]->params[] = new Node\Param(new Expr\Variable('param2'));
-----
<?php
function test(Foo $param1, $param2) {}
-----
<?php
try {
/* stuff */
} catch
(Foo $x) {}
-----
$stmts[0]->catches[0]->types[] = new Node\Name('Bar');
-----
<?php
try {
/* stuff */
} catch
(Foo|Bar $x) {}
-----
<?php
function test(Foo $param1) {}
-----
array_unshift($stmts[0]->params, new Node\Param(new Expr\Variable('param0')));
-----
<?php
function test($param0, Foo $param1) {}
-----
<?php
function test() {}
-----
$stmts[0]->params[] = new Node\Param(new Expr\Variable('param0'));
/* Insertion into empty list not handled yet */
-----
<?php
function test($param0)
{
}
-----
<?php
if ($cond) {
} elseif ($cond2) {
}
-----
$stmts[0]->elseifs[] = new Stmt\ElseIf_(new Expr\Variable('cond3'), []);
-----
<?php
if ($cond) {
} elseif ($cond2) {
} elseif ($cond3) {
}
-----
<?php
try {
} catch (Foo $foo) {
}
-----
$stmts[0]->catches[] = new Stmt\Catch_([new Node\Name('Bar')], new Expr\Variable('bar'), []);
-----
<?php
try {
} catch (Foo $foo) {
} catch (Bar $bar) {
}
-----
<?php
$foo; $bar;
-----
$node = new Stmt\Expression(new Expr\Variable('baz'));
$node->setAttribute('comments', [new Comment('// Test')]);
$stmts[] = $node;
-----
<?php
$foo; $bar;
// Test
$baz;
-----
<?php
function test() {
$foo; $bar;
}
-----
$node = new Stmt\Expression(new Expr\Variable('baz'));
$node->setAttribute('comments', [new Comment('// Test'), new Comment('// Test 2')]);
$stmts[0]->stmts[] = $node;
-----
<?php
function test() {
$foo; $bar;
// Test
// Test 2
$baz;
}
-----
<?php
namespace
Foo;
-----
$stmts[0]->name->parts[0] = 'Xyz';
-----
<?php
namespace
Xyz;
-----
<?php
function test() {
$foo; $bar;
}
-----
$node = new Stmt\Expression(new Expr\Variable('baz'));
array_unshift($stmts[0]->stmts, $node);
-----
<?php
function test() {
$baz;
$foo; $bar;
}
-----
<?php
function test() {
$foo; $bar;
}
-----
$node = new Stmt\Expression(new Expr\Variable('baz'));
$node->setAttribute('comments', [new Comment('// Test')]);
array_unshift($stmts[0]->stmts, $node);
-----
<?php
function test() {
// Test
$baz;
$foo; $bar;
}
-----
<?php
function test() {
// Foo bar
$foo; $bar;
}
-----
$node = new Stmt\Expression(new Expr\Variable('baz'));
$node->setAttribute('comments', [new Comment('// Test')]);
array_unshift($stmts[0]->stmts, $node);
-----
<?php
function test() {
// Test
$baz;
// Foo bar
$foo; $bar;
}
-----
<?php
function test() {
// Foo bar
$foo; $bar;
}
-----
$node = new Stmt\Expression(new Expr\Variable('baz'));
$node->setAttribute('comments', [new Comment('// Test')]);
array_unshift($stmts[0]->stmts, $node);
$stmts[0]->stmts[1]->setAttribute('comments', [new Comment('// Bar foo')]);
-----
<?php
function test() {
// Test
$baz;
// Bar foo
$foo; $bar;
}
-----
<?php
function test() {
// Foo bar
$foo; $bar;
}
-----
$node = new Stmt\Expression(new Expr\Variable('baz'));
$node->setAttribute('comments', [new Comment('// Test')]);
array_unshift($stmts[0]->stmts, $node);
$stmts[0]->stmts[1]->setAttribute('comments', []);
-----
<?php
function test() {
// Test
$baz;
$foo; $bar;
}
-----
<?php
function test() {
// Foo bar
$foo; $bar;
}
-----
array_unshift(
$stmts[0]->stmts,
new Stmt\Expression(new Expr\Variable('a')),
new Stmt\Expression(new Expr\Variable('b')));
-----
<?php
function test() {
$a;
$b;
// Foo bar
$foo; $bar;
}
-----
<?php
function test() {}
-----
/* Insertion into empty list not handled yet */
$stmts[0]->stmts = [
new Stmt\Expression(new Expr\Variable('a')),
new Stmt\Expression(new Expr\Variable('b')),
];
-----
<?php
function test()
{
$a;
$b;
}
-----
<?php
$array = [
1,
2,
3,
];
-----
array_unshift($stmts[0]->expr->expr->items, new Expr\ArrayItem(new Scalar\LNumber(42)));
$stmts[0]->expr->expr->items[] = new Expr\ArrayItem(new Scalar\LNumber(24));
-----
<?php
$array = [
42,
1,
2,
3,
24,
];
-----
<?php
$array = [
1, 2,
3,
];
-----
$stmts[0]->expr->expr->items[] = new Expr\ArrayItem(new Scalar\LNumber(24));
-----
<?php
$array = [
1, 2,
3, 24,
];

View file

@ -0,0 +1,17 @@
Check correct indentation use when inserting into list node
-----
<?php
$this->foo = new Foo;
$this->foo->a()
->b();
-----
$outerCall = $stmts[1]->expr;
$innerCall = $outerCall->var;
$var = $innerCall->var;
$stmts[1]->expr = $innerCall;
$stmts[2] = new Stmt\Expression(new Expr\MethodCall($var, $outerCall->name));
-----
<?php
$this->foo = new Foo;
$this->foo->a();
$this->foo->b();

View file

@ -0,0 +1,41 @@
Removing from list nodes
-----
<?php $foo; $bar; $baz;
-----
array_splice($stmts, 1, 1, []);
-----
<?php $foo; $baz;
-----
<?php
function foo(
$a,
$b,
$c
) {}
-----
array_pop($stmts[0]->params);
-----
<?php
function foo(
$a,
$b
) {}
-----
<?php
function foo(
$a,
$b,
$c
) {}
-----
array_pop($stmts[0]->params);
$stmts[0]->params[] = new Node\Param(new Expr\Variable('x'));
$stmts[0]->params[] = new Node\Param(new Expr\Variable('y'));
-----
<?php
function foo(
$a,
$b,
$x,
$y
) {}

View file

@ -0,0 +1,33 @@
Modifier change
-----
<?php
class Foo {}
abstract class Bar {
const
FOO = 42;
var $foo
= 24;
public function
foo() {}
}
-----
$stmts[0]->flags = Stmt\Class_::MODIFIER_ABSTRACT;
$stmts[1]->flags = 0;
$stmts[1]->stmts[0]->flags = Stmt\Class_::MODIFIER_PRIVATE;
$stmts[1]->stmts[1]->flags = Stmt\Class_::MODIFIER_PROTECTED;
$stmts[1]->stmts[2]->flags |= Stmt\Class_::MODIFIER_FINAL;
-----
<?php
abstract class Foo {}
class Bar {
private const
FOO = 42;
protected $foo
= 24;
public final function
foo() {}
}

View file

@ -0,0 +1,11 @@
Nop statement with comment at end (#513)
-----
<?php
$foo;
$bar;
-----
$stmts[1] = new Stmt\Nop(['comments' => [new Comment('//Some comment here')]]);
-----
<?php
$foo;
//Some comment here

View file

@ -0,0 +1,194 @@
Removing subnodes by setting them to null
-----
<?php
function
foo (
Bar $foo
= null,
Foo $bar) : baz
{}
function
()
: int
{};
class
Foo
extends
Bar
{
public
function
foo() : ?X {}
public
$prop = 'x'
;
use T {
T
::
x
as
public
y
;
}
}
$foo [ $bar ];
exit ( $bar );
$foo
? $bar :
$baz;
[ $a => $b
, $c => $d];
yield
$foo
=>
$bar;
yield
$bar;
break
2
;
continue
2
;
foreach(
$array
as
$key
=>
$value
) {}
if
($x)
{
}
else {}
return
$val
;
static
$x
=
$y
;
try {} catch
(X $y)
{}
finally
{}
-----
$stmts[0]->returnType = null;
$stmts[0]->params[0]->default = null;
$stmts[0]->params[1]->type = null;
$stmts[1]->expr->returnType = null;
$stmts[2]->extends = null;
$stmts[2]->stmts[0]->returnType = null;
$stmts[2]->stmts[1]->props[0]->default = null;
$stmts[2]->stmts[2]->adaptations[0]->newName = null;
$stmts[3]->expr->dim = null;
$stmts[4]->expr->expr = null;
$stmts[5]->expr->if = null;
$stmts[6]->expr->items[1]->key = null;
$stmts[7]->expr->key = null;
$stmts[8]->expr->value = null;
$stmts[9]->num = null;
$stmts[10]->num = null;
$stmts[11]->keyVar = null;
$stmts[12]->else = null;
$stmts[13]->expr = null;
$stmts[14]->vars[0]->default = null;
$stmts[15]->finally = null;
-----
<?php
function
foo (
Bar $foo,
$bar)
{}
function
()
{};
class
Foo
{
public
function
foo() {}
public
$prop
;
use T {
T
::
x
as
public
;
}
}
$foo [];
exit ();
$foo
?:
$baz;
[ $a => $b
, $d];
yield
$bar;
yield;
break;
continue;
foreach(
$array
as
$value
) {}
if
($x)
{
}
return;
static
$x
;
try {} catch
(X $y)
{}
-----
<?php
namespace
A
{
}
-----
$stmts[0]->name = null;
-----
<?php
namespace
{
}

View file

@ -0,0 +1,22 @@
Removing property type
-----
<?php
class B
{
public
?float
$b;
}
-----
$stmts[0]->stmts[0]->type = null;
-----
<?php
class B
{
public
$b;
}

View file

@ -0,0 +1,19 @@
Trait alias
-----
<?php
class X {
use T {
exit
as die;
}
}
-----
/* do nothing */
-----
<?php
class X {
use T {
exit
as die;
}
}

View file

@ -0,0 +1,36 @@
Comments on blocks
-----
<?php
// foo
{
// bar
{
// baz
$a;
}
}
// empty
{}
-----
array(
0: Stmt_Expression(
expr: Expr_Variable(
name: a
comments: array(
0: // baz
)
)
comments: array(
0: // foo
1: // bar
2: // baz
)
)
1: Stmt_Nop(
comments: array(
0: // empty
)
)
)

View file

@ -0,0 +1,38 @@
Comment at end of class (#509)
-----
<?php
class MyClass {
protected $a;
// my comment
}
-----
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: MyClass
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_Property(
flags: MODIFIER_PROTECTED (2)
type: null
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: a
)
default: null
)
)
)
1: Stmt_Nop(
comments: array(
0: // my comment
)
)
)
)
)

View file

@ -0,0 +1,108 @@
Comments
-----
<?php
/** doc 1 */
/* foobar 1 */
// foo 1
// bar 1
$var;
if ($cond) {
/** doc 2 */
/* foobar 2 */
// foo 2
// bar 2
}
/** doc 3 */
/* foobar 3 */
// foo 3
// bar 3
-----
array(
0: Stmt_Expression(
expr: Expr_Variable(
name: var
comments: array(
0: /** doc 1 */
1: /* foobar 1 */
2: // foo 1
3: // bar 1
)
)
comments: array(
0: /** doc 1 */
1: /* foobar 1 */
2: // foo 1
3: // bar 1
)
)
1: Stmt_If(
cond: Expr_Variable(
name: cond
)
stmts: array(
0: Stmt_Nop(
comments: array(
0: /** doc 2 */
1: /* foobar 2 */
2: // foo 2
3: // bar 2
)
)
)
elseifs: array(
)
else: null
)
2: Stmt_Nop(
comments: array(
0: /** doc 3 */
1: /* foobar 3 */
2: // foo 3
3: // bar 3
)
)
)
-----
<?php
/** doc */
/* foobar */
// foo
// bar
?>
-----
array(
0: Stmt_Nop(
comments: array(
0: /** doc */
1: /* foobar */
2: // foo
3: // bar
)
)
)
-----
<?php
// comment
if (42) {}
-----
array(
0: Stmt_If(
cond: Scalar_LNumber(
value: 42
)
stmts: array(
)
elseifs: array(
)
else: null
comments: array(
0: // comment
)
)
)

View file

@ -0,0 +1,36 @@
Error positions
-----
<?php foo
-----
Syntax error, unexpected EOF from 1:10 to 1:10
array(
0: Stmt_Expression(
expr: Expr_ConstFetch(
name: Name(
parts: array(
0: foo
)
)
)
)
)
-----
<?php foo /* bar */
-----
Syntax error, unexpected EOF from 1:20 to 1:20
array(
0: Stmt_Expression(
expr: Expr_ConstFetch(
name: Name(
parts: array(
0: foo
)
)
)
)
1: Stmt_Nop(
comments: array(
0: /* bar */
)
)
)

View file

@ -0,0 +1,140 @@
Lexer errors
-----
<?php
$a = 42;
/*
$b = 24;
-----
Unterminated comment from 4:1 to 5:9
array(
0: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: a
)
expr: Scalar_LNumber(
value: 42
)
)
)
1: Stmt_Nop(
comments: array(
0: /*
$b = 24;
)
)
)
-----
<?php
$a = 42;
@@{ "\1" }@@
$b = 24;
-----
Unexpected character "" (ASCII 1) from 4:1 to 4:1
array(
0: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: a
)
expr: Scalar_LNumber(
value: 42
)
)
)
1: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: b
)
expr: Scalar_LNumber(
value: 24
)
)
)
)
-----
<?php
$a = 42;
@@{ "\0" }@@
$b = 24;
-----
Unexpected null byte from 4:1 to 4:1
array(
0: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: a
)
expr: Scalar_LNumber(
value: 42
)
)
)
1: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: b
)
expr: Scalar_LNumber(
value: 24
)
)
)
)
-----
<?php
$a = 1;
@@{ "\1" }@@
$b = 2;
@@{ "\2" }@@
$c = 3;
-----
Unexpected character "@@{ "\1" }@@" (ASCII 1) from 4:1 to 4:1
Unexpected character "@@{ "\2" }@@" (ASCII 2) from 6:1 to 6:1
array(
0: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: a
)
expr: Scalar_LNumber(
value: 1
)
)
)
1: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: b
)
expr: Scalar_LNumber(
value: 2
)
)
)
2: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: c
)
expr: Scalar_LNumber(
value: 3
)
)
)
)
-----
<?php
if ($b) {
$a = 1;
/* unterminated
}
-----
Unterminated comment from 5:5 to 6:2
Syntax error, unexpected EOF from 6:2 to 6:2

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,161 @@
Array definitions
-----
<?php
array();
array('a');
array('a', );
array('a', 'b');
array('a', &$b, 'c' => 'd', 'e' => &$f);
// short array syntax
[];
[1, 2, 3];
['a' => 'b'];
-----
array(
0: Stmt_Expression(
expr: Expr_Array(
items: array(
)
)
)
1: Stmt_Expression(
expr: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_String(
value: a
)
byRef: false
)
)
)
)
2: Stmt_Expression(
expr: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_String(
value: a
)
byRef: false
)
)
)
)
3: Stmt_Expression(
expr: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_String(
value: a
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Scalar_String(
value: b
)
byRef: false
)
)
)
)
4: Stmt_Expression(
expr: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_String(
value: a
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: b
)
byRef: true
)
2: Expr_ArrayItem(
key: Scalar_String(
value: c
)
value: Scalar_String(
value: d
)
byRef: false
)
3: Expr_ArrayItem(
key: Scalar_String(
value: e
)
value: Expr_Variable(
name: f
)
byRef: true
)
)
)
)
5: Stmt_Expression(
expr: Expr_Array(
items: array(
)
comments: array(
0: // short array syntax
)
)
comments: array(
0: // short array syntax
)
)
6: Stmt_Expression(
expr: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 1
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 2
)
byRef: false
)
2: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 3
)
byRef: false
)
)
)
)
7: Stmt_Expression(
expr: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: Scalar_String(
value: a
)
value: Scalar_String(
value: b
)
byRef: false
)
)
)
)
)

View file

@ -0,0 +1,152 @@
Array destructuring
-----
<?php
[$a, $b] = [$c, $d];
[, $a, , , $b, ,] = $foo;
[, [[$a]], $b] = $bar;
['a' => $b, 'b' => $a] = $baz;
-----
!!php7
array(
0: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: a
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: b
)
byRef: false
)
)
)
expr: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: c
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: d
)
byRef: false
)
)
)
)
)
1: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Array(
items: array(
0: null
1: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: a
)
byRef: false
)
2: null
3: null
4: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: b
)
byRef: false
)
5: null
)
)
expr: Expr_Variable(
name: foo
)
)
)
2: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Array(
items: array(
0: null
1: Expr_ArrayItem(
key: null
value: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: a
)
byRef: false
)
)
)
byRef: false
)
)
)
byRef: false
)
2: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: b
)
byRef: false
)
)
)
expr: Expr_Variable(
name: bar
)
)
)
3: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: Scalar_String(
value: a
)
value: Expr_Variable(
name: b
)
byRef: false
)
1: Expr_ArrayItem(
key: Scalar_String(
value: b
)
value: Expr_Variable(
name: a
)
byRef: false
)
)
)
expr: Expr_Variable(
name: baz
)
)
)
)

View file

@ -0,0 +1,374 @@
Assignments
-----
<?php
// simple assign
$a = $b;
// combined assign
$a &= $b;
$a |= $b;
$a ^= $b;
$a .= $b;
$a /= $b;
$a -= $b;
$a %= $b;
$a *= $b;
$a += $b;
$a <<= $b;
$a >>= $b;
$a **= $b;
$a ??= $b;
// chained assign
$a = $b *= $c **= $d;
// by ref assign
$a =& $b;
// list() assign
list($a) = $b;
list($a, , $b) = $c;
list($a, list(, $c), $d) = $e;
// inc/dec
++$a;
$a++;
--$a;
$a--;
-----
array(
0: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: a
comments: array(
0: // simple assign
)
)
expr: Expr_Variable(
name: b
)
comments: array(
0: // simple assign
)
)
comments: array(
0: // simple assign
)
)
1: Stmt_Expression(
expr: Expr_AssignOp_BitwiseAnd(
var: Expr_Variable(
name: a
comments: array(
0: // combined assign
)
)
expr: Expr_Variable(
name: b
)
comments: array(
0: // combined assign
)
)
comments: array(
0: // combined assign
)
)
2: Stmt_Expression(
expr: Expr_AssignOp_BitwiseOr(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
)
3: Stmt_Expression(
expr: Expr_AssignOp_BitwiseXor(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
)
4: Stmt_Expression(
expr: Expr_AssignOp_Concat(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
)
5: Stmt_Expression(
expr: Expr_AssignOp_Div(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
)
6: Stmt_Expression(
expr: Expr_AssignOp_Minus(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
)
7: Stmt_Expression(
expr: Expr_AssignOp_Mod(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
)
8: Stmt_Expression(
expr: Expr_AssignOp_Mul(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
)
9: Stmt_Expression(
expr: Expr_AssignOp_Plus(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
)
10: Stmt_Expression(
expr: Expr_AssignOp_ShiftLeft(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
)
11: Stmt_Expression(
expr: Expr_AssignOp_ShiftRight(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
)
12: Stmt_Expression(
expr: Expr_AssignOp_Pow(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
)
13: Stmt_Expression(
expr: Expr_AssignOp_Coalesce(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
)
14: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: a
comments: array(
0: // chained assign
)
)
expr: Expr_AssignOp_Mul(
var: Expr_Variable(
name: b
)
expr: Expr_AssignOp_Pow(
var: Expr_Variable(
name: c
)
expr: Expr_Variable(
name: d
)
)
)
comments: array(
0: // chained assign
)
)
comments: array(
0: // chained assign
)
)
15: Stmt_Expression(
expr: Expr_AssignRef(
var: Expr_Variable(
name: a
comments: array(
0: // by ref assign
)
)
expr: Expr_Variable(
name: b
)
comments: array(
0: // by ref assign
)
)
comments: array(
0: // by ref assign
)
)
16: Stmt_Expression(
expr: Expr_Assign(
var: Expr_List(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: a
)
byRef: false
)
)
comments: array(
0: // list() assign
)
)
expr: Expr_Variable(
name: b
)
comments: array(
0: // list() assign
)
)
comments: array(
0: // list() assign
)
)
17: Stmt_Expression(
expr: Expr_Assign(
var: Expr_List(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: a
)
byRef: false
)
1: null
2: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: b
)
byRef: false
)
)
)
expr: Expr_Variable(
name: c
)
)
)
18: Stmt_Expression(
expr: Expr_Assign(
var: Expr_List(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: a
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Expr_List(
items: array(
0: null
1: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: c
)
byRef: false
)
)
)
byRef: false
)
2: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: d
)
byRef: false
)
)
)
expr: Expr_Variable(
name: e
)
)
)
19: Stmt_Expression(
expr: Expr_PreInc(
var: Expr_Variable(
name: a
)
comments: array(
0: // inc/dec
)
)
comments: array(
0: // inc/dec
)
)
20: Stmt_Expression(
expr: Expr_PostInc(
var: Expr_Variable(
name: a
)
)
)
21: Stmt_Expression(
expr: Expr_PreDec(
var: Expr_Variable(
name: a
)
)
)
22: Stmt_Expression(
expr: Expr_PostDec(
var: Expr_Variable(
name: a
)
)
)
)

View file

@ -0,0 +1,43 @@
Assigning new by reference (PHP 5 only)
-----
<?php
$a =& new B;
-----
!!php5
array(
0: Stmt_Expression(
expr: Expr_AssignRef(
var: Expr_Variable(
name: a
)
expr: Expr_New(
class: Name(
parts: array(
0: B
)
)
args: array(
)
)
)
)
)
-----
<?php
$a =& new B;
-----
!!php7
Syntax error, unexpected T_NEW from 2:7 to 2:9
array(
0: Stmt_Expression(
expr: Expr_New(
class: Name(
parts: array(
0: B
)
)
args: array(
)
)
)
)

View file

@ -0,0 +1,94 @@
Casts
-----
<?php
(array) $a;
(bool) $a;
(boolean) $a;
(real) $a;
(double) $a;
(float) $a;
(int) $a;
(integer) $a;
(object) $a;
(string) $a;
(unset) $a;
-----
array(
0: Stmt_Expression(
expr: Expr_Cast_Array(
expr: Expr_Variable(
name: a
)
)
)
1: Stmt_Expression(
expr: Expr_Cast_Bool(
expr: Expr_Variable(
name: a
)
)
)
2: Stmt_Expression(
expr: Expr_Cast_Bool(
expr: Expr_Variable(
name: a
)
)
)
3: Stmt_Expression(
expr: Expr_Cast_Double(
expr: Expr_Variable(
name: a
)
)
)
4: Stmt_Expression(
expr: Expr_Cast_Double(
expr: Expr_Variable(
name: a
)
)
)
5: Stmt_Expression(
expr: Expr_Cast_Double(
expr: Expr_Variable(
name: a
)
)
)
6: Stmt_Expression(
expr: Expr_Cast_Int(
expr: Expr_Variable(
name: a
)
)
)
7: Stmt_Expression(
expr: Expr_Cast_Int(
expr: Expr_Variable(
name: a
)
)
)
8: Stmt_Expression(
expr: Expr_Cast_Object(
expr: Expr_Variable(
name: a
)
)
)
9: Stmt_Expression(
expr: Expr_Cast_String(
expr: Expr_Variable(
name: a
)
)
)
10: Stmt_Expression(
expr: Expr_Cast_Unset(
expr: Expr_Variable(
name: a
)
)
)
)

View file

@ -0,0 +1,15 @@
Clone
-----
<?php
clone $a;
-----
array(
0: Stmt_Expression(
expr: Expr_Clone(
expr: Expr_Variable(
name: a
)
)
)
)

View file

@ -0,0 +1,176 @@
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 {};
-----
array(
0: Stmt_Expression(
expr: Expr_Closure(
static: false
byRef: false
params: array(
0: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
name: a
)
default: null
)
)
uses: array(
)
returnType: null
stmts: array(
0: Stmt_Expression(
expr: Expr_Variable(
name: a
)
)
)
)
)
1: Stmt_Expression(
expr: Expr_Closure(
static: false
byRef: false
params: array(
0: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
name: a
)
default: null
)
)
uses: array(
0: Expr_ClosureUse(
var: Expr_Variable(
name: b
)
byRef: false
)
)
returnType: null
stmts: array(
)
)
)
2: Stmt_Expression(
expr: Expr_Closure(
static: false
byRef: false
params: array(
)
uses: array(
0: Expr_ClosureUse(
var: Expr_Variable(
name: a
)
byRef: false
)
1: Expr_ClosureUse(
var: Expr_Variable(
name: b
)
byRef: true
)
)
returnType: null
stmts: array(
)
)
)
3: Stmt_Expression(
expr: Expr_Closure(
static: false
byRef: true
params: array(
0: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
name: a
)
default: null
)
)
uses: array(
)
returnType: null
stmts: array(
)
)
)
4: Stmt_Expression(
expr: Expr_Closure(
static: true
byRef: false
params: array(
)
uses: array(
)
returnType: null
stmts: array(
)
)
)
5: Stmt_Expression(
expr: Expr_Closure(
static: false
byRef: false
params: array(
0: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
name: a
)
default: null
)
)
uses: array(
)
returnType: Identifier(
name: array
)
stmts: array(
)
)
)
6: Stmt_Expression(
expr: Expr_Closure(
static: false
byRef: false
params: array(
)
uses: array(
0: Expr_ClosureUse(
var: Expr_Variable(
name: a
)
byRef: false
)
)
returnType: Name_FullyQualified(
parts: array(
0: Foo
1: Bar
)
)
stmts: array(
)
)
)
)

View file

@ -0,0 +1,129 @@
Comparison operators
-----
<?php
$a < $b;
$a <= $b;
$a > $b;
$a >= $b;
$a == $b;
$a === $b;
$a != $b;
$a !== $b;
$a <=> $b;
$a instanceof B;
$a instanceof $b;
-----
array(
0: Stmt_Expression(
expr: Expr_BinaryOp_Smaller(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
1: Stmt_Expression(
expr: Expr_BinaryOp_SmallerOrEqual(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
2: Stmt_Expression(
expr: Expr_BinaryOp_Greater(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
3: Stmt_Expression(
expr: Expr_BinaryOp_GreaterOrEqual(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
4: Stmt_Expression(
expr: Expr_BinaryOp_Equal(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
5: Stmt_Expression(
expr: Expr_BinaryOp_Identical(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
6: Stmt_Expression(
expr: Expr_BinaryOp_NotEqual(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
7: Stmt_Expression(
expr: Expr_BinaryOp_NotIdentical(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
8: Stmt_Expression(
expr: Expr_BinaryOp_Spaceship(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
9: Stmt_Expression(
expr: Expr_Instanceof(
expr: Expr_Variable(
name: a
)
class: Name(
parts: array(
0: B
)
)
)
)
10: Stmt_Expression(
expr: Expr_Instanceof(
expr: Expr_Variable(
name: a
)
class: Expr_Variable(
name: b
)
)
)
)

View file

@ -0,0 +1,691 @@
Expressions in static scalar context
-----
<?php
const T_1 = 1 << 1;
const T_2 = 1 / 2;
const T_3 = 1.5 + 1.5;
const T_4 = "foo" . "bar";
const T_5 = (1.5 + 1.5) * 2;
const T_6 = "foo" . 2 . 3 . 4.0;
const T_7 = __LINE__;
const T_8 = <<<ENDOFSTRING
This is a test string
ENDOFSTRING;
const T_9 = ~-1;
const T_10 = (-1?:1) + (0?2:3);
const T_11 = 1 && 0;
const T_12 = 1 and 1;
const T_13 = 0 || 0;
const T_14 = 1 or 0;
const T_15 = 1 xor 1;
const T_16 = 1 xor 0;
const T_17 = 1 < 0;
const T_18 = 0 <= 0;
const T_19 = 1 > 0;
const T_20 = 1 >= 0;
const T_21 = 1 === 1;
const T_22 = 1 !== 1;
const T_23 = 0 != "0";
const T_24 = 1 == "1";
const T_25 = 1 + 2 * 3;
const T_26 = "1" + 2 + "3";
const T_27 = 2 ** 3;
const T_28 = [1, 2, 3][1];
const T_29 = 12 - 13;
const T_30 = 12 ^ 13;
const T_31 = 12 & 13;
const T_32 = 12 | 13;
const T_33 = 12 % 3;
const T_34 = 100 >> 4;
const T_35 = !false;
-----
array(
0: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_1
)
value: Expr_BinaryOp_ShiftLeft(
left: Scalar_LNumber(
value: 1
)
right: Scalar_LNumber(
value: 1
)
)
)
)
)
1: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_2
)
value: Expr_BinaryOp_Div(
left: Scalar_LNumber(
value: 1
)
right: Scalar_LNumber(
value: 2
)
)
)
)
)
2: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_3
)
value: Expr_BinaryOp_Plus(
left: Scalar_DNumber(
value: 1.5
)
right: Scalar_DNumber(
value: 1.5
)
)
)
)
)
3: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_4
)
value: Expr_BinaryOp_Concat(
left: Scalar_String(
value: foo
)
right: Scalar_String(
value: bar
)
)
)
)
)
4: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_5
)
value: Expr_BinaryOp_Mul(
left: Expr_BinaryOp_Plus(
left: Scalar_DNumber(
value: 1.5
)
right: Scalar_DNumber(
value: 1.5
)
)
right: Scalar_LNumber(
value: 2
)
)
)
)
)
5: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_6
)
value: Expr_BinaryOp_Concat(
left: Expr_BinaryOp_Concat(
left: Expr_BinaryOp_Concat(
left: Scalar_String(
value: foo
)
right: Scalar_LNumber(
value: 2
)
)
right: Scalar_LNumber(
value: 3
)
)
right: Scalar_DNumber(
value: 4
)
)
)
)
)
6: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_7
)
value: Scalar_MagicConst_Line(
)
)
)
)
7: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_8
)
value: Scalar_String(
value: This is a test string
)
)
)
)
8: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_9
)
value: Expr_BitwiseNot(
expr: Expr_UnaryMinus(
expr: Scalar_LNumber(
value: 1
)
)
)
)
)
)
9: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_10
)
value: Expr_BinaryOp_Plus(
left: Expr_Ternary(
cond: Expr_UnaryMinus(
expr: Scalar_LNumber(
value: 1
)
)
if: null
else: Scalar_LNumber(
value: 1
)
)
right: Expr_Ternary(
cond: Scalar_LNumber(
value: 0
)
if: Scalar_LNumber(
value: 2
)
else: Scalar_LNumber(
value: 3
)
)
)
)
)
)
10: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_11
)
value: Expr_BinaryOp_BooleanAnd(
left: Scalar_LNumber(
value: 1
)
right: Scalar_LNumber(
value: 0
)
)
)
)
)
11: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_12
)
value: Expr_BinaryOp_LogicalAnd(
left: Scalar_LNumber(
value: 1
)
right: Scalar_LNumber(
value: 1
)
)
)
)
)
12: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_13
)
value: Expr_BinaryOp_BooleanOr(
left: Scalar_LNumber(
value: 0
)
right: Scalar_LNumber(
value: 0
)
)
)
)
)
13: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_14
)
value: Expr_BinaryOp_LogicalOr(
left: Scalar_LNumber(
value: 1
)
right: Scalar_LNumber(
value: 0
)
)
)
)
)
14: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_15
)
value: Expr_BinaryOp_LogicalXor(
left: Scalar_LNumber(
value: 1
)
right: Scalar_LNumber(
value: 1
)
)
)
)
)
15: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_16
)
value: Expr_BinaryOp_LogicalXor(
left: Scalar_LNumber(
value: 1
)
right: Scalar_LNumber(
value: 0
)
)
)
)
)
16: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_17
)
value: Expr_BinaryOp_Smaller(
left: Scalar_LNumber(
value: 1
)
right: Scalar_LNumber(
value: 0
)
)
)
)
)
17: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_18
)
value: Expr_BinaryOp_SmallerOrEqual(
left: Scalar_LNumber(
value: 0
)
right: Scalar_LNumber(
value: 0
)
)
)
)
)
18: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_19
)
value: Expr_BinaryOp_Greater(
left: Scalar_LNumber(
value: 1
)
right: Scalar_LNumber(
value: 0
)
)
)
)
)
19: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_20
)
value: Expr_BinaryOp_GreaterOrEqual(
left: Scalar_LNumber(
value: 1
)
right: Scalar_LNumber(
value: 0
)
)
)
)
)
20: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_21
)
value: Expr_BinaryOp_Identical(
left: Scalar_LNumber(
value: 1
)
right: Scalar_LNumber(
value: 1
)
)
)
)
)
21: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_22
)
value: Expr_BinaryOp_NotIdentical(
left: Scalar_LNumber(
value: 1
)
right: Scalar_LNumber(
value: 1
)
)
)
)
)
22: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_23
)
value: Expr_BinaryOp_NotEqual(
left: Scalar_LNumber(
value: 0
)
right: Scalar_String(
value: 0
)
)
)
)
)
23: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_24
)
value: Expr_BinaryOp_Equal(
left: Scalar_LNumber(
value: 1
)
right: Scalar_String(
value: 1
)
)
)
)
)
24: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_25
)
value: Expr_BinaryOp_Plus(
left: Scalar_LNumber(
value: 1
)
right: Expr_BinaryOp_Mul(
left: Scalar_LNumber(
value: 2
)
right: Scalar_LNumber(
value: 3
)
)
)
)
)
)
25: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_26
)
value: Expr_BinaryOp_Plus(
left: Expr_BinaryOp_Plus(
left: Scalar_String(
value: 1
)
right: Scalar_LNumber(
value: 2
)
)
right: Scalar_String(
value: 3
)
)
)
)
)
26: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_27
)
value: Expr_BinaryOp_Pow(
left: Scalar_LNumber(
value: 2
)
right: Scalar_LNumber(
value: 3
)
)
)
)
)
27: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_28
)
value: Expr_ArrayDimFetch(
var: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 1
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 2
)
byRef: false
)
2: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 3
)
byRef: false
)
)
)
dim: Scalar_LNumber(
value: 1
)
)
)
)
)
28: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_29
)
value: Expr_BinaryOp_Minus(
left: Scalar_LNumber(
value: 12
)
right: Scalar_LNumber(
value: 13
)
)
)
)
)
29: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_30
)
value: Expr_BinaryOp_BitwiseXor(
left: Scalar_LNumber(
value: 12
)
right: Scalar_LNumber(
value: 13
)
)
)
)
)
30: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_31
)
value: Expr_BinaryOp_BitwiseAnd(
left: Scalar_LNumber(
value: 12
)
right: Scalar_LNumber(
value: 13
)
)
)
)
)
31: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_32
)
value: Expr_BinaryOp_BitwiseOr(
left: Scalar_LNumber(
value: 12
)
right: Scalar_LNumber(
value: 13
)
)
)
)
)
32: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_33
)
value: Expr_BinaryOp_Mod(
left: Scalar_LNumber(
value: 12
)
right: Scalar_LNumber(
value: 3
)
)
)
)
)
33: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_34
)
value: Expr_BinaryOp_ShiftRight(
left: Scalar_LNumber(
value: 100
)
right: Scalar_LNumber(
value: 4
)
)
)
)
)
34: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: T_35
)
value: Expr_BooleanNot(
expr: Expr_ConstFetch(
name: Name(
parts: array(
0: false
)
)
)
)
)
)
)
)

View file

@ -0,0 +1,14 @@
Error suppression
-----
<?php
@$a;
-----
array(
0: Stmt_Expression(
expr: Expr_ErrorSuppress(
expr: Expr_Variable(
name: a
)
)
)
)

View file

@ -0,0 +1,46 @@
Exit
-----
<?php
exit;
exit();
exit('Die!');
die;
die();
die('Exit!');
-----
array(
0: Stmt_Expression(
expr: Expr_Exit(
expr: null
)
)
1: Stmt_Expression(
expr: Expr_Exit(
expr: null
)
)
2: Stmt_Expression(
expr: Expr_Exit(
expr: Scalar_String(
value: Die!
)
)
)
3: Stmt_Expression(
expr: Expr_Exit(
expr: null
)
)
4: Stmt_Expression(
expr: Expr_Exit(
expr: null
)
)
5: Stmt_Expression(
expr: Expr_Exit(
expr: Scalar_String(
value: Exit!
)
)
)
)

View file

@ -0,0 +1,109 @@
Arguments
-----
<?php
f();
f($a);
f($a, $b);
f(&$a);
f($a, ...$b);
-----
array(
0: Stmt_Expression(
expr: Expr_FuncCall(
name: Name(
parts: array(
0: f
)
)
args: array(
)
)
)
1: Stmt_Expression(
expr: Expr_FuncCall(
name: Name(
parts: array(
0: f
)
)
args: array(
0: Arg(
value: Expr_Variable(
name: a
)
byRef: false
unpack: false
)
)
)
)
2: Stmt_Expression(
expr: Expr_FuncCall(
name: Name(
parts: array(
0: f
)
)
args: array(
0: Arg(
value: Expr_Variable(
name: a
)
byRef: false
unpack: false
)
1: Arg(
value: Expr_Variable(
name: b
)
byRef: false
unpack: false
)
)
)
)
3: Stmt_Expression(
expr: Expr_FuncCall(
name: Name(
parts: array(
0: f
)
)
args: array(
0: Arg(
value: Expr_Variable(
name: a
)
byRef: true
unpack: false
)
)
)
)
4: Stmt_Expression(
expr: Expr_FuncCall(
name: Name(
parts: array(
0: f
)
)
args: array(
0: Arg(
value: Expr_Variable(
name: a
)
byRef: false
unpack: false
)
1: Arg(
value: Expr_Variable(
name: b
)
byRef: false
unpack: true
)
)
)
)
)

View file

@ -0,0 +1,43 @@
Constant fetches
-----
<?php
A;
A::B;
A::class;
-----
array(
0: Stmt_Expression(
expr: Expr_ConstFetch(
name: Name(
parts: array(
0: A
)
)
)
)
1: Stmt_Expression(
expr: Expr_ClassConstFetch(
class: Name(
parts: array(
0: A
)
)
name: Identifier(
name: B
)
)
)
2: Stmt_Expression(
expr: Expr_ClassConstFetch(
class: Name(
parts: array(
0: A
)
)
name: Identifier(
name: class
)
)
)
)

View file

@ -0,0 +1,253 @@
Array/string dereferencing
-----
<?php
"abc"[2];
"abc"[2][0][0];
[1, 2, 3][2];
[1, 2, 3][2][0][0];
array(1, 2, 3)[2];
array(1, 2, 3)[2][0][0];
FOO[0];
Foo::BAR[1];
$foo::BAR[2][1][0];
-----
array(
0: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Scalar_String(
value: abc
)
dim: Scalar_LNumber(
value: 2
)
)
)
1: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_ArrayDimFetch(
var: Expr_ArrayDimFetch(
var: Scalar_String(
value: abc
)
dim: Scalar_LNumber(
value: 2
)
)
dim: Scalar_LNumber(
value: 0
)
)
dim: Scalar_LNumber(
value: 0
)
)
)
2: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 1
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 2
)
byRef: false
)
2: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 3
)
byRef: false
)
)
)
dim: Scalar_LNumber(
value: 2
)
)
)
3: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_ArrayDimFetch(
var: Expr_ArrayDimFetch(
var: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 1
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 2
)
byRef: false
)
2: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 3
)
byRef: false
)
)
)
dim: Scalar_LNumber(
value: 2
)
)
dim: Scalar_LNumber(
value: 0
)
)
dim: Scalar_LNumber(
value: 0
)
)
)
4: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 1
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 2
)
byRef: false
)
2: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 3
)
byRef: false
)
)
)
dim: Scalar_LNumber(
value: 2
)
)
)
5: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_ArrayDimFetch(
var: Expr_ArrayDimFetch(
var: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 1
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 2
)
byRef: false
)
2: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 3
)
byRef: false
)
)
)
dim: Scalar_LNumber(
value: 2
)
)
dim: Scalar_LNumber(
value: 0
)
)
dim: Scalar_LNumber(
value: 0
)
)
)
6: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_ConstFetch(
name: Name(
parts: array(
0: FOO
)
)
)
dim: Scalar_LNumber(
value: 0
)
)
)
7: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_ClassConstFetch(
class: Name(
parts: array(
0: Foo
)
)
name: Identifier(
name: BAR
)
)
dim: Scalar_LNumber(
value: 1
)
)
)
8: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_ArrayDimFetch(
var: Expr_ArrayDimFetch(
var: Expr_ClassConstFetch(
class: Expr_Variable(
name: foo
)
name: Identifier(
name: BAR
)
)
dim: Scalar_LNumber(
value: 2
)
)
dim: Scalar_LNumber(
value: 1
)
)
dim: Scalar_LNumber(
value: 0
)
)
)
)

View file

@ -0,0 +1,158 @@
Function calls
-----
<?php
// function name variations
a();
$a();
${'a'}();
$$a();
$$$a();
$a['b']();
$a{'b'}();
$a->b['c']();
// array dereferencing
a()['b'];
-----
array(
0: Stmt_Expression(
expr: Expr_FuncCall(
name: Name(
parts: array(
0: a
)
comments: array(
0: // function name variations
)
)
args: array(
)
comments: array(
0: // function name variations
)
)
comments: array(
0: // function name variations
)
)
1: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_Variable(
name: a
)
args: array(
)
)
)
2: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_Variable(
name: Scalar_String(
value: a
)
)
args: array(
)
)
)
3: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_Variable(
name: Expr_Variable(
name: a
)
)
args: array(
)
)
)
4: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_Variable(
name: Expr_Variable(
name: Expr_Variable(
name: a
)
)
)
args: array(
)
)
)
5: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_ArrayDimFetch(
var: Expr_Variable(
name: a
)
dim: Scalar_String(
value: b
)
)
args: array(
)
)
)
6: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_ArrayDimFetch(
var: Expr_Variable(
name: a
)
dim: Scalar_String(
value: b
)
)
args: array(
)
)
)
7: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_ArrayDimFetch(
var: Expr_PropertyFetch(
var: Expr_Variable(
name: a
)
name: Identifier(
name: b
)
)
dim: Scalar_String(
value: c
)
)
args: array(
)
)
)
8: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_FuncCall(
name: Name(
parts: array(
0: a
)
comments: array(
0: // array dereferencing
)
)
args: array(
)
comments: array(
0: // array dereferencing
)
)
dim: Scalar_String(
value: b
)
comments: array(
0: // array dereferencing
)
)
comments: array(
0: // array dereferencing
)
)
)

View file

@ -0,0 +1,82 @@
New expression dereferencing
-----
<?php
(new A)->b;
(new A)->b();
(new A)['b'];
(new A)['b']['c'];
-----
array(
0: Stmt_Expression(
expr: Expr_PropertyFetch(
var: Expr_New(
class: Name(
parts: array(
0: A
)
)
args: array(
)
)
name: Identifier(
name: b
)
)
)
1: Stmt_Expression(
expr: Expr_MethodCall(
var: Expr_New(
class: Name(
parts: array(
0: A
)
)
args: array(
)
)
name: Identifier(
name: b
)
args: array(
)
)
)
2: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_New(
class: Name(
parts: array(
0: A
)
)
args: array(
)
)
dim: Scalar_String(
value: b
)
)
)
3: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_ArrayDimFetch(
var: Expr_New(
class: Name(
parts: array(
0: A
)
)
args: array(
)
)
dim: Scalar_String(
value: b
)
)
dim: Scalar_String(
value: c
)
)
)
)

View file

@ -0,0 +1,184 @@
Object access
-----
<?php
// property fetch variations
$a->b;
$a->b['c'];
$a->b{'c'};
// method call variations
$a->b();
$a->{'b'}();
$a->$b();
$a->$b['c']();
// array dereferencing
$a->b()['c'];
$a->b(){'c'}; // invalid PHP: drop Support?
-----
!!php5
array(
0: Stmt_Expression(
expr: Expr_PropertyFetch(
var: Expr_Variable(
name: a
comments: array(
0: // property fetch variations
)
)
name: Identifier(
name: b
)
comments: array(
0: // property fetch variations
)
)
comments: array(
0: // property fetch variations
)
)
1: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_PropertyFetch(
var: Expr_Variable(
name: a
)
name: Identifier(
name: b
)
)
dim: Scalar_String(
value: c
)
)
)
2: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_PropertyFetch(
var: Expr_Variable(
name: a
)
name: Identifier(
name: b
)
)
dim: Scalar_String(
value: c
)
)
)
3: Stmt_Expression(
expr: Expr_MethodCall(
var: Expr_Variable(
name: a
comments: array(
0: // method call variations
)
)
name: Identifier(
name: b
)
args: array(
)
comments: array(
0: // method call variations
)
)
comments: array(
0: // method call variations
)
)
4: Stmt_Expression(
expr: Expr_MethodCall(
var: Expr_Variable(
name: a
)
name: Scalar_String(
value: b
)
args: array(
)
)
)
5: Stmt_Expression(
expr: Expr_MethodCall(
var: Expr_Variable(
name: a
)
name: Expr_Variable(
name: b
)
args: array(
)
)
)
6: Stmt_Expression(
expr: Expr_MethodCall(
var: Expr_Variable(
name: a
)
name: Expr_ArrayDimFetch(
var: Expr_Variable(
name: b
)
dim: Scalar_String(
value: c
)
)
args: array(
)
)
)
7: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_MethodCall(
var: Expr_Variable(
name: a
comments: array(
0: // array dereferencing
)
)
name: Identifier(
name: b
)
args: array(
)
comments: array(
0: // array dereferencing
)
)
dim: Scalar_String(
value: c
)
comments: array(
0: // array dereferencing
)
)
comments: array(
0: // array dereferencing
)
)
8: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_MethodCall(
var: Expr_Variable(
name: a
)
name: Identifier(
name: b
)
args: array(
)
)
dim: Scalar_String(
value: c
)
)
)
9: Stmt_Nop(
comments: array(
0: // invalid PHP: drop Support?
)
)
)

View file

@ -0,0 +1,72 @@
Simple array access
-----
<?php
$a['b'];
$a['b']['c'];
$a[] = $b;
$a{'b'};
${$a}['b'];
-----
array(
0: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_Variable(
name: a
)
dim: Scalar_String(
value: b
)
)
)
1: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_ArrayDimFetch(
var: Expr_Variable(
name: a
)
dim: Scalar_String(
value: b
)
)
dim: Scalar_String(
value: c
)
)
)
2: Stmt_Expression(
expr: Expr_Assign(
var: Expr_ArrayDimFetch(
var: Expr_Variable(
name: a
)
dim: null
)
expr: Expr_Variable(
name: b
)
)
)
3: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_Variable(
name: a
)
dim: Scalar_String(
value: b
)
)
)
4: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_Variable(
name: Expr_Variable(
name: a
)
)
dim: Scalar_String(
value: b
)
)
)
)

View file

@ -0,0 +1,214 @@
Static calls
-----
<?php
// method name variations
A::b();
A::{'b'}();
A::$b();
A::$b['c']();
A::$b['c']['d']();
// array dereferencing
A::b()['c'];
// class name variations
static::b();
$a::b();
${'a'}::b();
$a['b']::c();
-----
!!php5
array(
0: Stmt_Expression(
expr: Expr_StaticCall(
class: Name(
parts: array(
0: A
)
comments: array(
0: // method name variations
)
)
name: Identifier(
name: b
)
args: array(
)
comments: array(
0: // method name variations
)
)
comments: array(
0: // method name variations
)
)
1: Stmt_Expression(
expr: Expr_StaticCall(
class: Name(
parts: array(
0: A
)
)
name: Scalar_String(
value: b
)
args: array(
)
)
)
2: Stmt_Expression(
expr: Expr_StaticCall(
class: Name(
parts: array(
0: A
)
)
name: Expr_Variable(
name: b
)
args: array(
)
)
)
3: Stmt_Expression(
expr: Expr_StaticCall(
class: Name(
parts: array(
0: A
)
)
name: Expr_ArrayDimFetch(
var: Expr_Variable(
name: b
)
dim: Scalar_String(
value: c
)
)
args: array(
)
)
)
4: Stmt_Expression(
expr: Expr_StaticCall(
class: Name(
parts: array(
0: A
)
)
name: Expr_ArrayDimFetch(
var: Expr_ArrayDimFetch(
var: Expr_Variable(
name: b
)
dim: Scalar_String(
value: c
)
)
dim: Scalar_String(
value: d
)
)
args: array(
)
)
)
5: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_StaticCall(
class: Name(
parts: array(
0: A
)
comments: array(
0: // array dereferencing
)
)
name: Identifier(
name: b
)
args: array(
)
comments: array(
0: // array dereferencing
)
)
dim: Scalar_String(
value: c
)
comments: array(
0: // array dereferencing
)
)
comments: array(
0: // array dereferencing
)
)
6: Stmt_Expression(
expr: Expr_StaticCall(
class: Name(
parts: array(
0: static
)
comments: array(
0: // class name variations
)
)
name: Identifier(
name: b
)
args: array(
)
comments: array(
0: // class name variations
)
)
comments: array(
0: // class name variations
)
)
7: Stmt_Expression(
expr: Expr_StaticCall(
class: Expr_Variable(
name: a
)
name: Identifier(
name: b
)
args: array(
)
)
)
8: Stmt_Expression(
expr: Expr_StaticCall(
class: Expr_Variable(
name: Scalar_String(
value: a
)
)
name: Identifier(
name: b
)
args: array(
)
)
)
9: Stmt_Expression(
expr: Expr_StaticCall(
class: Expr_ArrayDimFetch(
var: Expr_Variable(
name: a
)
dim: Scalar_String(
value: b
)
)
name: Identifier(
name: c
)
args: array(
)
)
)
)

View file

@ -0,0 +1,113 @@
Static property fetches
-----
<?php
// property name variations
A::$b;
A::$$b;
A::${'b'};
// array access
A::$b['c'];
A::$b{'c'};
// class name variations can be found in staticCall.test
-----
array(
0: Stmt_Expression(
expr: Expr_StaticPropertyFetch(
class: Name(
parts: array(
0: A
)
comments: array(
0: // property name variations
)
)
name: VarLikeIdentifier(
name: b
)
comments: array(
0: // property name variations
)
)
comments: array(
0: // property name variations
)
)
1: Stmt_Expression(
expr: Expr_StaticPropertyFetch(
class: Name(
parts: array(
0: A
)
)
name: Expr_Variable(
name: b
)
)
)
2: Stmt_Expression(
expr: Expr_StaticPropertyFetch(
class: Name(
parts: array(
0: A
)
)
name: Scalar_String(
value: b
)
)
)
3: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_StaticPropertyFetch(
class: Name(
parts: array(
0: A
)
comments: array(
0: // array access
)
)
name: VarLikeIdentifier(
name: b
)
comments: array(
0: // array access
)
)
dim: Scalar_String(
value: c
)
comments: array(
0: // array access
)
)
comments: array(
0: // array access
)
)
4: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_StaticPropertyFetch(
class: Name(
parts: array(
0: A
)
)
name: VarLikeIdentifier(
name: b
)
)
dim: Scalar_String(
value: c
)
)
)
5: Stmt_Nop(
comments: array(
0: // class name variations can be found in staticCall.test
)
)
)

View file

@ -0,0 +1,50 @@
Include and eval
-----
<?php
include 'A.php';
include_once 'A.php';
require 'A.php';
require_once 'A.php';
eval('A');
-----
array(
0: Stmt_Expression(
expr: Expr_Include(
expr: Scalar_String(
value: A.php
)
type: TYPE_INCLUDE (1)
)
)
1: Stmt_Expression(
expr: Expr_Include(
expr: Scalar_String(
value: A.php
)
type: TYPE_INCLUDE_ONCE (2)
)
)
2: Stmt_Expression(
expr: Expr_Include(
expr: Scalar_String(
value: A.php
)
type: TYPE_REQUIRE (3)
)
)
3: Stmt_Expression(
expr: Expr_Include(
expr: Scalar_String(
value: A.php
)
type: TYPE_REQUIRE_ONCE (4)
)
)
4: Stmt_Expression(
expr: Expr_Eval(
expr: Scalar_String(
value: A
)
)
)
)

View file

@ -0,0 +1,85 @@
isset() and empty()
-----
<?php
isset($a);
isset($a, $b, $c);
empty($a);
empty(foo());
empty(array(1, 2, 3));
-----
array(
0: Stmt_Expression(
expr: Expr_Isset(
vars: array(
0: Expr_Variable(
name: a
)
)
)
)
1: Stmt_Expression(
expr: Expr_Isset(
vars: array(
0: Expr_Variable(
name: a
)
1: Expr_Variable(
name: b
)
2: Expr_Variable(
name: c
)
)
)
)
2: Stmt_Expression(
expr: Expr_Empty(
expr: Expr_Variable(
name: a
)
)
)
3: Stmt_Expression(
expr: Expr_Empty(
expr: Expr_FuncCall(
name: Name(
parts: array(
0: foo
)
)
args: array(
)
)
)
)
4: Stmt_Expression(
expr: Expr_Empty(
expr: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 1
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 2
)
byRef: false
)
2: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 3
)
byRef: false
)
)
)
)
)
)

View file

@ -0,0 +1,88 @@
List reference assignments (PHP 7.3)
-----
<?php
list(&$v) = $x;
list('k' => &$v) = $x;
[&$v] = $x;
['k' => &$v] = $x;
-----
!!php7
array(
0: Stmt_Expression(
expr: Expr_Assign(
var: Expr_List(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: v
)
byRef: true
)
)
)
expr: Expr_Variable(
name: x
)
)
)
1: Stmt_Expression(
expr: Expr_Assign(
var: Expr_List(
items: array(
0: Expr_ArrayItem(
key: Scalar_String(
value: k
)
value: Expr_Variable(
name: v
)
byRef: true
)
)
)
expr: Expr_Variable(
name: x
)
)
)
2: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: v
)
byRef: true
)
)
)
expr: Expr_Variable(
name: x
)
)
)
3: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: Scalar_String(
value: k
)
value: Expr_Variable(
name: v
)
byRef: true
)
)
)
expr: Expr_Variable(
name: x
)
)
)
)

View file

@ -0,0 +1,79 @@
List destructing with keys
-----
<?php
list('a' => $b) = ['a' => 'b'];
list('a' => list($b => $c), 'd' => $e) = $x;
-----
!!php7
array(
0: Stmt_Expression(
expr: Expr_Assign(
var: Expr_List(
items: array(
0: Expr_ArrayItem(
key: Scalar_String(
value: a
)
value: Expr_Variable(
name: b
)
byRef: false
)
)
)
expr: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: Scalar_String(
value: a
)
value: Scalar_String(
value: b
)
byRef: false
)
)
)
)
)
1: Stmt_Expression(
expr: Expr_Assign(
var: Expr_List(
items: array(
0: Expr_ArrayItem(
key: Scalar_String(
value: a
)
value: Expr_List(
items: array(
0: Expr_ArrayItem(
key: Expr_Variable(
name: b
)
value: Expr_Variable(
name: c
)
byRef: false
)
)
)
byRef: false
)
1: Expr_ArrayItem(
key: Scalar_String(
value: d
)
value: Expr_Variable(
name: e
)
byRef: false
)
)
)
expr: Expr_Variable(
name: x
)
)
)
)

View file

@ -0,0 +1,190 @@
Logical operators
-----
<?php
// boolean ops
$a && $b;
$a || $b;
!$a;
!!$a;
// logical ops
$a and $b;
$a or $b;
$a xor $b;
// precedence
$a && $b || $c && $d;
$a && ($b || $c) && $d;
$a = $b || $c;
$a = $b or $c;
-----
array(
0: Stmt_Expression(
expr: Expr_BinaryOp_BooleanAnd(
left: Expr_Variable(
name: a
comments: array(
0: // boolean ops
)
)
right: Expr_Variable(
name: b
)
comments: array(
0: // boolean ops
)
)
comments: array(
0: // boolean ops
)
)
1: Stmt_Expression(
expr: Expr_BinaryOp_BooleanOr(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
2: Stmt_Expression(
expr: Expr_BooleanNot(
expr: Expr_Variable(
name: a
)
)
)
3: Stmt_Expression(
expr: Expr_BooleanNot(
expr: Expr_BooleanNot(
expr: Expr_Variable(
name: a
)
)
)
)
4: Stmt_Expression(
expr: Expr_BinaryOp_LogicalAnd(
left: Expr_Variable(
name: a
comments: array(
0: // logical ops
)
)
right: Expr_Variable(
name: b
)
comments: array(
0: // logical ops
)
)
comments: array(
0: // logical ops
)
)
5: Stmt_Expression(
expr: Expr_BinaryOp_LogicalOr(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
6: Stmt_Expression(
expr: Expr_BinaryOp_LogicalXor(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
7: Stmt_Expression(
expr: Expr_BinaryOp_BooleanOr(
left: Expr_BinaryOp_BooleanAnd(
left: Expr_Variable(
name: a
comments: array(
0: // precedence
)
)
right: Expr_Variable(
name: b
)
comments: array(
0: // precedence
)
)
right: Expr_BinaryOp_BooleanAnd(
left: Expr_Variable(
name: c
)
right: Expr_Variable(
name: d
)
)
comments: array(
0: // precedence
)
)
comments: array(
0: // precedence
)
)
8: Stmt_Expression(
expr: Expr_BinaryOp_BooleanAnd(
left: Expr_BinaryOp_BooleanAnd(
left: Expr_Variable(
name: a
)
right: Expr_BinaryOp_BooleanOr(
left: Expr_Variable(
name: b
)
right: Expr_Variable(
name: c
)
)
)
right: Expr_Variable(
name: d
)
)
)
9: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: a
)
expr: Expr_BinaryOp_BooleanOr(
left: Expr_Variable(
name: b
)
right: Expr_Variable(
name: c
)
)
)
)
10: Stmt_Expression(
expr: Expr_BinaryOp_LogicalOr(
left: Expr_Assign(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
right: Expr_Variable(
name: c
)
)
)
)

View file

@ -0,0 +1,313 @@
Mathematical operators
-----
<?php
// unary ops
~$a;
+$a;
-$a;
// binary ops
$a & $b;
$a | $b;
$a ^ $b;
$a . $b;
$a / $b;
$a - $b;
$a % $b;
$a * $b;
$a + $b;
$a << $b;
$a >> $b;
$a ** $b;
// associativity
$a * $b * $c;
$a * ($b * $c);
// precedence
$a + $b * $c;
($a + $b) * $c;
// pow is special
$a ** $b ** $c;
($a ** $b) ** $c;
-----
array(
0: Stmt_Expression(
expr: Expr_BitwiseNot(
expr: Expr_Variable(
name: a
)
comments: array(
0: // unary ops
)
)
comments: array(
0: // unary ops
)
)
1: Stmt_Expression(
expr: Expr_UnaryPlus(
expr: Expr_Variable(
name: a
)
)
)
2: Stmt_Expression(
expr: Expr_UnaryMinus(
expr: Expr_Variable(
name: a
)
)
)
3: Stmt_Expression(
expr: Expr_BinaryOp_BitwiseAnd(
left: Expr_Variable(
name: a
comments: array(
0: // binary ops
)
)
right: Expr_Variable(
name: b
)
comments: array(
0: // binary ops
)
)
comments: array(
0: // binary ops
)
)
4: Stmt_Expression(
expr: Expr_BinaryOp_BitwiseOr(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
5: Stmt_Expression(
expr: Expr_BinaryOp_BitwiseXor(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
6: Stmt_Expression(
expr: Expr_BinaryOp_Concat(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
7: Stmt_Expression(
expr: Expr_BinaryOp_Div(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
8: Stmt_Expression(
expr: Expr_BinaryOp_Minus(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
9: Stmt_Expression(
expr: Expr_BinaryOp_Mod(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
10: Stmt_Expression(
expr: Expr_BinaryOp_Mul(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
11: Stmt_Expression(
expr: Expr_BinaryOp_Plus(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
12: Stmt_Expression(
expr: Expr_BinaryOp_ShiftLeft(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
13: Stmt_Expression(
expr: Expr_BinaryOp_ShiftRight(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
14: Stmt_Expression(
expr: Expr_BinaryOp_Pow(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
)
15: Stmt_Expression(
expr: Expr_BinaryOp_Mul(
left: Expr_BinaryOp_Mul(
left: Expr_Variable(
name: a
comments: array(
0: // associativity
)
)
right: Expr_Variable(
name: b
)
comments: array(
0: // associativity
)
)
right: Expr_Variable(
name: c
)
comments: array(
0: // associativity
)
)
comments: array(
0: // associativity
)
)
16: Stmt_Expression(
expr: Expr_BinaryOp_Mul(
left: Expr_Variable(
name: a
)
right: Expr_BinaryOp_Mul(
left: Expr_Variable(
name: b
)
right: Expr_Variable(
name: c
)
)
)
)
17: Stmt_Expression(
expr: Expr_BinaryOp_Plus(
left: Expr_Variable(
name: a
comments: array(
0: // precedence
)
)
right: Expr_BinaryOp_Mul(
left: Expr_Variable(
name: b
)
right: Expr_Variable(
name: c
)
)
comments: array(
0: // precedence
)
)
comments: array(
0: // precedence
)
)
18: Stmt_Expression(
expr: Expr_BinaryOp_Mul(
left: Expr_BinaryOp_Plus(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
right: Expr_Variable(
name: c
)
)
)
19: Stmt_Expression(
expr: Expr_BinaryOp_Pow(
left: Expr_Variable(
name: a
comments: array(
0: // pow is special
)
)
right: Expr_BinaryOp_Pow(
left: Expr_Variable(
name: b
)
right: Expr_Variable(
name: c
)
)
comments: array(
0: // pow is special
)
)
comments: array(
0: // pow is special
)
)
20: Stmt_Expression(
expr: Expr_BinaryOp_Pow(
left: Expr_BinaryOp_Pow(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
right: Expr_Variable(
name: c
)
)
)
)

View file

@ -0,0 +1,187 @@
New
-----
<?php
new A;
new A($b);
// class name variations
new $a();
new $a['b']();
new A::$b();
// DNCR object access
new $a->b();
new $a->b->c();
new $a->b['c']();
new $a->b{'c'}();
// test regression introduces by new dereferencing syntax
(new A);
-----
array(
0: Stmt_Expression(
expr: Expr_New(
class: Name(
parts: array(
0: A
)
)
args: array(
)
)
)
1: Stmt_Expression(
expr: Expr_New(
class: Name(
parts: array(
0: A
)
)
args: array(
0: Arg(
value: Expr_Variable(
name: b
)
byRef: false
unpack: false
)
)
)
)
2: Stmt_Expression(
expr: Expr_New(
class: Expr_Variable(
name: a
)
args: array(
)
comments: array(
0: // class name variations
)
)
comments: array(
0: // class name variations
)
)
3: Stmt_Expression(
expr: Expr_New(
class: Expr_ArrayDimFetch(
var: Expr_Variable(
name: a
)
dim: Scalar_String(
value: b
)
)
args: array(
)
)
)
4: Stmt_Expression(
expr: Expr_New(
class: Expr_StaticPropertyFetch(
class: Name(
parts: array(
0: A
)
)
name: VarLikeIdentifier(
name: b
)
)
args: array(
)
)
)
5: Stmt_Expression(
expr: Expr_New(
class: Expr_PropertyFetch(
var: Expr_Variable(
name: a
)
name: Identifier(
name: b
)
)
args: array(
)
comments: array(
0: // DNCR object access
)
)
comments: array(
0: // DNCR object access
)
)
6: Stmt_Expression(
expr: Expr_New(
class: Expr_PropertyFetch(
var: Expr_PropertyFetch(
var: Expr_Variable(
name: a
)
name: Identifier(
name: b
)
)
name: Identifier(
name: c
)
)
args: array(
)
)
)
7: Stmt_Expression(
expr: Expr_New(
class: Expr_ArrayDimFetch(
var: Expr_PropertyFetch(
var: Expr_Variable(
name: a
)
name: Identifier(
name: b
)
)
dim: Scalar_String(
value: c
)
)
args: array(
)
)
)
8: Stmt_Expression(
expr: Expr_New(
class: Expr_ArrayDimFetch(
var: Expr_PropertyFetch(
var: Expr_Variable(
name: a
)
name: Identifier(
name: b
)
)
dim: Scalar_String(
value: c
)
)
args: array(
)
)
)
9: Stmt_Expression(
expr: Expr_New(
class: Name(
parts: array(
0: A
)
)
args: array(
)
)
comments: array(
0: // test regression introduces by new dereferencing syntax
)
)
)

View file

@ -0,0 +1,25 @@
New without a class
-----
<?php
new;
-----
!!php5
Syntax error, unexpected ';' from 2:4 to 2:4
array(
)
-----
<?php
new;
-----
!!php7
Syntax error, unexpected ';' from 2:4 to 2:4
array(
0: Stmt_Expression(
expr: Expr_New(
class: Expr_Error(
)
args: array(
)
)
)
)

View file

@ -0,0 +1,14 @@
Print
-----
<?php
print $a;
-----
array(
0: Stmt_Expression(
expr: Expr_Print(
expr: Expr_Variable(
name: a
)
)
)
)

View file

@ -0,0 +1,56 @@
Shell execution
-----
<?php
``;
`test`;
`test $A`;
`test \``;
`test \"`;
-----
array(
0: Stmt_Expression(
expr: Expr_ShellExec(
parts: array(
)
)
)
1: Stmt_Expression(
expr: Expr_ShellExec(
parts: array(
0: Scalar_EncapsedStringPart(
value: test
)
)
)
)
2: Stmt_Expression(
expr: Expr_ShellExec(
parts: array(
0: Scalar_EncapsedStringPart(
value: test
)
1: Expr_Variable(
name: A
)
)
)
)
3: Stmt_Expression(
expr: Expr_ShellExec(
parts: array(
0: Scalar_EncapsedStringPart(
value: test `
)
)
)
)
4: Stmt_Expression(
expr: Expr_ShellExec(
parts: array(
0: Scalar_EncapsedStringPart(
value: test \"
)
)
)
)
)

View file

@ -0,0 +1,174 @@
Ternary operator
-----
<?php
// ternary
$a ? $b : $c;
$a ?: $c;
// precedence
$a ? $b : $c ? $d : $e;
$a ? $b : ($c ? $d : $e);
// null coalesce
$a ?? $b;
$a ?? $b ?? $c;
$a ?? $b ? $c : $d;
$a && $b ?? $c;
-----
array(
0: Stmt_Expression(
expr: Expr_Ternary(
cond: Expr_Variable(
name: a
comments: array(
0: // ternary
)
)
if: Expr_Variable(
name: b
)
else: Expr_Variable(
name: c
)
comments: array(
0: // ternary
)
)
comments: array(
0: // ternary
)
)
1: Stmt_Expression(
expr: Expr_Ternary(
cond: Expr_Variable(
name: a
)
if: null
else: Expr_Variable(
name: c
)
)
)
2: Stmt_Expression(
expr: Expr_Ternary(
cond: Expr_Ternary(
cond: Expr_Variable(
name: a
comments: array(
0: // precedence
)
)
if: Expr_Variable(
name: b
)
else: Expr_Variable(
name: c
)
comments: array(
0: // precedence
)
)
if: Expr_Variable(
name: d
)
else: Expr_Variable(
name: e
)
comments: array(
0: // precedence
)
)
comments: array(
0: // precedence
)
)
3: Stmt_Expression(
expr: Expr_Ternary(
cond: Expr_Variable(
name: a
)
if: Expr_Variable(
name: b
)
else: Expr_Ternary(
cond: Expr_Variable(
name: c
)
if: Expr_Variable(
name: d
)
else: Expr_Variable(
name: e
)
)
)
)
4: Stmt_Expression(
expr: Expr_BinaryOp_Coalesce(
left: Expr_Variable(
name: a
comments: array(
0: // null coalesce
)
)
right: Expr_Variable(
name: b
)
comments: array(
0: // null coalesce
)
)
comments: array(
0: // null coalesce
)
)
5: Stmt_Expression(
expr: Expr_BinaryOp_Coalesce(
left: Expr_Variable(
name: a
)
right: Expr_BinaryOp_Coalesce(
left: Expr_Variable(
name: b
)
right: Expr_Variable(
name: c
)
)
)
)
6: Stmt_Expression(
expr: Expr_Ternary(
cond: Expr_BinaryOp_Coalesce(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
if: Expr_Variable(
name: c
)
else: Expr_Variable(
name: d
)
)
)
7: Stmt_Expression(
expr: Expr_BinaryOp_Coalesce(
left: Expr_BinaryOp_BooleanAnd(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
)
right: Expr_Variable(
name: c
)
)
)
)

View file

@ -0,0 +1,140 @@
PHP 7.3 trailing comma additions
-----
<?php
foo($a, $b, );
$foo->bar($a, $b, );
Foo::bar($a, $b, );
new Foo($a, $b, );
unset($a, $b, );
isset($a, $b, );
-----
!!php7
array(
0: Stmt_Expression(
expr: Expr_FuncCall(
name: Name(
parts: array(
0: foo
)
)
args: array(
0: Arg(
value: Expr_Variable(
name: a
)
byRef: false
unpack: false
)
1: Arg(
value: Expr_Variable(
name: b
)
byRef: false
unpack: false
)
)
)
)
1: Stmt_Expression(
expr: Expr_MethodCall(
var: Expr_Variable(
name: foo
)
name: Identifier(
name: bar
)
args: array(
0: Arg(
value: Expr_Variable(
name: a
)
byRef: false
unpack: false
)
1: Arg(
value: Expr_Variable(
name: b
)
byRef: false
unpack: false
)
)
)
)
2: Stmt_Expression(
expr: Expr_StaticCall(
class: Name(
parts: array(
0: Foo
)
)
name: Identifier(
name: bar
)
args: array(
0: Arg(
value: Expr_Variable(
name: a
)
byRef: false
unpack: false
)
1: Arg(
value: Expr_Variable(
name: b
)
byRef: false
unpack: false
)
)
)
)
3: Stmt_Expression(
expr: Expr_New(
class: Name(
parts: array(
0: Foo
)
)
args: array(
0: Arg(
value: Expr_Variable(
name: a
)
byRef: false
unpack: false
)
1: Arg(
value: Expr_Variable(
name: b
)
byRef: false
unpack: false
)
)
)
)
4: Stmt_Unset(
vars: array(
0: Expr_Variable(
name: a
)
1: Expr_Variable(
name: b
)
)
)
5: Stmt_Expression(
expr: Expr_Isset(
vars: array(
0: Expr_Variable(
name: a
)
1: Expr_Variable(
name: b
)
)
)
)
)

View file

@ -0,0 +1,27 @@
Non-simple variables are forbidden in PHP 7
-----
<?php
global $$foo->bar;
-----
!!php7
Syntax error, unexpected T_OBJECT_OPERATOR, expecting ';' from 2:13 to 2:14
array(
0: Stmt_Global(
vars: array(
0: Expr_Variable(
name: Expr_Variable(
name: foo
)
)
)
)
1: Stmt_Expression(
expr: Expr_ConstFetch(
name: Name(
parts: array(
0: bar
)
)
)
)
)

View file

@ -0,0 +1,507 @@
UVS indirect calls
-----
<?php
id('var_dump')(1);
id('id')('var_dump')(2);
id()()('var_dump')(4);
id(['udef', 'id'])[1]()('var_dump')(5);
(function($x) { return $x; })('id')('var_dump')(8);
($f = function($x = null) use (&$f) {
return $x ?: $f;
})()()()('var_dump')(9);
[$obj, 'id']()('id')($id)('var_dump')(10);
'id'()('id')('var_dump')(12);
('i' . 'd')()('var_dump')(13);
'\id'('var_dump')(14);
-----
!!php7
array(
0: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_FuncCall(
name: Name(
parts: array(
0: id
)
)
args: array(
0: Arg(
value: Scalar_String(
value: var_dump
)
byRef: false
unpack: false
)
)
)
args: array(
0: Arg(
value: Scalar_LNumber(
value: 1
)
byRef: false
unpack: false
)
)
)
)
1: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_FuncCall(
name: Name(
parts: array(
0: id
)
)
args: array(
0: Arg(
value: Scalar_String(
value: id
)
byRef: false
unpack: false
)
)
)
args: array(
0: Arg(
value: Scalar_String(
value: var_dump
)
byRef: false
unpack: false
)
)
)
args: array(
0: Arg(
value: Scalar_LNumber(
value: 2
)
byRef: false
unpack: false
)
)
)
)
2: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_FuncCall(
name: Name(
parts: array(
0: id
)
)
args: array(
)
)
args: array(
)
)
args: array(
0: Arg(
value: Scalar_String(
value: var_dump
)
byRef: false
unpack: false
)
)
)
args: array(
0: Arg(
value: Scalar_LNumber(
value: 4
)
byRef: false
unpack: false
)
)
)
)
3: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_ArrayDimFetch(
var: Expr_FuncCall(
name: Name(
parts: array(
0: id
)
)
args: array(
0: Arg(
value: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_String(
value: udef
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Scalar_String(
value: id
)
byRef: false
)
)
)
byRef: false
unpack: false
)
)
)
dim: Scalar_LNumber(
value: 1
)
)
args: array(
)
)
args: array(
0: Arg(
value: Scalar_String(
value: var_dump
)
byRef: false
unpack: false
)
)
)
args: array(
0: Arg(
value: Scalar_LNumber(
value: 5
)
byRef: false
unpack: false
)
)
)
)
4: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_Closure(
static: false
byRef: false
params: array(
0: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
name: x
)
default: null
)
)
uses: array(
)
returnType: null
stmts: array(
0: Stmt_Return(
expr: Expr_Variable(
name: x
)
)
)
)
args: array(
0: Arg(
value: Scalar_String(
value: id
)
byRef: false
unpack: false
)
)
)
args: array(
0: Arg(
value: Scalar_String(
value: var_dump
)
byRef: false
unpack: false
)
)
)
args: array(
0: Arg(
value: Scalar_LNumber(
value: 8
)
byRef: false
unpack: false
)
)
)
)
5: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_Assign(
var: Expr_Variable(
name: f
)
expr: Expr_Closure(
static: false
byRef: false
params: array(
0: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
name: x
)
default: Expr_ConstFetch(
name: Name(
parts: array(
0: null
)
)
)
)
)
uses: array(
0: Expr_ClosureUse(
var: Expr_Variable(
name: f
)
byRef: true
)
)
returnType: null
stmts: array(
0: Stmt_Return(
expr: Expr_Ternary(
cond: Expr_Variable(
name: x
)
if: null
else: Expr_Variable(
name: f
)
)
)
)
)
)
args: array(
)
)
args: array(
)
)
args: array(
)
)
args: array(
0: Arg(
value: Scalar_String(
value: var_dump
)
byRef: false
unpack: false
)
)
)
args: array(
0: Arg(
value: Scalar_LNumber(
value: 9
)
byRef: false
unpack: false
)
)
)
)
6: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Expr_Variable(
name: obj
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Scalar_String(
value: id
)
byRef: false
)
)
)
args: array(
)
)
args: array(
0: Arg(
value: Scalar_String(
value: id
)
byRef: false
unpack: false
)
)
)
args: array(
0: Arg(
value: Expr_Variable(
name: id
)
byRef: false
unpack: false
)
)
)
args: array(
0: Arg(
value: Scalar_String(
value: var_dump
)
byRef: false
unpack: false
)
)
)
args: array(
0: Arg(
value: Scalar_LNumber(
value: 10
)
byRef: false
unpack: false
)
)
)
)
7: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_FuncCall(
name: Scalar_String(
value: id
)
args: array(
)
)
args: array(
0: Arg(
value: Scalar_String(
value: id
)
byRef: false
unpack: false
)
)
)
args: array(
0: Arg(
value: Scalar_String(
value: var_dump
)
byRef: false
unpack: false
)
)
)
args: array(
0: Arg(
value: Scalar_LNumber(
value: 12
)
byRef: false
unpack: false
)
)
)
)
8: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_FuncCall(
name: Expr_BinaryOp_Concat(
left: Scalar_String(
value: i
)
right: Scalar_String(
value: d
)
)
args: array(
)
)
args: array(
0: Arg(
value: Scalar_String(
value: var_dump
)
byRef: false
unpack: false
)
)
)
args: array(
0: Arg(
value: Scalar_LNumber(
value: 13
)
byRef: false
unpack: false
)
)
)
)
9: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_FuncCall(
name: Scalar_String(
value: \id
)
args: array(
0: Arg(
value: Scalar_String(
value: var_dump
)
byRef: false
unpack: false
)
)
)
args: array(
0: Arg(
value: Scalar_LNumber(
value: 14
)
byRef: false
unpack: false
)
)
)
)
)

View file

@ -0,0 +1,84 @@
UVS isset() on temporaries
-----
<?php
isset(([0, 1] + [])[0]);
isset(['a' => 'b']->a);
isset("str"->a);
-----
!!php7
array(
0: Stmt_Expression(
expr: Expr_Isset(
vars: array(
0: Expr_ArrayDimFetch(
var: Expr_BinaryOp_Plus(
left: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 0
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 1
)
byRef: false
)
)
)
right: Expr_Array(
items: array(
)
)
)
dim: Scalar_LNumber(
value: 0
)
)
)
)
)
1: Stmt_Expression(
expr: Expr_Isset(
vars: array(
0: Expr_PropertyFetch(
var: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: Scalar_String(
value: a
)
value: Scalar_String(
value: b
)
byRef: false
)
)
)
name: Identifier(
name: a
)
)
)
)
)
2: Stmt_Expression(
expr: Expr_Isset(
vars: array(
0: Expr_PropertyFetch(
var: Scalar_String(
value: str
)
name: Identifier(
name: a
)
)
)
)
)
)

View file

@ -0,0 +1,127 @@
Uniform variable syntax in PHP 7 (misc)
-----
<?php
A::A[0];
A::A[0][1][2];
"string"->length();
(clone $obj)->b[0](1);
[0, 1][0] = 1;
-----
!!php7
array(
0: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_ClassConstFetch(
class: Name(
parts: array(
0: A
)
)
name: Identifier(
name: A
)
)
dim: Scalar_LNumber(
value: 0
)
)
)
1: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_ArrayDimFetch(
var: Expr_ArrayDimFetch(
var: Expr_ClassConstFetch(
class: Name(
parts: array(
0: A
)
)
name: Identifier(
name: A
)
)
dim: Scalar_LNumber(
value: 0
)
)
dim: Scalar_LNumber(
value: 1
)
)
dim: Scalar_LNumber(
value: 2
)
)
)
2: Stmt_Expression(
expr: Expr_MethodCall(
var: Scalar_String(
value: string
)
name: Identifier(
name: length
)
args: array(
)
)
)
3: Stmt_Expression(
expr: Expr_FuncCall(
name: Expr_ArrayDimFetch(
var: Expr_PropertyFetch(
var: Expr_Clone(
expr: Expr_Variable(
name: obj
)
)
name: Identifier(
name: b
)
)
dim: Scalar_LNumber(
value: 0
)
)
args: array(
0: Arg(
value: Scalar_LNumber(
value: 1
)
byRef: false
unpack: false
)
)
)
)
4: Stmt_Expression(
expr: Expr_Assign(
var: Expr_ArrayDimFetch(
var: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 0
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Scalar_LNumber(
value: 1
)
byRef: false
)
)
)
dim: Scalar_LNumber(
value: 0
)
)
expr: Scalar_LNumber(
value: 1
)
)
)
)

View file

@ -0,0 +1,119 @@
UVS new expressions
-----
<?php
new $className;
new $array['className'];
new $array{'className'};
new $obj->className;
new Test::$className;
new $test::$className;
new $weird[0]->foo::$className;
-----
!!php7
array(
0: Stmt_Expression(
expr: Expr_New(
class: Expr_Variable(
name: className
)
args: array(
)
)
)
1: Stmt_Expression(
expr: Expr_New(
class: Expr_ArrayDimFetch(
var: Expr_Variable(
name: array
)
dim: Scalar_String(
value: className
)
)
args: array(
)
)
)
2: Stmt_Expression(
expr: Expr_New(
class: Expr_ArrayDimFetch(
var: Expr_Variable(
name: array
)
dim: Scalar_String(
value: className
)
)
args: array(
)
)
)
3: Stmt_Expression(
expr: Expr_New(
class: Expr_PropertyFetch(
var: Expr_Variable(
name: obj
)
name: Identifier(
name: className
)
)
args: array(
)
)
)
4: Stmt_Expression(
expr: Expr_New(
class: Expr_StaticPropertyFetch(
class: Name(
parts: array(
0: Test
)
)
name: VarLikeIdentifier(
name: className
)
)
args: array(
)
)
)
5: Stmt_Expression(
expr: Expr_New(
class: Expr_StaticPropertyFetch(
class: Expr_Variable(
name: test
)
name: VarLikeIdentifier(
name: className
)
)
args: array(
)
)
)
6: Stmt_Expression(
expr: Expr_New(
class: Expr_StaticPropertyFetch(
class: Expr_PropertyFetch(
var: Expr_ArrayDimFetch(
var: Expr_Variable(
name: weird
)
dim: Scalar_LNumber(
value: 0
)
)
name: Identifier(
name: foo
)
)
name: VarLikeIdentifier(
name: className
)
)
args: array(
)
)
)
)

View file

@ -0,0 +1,123 @@
UVS static access
-----
<?php
A::$b;
$A::$b;
'A'::$b;
('A' . '')::$b;
'A'[0]::$b;
A::$$b;
A::$$c[1];
A::$A::$b;
-----
!!php7
array(
0: Stmt_Expression(
expr: Expr_StaticPropertyFetch(
class: Name(
parts: array(
0: A
)
)
name: VarLikeIdentifier(
name: b
)
)
)
1: Stmt_Expression(
expr: Expr_StaticPropertyFetch(
class: Expr_Variable(
name: A
)
name: VarLikeIdentifier(
name: b
)
)
)
2: Stmt_Expression(
expr: Expr_StaticPropertyFetch(
class: Scalar_String(
value: A
)
name: VarLikeIdentifier(
name: b
)
)
)
3: Stmt_Expression(
expr: Expr_StaticPropertyFetch(
class: Expr_BinaryOp_Concat(
left: Scalar_String(
value: A
)
right: Scalar_String(
value:
)
)
name: VarLikeIdentifier(
name: b
)
)
)
4: Stmt_Expression(
expr: Expr_StaticPropertyFetch(
class: Expr_ArrayDimFetch(
var: Scalar_String(
value: A
)
dim: Scalar_LNumber(
value: 0
)
)
name: VarLikeIdentifier(
name: b
)
)
)
5: Stmt_Expression(
expr: Expr_StaticPropertyFetch(
class: Name(
parts: array(
0: A
)
)
name: Expr_Variable(
name: b
)
)
)
6: Stmt_Expression(
expr: Expr_ArrayDimFetch(
var: Expr_StaticPropertyFetch(
class: Name(
parts: array(
0: A
)
)
name: Expr_Variable(
name: c
)
)
dim: Scalar_LNumber(
value: 1
)
)
)
7: Stmt_Expression(
expr: Expr_StaticPropertyFetch(
class: Expr_StaticPropertyFetch(
class: Name(
parts: array(
0: A
)
)
name: VarLikeIdentifier(
name: A
)
)
name: VarLikeIdentifier(
name: b
)
)
)
)

View file

@ -0,0 +1,67 @@
Variable syntaxes
-----
<?php
$a;
${'a'};
${foo()};
$$a;
$$$a;
$$a['b'];
-----
!!php5
array(
0: Stmt_Expression(
expr: Expr_Variable(
name: a
)
)
1: Stmt_Expression(
expr: Expr_Variable(
name: Scalar_String(
value: a
)
)
)
2: Stmt_Expression(
expr: Expr_Variable(
name: Expr_FuncCall(
name: Name(
parts: array(
0: foo
)
)
args: array(
)
)
)
)
3: Stmt_Expression(
expr: Expr_Variable(
name: Expr_Variable(
name: a
)
)
)
4: Stmt_Expression(
expr: Expr_Variable(
name: Expr_Variable(
name: Expr_Variable(
name: a
)
)
)
)
5: Stmt_Expression(
expr: Expr_Variable(
name: Expr_ArrayDimFetch(
var: Expr_Variable(
name: a
)
dim: Scalar_String(
value: b
)
)
)
)
)

View file

@ -0,0 +1,57 @@
Expression statement mode
-----
<?php
$a = $b;
yield $x;
-----
!!exprStmts
array(
0: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
)
1: Stmt_Expression(
expr: Expr_Yield(
key: null
value: Expr_Variable(
name: x
)
)
)
)
-----
<?php
$a = $b
$c = $d
-----
!!exprStmts
Syntax error, unexpected T_VARIABLE from 3:1 to 3:2
Syntax error, unexpected EOF from 3:8 to 3:8
array(
0: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
)
1: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: c
)
expr: Expr_Variable(
name: d
)
)
)
)

View file

@ -0,0 +1,86 @@
Constant string syntaxes
-----
<?php
'';
"";
b'';
b"";
'Hi';
b'Hi';
B'Hi';
"Hi";
b"Hi";
B"Hi";
'!\'!\\!\a!';
"!\"!\\!\$!\n!\r!\t!\f!\v!\e!\a";
"!\xFF!\377!\400!\0!";
-----
array(
0: Stmt_Expression(
expr: Scalar_String(
value:
)
)
1: Stmt_Expression(
expr: Scalar_String(
value:
)
)
2: Stmt_Expression(
expr: Scalar_String(
value:
)
)
3: Stmt_Expression(
expr: Scalar_String(
value:
)
)
4: Stmt_Expression(
expr: Scalar_String(
value: Hi
)
)
5: Stmt_Expression(
expr: Scalar_String(
value: Hi
)
)
6: Stmt_Expression(
expr: Scalar_String(
value: Hi
)
)
7: Stmt_Expression(
expr: Scalar_String(
value: Hi
)
)
8: Stmt_Expression(
expr: Scalar_String(
value: Hi
)
)
9: Stmt_Expression(
expr: Scalar_String(
value: Hi
)
)
10: Stmt_Expression(
expr: Scalar_String(
value: !'!\!\a!
)
)
11: Stmt_Expression(
expr: Scalar_String(
value: !"!\!$!
!@@{ "\r" }@@!@@{ "\t" }@@!@@{ "\f" }@@!@@{ "\v" }@@!@@{ chr(27) /* "\e" */ }@@!\a
)
)
12: Stmt_Expression(
expr: Scalar_String(
value: !@@{ chr(255) }@@!@@{ chr(255) }@@!@@{ chr(0) }@@!@@{ chr(0) }@@!
)
)
)

View file

@ -0,0 +1,115 @@
Nowdoc and heredoc strings
-----
<?php
// empty strings
<<<'EOS'
EOS;
<<<EOS
EOS;
// constant encapsed strings
<<<'EOS'
Test '" $a \n
EOS;
<<<EOS
Test '" \$a \n
EOS;
// encapsed strings
<<<EOS
Test $a
EOS;
<<<EOS
Test $a and $b->c test
EOS;
b<<<EOS
Binary
EOS;
-----
array(
0: Stmt_Expression(
expr: Scalar_String(
value:
comments: array(
0: // empty strings
)
)
comments: array(
0: // empty strings
)
)
1: Stmt_Expression(
expr: Scalar_String(
value:
)
)
2: Stmt_Expression(
expr: Scalar_String(
value: Test '" $a \n
comments: array(
0: // constant encapsed strings
)
)
comments: array(
0: // constant encapsed strings
)
)
3: Stmt_Expression(
expr: Scalar_String(
value: Test '" $a
)
)
4: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Scalar_EncapsedStringPart(
value: Test
)
1: Expr_Variable(
name: a
)
)
comments: array(
0: // encapsed strings
)
)
comments: array(
0: // encapsed strings
)
)
5: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Scalar_EncapsedStringPart(
value: Test
)
1: Expr_Variable(
name: a
)
2: Scalar_EncapsedStringPart(
value: and
)
3: Expr_PropertyFetch(
var: Expr_Variable(
name: b
)
name: Identifier(
name: c
)
)
4: Scalar_EncapsedStringPart(
value: test
)
)
)
)
6: Stmt_Expression(
expr: Scalar_String(
value: Binary
)
)
)

View file

@ -0,0 +1,77 @@
Trailing newlines in doc strings
-----
<?php
<<<'EOF'@@{ "\n\n" }@@EOF;
<<<'EOF'@@{ "\n\n\n" }@@EOF;
<<<'EOF'@@{ "\nFoo\n\n" }@@EOF;
<<<EOF@@{ "\n\$var\n\n" }@@EOF;
<<<'EOF'@@{ "\r\n\r\n" }@@EOF;
<<<'EOF'@@{ "\r\n\r\n\r\n" }@@EOF;
<<<'EOF'@@{ "\r\nFoo\r\n\r\n" }@@EOF;
<<<EOF@@{ "\r\n\$var\r\n\r\n" }@@EOF;
-----
array(
0: Stmt_Expression(
expr: Scalar_String(
value:
)
)
1: Stmt_Expression(
expr: Scalar_String(
value:
)
)
2: Stmt_Expression(
expr: Scalar_String(
value: Foo
)
)
3: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: var
)
1: Scalar_EncapsedStringPart(
value:
)
)
)
)
4: Stmt_Expression(
expr: Scalar_String(
value:
)
)
5: Stmt_Expression(
expr: Scalar_String(
value:
)
)
6: Stmt_Expression(
expr: Scalar_String(
value: Foo
)
)
7: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: var
)
1: Scalar_EncapsedStringPart(
value:
)
)
)
)
)

View file

@ -0,0 +1,82 @@
Encapsed string negative var offsets
-----
<?php
"$a[-0]";
"$a[-1]";
"$a[-0x0]";
"$a[-00]";
"$a[@@{ -PHP_INT_MAX - 1 }@@]";
-----
!!php7
array(
0: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_ArrayDimFetch(
var: Expr_Variable(
name: a
)
dim: Scalar_String(
value: -0
)
)
)
)
)
1: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_ArrayDimFetch(
var: Expr_Variable(
name: a
)
dim: Scalar_LNumber(
value: -1
)
)
)
)
)
2: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_ArrayDimFetch(
var: Expr_Variable(
name: a
)
dim: Scalar_String(
value: -0x0
)
)
)
)
)
3: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_ArrayDimFetch(
var: Expr_Variable(
name: a
)
dim: Scalar_String(
value: -00
)
)
)
)
)
4: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_ArrayDimFetch(
var: Expr_Variable(
name: a
)
dim: Scalar_LNumber(
value: @@{ -PHP_INT_MAX - 1 }@@
)
)
)
)
)
)

View file

@ -0,0 +1,344 @@
Encapsed strings
-----
<?php
"$A";
"$A->B";
"$A[B]";
"$A[0]";
"$A[1234]";
"$A[9223372036854775808]";
"$A[000]";
"$A[0x0]";
"$A[0b0]";
"$A[$B]";
"{$A}";
"{$A['B']}";
"${A}";
"${A['B']}";
"${$A}";
"\{$A}";
"\{ $A }";
"\\{$A}";
"\\{ $A }";
"{$$A}[B]";
"$$A[B]";
"A $B C";
b"$A";
B"$A";
-----
array(
0: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: A
)
)
)
)
1: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_PropertyFetch(
var: Expr_Variable(
name: A
)
name: Identifier(
name: B
)
)
)
)
)
2: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_ArrayDimFetch(
var: Expr_Variable(
name: A
)
dim: Scalar_String(
value: B
)
)
)
)
)
3: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_ArrayDimFetch(
var: Expr_Variable(
name: A
)
dim: Scalar_LNumber(
value: 0
)
)
)
)
)
4: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_ArrayDimFetch(
var: Expr_Variable(
name: A
)
dim: Scalar_LNumber(
value: 1234
)
)
)
)
)
5: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_ArrayDimFetch(
var: Expr_Variable(
name: A
)
dim: Scalar_String(
value: 9223372036854775808
)
)
)
)
)
6: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_ArrayDimFetch(
var: Expr_Variable(
name: A
)
dim: Scalar_String(
value: 000
)
)
)
)
)
7: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_ArrayDimFetch(
var: Expr_Variable(
name: A
)
dim: Scalar_String(
value: 0x0
)
)
)
)
)
8: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_ArrayDimFetch(
var: Expr_Variable(
name: A
)
dim: Scalar_String(
value: 0b0
)
)
)
)
)
9: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_ArrayDimFetch(
var: Expr_Variable(
name: A
)
dim: Expr_Variable(
name: B
)
)
)
)
)
10: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: A
)
)
)
)
11: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_ArrayDimFetch(
var: Expr_Variable(
name: A
)
dim: Scalar_String(
value: B
)
)
)
)
)
12: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: A
)
)
)
)
13: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_ArrayDimFetch(
var: Expr_Variable(
name: A
)
dim: Scalar_String(
value: B
)
)
)
)
)
14: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: Expr_Variable(
name: A
)
)
)
)
)
15: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Scalar_EncapsedStringPart(
value: \{
)
1: Expr_Variable(
name: A
)
2: Scalar_EncapsedStringPart(
value: }
)
)
)
)
16: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Scalar_EncapsedStringPart(
value: \{
)
1: Expr_Variable(
name: A
)
2: Scalar_EncapsedStringPart(
value: }
)
)
)
)
17: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Scalar_EncapsedStringPart(
value: \
)
1: Expr_Variable(
name: A
)
)
)
)
18: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Scalar_EncapsedStringPart(
value: \{
)
1: Expr_Variable(
name: A
)
2: Scalar_EncapsedStringPart(
value: }
)
)
)
)
19: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: Expr_Variable(
name: A
)
)
1: Scalar_EncapsedStringPart(
value: [B]
)
)
)
)
20: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Scalar_EncapsedStringPart(
value: $
)
1: Expr_ArrayDimFetch(
var: Expr_Variable(
name: A
)
dim: Scalar_String(
value: B
)
)
)
)
)
21: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Scalar_EncapsedStringPart(
value: A
)
1: Expr_Variable(
name: B
)
2: Scalar_EncapsedStringPart(
value: C
)
)
)
)
22: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: A
)
)
)
)
23: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: A
)
)
)
)
)

View file

@ -0,0 +1,359 @@
Flexible heredoc/nowdoc (PHP 7.3)
-----
<?php
$ary = [
<<<FOO
Test
FOO,
<<<'BAR'
Test
BAR,
];
<<<'END'
END;
<<<END
END;
<<<END
@@{ " " }@@
END;
<<<'END'
a
b
c
d
e
END;
<<<END
a
b
$test
d
e
END;
<<<'END'
a
b
c
d
e
END;
<<<END
a\r\n
\ta\n
b\r\n
$test\n
d\r\n
e\n
END;
<<<BAR
$one-
BAR;
<<<BAR
$two -
BAR;
<<<BAR
$three -
BAR;
<<<BAR
$four-$four
BAR;
<<<BAR
$five-$five-
BAR;
<<<BAR
$six-$six-$six
BAR;
<<<BAR
$seven
-
BAR;
<<<BAR
$eight
-
BAR;
<<<BAR
$nine
BAR;
<<<BAR
-
BAR;
<<<BAR
-
BAR;
-----
array(
0: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: ary
)
expr: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_String(
value: Test
)
byRef: false
)
1: Expr_ArrayItem(
key: null
value: Scalar_String(
value: Test
)
byRef: false
)
)
)
)
)
1: Stmt_Expression(
expr: Scalar_String(
value:
)
)
2: Stmt_Expression(
expr: Scalar_String(
value:
)
)
3: Stmt_Expression(
expr: Scalar_String(
value:
)
)
4: Stmt_Expression(
expr: Scalar_String(
value: a
b
c
d
e
)
)
5: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Scalar_EncapsedStringPart(
value: a
b
)
1: Expr_Variable(
name: test
)
2: Scalar_EncapsedStringPart(
value:
d
e
)
)
)
)
6: Stmt_Expression(
expr: Scalar_String(
value:
a
b
c
d
e
)
)
7: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Scalar_EncapsedStringPart(
value: a
@@{ "\t" }@@a
b
)
1: Expr_Variable(
name: test
)
2: Scalar_EncapsedStringPart(
value:
d
e
)
)
)
)
8: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: one
)
1: Scalar_EncapsedStringPart(
value: -
)
)
)
)
9: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: two
)
1: Scalar_EncapsedStringPart(
value: -
)
)
)
)
10: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: three
)
1: Scalar_EncapsedStringPart(
value: -
)
)
)
)
11: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: four
)
1: Scalar_EncapsedStringPart(
value: -
)
2: Expr_Variable(
name: four
)
)
)
)
12: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: five
)
1: Scalar_EncapsedStringPart(
value: -
)
2: Expr_Variable(
name: five
)
3: Scalar_EncapsedStringPart(
value: -
)
)
)
)
13: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: six
)
1: Scalar_EncapsedStringPart(
value: -
)
2: Expr_Variable(
name: six
)
3: Scalar_EncapsedStringPart(
value: -
)
4: Expr_Variable(
name: six
)
)
)
)
14: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: seven
)
1: Scalar_EncapsedStringPart(
value:
-
)
)
)
)
15: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: eight
)
1: Scalar_EncapsedStringPart(
value:
-
)
)
)
)
16: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: nine
)
)
)
)
17: Stmt_Expression(
expr: Scalar_String(
value: -
)
)
18: Stmt_Expression(
expr: Scalar_String(
value: -
)
)
)

View file

@ -0,0 +1,117 @@
Error conditions for flexible doc strings
-----
<?php
<<<A
@@{ "\t" }@@A;
<<<A
FooBar
@@{ "\t" }@@A;
echo <<<END
@@{ "\t" }@@ X
@@{ "\t\t" }@@END;
echo <<<END
a
b
c
END;
<<<END
\ta
@@{ "\t" }@@END;
<<<TEST
Foo
$var
TEST;
<<<TEST
$var
TEST;
echo <<<END
a
$a
END;
-----
Invalid indentation - tabs and spaces cannot be mixed from 4:1 to 4:3
Invalid indentation - tabs and spaces cannot be mixed from 8:1 to 8:3
Invalid indentation - tabs and spaces cannot be mixed from 10:6 to 12:5
Invalid body indentation level (expecting an indentation level of at least 5) from 14:6 to 18:8
Invalid body indentation level (expecting an indentation level of at least 1) from 20:1 to 22:4
Invalid body indentation level (expecting an indentation level of at least 2) from 25:1 to 26:0
Invalid body indentation level (expecting an indentation level of at least 1) from 30:1 to 30:4
Invalid body indentation level (expecting an indentation level of at least 1) from 34:1 to 35:0
array(
0: Stmt_Expression(
expr: Scalar_String(
value:
)
)
1: Stmt_Expression(
expr: Scalar_String(
value: FooBar
)
)
2: Stmt_Echo(
exprs: array(
0: Scalar_String(
value: X
)
)
)
3: Stmt_Echo(
exprs: array(
0: Scalar_String(
value: a
b
c
)
)
)
4: Stmt_Expression(
expr: Scalar_String(
value: a
)
)
5: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Scalar_EncapsedStringPart(
value: Foo
)
1: Expr_Variable(
name: var
)
)
)
)
6: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_Variable(
name: var
)
)
)
)
7: Stmt_Echo(
exprs: array(
0: Scalar_Encapsed(
parts: array(
0: Scalar_EncapsedStringPart(
value: a
)
1: Expr_Variable(
name: a
)
)
)
)
)
)

View file

@ -0,0 +1,108 @@
Different float syntaxes
-----
<?php
0.0;
0.;
.0;
0e0;
0E0;
0e+0;
0e-0;
30.20e10;
300.200e100;
1e10000;
// various integer -> float overflows
// (all are actually the same number, just in different representations)
18446744073709551615;
0xFFFFFFFFFFFFFFFF;
01777777777777777777777;
0177777777777777777777787;
0b1111111111111111111111111111111111111111111111111111111111111111;
-----
array(
0: Stmt_Expression(
expr: Scalar_DNumber(
value: 0
)
)
1: Stmt_Expression(
expr: Scalar_DNumber(
value: 0
)
)
2: Stmt_Expression(
expr: Scalar_DNumber(
value: 0
)
)
3: Stmt_Expression(
expr: Scalar_DNumber(
value: 0
)
)
4: Stmt_Expression(
expr: Scalar_DNumber(
value: 0
)
)
5: Stmt_Expression(
expr: Scalar_DNumber(
value: 0
)
)
6: Stmt_Expression(
expr: Scalar_DNumber(
value: 0
)
)
7: Stmt_Expression(
expr: Scalar_DNumber(
value: 302000000000
)
)
8: Stmt_Expression(
expr: Scalar_DNumber(
value: 3.002E+102
)
)
9: Stmt_Expression(
expr: Scalar_DNumber(
value: INF
)
)
10: Stmt_Expression(
expr: Scalar_DNumber(
value: 1.844674407371E+19
comments: array(
0: // various integer -> float overflows
1: // (all are actually the same number, just in different representations)
)
)
comments: array(
0: // various integer -> float overflows
1: // (all are actually the same number, just in different representations)
)
)
11: Stmt_Expression(
expr: Scalar_DNumber(
value: 1.844674407371E+19
)
)
12: Stmt_Expression(
expr: Scalar_DNumber(
value: 1.844674407371E+19
)
)
13: Stmt_Expression(
expr: Scalar_DNumber(
value: 1.844674407371E+19
)
)
14: Stmt_Expression(
expr: Scalar_DNumber(
value: 1.844674407371E+19
)
)
)

View file

@ -0,0 +1,61 @@
Different integer syntaxes
-----
<?php
0;
1;
@@{ PHP_INT_MAX }@@;
@@{ PHP_INT_MAX + 1 }@@;
0xFFF;
0xfff;
0XfFf;
0777;
0b111000111000;
-----
array(
0: Stmt_Expression(
expr: Scalar_LNumber(
value: 0
)
)
1: Stmt_Expression(
expr: Scalar_LNumber(
value: 1
)
)
2: Stmt_Expression(
expr: Scalar_LNumber(
value: @@{ PHP_INT_MAX }@@
)
)
3: Stmt_Expression(
expr: Scalar_DNumber(
value: @@{ PHP_INT_MAX + 1 }@@
)
)
4: Stmt_Expression(
expr: Scalar_LNumber(
value: 4095
)
)
5: Stmt_Expression(
expr: Scalar_LNumber(
value: 4095
)
)
6: Stmt_Expression(
expr: Scalar_LNumber(
value: 4095
)
)
7: Stmt_Expression(
expr: Scalar_LNumber(
value: 511
)
)
8: Stmt_Expression(
expr: Scalar_LNumber(
value: 3640
)
)
)

View file

@ -0,0 +1,26 @@
Invalid octal literals
-----
<?php
0787;
-----
!!php7
Invalid numeric literal from 2:1 to 2:4
array(
0: Stmt_Expression(
expr: Scalar_LNumber(
value: 0
)
)
)
-----
<?php
0787;
-----
!!php5
array(
0: Stmt_Expression(
expr: Scalar_LNumber(
value: 7
)
)
)

View file

@ -0,0 +1,47 @@
Magic constants
-----
<?php
__CLASS__;
__DIR__;
__FILE__;
__FUNCTION__;
__LINE__;
__METHOD__;
__NAMESPACE__;
__TRAIT__;
-----
array(
0: Stmt_Expression(
expr: Scalar_MagicConst_Class(
)
)
1: Stmt_Expression(
expr: Scalar_MagicConst_Dir(
)
)
2: Stmt_Expression(
expr: Scalar_MagicConst_File(
)
)
3: Stmt_Expression(
expr: Scalar_MagicConst_Function(
)
)
4: Stmt_Expression(
expr: Scalar_MagicConst_Line(
)
)
5: Stmt_Expression(
expr: Scalar_MagicConst_Method(
)
)
6: Stmt_Expression(
expr: Scalar_MagicConst_Namespace(
)
)
7: Stmt_Expression(
expr: Scalar_MagicConst_Trait(
)
)
)

View file

@ -0,0 +1,26 @@
Unicode escape sequence
-----
<?php
"\u{0}";
"\u{114}";
"\u{1F602}";
-----
!!php7
array(
0: Stmt_Expression(
expr: Scalar_String(
value: @@{"\0"}@@
)
)
1: Stmt_Expression(
expr: Scalar_String(
value: Ĕ
)
)
2: Stmt_Expression(
expr: Scalar_String(
value: @@{"\xF0\x9F\x98\x82"}@@
)
)
)

View file

@ -0,0 +1,490 @@
Valid usages of reserved keywords as identifiers
-----
<?php
class Test {
function array() {}
function public() {}
static function list() {}
static function protected() {}
public $class;
public $private;
const TRAIT = 3, FINAL = 4;
const __CLASS__ = 1, __TRAIT__ = 2, __FUNCTION__ = 3, __METHOD__ = 4, __LINE__ = 5,
__FILE__ = 6, __DIR__ = 7, __NAMESPACE__ = 8;
// __halt_compiler does not work
}
$t = new Test;
$t->array();
$t->public();
Test::list();
Test::protected();
$t->class;
$t->private;
Test::TRAIT;
Test::FINAL;
class Foo {
use TraitA, TraitB {
TraitA::catch insteadof namespace\TraitB;
TraitA::list as foreach;
TraitB::throw as protected public;
TraitB::self as protected;
exit as die;
\TraitC::exit as bye;
namespace\TraitC::exit as byebye;
TraitA::
//
/** doc comment */
#
catch /* comment */
// comment
# comment
insteadof TraitB;
}
}
-----
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: Test
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassMethod(
flags: 0
byRef: false
name: Identifier(
name: array
)
params: array(
)
returnType: null
stmts: array(
)
)
1: Stmt_ClassMethod(
flags: 0
byRef: false
name: Identifier(
name: public
)
params: array(
)
returnType: null
stmts: array(
)
)
2: Stmt_ClassMethod(
flags: MODIFIER_STATIC (8)
byRef: false
name: Identifier(
name: list
)
params: array(
)
returnType: null
stmts: array(
)
)
3: Stmt_ClassMethod(
flags: MODIFIER_STATIC (8)
byRef: false
name: Identifier(
name: protected
)
params: array(
)
returnType: null
stmts: array(
)
)
4: Stmt_Property(
flags: MODIFIER_PUBLIC (1)
type: null
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: class
)
default: null
)
)
)
5: Stmt_Property(
flags: MODIFIER_PUBLIC (1)
type: null
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: private
)
default: null
)
)
)
6: Stmt_ClassConst(
flags: 0
consts: array(
0: Const(
name: Identifier(
name: TRAIT
)
value: Scalar_LNumber(
value: 3
)
)
1: Const(
name: Identifier(
name: FINAL
)
value: Scalar_LNumber(
value: 4
)
)
)
)
7: Stmt_ClassConst(
flags: 0
consts: array(
0: Const(
name: Identifier(
name: __CLASS__
)
value: Scalar_LNumber(
value: 1
)
)
1: Const(
name: Identifier(
name: __TRAIT__
)
value: Scalar_LNumber(
value: 2
)
)
2: Const(
name: Identifier(
name: __FUNCTION__
)
value: Scalar_LNumber(
value: 3
)
)
3: Const(
name: Identifier(
name: __METHOD__
)
value: Scalar_LNumber(
value: 4
)
)
4: Const(
name: Identifier(
name: __LINE__
)
value: Scalar_LNumber(
value: 5
)
)
5: Const(
name: Identifier(
name: __FILE__
)
value: Scalar_LNumber(
value: 6
)
)
6: Const(
name: Identifier(
name: __DIR__
)
value: Scalar_LNumber(
value: 7
)
)
7: Const(
name: Identifier(
name: __NAMESPACE__
)
value: Scalar_LNumber(
value: 8
)
)
)
)
8: Stmt_Nop(
comments: array(
0: // __halt_compiler does not work
)
)
)
)
1: Stmt_Expression(
expr: Expr_Assign(
var: Expr_Variable(
name: t
)
expr: Expr_New(
class: Name(
parts: array(
0: Test
)
)
args: array(
)
)
)
)
2: Stmt_Expression(
expr: Expr_MethodCall(
var: Expr_Variable(
name: t
)
name: Identifier(
name: array
)
args: array(
)
)
)
3: Stmt_Expression(
expr: Expr_MethodCall(
var: Expr_Variable(
name: t
)
name: Identifier(
name: public
)
args: array(
)
)
)
4: Stmt_Expression(
expr: Expr_StaticCall(
class: Name(
parts: array(
0: Test
)
)
name: Identifier(
name: list
)
args: array(
)
)
)
5: Stmt_Expression(
expr: Expr_StaticCall(
class: Name(
parts: array(
0: Test
)
)
name: Identifier(
name: protected
)
args: array(
)
)
)
6: Stmt_Expression(
expr: Expr_PropertyFetch(
var: Expr_Variable(
name: t
)
name: Identifier(
name: class
)
)
)
7: Stmt_Expression(
expr: Expr_PropertyFetch(
var: Expr_Variable(
name: t
)
name: Identifier(
name: private
)
)
)
8: Stmt_Expression(
expr: Expr_ClassConstFetch(
class: Name(
parts: array(
0: Test
)
)
name: Identifier(
name: TRAIT
)
)
)
9: Stmt_Expression(
expr: Expr_ClassConstFetch(
class: Name(
parts: array(
0: Test
)
)
name: Identifier(
name: FINAL
)
)
)
10: Stmt_Class(
flags: 0
name: Identifier(
name: Foo
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_TraitUse(
traits: array(
0: Name(
parts: array(
0: TraitA
)
)
1: Name(
parts: array(
0: TraitB
)
)
)
adaptations: array(
0: Stmt_TraitUseAdaptation_Precedence(
trait: Name(
parts: array(
0: TraitA
)
)
method: Identifier(
name: catch
)
insteadof: array(
0: Name_Relative(
parts: array(
0: TraitB
)
)
)
)
1: Stmt_TraitUseAdaptation_Alias(
trait: Name(
parts: array(
0: TraitA
)
)
method: Identifier(
name: list
)
newModifier: null
newName: Identifier(
name: foreach
)
)
2: Stmt_TraitUseAdaptation_Alias(
trait: Name(
parts: array(
0: TraitB
)
)
method: Identifier(
name: throw
)
newModifier: MODIFIER_PROTECTED (2)
newName: Identifier(
name: public
)
)
3: Stmt_TraitUseAdaptation_Alias(
trait: Name(
parts: array(
0: TraitB
)
)
method: Identifier(
name: self
)
newModifier: MODIFIER_PROTECTED (2)
newName: null
)
4: Stmt_TraitUseAdaptation_Alias(
trait: null
method: Identifier(
name: exit
)
newModifier: null
newName: Identifier(
name: die
)
)
5: Stmt_TraitUseAdaptation_Alias(
trait: Name_FullyQualified(
parts: array(
0: TraitC
)
)
method: Identifier(
name: exit
)
newModifier: null
newName: Identifier(
name: bye
)
)
6: Stmt_TraitUseAdaptation_Alias(
trait: Name_Relative(
parts: array(
0: TraitC
)
)
method: Identifier(
name: exit
)
newModifier: null
newName: Identifier(
name: byebye
)
)
7: Stmt_TraitUseAdaptation_Precedence(
trait: Name(
parts: array(
0: TraitA
)
)
method: Identifier(
name: catch
comments: array(
0: //
1: /** doc comment */
2: #
)
)
insteadof: array(
0: Name(
parts: array(
0: TraitB
)
)
)
)
)
)
)
)
)

View file

@ -0,0 +1,130 @@
Blockless statements for if/for/etc
-----
<?php
if ($a) $A;
elseif ($b) $B;
else $C;
for (;;) $foo;
foreach ($a as $b) $AB;
while ($a) $A;
do $A; while ($a);
declare (a='b') $C;
-----
array(
0: Stmt_If(
cond: Expr_Variable(
name: a
)
stmts: array(
0: Stmt_Expression(
expr: Expr_Variable(
name: A
)
)
)
elseifs: array(
0: Stmt_ElseIf(
cond: Expr_Variable(
name: b
)
stmts: array(
0: Stmt_Expression(
expr: Expr_Variable(
name: B
)
)
)
)
)
else: Stmt_Else(
stmts: array(
0: Stmt_Expression(
expr: Expr_Variable(
name: C
)
)
)
)
)
1: Stmt_For(
init: array(
)
cond: array(
)
loop: array(
)
stmts: array(
0: Stmt_Expression(
expr: Expr_Variable(
name: foo
)
)
)
)
2: Stmt_Foreach(
expr: Expr_Variable(
name: a
)
keyVar: null
byRef: false
valueVar: Expr_Variable(
name: b
)
stmts: array(
0: Stmt_Expression(
expr: Expr_Variable(
name: AB
)
)
)
)
3: Stmt_While(
cond: Expr_Variable(
name: a
)
stmts: array(
0: Stmt_Expression(
expr: Expr_Variable(
name: A
)
)
)
)
4: Stmt_Do(
stmts: array(
0: Stmt_Expression(
expr: Expr_Variable(
name: A
)
)
)
cond: Expr_Variable(
name: a
)
)
5: Stmt_Declare(
declares: array(
0: Stmt_DeclareDeclare(
key: Identifier(
name: a
)
value: Scalar_String(
value: b
)
)
)
stmts: array(
0: Stmt_Expression(
expr: Expr_Variable(
name: C
)
)
)
)
)

View file

@ -0,0 +1,45 @@
Abstract class
-----
<?php
abstract class A {
public function a() {}
abstract public function b();
}
-----
array(
0: Stmt_Class(
flags: MODIFIER_ABSTRACT (16)
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassMethod(
flags: MODIFIER_PUBLIC (1)
byRef: false
name: Identifier(
name: a
)
params: array(
)
returnType: null
stmts: array(
)
)
1: Stmt_ClassMethod(
flags: MODIFIER_PUBLIC | MODIFIER_ABSTRACT (17)
byRef: false
name: Identifier(
name: b
)
params: array(
)
returnType: null
stmts: null
)
)
)
)

View file

@ -0,0 +1,214 @@
Anonymous classes
-----
<?php
new class {
public function test() {}
};
new class extends A implements B, C {};
new class() {
public $foo;
};
new class($a, $b) extends A {
use T;
};
class A {
public function test() {
return new class($this) extends A {
const A = 'B';
};
}
}
-----
array(
0: Stmt_Expression(
expr: Expr_New(
class: Stmt_Class(
flags: 0
name: null
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassMethod(
flags: MODIFIER_PUBLIC (1)
byRef: false
name: Identifier(
name: test
)
params: array(
)
returnType: null
stmts: array(
)
)
)
)
args: array(
)
)
)
1: Stmt_Expression(
expr: Expr_New(
class: Stmt_Class(
flags: 0
name: null
extends: Name(
parts: array(
0: A
)
)
implements: array(
0: Name(
parts: array(
0: B
)
)
1: Name(
parts: array(
0: C
)
)
)
stmts: array(
)
)
args: array(
)
)
)
2: Stmt_Expression(
expr: Expr_New(
class: Stmt_Class(
flags: 0
name: null
extends: null
implements: array(
)
stmts: array(
0: Stmt_Property(
flags: MODIFIER_PUBLIC (1)
type: null
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: foo
)
default: null
)
)
)
)
)
args: array(
)
)
)
3: Stmt_Expression(
expr: Expr_New(
class: Stmt_Class(
flags: 0
name: null
extends: Name(
parts: array(
0: A
)
)
implements: array(
)
stmts: array(
0: Stmt_TraitUse(
traits: array(
0: Name(
parts: array(
0: T
)
)
)
adaptations: array(
)
)
)
)
args: array(
0: Arg(
value: Expr_Variable(
name: a
)
byRef: false
unpack: false
)
1: Arg(
value: Expr_Variable(
name: b
)
byRef: false
unpack: false
)
)
)
)
4: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassMethod(
flags: MODIFIER_PUBLIC (1)
byRef: false
name: Identifier(
name: test
)
params: array(
)
returnType: null
stmts: array(
0: Stmt_Return(
expr: Expr_New(
class: Stmt_Class(
flags: 0
name: null
extends: Name(
parts: array(
0: A
)
)
implements: array(
)
stmts: array(
0: Stmt_ClassConst(
flags: 0
consts: array(
0: Const(
name: Identifier(
name: A
)
value: Scalar_String(
value: B
)
)
)
)
)
)
args: array(
0: Arg(
value: Expr_Variable(
name: this
)
byRef: false
unpack: false
)
)
)
)
)
)
)
)
)

View file

@ -0,0 +1,35 @@
Conditional class definition
-----
<?php
if (true) {
class A {}
}
-----
array(
0: Stmt_If(
cond: Expr_ConstFetch(
name: Name(
parts: array(
0: true
)
)
)
stmts: array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
)
)
)
elseifs: array(
)
else: null
)
)

View file

@ -0,0 +1,137 @@
Invalid class constant modifiers
-----
<?php
class A {
static const X = 1;
}
-----
!!php7
Cannot use 'static' as constant modifier from 3:5 to 3:10
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassConst(
flags: MODIFIER_STATIC (8)
consts: array(
0: Const(
name: Identifier(
name: X
)
value: Scalar_LNumber(
value: 1
)
)
)
)
)
)
)
-----
<?php
class A {
abstract const X = 1;
}
-----
!!php7
Cannot use 'abstract' as constant modifier from 3:5 to 3:12
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassConst(
flags: MODIFIER_ABSTRACT (16)
consts: array(
0: Const(
name: Identifier(
name: X
)
value: Scalar_LNumber(
value: 1
)
)
)
)
)
)
)
-----
<?php
class A {
final const X = 1;
}
-----
!!php7
Cannot use 'final' as constant modifier from 3:5 to 3:9
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassConst(
flags: MODIFIER_FINAL (32)
consts: array(
0: Const(
name: Identifier(
name: X
)
value: Scalar_LNumber(
value: 1
)
)
)
)
)
)
)
-----
<?php
class A {
public public const X = 1;
}
-----
!!php7
Multiple access type modifiers are not allowed from 3:12 to 3:17
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassConst(
flags: MODIFIER_PUBLIC (1)
consts: array(
0: Const(
name: Identifier(
name: X
)
value: Scalar_LNumber(
value: 1
)
)
)
)
)
)
)

View file

@ -0,0 +1,77 @@
Class constant modifiers
-----
<?php
class Foo {
const A = 1;
public const B = 2;
protected const C = 3;
private const D = 4;
}
-----
!!php7
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: Foo
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassConst(
flags: 0
consts: array(
0: Const(
name: Identifier(
name: A
)
value: Scalar_LNumber(
value: 1
)
)
)
)
1: Stmt_ClassConst(
flags: MODIFIER_PUBLIC (1)
consts: array(
0: Const(
name: Identifier(
name: B
)
value: Scalar_LNumber(
value: 2
)
)
)
)
2: Stmt_ClassConst(
flags: MODIFIER_PROTECTED (2)
consts: array(
0: Const(
name: Identifier(
name: C
)
value: Scalar_LNumber(
value: 3
)
)
)
)
3: Stmt_ClassConst(
flags: MODIFIER_PRIVATE (4)
consts: array(
0: Const(
name: Identifier(
name: D
)
value: Scalar_LNumber(
value: 4
)
)
)
)
)
)
)

View file

@ -0,0 +1,19 @@
Final class
-----
<?php
final class A {}
-----
array(
0: Stmt_Class(
flags: MODIFIER_FINAL (32)
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
)
)
)

View file

@ -0,0 +1,110 @@
Implicitly public properties and methods
-----
<?php
abstract class A {
var $a;
static $b;
abstract function c();
final function d() {}
static function e() {}
final static function f() {}
function g() {}
}
-----
array(
0: Stmt_Class(
flags: MODIFIER_ABSTRACT (16)
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_Property(
flags: 0
type: null
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: a
)
default: null
)
)
)
1: Stmt_Property(
flags: MODIFIER_STATIC (8)
type: null
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: b
)
default: null
)
)
)
2: Stmt_ClassMethod(
flags: MODIFIER_ABSTRACT (16)
byRef: false
name: Identifier(
name: c
)
params: array(
)
returnType: null
stmts: null
)
3: Stmt_ClassMethod(
flags: MODIFIER_FINAL (32)
byRef: false
name: Identifier(
name: d
)
params: array(
)
returnType: null
stmts: array(
)
)
4: Stmt_ClassMethod(
flags: MODIFIER_STATIC (8)
byRef: false
name: Identifier(
name: e
)
params: array(
)
returnType: null
stmts: array(
)
)
5: Stmt_ClassMethod(
flags: MODIFIER_STATIC | MODIFIER_FINAL (40)
byRef: false
name: Identifier(
name: f
)
params: array(
)
returnType: null
stmts: array(
)
)
6: Stmt_ClassMethod(
flags: 0
byRef: false
name: Identifier(
name: g
)
params: array(
)
returnType: null
stmts: array(
)
)
)
)
)

View file

@ -0,0 +1,40 @@
Interface
-----
<?php
interface A extends C, D {
public function a();
}
-----
array(
0: Stmt_Interface(
name: Identifier(
name: A
)
extends: array(
0: Name(
parts: array(
0: C
)
)
1: Name(
parts: array(
0: D
)
)
)
stmts: array(
0: Stmt_ClassMethod(
flags: MODIFIER_PUBLIC (1)
byRef: false
name: Identifier(
name: a
)
params: array(
)
returnType: null
stmts: null
)
)
)
)

View file

@ -0,0 +1,254 @@
Invalid modifier combination
-----
<?php class A { public public $a; }
-----
Multiple access type modifiers are not allowed from 1:24 to 1:29
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_Property(
flags: MODIFIER_PUBLIC (1)
type: null
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: a
)
default: null
)
)
)
)
)
)
-----
<?php class A { public protected $a; }
-----
Multiple access type modifiers are not allowed from 1:24 to 1:32
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_Property(
flags: MODIFIER_PUBLIC | MODIFIER_PROTECTED (3)
type: null
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: a
)
default: null
)
)
)
)
)
)
-----
<?php class A { abstract abstract function a(); }
-----
Multiple abstract modifiers are not allowed from 1:26 to 1:33
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassMethod(
flags: MODIFIER_ABSTRACT (16)
byRef: false
name: Identifier(
name: a
)
params: array(
)
returnType: null
stmts: null
)
)
)
)
-----
<?php class A { static static $a; }
-----
Multiple static modifiers are not allowed from 1:24 to 1:29
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_Property(
flags: MODIFIER_STATIC (8)
type: null
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: a
)
default: null
)
)
)
)
)
)
-----
<?php class A { final final function a() {} }
-----
Multiple final modifiers are not allowed from 1:23 to 1:27
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassMethod(
flags: MODIFIER_FINAL (32)
byRef: false
name: Identifier(
name: a
)
params: array(
)
returnType: null
stmts: array(
)
)
)
)
)
-----
<?php class A { abstract final function a(); }
-----
Cannot use the final modifier on an abstract class member from 1:26 to 1:30
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassMethod(
flags: MODIFIER_ABSTRACT | MODIFIER_FINAL (48)
byRef: false
name: Identifier(
name: a
)
params: array(
)
returnType: null
stmts: null
)
)
)
)
-----
<?php abstract final class A { }
// Type in the partial parse could conceivably be any of 0, 16 or 32
-----
Syntax error, unexpected T_FINAL, expecting T_CLASS from 1:16 to 1:20
array(
0: Stmt_Class(
flags: MODIFIER_FINAL (32)
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
)
)
1: Stmt_Nop(
comments: array(
0: // Type in the partial parse could conceivably be any of 0, 16 or 32
)
)
)
-----
<?php class A { abstract $a; }
-----
Properties cannot be declared abstract from 1:17 to 1:24
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_Property(
flags: MODIFIER_ABSTRACT (16)
type: null
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: a
)
default: null
)
)
)
)
)
)
-----
<?php class A { final $a; }
-----
Properties cannot be declared final from 1:17 to 1:21
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_Property(
flags: MODIFIER_FINAL (32)
type: null
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: a
)
default: null
)
)
)
)
)
)

View file

@ -0,0 +1,266 @@
Invalid class name
-----
<?php class self {}
-----
Cannot use 'self' as class name as it is reserved from 1:13 to 1:16
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: self
)
extends: null
implements: array(
)
stmts: array(
)
)
)
-----
<?php class PARENT {}
-----
Cannot use 'PARENT' as class name as it is reserved from 1:13 to 1:18
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: PARENT
)
extends: null
implements: array(
)
stmts: array(
)
)
)
-----
<?php class static {}
-----
Syntax error, unexpected T_STATIC, expecting T_STRING from 1:13 to 1:18
array(
)
-----
<?php class A extends self {}
-----
Cannot use 'self' as class name as it is reserved from 1:23 to 1:26
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: Name(
parts: array(
0: self
)
)
implements: array(
)
stmts: array(
)
)
)
-----
<?php class A extends PARENT {}
-----
Cannot use 'PARENT' as class name as it is reserved from 1:23 to 1:28
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: Name(
parts: array(
0: PARENT
)
)
implements: array(
)
stmts: array(
)
)
)
-----
<?php class A extends static {}
-----
Cannot use 'static' as class name as it is reserved from 1:23 to 1:28
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: Name(
parts: array(
0: static
)
)
implements: array(
)
stmts: array(
)
)
)
-----
<?php class A implements self {}
-----
Cannot use 'self' as interface name as it is reserved from 1:26 to 1:29
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
0: Name(
parts: array(
0: self
)
)
)
stmts: array(
)
)
)
-----
<?php class A implements PARENT {}
-----
Cannot use 'PARENT' as interface name as it is reserved from 1:26 to 1:31
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
0: Name(
parts: array(
0: PARENT
)
)
)
stmts: array(
)
)
)
-----
<?php class A implements static {}
-----
Cannot use 'static' as interface name as it is reserved from 1:26 to 1:31
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
0: Name(
parts: array(
0: static
)
)
)
stmts: array(
)
)
)
-----
<?php interface self {}
-----
Cannot use 'self' as class name as it is reserved from 1:17 to 1:20
array(
0: Stmt_Interface(
name: Identifier(
name: self
)
extends: array(
)
stmts: array(
)
)
)
-----
<?php interface PARENT {}
-----
Cannot use 'PARENT' as class name as it is reserved from 1:17 to 1:22
array(
0: Stmt_Interface(
name: Identifier(
name: PARENT
)
extends: array(
)
stmts: array(
)
)
)
-----
<?php interface static {}
-----
Syntax error, unexpected T_STATIC, expecting T_STRING from 1:17 to 1:22
array(
)
-----
<?php interface A extends self {}
-----
Cannot use 'self' as interface name as it is reserved from 1:27 to 1:30
array(
0: Stmt_Interface(
name: Identifier(
name: A
)
extends: array(
0: Name(
parts: array(
0: self
)
)
)
stmts: array(
)
)
)
-----
<?php interface A extends PARENT {}
-----
Cannot use 'PARENT' as interface name as it is reserved from 1:27 to 1:32
array(
0: Stmt_Interface(
name: Identifier(
name: A
)
extends: array(
0: Name(
parts: array(
0: PARENT
)
)
)
stmts: array(
)
)
)
-----
<?php interface A extends static {}
-----
Cannot use 'static' as interface name as it is reserved from 1:27 to 1:32
array(
0: Stmt_Interface(
name: Identifier(
name: A
)
extends: array(
0: Name(
parts: array(
0: static
)
)
)
stmts: array(
)
)
)

View file

@ -0,0 +1,59 @@
PHP 4 style declarations
-----
<?php
class A {
var $foo;
function bar() {}
static abstract function baz() {}
}
-----
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_Property(
flags: 0
type: null
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: foo
)
default: null
)
)
)
1: Stmt_ClassMethod(
flags: 0
byRef: false
name: Identifier(
name: bar
)
params: array(
)
returnType: null
stmts: array(
)
)
2: Stmt_ClassMethod(
flags: MODIFIER_ABSTRACT | MODIFIER_STATIC (24)
byRef: false
name: Identifier(
name: baz
)
params: array(
)
returnType: null
stmts: array(
)
)
)
)
)

View file

@ -0,0 +1,70 @@
Class declaration
-----
<?php
class A {
public string $a;
protected static D $b;
private ?float $c;
}
-----
!!php7
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_Property(
flags: MODIFIER_PUBLIC (1)
type: Identifier(
name: string
)
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: a
)
default: null
)
)
)
1: Stmt_Property(
flags: MODIFIER_PROTECTED | MODIFIER_STATIC (10)
type: Name(
parts: array(
0: D
)
)
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: b
)
default: null
)
)
)
2: Stmt_Property(
flags: MODIFIER_PRIVATE (4)
type: NullableType(
type: Identifier(
name: float
)
)
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: c
)
default: null
)
)
)
)
)
)

View file

@ -0,0 +1,185 @@
Class declaration
-----
<?php
class A extends B implements C, D {
const A = 'B', C = 'D';
public $a = 'b', $c = 'd';
protected $e;
private $f;
public function a() {}
public static function b($a) {}
public final function c() : B {}
protected function d() {}
private function e() {}
}
-----
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: Name(
parts: array(
0: B
)
)
implements: array(
0: Name(
parts: array(
0: C
)
)
1: Name(
parts: array(
0: D
)
)
)
stmts: array(
0: Stmt_ClassConst(
flags: 0
consts: array(
0: Const(
name: Identifier(
name: A
)
value: Scalar_String(
value: B
)
)
1: Const(
name: Identifier(
name: C
)
value: Scalar_String(
value: D
)
)
)
)
1: Stmt_Property(
flags: MODIFIER_PUBLIC (1)
type: null
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: a
)
default: Scalar_String(
value: b
)
)
1: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: c
)
default: Scalar_String(
value: d
)
)
)
)
2: Stmt_Property(
flags: MODIFIER_PROTECTED (2)
type: null
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: e
)
default: null
)
)
)
3: Stmt_Property(
flags: MODIFIER_PRIVATE (4)
type: null
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: f
)
default: null
)
)
)
4: Stmt_ClassMethod(
flags: MODIFIER_PUBLIC (1)
byRef: false
name: Identifier(
name: a
)
params: array(
)
returnType: null
stmts: array(
)
)
5: Stmt_ClassMethod(
flags: MODIFIER_PUBLIC | MODIFIER_STATIC (9)
byRef: false
name: Identifier(
name: b
)
params: array(
0: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
name: a
)
default: null
)
)
returnType: null
stmts: array(
)
)
6: Stmt_ClassMethod(
flags: MODIFIER_PUBLIC | MODIFIER_FINAL (33)
byRef: false
name: Identifier(
name: c
)
params: array(
)
returnType: Name(
parts: array(
0: B
)
)
stmts: array(
)
)
7: Stmt_ClassMethod(
flags: MODIFIER_PROTECTED (2)
byRef: false
name: Identifier(
name: d
)
params: array(
)
returnType: null
stmts: array(
)
)
8: Stmt_ClassMethod(
flags: MODIFIER_PRIVATE (4)
byRef: false
name: Identifier(
name: e
)
params: array(
)
returnType: null
stmts: array(
)
)
)
)
)

View file

@ -0,0 +1,175 @@
Some special methods cannot be static
-----
<?php class A { static function __construct() {} }
-----
Constructor __construct() cannot be static from 1:17 to 1:22
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassMethod(
flags: MODIFIER_STATIC (8)
byRef: false
name: Identifier(
name: __construct
)
params: array(
)
returnType: null
stmts: array(
)
)
)
)
)
-----
<?php class A { static function __destruct() {} }
-----
Destructor __destruct() cannot be static from 1:17 to 1:22
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassMethod(
flags: MODIFIER_STATIC (8)
byRef: false
name: Identifier(
name: __destruct
)
params: array(
)
returnType: null
stmts: array(
)
)
)
)
)
-----
<?php class A { static function __clone() {} }
-----
Clone method __clone() cannot be static from 1:17 to 1:22
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassMethod(
flags: MODIFIER_STATIC (8)
byRef: false
name: Identifier(
name: __clone
)
params: array(
)
returnType: null
stmts: array(
)
)
)
)
)
-----
<?php class A { static function __CONSTRUCT() {} }
-----
Constructor __CONSTRUCT() cannot be static from 1:17 to 1:22
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassMethod(
flags: MODIFIER_STATIC (8)
byRef: false
name: Identifier(
name: __CONSTRUCT
)
params: array(
)
returnType: null
stmts: array(
)
)
)
)
)
-----
<?php class A { static function __Destruct() {} }
-----
Destructor __Destruct() cannot be static from 1:17 to 1:22
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassMethod(
flags: MODIFIER_STATIC (8)
byRef: false
name: Identifier(
name: __Destruct
)
params: array(
)
returnType: null
stmts: array(
)
)
)
)
)
-----
<?php class A { static function __cLoNe() {} }
-----
Clone method __cLoNe() cannot be static from 1:17 to 1:22
array(
0: Stmt_Class(
flags: 0
name: Identifier(
name: A
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassMethod(
flags: MODIFIER_STATIC (8)
byRef: false
name: Identifier(
name: __cLoNe
)
params: array(
)
returnType: null
stmts: array(
)
)
)
)
)

View file

@ -0,0 +1,188 @@
Traits
-----
<?php
trait A {
public function a() {}
}
class B {
use C;
use D {
a as protected b;
c as d;
e as private;
}
use E, F, G {
E::a insteadof F, G;
E::b as protected c;
E::d as e;
E::f as private;
}
}
-----
array(
0: Stmt_Trait(
name: Identifier(
name: A
)
stmts: array(
0: Stmt_ClassMethod(
flags: MODIFIER_PUBLIC (1)
byRef: false
name: Identifier(
name: a
)
params: array(
)
returnType: null
stmts: array(
)
)
)
)
1: Stmt_Class(
flags: 0
name: Identifier(
name: B
)
extends: null
implements: array(
)
stmts: array(
0: Stmt_TraitUse(
traits: array(
0: Name(
parts: array(
0: C
)
)
)
adaptations: array(
)
)
1: Stmt_TraitUse(
traits: array(
0: Name(
parts: array(
0: D
)
)
)
adaptations: array(
0: Stmt_TraitUseAdaptation_Alias(
trait: null
method: Identifier(
name: a
)
newModifier: MODIFIER_PROTECTED (2)
newName: Identifier(
name: b
)
)
1: Stmt_TraitUseAdaptation_Alias(
trait: null
method: Identifier(
name: c
)
newModifier: null
newName: Identifier(
name: d
)
)
2: Stmt_TraitUseAdaptation_Alias(
trait: null
method: Identifier(
name: e
)
newModifier: MODIFIER_PRIVATE (4)
newName: null
)
)
)
2: Stmt_TraitUse(
traits: array(
0: Name(
parts: array(
0: E
)
)
1: Name(
parts: array(
0: F
)
)
2: Name(
parts: array(
0: G
)
)
)
adaptations: array(
0: Stmt_TraitUseAdaptation_Precedence(
trait: Name(
parts: array(
0: E
)
)
method: Identifier(
name: a
)
insteadof: array(
0: Name(
parts: array(
0: F
)
)
1: Name(
parts: array(
0: G
)
)
)
)
1: Stmt_TraitUseAdaptation_Alias(
trait: Name(
parts: array(
0: E
)
)
method: Identifier(
name: b
)
newModifier: MODIFIER_PROTECTED (2)
newName: Identifier(
name: c
)
)
2: Stmt_TraitUseAdaptation_Alias(
trait: Name(
parts: array(
0: E
)
)
method: Identifier(
name: d
)
newModifier: null
newName: Identifier(
name: e
)
)
3: Stmt_TraitUseAdaptation_Alias(
trait: Name(
parts: array(
0: E
)
)
method: Identifier(
name: f
)
newModifier: MODIFIER_PRIVATE (4)
newName: null
)
)
)
)
)
)

View file

@ -0,0 +1,48 @@
Global constants
-----
<?php
const A = 0, B = 1.0, C = 'A', D = E;
-----
array(
0: Stmt_Const(
consts: array(
0: Const(
name: Identifier(
name: A
)
value: Scalar_LNumber(
value: 0
)
)
1: Const(
name: Identifier(
name: B
)
value: Scalar_DNumber(
value: 1
)
)
2: Const(
name: Identifier(
name: C
)
value: Scalar_String(
value: A
)
)
3: Const(
name: Identifier(
name: D
)
value: Expr_ConstFetch(
name: Name(
parts: array(
0: E
)
)
)
)
)
)
)

View file

@ -0,0 +1,59 @@
Control flow statements
-----
<?php
break;
break 2;
continue;
continue 2;
return;
return $a;
throw $e;
label:
goto label;
-----
array(
0: Stmt_Break(
num: null
)
1: Stmt_Break(
num: Scalar_LNumber(
value: 2
)
)
2: Stmt_Continue(
num: null
)
3: Stmt_Continue(
num: Scalar_LNumber(
value: 2
)
)
4: Stmt_Return(
expr: null
)
5: Stmt_Return(
expr: Expr_Variable(
name: a
)
)
6: Stmt_Throw(
expr: Expr_Variable(
name: e
)
)
7: Stmt_Label(
name: Identifier(
name: label
)
)
8: Stmt_Goto(
name: Identifier(
name: label
)
)
)

View file

@ -0,0 +1,70 @@
Declare
-----
<?php
declare (X='Y');
declare (A='B', C='D') {}
declare (A='B', C='D'):
enddeclare;
-----
array(
0: Stmt_Declare(
declares: array(
0: Stmt_DeclareDeclare(
key: Identifier(
name: X
)
value: Scalar_String(
value: Y
)
)
)
stmts: null
)
1: Stmt_Declare(
declares: array(
0: Stmt_DeclareDeclare(
key: Identifier(
name: A
)
value: Scalar_String(
value: B
)
)
1: Stmt_DeclareDeclare(
key: Identifier(
name: C
)
value: Scalar_String(
value: D
)
)
)
stmts: array(
)
)
2: Stmt_Declare(
declares: array(
0: Stmt_DeclareDeclare(
key: Identifier(
name: A
)
value: Scalar_String(
value: B
)
)
1: Stmt_DeclareDeclare(
key: Identifier(
name: C
)
value: Scalar_String(
value: D
)
)
)
stmts: array(
)
)
)

View file

@ -0,0 +1,32 @@
Echo
-----
<?php
echo 'Hallo World!';
echo 'Hallo', ' ', 'World', '!';
-----
array(
0: Stmt_Echo(
exprs: array(
0: Scalar_String(
value: Hallo World!
)
)
)
1: Stmt_Echo(
exprs: array(
0: Scalar_String(
value: Hallo
)
1: Scalar_String(
value:
)
2: Scalar_String(
value: World
)
3: Scalar_String(
value: !
)
)
)
)

View file

@ -0,0 +1,87 @@
Scalar type declarations
-----
<?php
function test(bool $a, Int $b, FLOAT $c, StRiNg $d, iterable $e, object $f) : void {}
-----
!!php7
array(
0: Stmt_Function(
byRef: false
name: Identifier(
name: test
)
params: array(
0: Param(
type: Identifier(
name: bool
)
byRef: false
variadic: false
var: Expr_Variable(
name: a
)
default: null
)
1: Param(
type: Identifier(
name: int
)
byRef: false
variadic: false
var: Expr_Variable(
name: b
)
default: null
)
2: Param(
type: Identifier(
name: float
)
byRef: false
variadic: false
var: Expr_Variable(
name: c
)
default: null
)
3: Param(
type: Identifier(
name: string
)
byRef: false
variadic: false
var: Expr_Variable(
name: d
)
default: null
)
4: Param(
type: Identifier(
name: iterable
)
byRef: false
variadic: false
var: Expr_Variable(
name: e
)
default: null
)
5: Param(
type: Identifier(
name: object
)
byRef: false
variadic: false
var: Expr_Variable(
name: f
)
default: null
)
)
returnType: Identifier(
name: void
)
stmts: array(
)
)
)

View file

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

View file

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

View file

@ -0,0 +1,170 @@
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
name: Identifier(
name: a
)
params: array(
0: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
name: b
)
default: Expr_ConstFetch(
name: Name(
parts: array(
0: null
)
)
)
)
1: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
name: c
)
default: Scalar_String(
value: foo
)
)
2: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
name: d
)
default: Expr_ClassConstFetch(
class: Name(
parts: array(
0: A
)
)
name: Identifier(
name: B
)
)
)
3: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
name: f
)
default: Expr_UnaryPlus(
expr: Scalar_LNumber(
value: 1
)
)
)
4: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
name: g
)
default: Expr_UnaryMinus(
expr: Scalar_DNumber(
value: 1
)
)
)
5: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
name: h
)
default: Expr_Array(
items: array(
)
)
)
6: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
name: i
)
default: Expr_Array(
items: array(
)
)
)
7: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
name: j
)
default: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_String(
value: foo
)
byRef: false
)
)
)
)
8: Param(
type: null
byRef: false
variadic: false
var: Expr_Variable(
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
)
)
)
)
)
returnType: null
stmts: array(
)
)
)

View file

@ -0,0 +1,55 @@
Nullable types
-----
<?php
function test(?Foo $bar, ?string $foo) : ?Baz {
}
-----
!!php7
array(
0: Stmt_Function(
byRef: false
name: Identifier(
name: test
)
params: array(
0: Param(
type: NullableType(
type: Name(
parts: array(
0: Foo
)
)
)
byRef: false
variadic: false
var: Expr_Variable(
name: bar
)
default: null
)
1: Param(
type: NullableType(
type: Identifier(
name: string
)
)
byRef: false
variadic: false
var: Expr_Variable(
name: foo
)
default: null
)
)
returnType: NullableType(
type: Name(
parts: array(
0: Baz
)
)
)
stmts: array(
)
)
)

Some files were not shown because too many files have changed in this diff Show more