1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-04 18:28:25 +01:00
PHP-Parser/test/code/parser/expr/fetchAndCall/objectAccess.test
Nikita Popov a6846e3b71 Always use Identifier nodes
The parser will now always generate Identifier nodes (for
non-namespaced identifiers). This obsoletes the useIdentifierNodes
parser option.

Node constructors still accepts strings and will implicitly create
an Identifier wrapper. Identifier implement __toString(), so that
outside of strict-mode many things continue to work without changes.
2017-04-28 20:57:32 +02:00

184 lines
4.1 KiB
Plaintext

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?
)
)
)