Repository navigation
Parse partial function application placeholders and invoking new without parentheses in php8 - #39
Merged
Conversation
…out parentheses in php8 f(?, name: ?, ...) and new Foo()() were syntax errors. A placeholder is an Argument without Expr: '?' sets the new PlaceholderTkn, a bare '...' sets VariadicTkn, as a first-class callable already did. new_dereferenceable joins callable_expr, as in php-src, so a new with an argument list can be invoked directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two PHP syntax forms were syntax errors in php8:
array_map(trim(?), $items),f($x, ?, y: ?, ...). A placeholder is anast.ArgumentwithoutExpr:?sets the newPlaceholderTkn(withName/ColonTknfory: ?), a bare...setsVariadicTkn, the same shape a first-class callablef(...)already had. The dedicated'(' T_ELLIPSIS ')'rule is gone, since a bare...is now an argument. Printer, dumper and formatter handle the new token.new Invokable()().new_dereferenceablejoinscallable_expr, as in php-src.->,?->,::and[already worked.Grammar conflicts stay at the baseline 3 shift/reduce, 7 reduce/reduce.
The legacy curly offset
$value{0}is left out on purpose: it is a syntax error since PHP 8.0 (nikic/PHP-Parser rejects it too), and adding it to php8 makes{conflict with property hooks ($x = default { get; }).