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

Universal/NoReservedKeywordParameterNames: various improvements #173

Merged

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Dec 4, 2022

Universal/NoReservedKeywordParameterNames: minor code simplification

... which can be made now support for PHPCS < 3.7.1 has been dropped.

The sniff now only listens to tokens which are accepted by the FunctionDeclarations::getParameters() method, so checking for an exception should be unnecessary.

Includes removing a stray $paramNames variable setting, which is never used.

Universal/NoReservedKeywordParameterNames: make tests more descriptive

Universal/NoReservedKeywordParameterNames: add extra tests

... to safeguard bowing out for function declarations without parameters and that the sniff stays silent for unfinished function declarations.

Universal/NoReservedKeywordParameterNames: make the check case-insensitive

While parameters (variables) are case-sensitive in PHP, keywords are not.

This commit improves the sniff to check for the keyword used in parameter names in a case-insensitive manner to make this sniff independent of code style rules regarding the case for parameter names.

Includes additional tests.

Universal/NoReservedKeywordParameterNames: add tests with PHP 8.0 constructor property promotion

... to confirm that properties set via the constructor are also checked.

Properties set via the constructor can be passed to the constructor using named parameters, so this check should also apply to those properties.

... which can be made now support for PHPCS < 3.7.1 has been dropped.

The sniff now only listens to tokens which are accepted by the `FunctionDeclarations::getParameters()` method, so checking for an exception should be unnecessary.

Includes removing a stray `$paramNames` variable setting, which is never used.
... to safeguard bowing out for function declarations without parameters and that the sniff stays silent for unfinished function declarations.
…itive

While parameters (variables) are case-sensitive in PHP, keywords are not.

This commit improves the sniff to check for the keyword used in parameter names in a case-insensitive manner to make this sniff independent of code style rules regarding the case for parameter names.

Includes additional tests.
…structor property promotion

... to confirm that properties set via the constructor are also checked.

Properties set via the constructor can be _passed_ to the constructor using named parameters, so this check should also apply to those properties.
@jrfnl jrfnl added this to the 1.0.0-alpha4 milestone Dec 4, 2022
@jrfnl jrfnl merged commit becd4f0 into develop Dec 4, 2022
@jrfnl jrfnl deleted the universal/noreservedkeywordparamname-various-improvements branch December 4, 2022 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant