mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-12-11 17:09:41 +01:00
287 lines
5.9 KiB
Plaintext
287 lines
5.9 KiB
Plaintext
Identifier node mode
|
|
-----
|
|
<?php
|
|
|
|
use Foo as Bar;
|
|
|
|
class Foo {
|
|
const BAR = 1;
|
|
function foo() {}
|
|
|
|
use A, B {
|
|
A::b as c;
|
|
d as public e;
|
|
}
|
|
}
|
|
interface Bar {}
|
|
trait Baz {}
|
|
|
|
function foo(array $x) : callable {}
|
|
|
|
const FOO = 1;
|
|
|
|
declare(foo=1);
|
|
|
|
foo:
|
|
goto foo;
|
|
|
|
Foo::BAR;
|
|
$foo->bar;
|
|
$foo->bar();
|
|
Foo::bar();
|
|
"$foo->bar";
|
|
$foo;
|
|
-----
|
|
!!ident
|
|
array(
|
|
0: Stmt_Use(
|
|
type: TYPE_NORMAL (1)
|
|
uses: array(
|
|
0: Stmt_UseUse(
|
|
type: TYPE_UNKNOWN (0)
|
|
name: Name(
|
|
parts: array(
|
|
0: Foo
|
|
)
|
|
)
|
|
alias: Identifier(
|
|
name: Bar
|
|
)
|
|
)
|
|
)
|
|
)
|
|
1: 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: BAR
|
|
)
|
|
value: Scalar_LNumber(
|
|
value: 1
|
|
)
|
|
)
|
|
)
|
|
)
|
|
1: Stmt_ClassMethod(
|
|
flags: 0
|
|
byRef: false
|
|
name: Identifier(
|
|
name: foo
|
|
)
|
|
params: array(
|
|
)
|
|
returnType: null
|
|
stmts: array(
|
|
)
|
|
)
|
|
2: Stmt_TraitUse(
|
|
traits: array(
|
|
0: Name(
|
|
parts: array(
|
|
0: A
|
|
)
|
|
)
|
|
1: Name(
|
|
parts: array(
|
|
0: B
|
|
)
|
|
)
|
|
)
|
|
adaptations: array(
|
|
0: Stmt_TraitUseAdaptation_Alias(
|
|
trait: Name(
|
|
parts: array(
|
|
0: A
|
|
)
|
|
)
|
|
method: Identifier(
|
|
name: b
|
|
)
|
|
newModifier: null
|
|
newName: Identifier(
|
|
name: c
|
|
)
|
|
)
|
|
1: Stmt_TraitUseAdaptation_Alias(
|
|
trait: null
|
|
method: Identifier(
|
|
name: d
|
|
)
|
|
newModifier: MODIFIER_PUBLIC (1)
|
|
newName: Identifier(
|
|
name: e
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
2: Stmt_Interface(
|
|
name: Identifier(
|
|
name: Bar
|
|
)
|
|
extends: array(
|
|
)
|
|
stmts: array(
|
|
)
|
|
)
|
|
3: Stmt_Trait(
|
|
name: Identifier(
|
|
name: Baz
|
|
)
|
|
stmts: array(
|
|
)
|
|
)
|
|
4: Stmt_Function(
|
|
byRef: false
|
|
name: Identifier(
|
|
name: foo
|
|
)
|
|
params: array(
|
|
0: Param(
|
|
type: Identifier(
|
|
name: array
|
|
)
|
|
byRef: false
|
|
variadic: false
|
|
name: x
|
|
default: null
|
|
)
|
|
)
|
|
returnType: Identifier(
|
|
name: callable
|
|
)
|
|
stmts: array(
|
|
)
|
|
)
|
|
5: Stmt_Const(
|
|
consts: array(
|
|
0: Const(
|
|
name: Identifier(
|
|
name: FOO
|
|
)
|
|
value: Scalar_LNumber(
|
|
value: 1
|
|
)
|
|
)
|
|
)
|
|
)
|
|
6: Stmt_Declare(
|
|
declares: array(
|
|
0: Stmt_DeclareDeclare(
|
|
key: Identifier(
|
|
name: foo
|
|
)
|
|
value: Scalar_LNumber(
|
|
value: 1
|
|
)
|
|
)
|
|
)
|
|
stmts: null
|
|
)
|
|
7: Stmt_Label(
|
|
name: Identifier(
|
|
name: foo
|
|
)
|
|
)
|
|
8: Stmt_Goto(
|
|
name: Identifier(
|
|
name: foo
|
|
)
|
|
)
|
|
9: Expr_ClassConstFetch(
|
|
class: Name(
|
|
parts: array(
|
|
0: Foo
|
|
)
|
|
)
|
|
name: Identifier(
|
|
name: BAR
|
|
)
|
|
)
|
|
10: Expr_PropertyFetch(
|
|
var: Expr_Variable(
|
|
name: foo
|
|
)
|
|
name: Identifier(
|
|
name: bar
|
|
)
|
|
)
|
|
11: Expr_MethodCall(
|
|
var: Expr_Variable(
|
|
name: foo
|
|
)
|
|
name: Identifier(
|
|
name: bar
|
|
)
|
|
args: array(
|
|
)
|
|
)
|
|
12: Expr_StaticCall(
|
|
class: Name(
|
|
parts: array(
|
|
0: Foo
|
|
)
|
|
)
|
|
name: Identifier(
|
|
name: bar
|
|
)
|
|
args: array(
|
|
)
|
|
)
|
|
13: Scalar_Encapsed(
|
|
parts: array(
|
|
0: Expr_PropertyFetch(
|
|
var: Expr_Variable(
|
|
name: foo
|
|
)
|
|
name: Identifier(
|
|
name: bar
|
|
)
|
|
)
|
|
)
|
|
)
|
|
14: Expr_Variable(
|
|
name: foo
|
|
)
|
|
)
|
|
-----
|
|
<?php
|
|
|
|
function foo(int $bar) : bool {}
|
|
-----
|
|
!!php7,ident
|
|
array(
|
|
0: Stmt_Function(
|
|
byRef: false
|
|
name: Identifier(
|
|
name: foo
|
|
)
|
|
params: array(
|
|
0: Param(
|
|
type: Identifier(
|
|
name: int
|
|
)
|
|
byRef: false
|
|
variadic: false
|
|
name: bar
|
|
default: null
|
|
)
|
|
)
|
|
returnType: Identifier(
|
|
name: bool
|
|
)
|
|
stmts: array(
|
|
)
|
|
)
|
|
) |