mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-03-15 03:39:50 +01:00
Add specialized constructors for Expr_Array*, make Variable an Expr
This commit is contained in:
parent
c06cbb53dc
commit
d9a23f2dc7
@ -512,14 +512,14 @@ expr:
|
||||
| T_INT_CAST expr { $$ = Expr_IntCast[expr: $2]; }
|
||||
| T_DOUBLE_CAST expr { $$ = Expr_DoubleCast[expr: $2]; }
|
||||
| T_STRING_CAST expr { $$ = Expr_StringCast[expr: $2]; }
|
||||
| T_ARRAY_CAST expr { $$ = Expr_ArrayCast[expr: $2]; }
|
||||
| T_ARRAY_CAST expr { $$ = Expr_ArrayCast[$2]; }
|
||||
| T_OBJECT_CAST expr { $$ = Expr_ObjectCast[expr: $2]; }
|
||||
| T_BOOL_CAST expr { $$ = Expr_BoolCast[expr: $2]; }
|
||||
| T_UNSET_CAST expr { $$ = Expr_UnsetCast[expr: $2]; }
|
||||
| T_EXIT exit_expr { $$ = Expr_Exit[expr: $2]; }
|
||||
| '@' expr { $$ = Expr_ErrorSuppress[expr: $2]; }
|
||||
| scalar { $$ = $1; }
|
||||
| T_ARRAY '(' array_pair_list ')' { $$ = Expr_Array[items: $3]; }
|
||||
| T_ARRAY '(' array_pair_list ')' { $$ = Expr_Array[$3]; }
|
||||
| '`' backticks_expr '`' { $$ = Expr_ShellExec[parts: $2]; }
|
||||
| T_PRINT expr { $$ = Expr_Print[expr: $2]; }
|
||||
| T_FUNCTION optional_ref '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
|
||||
@ -589,8 +589,8 @@ object_access_for_dcnr:
|
||||
{ $$ = Expr_PropertyFetch[var: $1, name: $3]; }
|
||||
| object_access_for_dcnr T_OBJECT_OPERATOR object_property
|
||||
{ $$ = Expr_PropertyFetch[var: $1, name: $3]; }
|
||||
| object_access_for_dcnr '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[var: $1, dim: $3]; }
|
||||
| object_access_for_dcnr '{' expr '}' { $$ = Expr_ArrayDimFetch[var: $1, dim: $3]; }
|
||||
| object_access_for_dcnr '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[$1, $3]; }
|
||||
| object_access_for_dcnr '{' expr '}' { $$ = Expr_ArrayDimFetch[$1, $3]; }
|
||||
;
|
||||
|
||||
exit_expr:
|
||||
@ -632,7 +632,7 @@ static_scalar: /* compile-time evaluated scalars */
|
||||
| name { $$ = Expr_ConstFetch[name: $1]; }
|
||||
| '+' static_scalar { $$ = Expr_UnaryPlus[expr: $2]; }
|
||||
| '-' static_scalar { $$ = Expr_UnaryMinus[expr: $2]; }
|
||||
| T_ARRAY '(' static_array_pair_list ')' { $$ = Expr_Array[items: $3]; }
|
||||
| T_ARRAY '(' static_array_pair_list ')' { $$ = Expr_Array[$3]; }
|
||||
| class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { $$ = Expr_ClassConstFetch[class: $1, name: $3]; }
|
||||
;
|
||||
|
||||
@ -661,8 +661,8 @@ non_empty_static_array_pair_list:
|
||||
;
|
||||
|
||||
static_array_pair:
|
||||
static_scalar T_DOUBLE_ARROW static_scalar { $$ = Expr_ArrayItem[key: $1, value: $3, byRef: false]; }
|
||||
| static_scalar { $$ = Expr_ArrayItem[key: null, value: $1, byRef: false]; }
|
||||
static_scalar T_DOUBLE_ARROW static_scalar { $$ = Expr_ArrayItem[$1, $3, false]; }
|
||||
| static_scalar { $$ = Expr_ArrayItem[null, $1, false]; }
|
||||
;
|
||||
|
||||
variable:
|
||||
@ -682,8 +682,8 @@ object_access:
|
||||
object_access_arrayable:
|
||||
variable T_OBJECT_OPERATOR object_property
|
||||
{ $$ = Expr_PropertyFetch[var: $1, name: $3]; }
|
||||
| object_access_arrayable '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[var: $1, dim: $3]; }
|
||||
| object_access_arrayable '{' expr '}' { $$ = Expr_ArrayDimFetch[var: $1, dim: $3]; }
|
||||
| object_access_arrayable '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[$1, $3]; }
|
||||
| object_access_arrayable '{' expr '}' { $$ = Expr_ArrayDimFetch[$1, $3]; }
|
||||
;
|
||||
|
||||
variable_without_objects:
|
||||
@ -709,13 +709,13 @@ static_property_with_arrays:
|
||||
{ $$ = Expr_StaticPropertyFetch[class: $1, name: $5]; }
|
||||
| reference_variable T_PAAMAYIM_NEKUDOTAYIM '$' '{' expr '}'
|
||||
{ $$ = Expr_StaticPropertyFetch[class: $1, name: $5]; }
|
||||
| static_property_with_arrays '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[var: $1, dim: $3]; }
|
||||
| static_property_with_arrays '{' expr '}' { $$ = Expr_ArrayDimFetch[var: $1, dim: $3]; }
|
||||
| static_property_with_arrays '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[$1, $3]; }
|
||||
| static_property_with_arrays '{' expr '}' { $$ = Expr_ArrayDimFetch[$1, $3]; }
|
||||
;
|
||||
|
||||
reference_variable:
|
||||
reference_variable '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[var: $1, dim: $3]; }
|
||||
| reference_variable '{' expr '}' { $$ = Expr_ArrayDimFetch[var: $1, dim: $3]; }
|
||||
reference_variable '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[$1, $3]; }
|
||||
| reference_variable '{' expr '}' { $$ = Expr_ArrayDimFetch[$1, $3]; }
|
||||
| T_VARIABLE { $$ = Variable[parseVar($1)]; }
|
||||
| '$' '{' expr '}' { $$ = Variable[$3]; }
|
||||
;
|
||||
@ -753,10 +753,10 @@ non_empty_array_pair_list:
|
||||
;
|
||||
|
||||
array_pair:
|
||||
expr T_DOUBLE_ARROW expr { $$ = Expr_ArrayItem[key: $1, value: $3, byRef: false]; }
|
||||
| expr { $$ = Expr_ArrayItem[key: null, value: $1, byRef: false]; }
|
||||
| expr T_DOUBLE_ARROW '&' variable { $$ = Expr_ArrayItem[key: $1, value: $4, byRef: true]; }
|
||||
| '&' variable { $$ = Expr_ArrayItem[key: null, value: $2, byRef: true]; }
|
||||
expr T_DOUBLE_ARROW expr { $$ = Expr_ArrayItem[$1, $3, false]; }
|
||||
| expr { $$ = Expr_ArrayItem[null, $1, false]; }
|
||||
| expr T_DOUBLE_ARROW '&' variable { $$ = Expr_ArrayItem[$1, $4, true]; }
|
||||
| '&' variable { $$ = Expr_ArrayItem[null, $2, true]; }
|
||||
;
|
||||
|
||||
encaps_list:
|
||||
@ -768,11 +768,11 @@ encaps_list:
|
||||
|
||||
encaps_var:
|
||||
T_VARIABLE { $$ = Variable[parseVar($1)]; }
|
||||
| T_VARIABLE '[' encaps_var_offset ']' { $$ = Expr_ArrayDimFetch[var: Variable[parseVar($1)], dim: $3]; }
|
||||
| T_VARIABLE '[' encaps_var_offset ']' { $$ = Expr_ArrayDimFetch[Variable[parseVar($1)], $3]; }
|
||||
| T_VARIABLE T_OBJECT_OPERATOR T_STRING { $$ = Expr_PropertyFetch[var: Variable[parseVar($1)], name: $3]; }
|
||||
| T_DOLLAR_OPEN_CURLY_BRACES expr '}' { $$ = Variable[$2]; }
|
||||
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'
|
||||
{ $$ = Expr_ArrayDimFetch[var: Variable[$2], dim: $4]; }
|
||||
{ $$ = Expr_ArrayDimFetch[Variable[$2], $4]; }
|
||||
| T_CURLY_OPEN variable '}' { $$ = $2; }
|
||||
;
|
||||
|
||||
|
@ -5,4 +5,19 @@
|
||||
*/
|
||||
class PHPParser_Node_Expr_Array extends PHPParser_Node_Expr
|
||||
{
|
||||
/**
|
||||
* Constructs an array node.
|
||||
*
|
||||
* @param array $items Items of the array
|
||||
* @param int $line Line
|
||||
* @param null|string $docComment Nearest doc comment
|
||||
*/
|
||||
public function __construct(array $items = array(), $line = -1, $docComment = null) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'items' => $items
|
||||
),
|
||||
$line, $docComment
|
||||
);
|
||||
}
|
||||
}
|
@ -5,4 +5,19 @@
|
||||
*/
|
||||
class PHPParser_Node_Expr_ArrayCast extends PHPParser_Node_Expr
|
||||
{
|
||||
/**
|
||||
* Constructs an array cast node.
|
||||
*
|
||||
* @param PHPParser_Node_Expr $expr Expression
|
||||
* @param int $line Line
|
||||
* @param null|string $docComment Nearest doc comment
|
||||
*/
|
||||
public function __construct(PHPParser_Node_Expr $expr, $line = -1, $docComment = null) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr
|
||||
),
|
||||
$line, $docComment
|
||||
);
|
||||
}
|
||||
}
|
@ -1,9 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @property PHPParser_Node_Variable $var Variable
|
||||
* @property PHPParser_Node_Expr $var Variable
|
||||
* @property null|PHPParser_Node_Expr $dim Array index / dim
|
||||
*/
|
||||
class PHPParser_Node_Expr_ArrayDimFetch extends PHPParser_Node_Expr
|
||||
{
|
||||
/**
|
||||
* Constructs an array index fetch node.
|
||||
*
|
||||
* @param PHPParser_Node_Expr $var Variable
|
||||
* @param null|PHPParser_Node_Expr $dim Array index / dim
|
||||
* @param int $line Line
|
||||
* @param null|string $docComment Nearest doc comment
|
||||
*/
|
||||
public function __construct(PHPParser_Node_Expr $var, $dim, $line = -1, $docComment = null) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'var' => $var,
|
||||
'dim' => $dim
|
||||
),
|
||||
$line, $docComment
|
||||
);
|
||||
}
|
||||
}
|
@ -1,10 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @property PHPParser_Node_Expr $key Key
|
||||
* @property PHPParser_Node_Expr $value Value
|
||||
* @property bool $byRef Whether to assign by reference
|
||||
* @property null|PHPParser_Node_Expr $key Key
|
||||
* @property PHPParser_Node_Expr $value Value
|
||||
* @property bool $byRef Whether to assign by reference
|
||||
*/
|
||||
class PHPParser_Node_Expr_ArrayItem extends PHPParser_Node_Expr
|
||||
{
|
||||
/**
|
||||
* Constructs an array item node.
|
||||
*
|
||||
* @param null|PHPParser_Node_Expr $key Key
|
||||
* @param PHPParser_Node_Expr $value Value
|
||||
* @param bool $byRef Whether to assign by reference
|
||||
* @param int $line Line
|
||||
* @param null|string $docComment Nearest doc comment
|
||||
*/
|
||||
public function __construct($key, PHPParser_Node_Expr $value, $byRef = false, $line = -1, $docComment = null) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
'byRef' => $byRef
|
||||
),
|
||||
$line, $docComment
|
||||
);
|
||||
}
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @property string|PHPParser_Node_Variable|PHPParser_Node_Expr $name Name
|
||||
* @property string|PHPParser_Node_Expr $name Name
|
||||
*/
|
||||
class PHPParser_Node_Variable extends PHPParser_NodeAbstract
|
||||
class PHPParser_Node_Variable extends PHPParser_Node_Expr
|
||||
{
|
||||
/**
|
||||
* Constructs a variable node.
|
||||
*
|
||||
* @param string|PHPParser_Node_Variable|PHPParser_Node_Expr $name Name
|
||||
* @param int $line Line
|
||||
* @param null|string $docComment Nearest doc comment
|
||||
* @param string|PHPParser_Node_Expr $name Name
|
||||
* @param int $line Line
|
||||
* @param null|string $docComment Nearest doc comment
|
||||
*/
|
||||
public function __construct($name, $line = -1, $docComment = null) {
|
||||
parent::__construct(
|
||||
|
@ -1875,7 +1875,7 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
private function yyn223($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayCast(array('expr' => $this->yyastk[$this->yysp-(2-2)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayCast($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn224($line, $docComment) {
|
||||
@ -1903,7 +1903,7 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
private function yyn230($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_Array(array('items' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_Array($this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn231($line, $docComment) {
|
||||
@ -2017,11 +2017,11 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
private function yyn255($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn256($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn257($line, $docComment) {
|
||||
@ -2121,7 +2121,7 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
private function yyn281($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_Array(array('items' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_Array($this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn282($line, $docComment) {
|
||||
@ -2177,11 +2177,11 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
private function yyn295($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(array('key' => $this->yyastk[$this->yysp-(3-1)], 'value' => $this->yyastk[$this->yysp-(3-3)], 'byRef' => false), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem($this->yyastk[$this->yysp-(3-1)], $this->yyastk[$this->yysp-(3-3)], false, $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn296($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(array('key' => null, 'value' => $this->yyastk[$this->yysp-(1-1)], 'byRef' => false), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(null, $this->yyastk[$this->yysp-(1-1)], false, $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn297($line, $docComment) {
|
||||
@ -2213,11 +2213,11 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
private function yyn304($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn305($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn306($line, $docComment) {
|
||||
@ -2261,19 +2261,19 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
private function yyn316($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn317($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn318($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn319($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn320($line, $docComment) {
|
||||
@ -2341,19 +2341,19 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
private function yyn336($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(array('key' => $this->yyastk[$this->yysp-(3-1)], 'value' => $this->yyastk[$this->yysp-(3-3)], 'byRef' => false), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem($this->yyastk[$this->yysp-(3-1)], $this->yyastk[$this->yysp-(3-3)], false, $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn337($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(array('key' => null, 'value' => $this->yyastk[$this->yysp-(1-1)], 'byRef' => false), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(null, $this->yyastk[$this->yysp-(1-1)], false, $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn338($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(array('key' => $this->yyastk[$this->yysp-(4-1)], 'value' => $this->yyastk[$this->yysp-(4-4)], 'byRef' => true), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-4)], true, $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn339($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(array('key' => null, 'value' => $this->yyastk[$this->yysp-(2-2)], 'byRef' => true), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(null, $this->yyastk[$this->yysp-(2-2)], true, $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn340($line, $docComment) {
|
||||
@ -2377,7 +2377,7 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
private function yyn345($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => new PHPParser_Node_Variable(substr($this->yyastk[$this->yysp-(4-1)], 1), $line, $docComment), 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(new PHPParser_Node_Variable(substr($this->yyastk[$this->yysp-(4-1)], 1), $line, $docComment), $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn346($line, $docComment) {
|
||||
@ -2389,7 +2389,7 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
private function yyn348($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => new PHPParser_Node_Variable($this->yyastk[$this->yysp-(6-2)], $line, $docComment), 'dim' => $this->yyastk[$this->yysp-(6-4)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(new PHPParser_Node_Variable($this->yyastk[$this->yysp-(6-2)], $line, $docComment), $this->yyastk[$this->yysp-(6-4)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn349($line, $docComment) {
|
||||
|
@ -2272,7 +2272,7 @@ class PHPParser_ParserDebug
|
||||
}
|
||||
|
||||
private function yyn223($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayCast(array('expr' => $this->yyastk[$this->yysp-(2-2)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayCast($this->yyastk[$this->yysp-(2-2)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn224($line, $docComment) {
|
||||
@ -2300,7 +2300,7 @@ class PHPParser_ParserDebug
|
||||
}
|
||||
|
||||
private function yyn230($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_Array(array('items' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_Array($this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn231($line, $docComment) {
|
||||
@ -2414,11 +2414,11 @@ class PHPParser_ParserDebug
|
||||
}
|
||||
|
||||
private function yyn255($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn256($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn257($line, $docComment) {
|
||||
@ -2518,7 +2518,7 @@ class PHPParser_ParserDebug
|
||||
}
|
||||
|
||||
private function yyn281($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_Array(array('items' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_Array($this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn282($line, $docComment) {
|
||||
@ -2574,11 +2574,11 @@ class PHPParser_ParserDebug
|
||||
}
|
||||
|
||||
private function yyn295($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(array('key' => $this->yyastk[$this->yysp-(3-1)], 'value' => $this->yyastk[$this->yysp-(3-3)], 'byRef' => false), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem($this->yyastk[$this->yysp-(3-1)], $this->yyastk[$this->yysp-(3-3)], false, $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn296($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(array('key' => null, 'value' => $this->yyastk[$this->yysp-(1-1)], 'byRef' => false), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(null, $this->yyastk[$this->yysp-(1-1)], false, $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn297($line, $docComment) {
|
||||
@ -2610,11 +2610,11 @@ class PHPParser_ParserDebug
|
||||
}
|
||||
|
||||
private function yyn304($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn305($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn306($line, $docComment) {
|
||||
@ -2658,19 +2658,19 @@ class PHPParser_ParserDebug
|
||||
}
|
||||
|
||||
private function yyn316($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn317($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn318($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn319($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => $this->yyastk[$this->yysp-(4-1)], 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn320($line, $docComment) {
|
||||
@ -2738,19 +2738,19 @@ class PHPParser_ParserDebug
|
||||
}
|
||||
|
||||
private function yyn336($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(array('key' => $this->yyastk[$this->yysp-(3-1)], 'value' => $this->yyastk[$this->yysp-(3-3)], 'byRef' => false), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem($this->yyastk[$this->yysp-(3-1)], $this->yyastk[$this->yysp-(3-3)], false, $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn337($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(array('key' => null, 'value' => $this->yyastk[$this->yysp-(1-1)], 'byRef' => false), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(null, $this->yyastk[$this->yysp-(1-1)], false, $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn338($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(array('key' => $this->yyastk[$this->yysp-(4-1)], 'value' => $this->yyastk[$this->yysp-(4-4)], 'byRef' => true), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem($this->yyastk[$this->yysp-(4-1)], $this->yyastk[$this->yysp-(4-4)], true, $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn339($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(array('key' => null, 'value' => $this->yyastk[$this->yysp-(2-2)], 'byRef' => true), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayItem(null, $this->yyastk[$this->yysp-(2-2)], true, $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn340($line, $docComment) {
|
||||
@ -2774,7 +2774,7 @@ class PHPParser_ParserDebug
|
||||
}
|
||||
|
||||
private function yyn345($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => new PHPParser_Node_Variable(substr($this->yyastk[$this->yysp-(4-1)], 1), $line, $docComment), 'dim' => $this->yyastk[$this->yysp-(4-3)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(new PHPParser_Node_Variable(substr($this->yyastk[$this->yysp-(4-1)], 1), $line, $docComment), $this->yyastk[$this->yysp-(4-3)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn346($line, $docComment) {
|
||||
@ -2786,7 +2786,7 @@ class PHPParser_ParserDebug
|
||||
}
|
||||
|
||||
private function yyn348($line, $docComment) {
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(array('var' => new PHPParser_Node_Variable($this->yyastk[$this->yysp-(6-2)], $line, $docComment), 'dim' => $this->yyastk[$this->yysp-(6-4)]), $line, $docComment);
|
||||
$this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(new PHPParser_Node_Variable($this->yyastk[$this->yysp-(6-2)], $line, $docComment), $this->yyastk[$this->yysp-(6-4)], $line, $docComment);
|
||||
}
|
||||
|
||||
private function yyn349($line, $docComment) {
|
||||
|
@ -10,10 +10,10 @@ class PHPParser_PrettyPrinter_Zend extends PHPParser_PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
public function pVariable(PHPParser_Node_Variable $node) {
|
||||
if ($node->name instanceof PHPParser_Node_Expr) {
|
||||
return '${' . $this->p($node->name) . '}';
|
||||
} elseif ($node->name instanceof PHPParser_Node_Variable) {
|
||||
if ($node->name instanceof PHPParser_Node_Variable) {
|
||||
return '$' . $this->p($node->name);
|
||||
} elseif ($node->name instanceof PHPParser_Node_Expr) {
|
||||
return '${' . $this->p($node->name) . '}';
|
||||
} else {
|
||||
return '$' . $node->name;
|
||||
}
|
||||
@ -619,7 +619,7 @@ class PHPParser_PrettyPrinter_Zend extends PHPParser_PrettyPrinterAbstract
|
||||
// Helpers
|
||||
|
||||
public function pObjectProperty($node) {
|
||||
if ($node instanceof PHPParser_Node_Variable || $node instanceof PHPParser_Node_Expr) {
|
||||
if ($node instanceof PHPParser_Node_Expr) {
|
||||
return '{' . $this->p($node) . '}';
|
||||
} else {
|
||||
return $node;
|
||||
|
@ -37,14 +37,16 @@ class PHPParser_Tests_NodeDumperTest extends PHPUnit_Framework_TestCase
|
||||
)'
|
||||
),
|
||||
array(
|
||||
new PHPParser_Node_Expr_Array(array('items' => array(
|
||||
new PHPParser_Node_Expr_ArrayItem(array('key' => 'Foo', 'value' => 'Bar', 'byRef' => false))
|
||||
))),
|
||||
new PHPParser_Node_Expr_Array(array(
|
||||
new PHPParser_Node_Expr_ArrayItem(null, new PHPParser_Node_Scalar_String('Foo'))
|
||||
)),
|
||||
'Expr_Array(
|
||||
items: array(
|
||||
0: Expr_ArrayItem(
|
||||
key: Foo
|
||||
value: Bar
|
||||
key: null
|
||||
value: Scalar_String(
|
||||
value: Foo
|
||||
)
|
||||
byRef: false
|
||||
)
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user