[5.4] Add support for ClassName::{expr}

This commit is contained in:
nikic 2011-10-21 14:09:41 +02:00
parent 73cc546140
commit 7806bf025e
4 changed files with 557 additions and 546 deletions

View File

@ -541,6 +541,8 @@ function_call:
name '(' function_call_argument_list ')' { $$ = Expr_FuncCall[$1, $3]; }
| class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' function_call_argument_list ')'
{ $$ = Expr_StaticCall[$1, $3, $5]; }
| class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '{' expr '}' '(' function_call_argument_list ')'
{ $$ = Expr_StaticCall[$1, $4, $7]; }
| static_property '(' function_call_argument_list ')' {
if ($1 instanceof PHPParser_Node_Expr_StaticPropertyFetch) {
$$ = Expr_StaticCall[$1->class, Expr_Variable[$1->name], $3];

File diff suppressed because it is too large Load Diff

View File

@ -247,6 +247,7 @@ class PHPParser_Parser_Debug extends PHPParser_Parser
"lexical_var_list : optional_ref T_VARIABLE",
"function_call : name '(' function_call_argument_list ')'",
"function_call : class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' function_call_argument_list ')'",
"function_call : class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '{' expr '}' '(' function_call_argument_list ')'",
"function_call : static_property '(' function_call_argument_list ')'",
"function_call : variable_without_objects '(' function_call_argument_list ')'",
"class_name : T_STATIC",

View File

@ -325,7 +325,12 @@ class PHPParser_PrettyPrinter_Zend extends PHPParser_PrettyPrinterAbstract
public function pExpr_StaticCall(PHPParser_Node_Expr_StaticCall $node) {
return $this->p($node->class) . '::'
. ($node->name instanceof PHPParser_Node_Expr ? $this->p($node->name) : $node->name)
. ($node->name instanceof PHPParser_Node_Expr
? ($node->name instanceof PHPParser_Node_Expr_Variable
|| $node->name instanceof PHPParser_Node_Expr_ArrayDimFetch
? $this->p($node->name)
: '{' . $this->p($node->name) . '}')
: $node->name)
. '(' . $this->pCommaSeparated($node->args) . ')';
}