Universal/NoReservedKeywordParameterNames: various improvements #173
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.
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.