1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-11 17:09:41 +01:00
PHP-Parser/test/code/parser/identMode.test
Nikita Popov d7f3c4f9d3 Renamve Param::$name to Param::$var
As it now contains a Variable node.
2017-01-19 23:39:15 +01:00

351 lines
7.6 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;
}
public $foo, $bar = 42;
}
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;
Foo::$bar;
Foo::$$bar;
-----
!!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
)
)
)
)
3: Stmt_Property(
flags: MODIFIER_PUBLIC (1)
props: array(
0: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: foo
)
default: null
)
1: Stmt_PropertyProperty(
name: VarLikeIdentifier(
name: bar
)
default: Scalar_LNumber(
value: 42
)
)
)
)
)
)
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
var: Expr_Variable(
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: Stmt_Expression(
expr: Expr_ClassConstFetch(
class: Name(
parts: array(
0: Foo
)
)
name: Identifier(
name: BAR
)
)
)
10: Stmt_Expression(
expr: Expr_PropertyFetch(
var: Expr_Variable(
name: foo
)
name: Identifier(
name: bar
)
)
)
11: Stmt_Expression(
expr: Expr_MethodCall(
var: Expr_Variable(
name: foo
)
name: Identifier(
name: bar
)
args: array(
)
)
)
12: Stmt_Expression(
expr: Expr_StaticCall(
class: Name(
parts: array(
0: Foo
)
)
name: Identifier(
name: bar
)
args: array(
)
)
)
13: Stmt_Expression(
expr: Scalar_Encapsed(
parts: array(
0: Expr_PropertyFetch(
var: Expr_Variable(
name: foo
)
name: Identifier(
name: bar
)
)
)
)
)
14: Stmt_Expression(
expr: Expr_Variable(
name: foo
)
)
15: Stmt_Expression(
expr: Expr_StaticPropertyFetch(
class: Name(
parts: array(
0: Foo
)
)
name: VarLikeIdentifier(
name: bar
)
)
)
16: Stmt_Expression(
expr: Expr_StaticPropertyFetch(
class: Name(
parts: array(
0: Foo
)
)
name: Expr_Variable(
name: bar
)
)
)
)
-----
<?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
var: Expr_Variable(
name: bar
)
default: null
)
)
returnType: Identifier(
name: bool
)
stmts: array(
)
)
)