Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tokenizer/PHP: fix ? tokenization after attribute #3446

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Oct 6, 2021

In a select set of circumstance, when a ? would follow an attribute with a nested array in it, the ? would be tokenized as T_INLINE_THEN, not T_NULLABLE.
Fixed now.

Includes unit test via the PSR12.Operators.OperatorSpacing sniff.

Note: Ternary ? vs nullable (and ternary : vs colon) should really get a full set of unit tests, but I don't currently have the time to set that up.

Fixes #3445

In a select set of circumstance, when a `?` would follow an attribute with a nested array in it, the `?` would be tokenized as `T_INLINE_THEN`, not `T_NULLABLE`.
Fixed now.

Includes unit test via the `PSR12.Operators.OperatorSpacing` sniff.

Note: Ternary `?` vs nullable (and ternary `:` vs colon) should really get a full set of unit tests, but I don't currently have the time to set that up.

Fixes 3445
@mhlsf
Copy link

mhlsf commented Oct 7, 2021

I tested it on my project, this is the correct fix for #3445 , Thank you !

@jrfnl
Copy link
Contributor Author

jrfnl commented Oct 7, 2021

Thanks for testing @mhlsf !

@gsherwood gsherwood added this to Idea Bank in PHPCS v3 Development via automation Oct 11, 2021
@gsherwood gsherwood added this to the 3.6.1 milestone Oct 11, 2021
gsherwood added a commit that referenced this pull request Oct 11, 2021
@gsherwood gsherwood merged commit 9362d14 into squizlabs:master Oct 11, 2021
PHPCS v3 Development automation moved this from Idea Bank to Ready for Release Oct 11, 2021
@jrfnl jrfnl deleted the feature/3445-tokenizer-attributes-vs-nullable branch October 11, 2021 04:05
@gsherwood
Copy link
Member

Thanks for fixing this so quickly. Will sneak it into 3.6.1.

@jrfnl
Copy link
Contributor Author

jrfnl commented Oct 11, 2021

Felt like an icky one... and thanks for including it in 3.6.1!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
PHPCS v3 Development
Ready for Release
Development

Successfully merging this pull request may close these issues.

Nullable parameter after attribute incorrectly tokenized as ternary operator
3 participants