New PHPCompatibility.FunctionDeclarations.AbstractPrivateMethods sniff
#1149
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.
👉 Open questions - please answer these before considering merging this PR:
NewTraitAbstractPrivateMethodssniff. Should this check be added to the existingForbiddenAbstractPrivateMethodssniff instead ? The logic in the sniffs is > 90% the same.And if so, should the existing sniff be renamed to better cover both changes ?
Currently the
ForbiddenAbstractPrivateMethodsis in theClassescategory, while I've elected to place theForbiddenAbstractPrivateMethodsin theFunctionDeclarationscategory.IMO
FunctionDeclarationsseems more logical and if we'd choose to make a change in this for the existing sniff, now would be the time considering the next release is a major.Updated PR description - this addresses the above points:
This sniff replaces the
PHPCompatibility.Classes.ForbiddenAbstractPrivateMethodssniff.The new sniff addresses both the PHP 5.1 change which forbade
abstract privatemethods, as well as the PHP 8.0 change where "abstract private" methods are now allowed in traits.Refs:
Includes unit tests.
Related to #809
Old (superseded) PR description
PHP 8.0: new
PHPCompatibility.FunctionDeclarations.NewTraitAbstractPrivateMethodssniffPHP 8.0 will allow "abstract private" methods in traits
Refs:
This new sniff detects those.
Includes unit tests.
ForbiddenAbstractPrivateMethods: bow out for abstract private methods in traits
... as this is now checked via the new
PHPCompatibility.FunctionDeclarations.NewTraitAbstractPrivateMethodssniff and would otherwise cause duplicate and - if PHP 8 is supported - incorrect errors.