php-parser/test/code/parser/consistentVarMode.test
Nikita Popov a947e731c3 Add useConsistentVariableNodes mode
The parameter case is a bit weird, because the subnode is called
"name" here, rather than "var". Nothing we can do about that in
this version though.

The two parser options might be merged. I've kept it separate,
because I think this variable representation should become the
default (or even only representation) in the future, while I'm
less sure about the Identifier thing.
2016-12-23 00:10:59 +01:00

106 lines
2.4 KiB
Plaintext

Consistent variable mode
-----
<?php
function test($param1, $param2 = 0) {
static $foo, $bar = 0;
}
function() use ($foo, &$bar) {};
try {} catch (Exception $var) {}
-----
!!consistentVars
array(
0: Stmt_Function(
byRef: false
name: test
params: array(
0: Param(
type: null
byRef: false
variadic: false
name: Expr_Variable(
name: param1
)
default: null
)
1: Param(
type: null
byRef: false
variadic: false
name: Expr_Variable(
name: param2
)
default: Scalar_LNumber(
value: 0
)
)
)
returnType: null
stmts: array(
0: Stmt_Static(
vars: array(
0: Stmt_StaticVar(
name: Expr_Variable(
name: foo
)
default: null
)
1: Stmt_StaticVar(
name: Expr_Variable(
name: bar
)
default: Scalar_LNumber(
value: 0
)
)
)
)
)
)
1: Expr_Closure(
static: false
byRef: false
params: array(
)
uses: array(
0: Expr_ClosureUse(
var: Expr_Variable(
name: foo
)
byRef: false
)
1: Expr_ClosureUse(
var: Expr_Variable(
name: bar
)
byRef: true
)
)
returnType: null
stmts: array(
)
)
2: Stmt_TryCatch(
stmts: array(
)
catches: array(
0: Stmt_Catch(
types: array(
0: Name(
parts: array(
0: Exception
)
)
)
var: Expr_Variable(
name: var
)
stmts: array(
)
)
)
finally: null
)
)