diff --git a/CHANGELOG.md b/CHANGELOG.md index 05d817b..72d585e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,8 @@ Version 4.12.1-dev * [PHP 8.1] Added support for intersection types using a new `IntersectionType` node. * [PHP 8.1] Added support for explicit octal literals. * [PHP 8.1] Added support for first-class callables. These are represented using a call whose first - `Arg->expr` is an `Expr\VariadicPlaceholder`. The representation is intended to be - forward-compatible with partial function application, just like the PHP feature itself. + argument is a `VariadicPlaceholder`. The representation is intended to be forward-compatible with + partial function application, just like the PHP feature itself. Version 4.12.0 (2021-07-21) --------------------------- diff --git a/grammar/php7.y b/grammar/php7.y index 1bae055..ef0f271 100644 --- a/grammar/php7.y +++ b/grammar/php7.y @@ -623,8 +623,7 @@ argument_list: ; variadic_placeholder: - T_ELLIPSIS - { $$ = Node\Arg[Node\VariadicPlaceholder[], false, false]; } + T_ELLIPSIS { $$ = Node\VariadicPlaceholder[]; } ; non_empty_argument_list: diff --git a/lib/PhpParser/Node/Arg.php b/lib/PhpParser/Node/Arg.php index e70a20e..bcf130e 100644 --- a/lib/PhpParser/Node/Arg.php +++ b/lib/PhpParser/Node/Arg.php @@ -2,7 +2,7 @@ namespace PhpParser\Node; -use PhpParser\Node\Expr\VariadicPlaceholder; +use PhpParser\Node\VariadicPlaceholder; use PhpParser\NodeAbstract; class Arg extends NodeAbstract diff --git a/lib/PhpParser/Node/Expr/VariadicPlaceholder.php b/lib/PhpParser/Node/VariadicPlaceholder.php similarity index 77% rename from lib/PhpParser/Node/Expr/VariadicPlaceholder.php rename to lib/PhpParser/Node/VariadicPlaceholder.php index a4e4e5c..403a24d 100644 --- a/lib/PhpParser/Node/Expr/VariadicPlaceholder.php +++ b/lib/PhpParser/Node/VariadicPlaceholder.php @@ -1,13 +1,13 @@ semValue = array($this->semStack[$stackPos-(3-2)]); }, 310 => function ($stackPos) { - $this->semValue = new Node\Arg(new Expr\VariadicPlaceholder($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes), false, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + $this->semValue = new Node\VariadicPlaceholder($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); }, 311 => function ($stackPos) { $this->semValue = array($this->semStack[$stackPos-(1-1)]); diff --git a/lib/PhpParser/PrettyPrinter/Standard.php b/lib/PhpParser/PrettyPrinter/Standard.php index 6a5e16a..bb70de6 100644 --- a/lib/PhpParser/PrettyPrinter/Standard.php +++ b/lib/PhpParser/PrettyPrinter/Standard.php @@ -33,6 +33,10 @@ class Standard extends PrettyPrinterAbstract . $this->p($node->value); } + protected function pVariadicPlaceholder(Node\VariadicPlaceholder $node) { + return '...'; + } + protected function pConst(Node\Const_ $node) { return $node->name . ' = ' . $this->p($node->value); } @@ -692,10 +696,6 @@ class Standard extends PrettyPrinterAbstract } } - protected function pExpr_VariadicPlaceholder(Expr\VariadicPlaceholder $node) { - return '...'; - } - // Declarations protected function pStmt_Namespace(Stmt\Namespace_ $node) { diff --git a/test/code/parser/expr/firstClassCallables.test b/test/code/parser/expr/firstClassCallables.test index c02c3d7..1e15a98 100644 --- a/test/code/parser/expr/firstClassCallables.test +++ b/test/code/parser/expr/firstClassCallables.test @@ -21,12 +21,7 @@ array( ) ) args: array( - 0: Arg( - name: null - value: Expr_VariadicPlaceholder( - ) - byRef: false - unpack: false + 0: VariadicPlaceholder( ) ) ) @@ -40,12 +35,7 @@ array( name: foo ) args: array( - 0: Arg( - name: null - value: Expr_VariadicPlaceholder( - ) - byRef: false - unpack: false + 0: VariadicPlaceholder( ) ) ) @@ -61,12 +51,7 @@ array( name: foo ) args: array( - 0: Arg( - name: null - value: Expr_VariadicPlaceholder( - ) - byRef: false - unpack: false + 0: VariadicPlaceholder( ) ) ) @@ -79,12 +64,7 @@ array( ) ) args: array( - 0: Arg( - name: null - value: Expr_VariadicPlaceholder( - ) - byRef: false - unpack: false + 0: VariadicPlaceholder( ) ) comments: array( @@ -106,12 +86,7 @@ array( ) ) args: array( - 0: Arg( - name: null - value: Expr_VariadicPlaceholder( - ) - byRef: false - unpack: false + 0: VariadicPlaceholder( ) ) )