Tokenizer/PHP: fix ? tokenization in property hook parameters - #1495
Open
lazerg wants to merge 1 commit into
Open
Tokenizer/PHP: fix ? tokenization in property hook parameters#1495lazerg wants to merge 1 commit into
lazerg wants to merge 1 commit into
Conversation
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.
Description
The
?of a nullable type on a property hook parameter, likeset(?int $value), was tokenized asT_INLINE_THENinstead ofT_NULLABLE, soSquiz.WhiteSpace.OperatorSpacingtreated it as a ternary andphpcbf"fixed" the accessor toset( ? int $value).When the backward walk in the
?disambiguation reaches the parameter list opener, it currently keeps walking and hits the{of the hook block, which is in the list of tokens that mean "ternary". A?directly preceded by(is always the start of a nullable type though, never a ternary, since a ternary needs an expression before its?. This adds(to the tokens that make the previous non-empty token check concludeT_NULLABLE, which also stops the walk before it can reach the hook block.Regular methods and closures were never affected: their backward walk finds
function/fnfirst.Suggested changelog entry
?of a nullable type on a property hook parameter would be tokenized asT_INLINE_THENinstead ofT_NULLABLE, which madeSquiz.WhiteSpace.OperatorSpacingreport false positives andphpcbfbreak the code.Related issues/external references
Fixes #1494
Types of changes
PR checklist