the whole shebang

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,29 @@
Invalid modifier combination
-----
<?php class A { public public $a; }
-----
Multiple access type modifiers are not allowed on line 1
-----
<?php class A { public protected $a; }
-----
Multiple access type modifiers are not allowed on line 1
-----
<?php class A { abstract abstract a(); }
-----
Multiple abstract modifiers are not allowed on line 1
-----
<?php class A { static static $a; }
-----
Multiple static modifiers are not allowed on line 1
-----
<?php class A { final final a() {} }
-----
Multiple final modifiers are not allowed on line 1
-----
<?php class A { abstract final a(); }
-----
Cannot use the final and abstract modifier at the same time on line 1
-----
<?php abstract final class A { }
-----
Syntax error, unexpected T_FINAL, expecting T_CLASS on line 1

View File

@@ -0,0 +1,61 @@
Invalid class name
-----
<?php class self {}
-----
Cannot use "self" as class name as it is reserved on line 1
-----
<?php class parent {}
-----
Cannot use "parent" as class name as it is reserved on line 1
-----
<?php class static {}
-----
Syntax error, unexpected T_STATIC, expecting T_STRING on line 1
-----
<?php class A extends self {}
-----
Cannot use "self" as class name as it is reserved on line 1
-----
<?php class A extends parent {}
-----
Cannot use "parent" as class name as it is reserved on line 1
-----
<?php class A extends static {}
-----
Syntax error, unexpected T_STATIC, expecting T_STRING or T_NAMESPACE or T_NS_SEPARATOR on line 1
-----
<?php class A implements self {}
-----
Cannot use "self" as interface name as it is reserved on line 1
-----
<?php class A implements parent {}
-----
Cannot use "parent" as interface name as it is reserved on line 1
-----
<?php class A implements static {}
-----
Syntax error, unexpected T_STATIC, expecting T_STRING or T_NAMESPACE or T_NS_SEPARATOR on line 1
-----
<?php interface self {}
-----
Cannot use "self" as interface name as it is reserved on line 1
-----
<?php interface parent {}
-----
Cannot use "parent" as interface name as it is reserved on line 1
-----
<?php interface static {}
-----
Syntax error, unexpected T_STATIC, expecting T_STRING on line 1
-----
<?php interface A extends self {}
-----
Cannot use "self" as interface name as it is reserved on line 1
-----
<?php interface A extends parent {}
-----
Cannot use "parent" as interface name as it is reserved on line 1
-----
<?php interface A extends static {}
-----
Syntax error, unexpected T_STATIC, expecting T_STRING or T_NAMESPACE or T_NS_SEPARATOR on line 1

View File

@@ -0,0 +1,38 @@
PHP 4 style declarations
-----
<?php
class A {
var $foo;
function bar() {}
}
-----
array(
0: Stmt_Class(
type: 0
extends: null
implements: array(
)
stmts: array(
0: Stmt_Property(
type: 1
props: array(
0: Stmt_PropertyProperty(
name: foo
default: null
)
)
)
1: Stmt_ClassMethod(
type: 1
byRef: false
params: array(
)
stmts: array(
)
name: bar
)
)
name: A
)
)

View File

@@ -0,0 +1,139 @@
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() {}
public final function c() {}
protected function d() {}
private function e() {}
}
-----
array(
0: Stmt_Class(
type: 0
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(
consts: array(
0: Const(
name: A
value: Scalar_String(
value: B
)
)
1: Const(
name: C
value: Scalar_String(
value: D
)
)
)
)
1: Stmt_Property(
type: 1
props: array(
0: Stmt_PropertyProperty(
name: a
default: Scalar_String(
value: b
)
)
1: Stmt_PropertyProperty(
name: c
default: Scalar_String(
value: d
)
)
)
)
2: Stmt_Property(
type: 2
props: array(
0: Stmt_PropertyProperty(
name: e
default: null
)
)
)
3: Stmt_Property(
type: 4
props: array(
0: Stmt_PropertyProperty(
name: f
default: null
)
)
)
4: Stmt_ClassMethod(
type: 1
byRef: false
params: array(
)
stmts: array(
)
name: a
)
5: Stmt_ClassMethod(
type: 9
byRef: false
params: array(
)
stmts: array(
)
name: b
)
6: Stmt_ClassMethod(
type: 33
byRef: false
params: array(
)
stmts: array(
)
name: c
)
7: Stmt_ClassMethod(
type: 2
byRef: false
params: array(
)
stmts: array(
)
name: d
)
8: Stmt_ClassMethod(
type: 4
byRef: false
params: array(
)
stmts: array(
)
name: e
)
)
name: A
)
)

View File

@@ -0,0 +1,13 @@
Some special methods cannot be static
-----
<?php class A { static function __construct() {} }
-----
"__construct" method cannot be static on line 1
-----
<?php class A { static function __destruct() {} }
-----
"__destruct" method cannot be static on line 1
-----
<?php class A { static function __clone() {} }
-----
"__clone" method cannot be static on line 1

View File

@@ -0,0 +1,159 @@
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: A
stmts: array(
0: Stmt_ClassMethod(
type: 1
byRef: false
params: array(
)
stmts: array(
)
name: a
)
)
)
1: Stmt_Class(
type: 0
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: a
newModifier: 2
newName: b
)
1: Stmt_TraitUseAdaptation_Alias(
trait: null
method: c
newModifier: null
newName: d
)
2: Stmt_TraitUseAdaptation_Alias(
trait: null
method: e
newModifier: 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: 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: b
newModifier: 2
newName: c
)
2: Stmt_TraitUseAdaptation_Alias(
trait: Name(
parts: array(
0: E
)
)
method: d
newModifier: null
newName: e
)
3: Stmt_TraitUseAdaptation_Alias(
trait: Name(
parts: array(
0: E
)
)
method: f
newModifier: 4
newName: null
)
)
)
)
name: B
)
)