Skip to content

CS/QA: make all classes final#1875

Merged
wimg merged 3 commits intodevelopfrom
feature/make-all-sniffs-final
Sep 1, 2025
Merged

CS/QA: make all classes final#1875
wimg merged 3 commits intodevelopfrom
feature/make-all-sniffs-final

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Aug 20, 2025

As the PHPCS native autoloader can run into trouble when one sniff extends another sniff and both sniffs are used within the same standard, all sniffs ought to be declared as final.

When inheritance or re-use of logic is needed for a sniff, use an abstract base class or a helper trait instead.

👉🏻 Note: this is a breaking change for any standard which would happen to be extending any of the PHPCompatibility sniffs and should be marked as such in the changelog.

Any "bug" reports regarding this change, should require users to detail the reason for extending the class and should advise users on what to do based on their usecase (send in PR to this repo to add a feature, instantiate the PHPCompatibility sniff within their own sniff, extend one of the abstract classes instead, use a helper trait etc).

The change to the PHPCompatibility classes, however, should not be undone.

CS/QA: make all classes final [1]

This commit adjusts all public facing classes which existed prior to PHPCompatibility 10.0 (as they need a changelog entry).

CS/QA: make all classes final [2]

This commit adjusts all public facing classes which are new in PHPCompatibility 10.0 (no changelog entry needed).

CS/QA: make all classes final [3]

This commit adjusts all test classes.

@jrfnl jrfnl added this to the 10.0.0 milestone Aug 20, 2025
@jrfnl jrfnl requested a review from wimg August 20, 2025 03:24
@jrfnl jrfnl added Type: breaking change PR: quick merge PR only contains relatively simple changes PR: ready for review labels Aug 20, 2025
jrfnl added 3 commits August 20, 2025 07:22
As the PHPCS native autoloader can run into trouble when one sniff extends another sniff and both sniffs are used within the same standard, all sniffs ought to be declared as `final`.

When inheritance or re-use of logic is needed for a sniff, use an abstract base class or a helper trait instead.

Note: this is a breaking change for any standard which would happen to be extending any of the PHPCompatibility sniffs and should be marked as such in the changelog.

Any "bug" reports regarding this change, should advise users to detail the reason for extending the class and should advise users on what to do based on their usecase (send in PR to this repo to add a feature, instantiate the PHPCompatibility sniff within their own sniff, extend one of the abstract classes instead, use a helper trait etc).

The change to the PHPCompatibility classes, however, should not be undone.

This commit adjusts all public facing classes which existed prior to PHPCompatibility 10.0 (as they need a changelog entry).
As the PHPCS native autoloader can run into trouble when one sniff extends another sniff and both sniffs are used within the same standard, all sniffs ought to be declared as `final`.

When inheritance or re-use of logic is needed for a sniff, use an abstract base class or a helper trait instead.

Note: this is a breaking change for any standard which would happen to be extending any of the PHPCompatibility sniffs and should be marked as such in the changelog.

Any "bug" reports regarding this change, should advise users to detail the reason for extending the class and should advise users on what to do based on their usecase (send in PR to this repo to add a feature, instantiate the PHPCompatibility sniff within their own sniff, extend one of the abstract classes instead, use a helper trait etc).

The change to the PHPCompatibility classes, however, should not be undone.

This commit adjusts all public facing classes which are new in PHPCompatibility 10.0.
As the PHPCS native autoloader can run into trouble when one sniff extends another sniff and both sniffs are used within the same standard, all sniffs ought to be declared as `final`.

When inheritance or re-use of logic is needed for a sniff, use an abstract base class or a helper trait instead.

Note: this is a breaking change for any standard which would happen to be extending any of the PHPCompatibility sniffs and should be marked as such in the changelog.

Any "bug" reports regarding this change, should advise users to detail the reason for extending the class and should advise users on what to do based on their usecase (send in PR to this repo to add a feature, instantiate the PHPCompatibility sniff within their own sniff, extend one of the abstract classes instead, use a helper trait etc).

The change to the PHPCompatibility classes, however, should not be undone.

This commit adjusts all test classes.
@wimg wimg merged commit 8066f5e into develop Sep 1, 2025
189 of 193 checks passed
@wimg wimg deleted the feature/make-all-sniffs-final branch September 1, 2025 15:31
@github-actions github-actions bot removed PR: quick merge PR only contains relatively simple changes PR: ready for review labels Sep 1, 2025
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.

2 participants