mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-27 04:24:43 +01:00
Fix parsing of static methods with dynamic method name
This commit is contained in:
parent
fabe44ecb1
commit
1c4d47613c
@ -152,7 +152,5 @@ For the code mentioned in the above section this should create the output:
|
||||
Known Issues
|
||||
============
|
||||
|
||||
* Parsing expressions of type `a::$b[c]()` (I.e. the method name is specifed by an array)
|
||||
currently does not work (causes 1 parse fail in test against Symfony Beta 3).
|
||||
* When pretty printing strings and InlineHTML those are indented like any other code, thus causing
|
||||
extra whitespace to be inserted (causes 23 compare fails in test against Symfony Beta 3).
|
29575
grammar/y.output
29575
grammar/y.output
File diff suppressed because it is too large
Load Diff
@ -544,12 +544,23 @@ function_call:
|
||||
name '(' function_call_argument_list ')' { $$ = new Node_Expr_FuncCall(array('func' => $1, 'args' => $3)); }
|
||||
| class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' function_call_argument_list ')'
|
||||
{ $$ = new Node_Expr_StaticCall(array('class' => $1, 'func' => $3, 'args' => $5)); }
|
||||
| class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' function_call_argument_list ')'
|
||||
{ $$ = new Node_Expr_StaticCall(array('class' => $1, 'func' => $3, 'args' => $5)); }
|
||||
| reference_variable T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' function_call_argument_list ')'
|
||||
{ $$ = new Node_Expr_StaticCall(array('class' => $1, 'func' => $3, 'args' => $5)); }
|
||||
| reference_variable T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' function_call_argument_list ')'
|
||||
{ $$ = new Node_Expr_StaticCall(array('class' => $1, 'func' => $3, 'args' => $5)); }
|
||||
| static_property_with_arrays '(' function_call_argument_list ')' {
|
||||
if ($1 instanceof Node_Expr_StaticPropertyFetch) {
|
||||
$$ = new Node_Expr_StaticCall(array('class' => $1->class, 'func' => $1->name, 'args' => $3));
|
||||
} elseif ($1 instanceof Node_Expr_ArrayDimFetch) {
|
||||
$2 = $1; // $2 is just a temporary variable. Nothing to do with the '('
|
||||
while ($2->var instanceof Node_Expr_ArrayDimFetch) {
|
||||
$2 = $2->var;
|
||||
}
|
||||
|
||||
$$ = new Node_Expr_StaticCall(array('class' => $2->var->class, 'func' => $1, 'args' => $3));
|
||||
$2->var = new Node_Variable(array('name' => $2->var->name));
|
||||
} else {
|
||||
throw new Exception;
|
||||
}
|
||||
}
|
||||
| variable_without_objects '(' function_call_argument_list ')'
|
||||
{ $$ = new Node_Expr_FuncCall(array('func' => $1, 'args' => $3)); }
|
||||
;
|
||||
|
@ -544,12 +544,23 @@ function_call:
|
||||
name '(' function_call_argument_list ')' { $$ = Expr_FuncCall[func: $1, args: $3]; }
|
||||
| class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' function_call_argument_list ')'
|
||||
{ $$ = Expr_StaticCall[class: $1, func: $3, args: $5]; }
|
||||
| class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' function_call_argument_list ')'
|
||||
{ $$ = Expr_StaticCall[class: $1, func: $3, args: $5]; }
|
||||
| reference_variable T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' function_call_argument_list ')'
|
||||
{ $$ = Expr_StaticCall[class: $1, func: $3, args: $5]; }
|
||||
| reference_variable T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' function_call_argument_list ')'
|
||||
{ $$ = Expr_StaticCall[class: $1, func: $3, args: $5]; }
|
||||
| static_property_with_arrays '(' function_call_argument_list ')' {
|
||||
if ($1 instanceof Node_Expr_StaticPropertyFetch) {
|
||||
$$ = Expr_StaticCall[class: $1->class, func: $1->name, args: $3];
|
||||
} elseif ($1 instanceof Node_Expr_ArrayDimFetch) {
|
||||
$2 = $1; // $2 is just a temporary variable. Nothing to do with the '('
|
||||
while ($2->var instanceof Node_Expr_ArrayDimFetch) {
|
||||
$2 = $2->var;
|
||||
}
|
||||
|
||||
$$ = Expr_StaticCall[class: $2->var->class, func: $1, args: $3];
|
||||
$2->var = Variable[name: $2->var->name];
|
||||
} else {
|
||||
throw new Exception;
|
||||
}
|
||||
}
|
||||
| variable_without_objects '(' function_call_argument_list ')'
|
||||
{ $$ = Expr_FuncCall[func: $1, args: $3]; }
|
||||
;
|
||||
|
@ -30,6 +30,16 @@ abstract class NodeAbstract implements IteratorAggregate
|
||||
return $this->subNodes[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a sub node.
|
||||
*
|
||||
* @param string $name Name of sub node
|
||||
* @param mixed $value Value to set sub node to
|
||||
*/
|
||||
public function __set($name, $value) {
|
||||
$this->subNodes[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a subnode exists.
|
||||
*
|
||||
|
996
lib/Parser.php
996
lib/Parser.php
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user