New `PHPCompatibility.FunctionDeclarations.AbstractPrivateMethods` sniff by jrfnl · Pull Request #1149 · PHPCompatibility/PHPCompatibility
👉 Open questions - please answer these before considering merging this PR:
- For now, I've added a new
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 ? - If this would remain two separate sniffs:
Currently theForbiddenAbstractPrivateMethodsis in theClassescategory, while I've elected to place theForbiddenAbstractPrivateMethodsin theFunctionDeclarationscategory.- Should they both be in the same category ?
- And so, which category should this be ?
IMOFunctionDeclarationsseems 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.ForbiddenAbstractPrivateMethods sniff.
The new sniff addresses both the PHP 5.1 change which forbade abstract private methods, as well as the PHP 8.0 change where "abstract private" methods are now allowed in traits.
Traits can now define abstract private methods.
Refs:
Includes unit tests.
Related to #809
Old (superseded) PR description
PHP 8.0: new PHPCompatibility.FunctionDeclarations.NewTraitAbstractPrivateMethods sniff
PHP 8.0 will allow "abstract private" methods in traits
Traits can now define abstract private methods.
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.NewTraitAbstractPrivateMethods sniff and would otherwise cause duplicate and - if PHP 8 is supported - incorrect errors.