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

PHP 8.0 | Squiz/ScopeKeywordSpacing: add support for constructor property promotion #3259

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Mar 5, 2021

PHP 7.4 | Squiz/ScopeKeywordSpacing: add tests with typed properties

PHP 8.0 | Squiz/ScopeKeywordSpacing: add support for constructor property promotion

Prevent the sniff from ignoring the spacing after the scope keyword in case of PHP 8.0 constructor property promotion.

As it was, the sniff would presume "normal" property syntax, which meant that in the case of constructor property promotion in a multi-line constructor declaration, the sniff would look for a semicolon to end the statement and bow out when the semicolon wasn't found.

By explicitly checking for constructor property promotion and skipping the above mentioned check in that case, we ensure that scope keywords in constructors are still handled correctly.

Includes tests.

jrfnl added 2 commits March 5, 2021 03:54
…erty promotion

Prevent the sniff from ignoring the spacing after the scope keyword in case of PHP 8.0 constructor property promotion.

As it was, the sniff would presume "normal" property syntax, which meant that in the case of constructor property promotion in a multi-line constructor declaration, the sniff would look for a semicolon to end the statement and bow out when the semicolon wasn't found.

By explicitly checking for constructor property promotion and skipping the next above mentioned check in that case, we ensure that scope keywords in constructors are still handled correctly.

Includes tests.
@gsherwood gsherwood added this to the 3.6.0 milestone Mar 12, 2021
gsherwood added a commit that referenced this pull request Mar 12, 2021
@gsherwood gsherwood merged commit e59e569 into squizlabs:master Mar 12, 2021
@gsherwood
Copy link
Member

Thank you! I think that would have gone completely unnoticed if not for you.

@jrfnl jrfnl deleted the php-8.0/squiz-scopekeywordspacing-support-cconstructor-prop-prom branch March 12, 2021 04:53
@jrfnl
Copy link
Contributor Author

jrfnl commented Mar 12, 2021

@gsherwood For most new PHP syntaxes, I've done some keyword/function call searches for tokens/function calls which could indicate a sniff would need changing. This was just one of the results of those.

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

Successfully merging this pull request may close these issues.

2 participants