Skip to content

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Jun 29, 2020


👉 Open questions - please answer these before considering merging this PR:

  • For now, I've added a new NewTraitAbstractPrivateMethods sniff. Should this check be added to the existing ForbiddenAbstractPrivateMethods sniff 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 the ForbiddenAbstractPrivateMethods is in the Classes category, while I've elected to place the ForbiddenAbstractPrivateMethods in the FunctionDeclarations category.
    • Should they both be in the same category ?
    • And so, which category should this be ?
      IMO FunctionDeclarations seems 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.


@jrfnl jrfnl added this to the 10.0.0 milestone Jun 29, 2020
@jrfnl jrfnl requested a review from wimg June 29, 2020 20:59
@jrfnl jrfnl changed the title PHP 8.0: new PHPCompatibility.FunctionDeclarations.NewTraitAbstractPrivateMethods sniff PHP 8.0: New PHPCompatibility.FunctionDeclarations.NewTraitAbstractPrivateMethods sniff Jun 29, 2020
@jrfnl
Copy link
Member Author

jrfnl commented Jul 11, 2020

Related to #809

@wimg
Copy link
Member

wimg commented Jul 11, 2020

I believe it makes most sense to join them, but give it a new name. That way we don't have too much duplicate code (which is what all the refactoring was designed to do anway) but the name is clear.

…sniff

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:
* https://wiki.php.net/rfc/abstract_trait_method_validation
* php/php-src@f74e30c

Includes unit tests.
@jrfnl jrfnl changed the title PHP 8.0: New PHPCompatibility.FunctionDeclarations.NewTraitAbstractPrivateMethods sniff New PHPCompatibility.FunctionDeclarations.AbstractPrivateMethods sniff Jul 12, 2020
@jrfnl jrfnl force-pushed the php-8.0/new-trait-abstract-private-methods-sniff branch from 2c9833c to 350454e Compare July 12, 2020 04:48
@jrfnl
Copy link
Member Author

jrfnl commented Jul 12, 2020

@wimg PR updated - or rather replaced - with a new commit which addresses both changes in PHP in one sniff. See the updated PR description.

@wimg wimg merged commit 6cfb50f into develop Jul 12, 2020
@wimg wimg deleted the php-8.0/new-trait-abstract-private-methods-sniff branch July 12, 2020 23:13
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.

3 participants