CS/QA: make all classes final by jrfnl · Pull Request #1875 · PHPCompatibility/PHPCompatibility
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 approved these changes Sep 1, 2025
wimg
deleted the
feature/make-all-sniffs-final
branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters