Generic/ConstructorName: fix minor bug #649
Merged
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
This PR fixes a minor bug in
Generic.NamingConventions .ConstructorName
when checking if a given class has a parent. The code was checking if the lowercase version of the value returned byFile::findExtendedClassName()
isfalse
. The problem is thatstrtolower()
never returnsfalse
. It always returns astring
. Thus, the condition would never be evaluated astrue
, and the sniff would not bail at this point when a given class has no parent.As far as I can check, this did not cause any issues to the sniff, even for invalid code, as there is not a scenario where a class method can have a
T_DOUBLE_COLON
token followed by aT_STRING
token with an emptycontent
. This is true even for empty strings as PHPCS includes the quotes in thecontent
.Types of changes
PR checklist