From ee4e55dc759c376a13412a2b1c3cfe05ae7706c0 Mon Sep 17 00:00:00 2001 From: nikic Date: Thu, 22 Sep 2011 20:34:35 +0200 Subject: [PATCH] Move Node_Expr_FuncCallArg to Node_Arg (just like Node_Param) --- README.md | 2 +- grammar/zend_language_parser.phpy | 8 ++++---- .../Node/{Expr/FuncCallArg.php => Arg.php} | 2 +- lib/PHPParser/Node/Expr/FuncCall.php | 4 ++-- lib/PHPParser/Node/Expr/MethodCall.php | 16 ++++++++-------- lib/PHPParser/Node/Expr/New.php | 4 ++-- lib/PHPParser/Node/Expr/StaticCall.php | 4 ++-- lib/PHPParser/Parser.php | 8 ++++---- lib/PHPParser/PrettyPrinter/Zend.php | 8 ++++---- 9 files changed, 28 insertions(+), 28 deletions(-) rename lib/PHPParser/Node/{Expr/FuncCallArg.php => Arg.php} (91%) diff --git a/README.md b/README.md index d33b941..97a3592 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ This script will have an output similar to the following: ) ) args: array( - 0: Expr_FuncCallArg( + 0: Arg( value: Scalar_String( value: Hallo World!!! ) diff --git a/grammar/zend_language_parser.phpy b/grammar/zend_language_parser.phpy index bb6f161..222e783 100644 --- a/grammar/zend_language_parser.phpy +++ b/grammar/zend_language_parser.phpy @@ -351,12 +351,12 @@ function_call_argument_list: ; non_empty_function_call_argument_list: - expr { init(Expr_FuncCallArg[$1, false]); } - | '&' variable { init(Expr_FuncCallArg[$2, true]); } + expr { init(Arg[$1, false]); } + | '&' variable { init(Arg[$2, true]); } | non_empty_function_call_argument_list ',' expr - { push($1, Expr_FuncCallArg[$3, false]); } + { push($1, Arg[$3, false]); } | non_empty_function_call_argument_list ',' '&' variable - { push($1, Expr_FuncCallArg[$4, true]); } + { push($1, Arg[$4, true]); } ; global_var_list: diff --git a/lib/PHPParser/Node/Expr/FuncCallArg.php b/lib/PHPParser/Node/Arg.php similarity index 91% rename from lib/PHPParser/Node/Expr/FuncCallArg.php rename to lib/PHPParser/Node/Arg.php index 1c817ca..a1a3c23 100644 --- a/lib/PHPParser/Node/Expr/FuncCallArg.php +++ b/lib/PHPParser/Node/Arg.php @@ -4,7 +4,7 @@ * @property PHPParser_Node_Expr $value Value to pass * @property bool $byRef Whether to pass by ref */ -class PHPParser_Node_Expr_FuncCallArg extends PHPParser_Node_Expr +class PHPParser_Node_Arg extends PHPParser_NodeAbstract { /** * Constructs a function call argument node. diff --git a/lib/PHPParser/Node/Expr/FuncCall.php b/lib/PHPParser/Node/Expr/FuncCall.php index f8ab109..91e9c2b 100644 --- a/lib/PHPParser/Node/Expr/FuncCall.php +++ b/lib/PHPParser/Node/Expr/FuncCall.php @@ -2,7 +2,7 @@ /** * @property PHPParser_Node_Name|PHPParser_Node_Expr $name Function name - * @property PHPParser_Node_Expr_FuncCallArg[] $args Arguments + * @property PHPParser_Node_Arg[] $args Arguments */ class PHPParser_Node_Expr_FuncCall extends PHPParser_Node_Expr { @@ -10,7 +10,7 @@ class PHPParser_Node_Expr_FuncCall extends PHPParser_Node_Expr * Constructs a function call node. * * @param PHPParser_Node_Name|PHPParser_Node_Expr $name Function name - * @param PHPParser_Node_Expr_FuncCallArg[] $args Arguments + * @param PHPParser_Node_Arg[] $args Arguments * @param int $line Line * @param null|string $docComment Nearest doc comment */ diff --git a/lib/PHPParser/Node/Expr/MethodCall.php b/lib/PHPParser/Node/Expr/MethodCall.php index cdab3d5..6537071 100644 --- a/lib/PHPParser/Node/Expr/MethodCall.php +++ b/lib/PHPParser/Node/Expr/MethodCall.php @@ -1,20 +1,20 @@ yyval = array(new PHPParser_Node_Expr_FuncCallArg($this->yyastk[$this->yysp-(1-1)], false, $line, $docComment)); + $this->yyval = array(new PHPParser_Node_Arg($this->yyastk[$this->yysp-(1-1)], false, $line, $docComment)); } protected function yyn118($line, $docComment) { - $this->yyval = array(new PHPParser_Node_Expr_FuncCallArg($this->yyastk[$this->yysp-(2-2)], true, $line, $docComment)); + $this->yyval = array(new PHPParser_Node_Arg($this->yyastk[$this->yysp-(2-2)], true, $line, $docComment)); } protected function yyn119($line, $docComment) { - $this->yyastk[$this->yysp-(3-1)][] = new PHPParser_Node_Expr_FuncCallArg($this->yyastk[$this->yysp-(3-3)], false, $line, $docComment); $this->yyval = $this->yyastk[$this->yysp-(3-1)]; + $this->yyastk[$this->yysp-(3-1)][] = new PHPParser_Node_Arg($this->yyastk[$this->yysp-(3-3)], false, $line, $docComment); $this->yyval = $this->yyastk[$this->yysp-(3-1)]; } protected function yyn120($line, $docComment) { - $this->yyastk[$this->yysp-(4-1)][] = new PHPParser_Node_Expr_FuncCallArg($this->yyastk[$this->yysp-(4-4)], true, $line, $docComment); $this->yyval = $this->yyastk[$this->yysp-(4-1)]; + $this->yyastk[$this->yysp-(4-1)][] = new PHPParser_Node_Arg($this->yyastk[$this->yysp-(4-4)], true, $line, $docComment); $this->yyval = $this->yyastk[$this->yysp-(4-1)]; } protected function yyn121($line, $docComment) { diff --git a/lib/PHPParser/PrettyPrinter/Zend.php b/lib/PHPParser/PrettyPrinter/Zend.php index 366d655..3653a76 100644 --- a/lib/PHPParser/PrettyPrinter/Zend.php +++ b/lib/PHPParser/PrettyPrinter/Zend.php @@ -16,6 +16,10 @@ class PHPParser_PrettyPrinter_Zend extends PHPParser_PrettyPrinterAbstract . ($node->default ? ' = ' . $this->p($node->default) : ''); } + public function pArg(PHPParser_Node_Arg $node) { + return ($node->byRef ? '&' : '') . $this->p($node->value); + } + // Magic Constants public function pScalar_ClassConst(PHPParser_Node_Scalar_ClassConst $node) { @@ -309,10 +313,6 @@ class PHPParser_PrettyPrinter_Zend extends PHPParser_PrettyPrinterAbstract return $this->p($node->name) . '(' . $this->pCommaSeparated($node->args) . ')'; } - public function pExpr_FuncCallArg(PHPParser_Node_Expr_FuncCallArg $node) { - return ($node->byRef ? '&' : '') . $this->p($node->value); - } - public function pExpr_MethodCall(PHPParser_Node_Expr_MethodCall $node) { return $this->p($node->var) . '->' . $this->pObjectProperty($node->name) . '(' . $this->pCommaSeparated($node->args) . ')';