Skip to content

Commit

Permalink
CS/QA: make all classes final
Browse files Browse the repository at this point in the history
This can now be enforced via a sniff available in PHPCSExtra.
  • Loading branch information
jrfnl committed Nov 3, 2023
1 parent 6754fc3 commit c0c80d1
Show file tree
Hide file tree
Showing 26 changed files with 28 additions and 25 deletions.
3 changes: 3 additions & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
<!-- Enforce PSR1 compatible namespaces. -->
<rule ref="PSR1.Classes.ClassDeclaration"/>

<!-- Enforce Final classes to prevent issues with the PHPCS autoloader. -->
<rule ref="Universal.Classes.RequireFinalClass"/>


<!--
#############################################################################
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Reports/Threshold.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @since 2.2.0
*/
class Threshold implements Report {
final class Threshold implements Report {

/**
* Escape sequence for making text white on the command-line.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @since 1.1.0
*/
class CodeCoverageIgnoreDeprecatedSniff implements Sniff {
final class CodeCoverageIgnoreDeprecatedSniff implements Sniff {

/**
* Returns an array of tokens this test wants to listen for.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Sniffs/Commenting/CoversTagSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* @since 1.3.0
*/
class CoversTagSniff implements Sniff {
final class CoversTagSniff implements Sniff {

/**
* Regex to check for valid content of a @covers tags.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Sniffs/Commenting/FileCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
* @since 1.2.0
*/
class FileCommentSniff extends Squiz_FileCommentSniff {
final class FileCommentSniff extends Squiz_FileCommentSniff {

/**
* Processes this test, when one of its tokens is encountered.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Sniffs/Commenting/TestsHaveCoversTagSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @since 1.3.0
*/
class TestsHaveCoversTagSniff implements Sniff {
final class TestsHaveCoversTagSniff implements Sniff {

/**
* Returns an array of tokens this test wants to listen for.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Sniffs/Files/FileNameSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @since 0.5
*/
class FileNameSniff implements Sniff {
final class FileNameSniff implements Sniff {

/**
* List of prefixes for object structures.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Sniffs/Files/TestDoublesSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @since 1.0.0
*/
class TestDoublesSniff implements Sniff {
final class TestDoublesSniff implements Sniff {

/**
* Relative paths to the directories where the test doubles/mocks are allowed to be placed.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Sniffs/NamingConventions/NamespaceNameSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* @since 2.0.0
*/
class NamespaceNameSniff implements Sniff {
final class NamespaceNameSniff implements Sniff {

use CustomPrefixesTrait;

Expand Down
2 changes: 1 addition & 1 deletion Yoast/Sniffs/NamingConventions/ObjectNameDepthSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @since 2.0.0
*/
class ObjectNameDepthSniff extends WPCS_Sniff {
final class ObjectNameDepthSniff extends WPCS_Sniff {

/**
* Maximum number of words.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Sniffs/NamingConventions/ValidHookNameSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*
* @since 2.0.0
*/
class ValidHookNameSniff extends WPCS_ValidHookNameSniff {
final class ValidHookNameSniff extends WPCS_ValidHookNameSniff {

use CustomPrefixesTrait;

Expand Down
2 changes: 1 addition & 1 deletion Yoast/Sniffs/Tools/BrainMonkeyRaceConditionSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @package Yoast\YoastCS
* @author Juliette Reinders Folmer
*/
class BrainMonkeyRaceConditionSniff extends Sniff {
final class BrainMonkeyRaceConditionSniff extends Sniff {

/**
* Returns an array of tokens this test wants to listen for.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Sniffs/WhiteSpace/FunctionSpacingSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @since 1.0.0
*/
class FunctionSpacingSniff extends Squiz_FunctionSpacingSniff {
final class FunctionSpacingSniff extends Squiz_FunctionSpacingSniff {

/**
* The number of blank lines between functions.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Sniffs/Yoast/AlternativeFunctionsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @since 1.3.0
*/
class AlternativeFunctionsSniff extends AbstractFunctionRestrictionsSniff {
final class AlternativeFunctionsSniff extends AbstractFunctionRestrictionsSniff {

/**
* Groups of functions to restrict.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @covers YoastCS\Yoast\Sniffs\Commenting\CodeCoverageIgnoreDeprecatedSniff
*/
class CodeCoverageIgnoreDeprecatedUnitTest extends AbstractSniffUnitTest {
final class CodeCoverageIgnoreDeprecatedUnitTest extends AbstractSniffUnitTest {

/**
* Returns the lines where errors should occur.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Tests/Commenting/CoversTagUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @covers YoastCS\Yoast\Sniffs\Commenting\CoversTagSniff
*/
class CoversTagUnitTest extends AbstractSniffUnitTest {
final class CoversTagUnitTest extends AbstractSniffUnitTest {

/**
* Returns the lines where errors should occur.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Tests/Commenting/FileCommentUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @covers YoastCS\Yoast\Sniffs\Commenting\FileCommentSniff
*/
class FileCommentUnitTest extends AbstractSniffUnitTest {
final class FileCommentUnitTest extends AbstractSniffUnitTest {

/**
* Returns the lines where errors should occur.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Tests/Commenting/TestsHaveCoversTagUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @covers YoastCS\Yoast\Sniffs\Commenting\TestsHaveCoversTagSniff
*/
class TestsHaveCoversTagUnitTest extends AbstractSniffUnitTest {
final class TestsHaveCoversTagUnitTest extends AbstractSniffUnitTest {

/**
* Returns the lines where errors should occur.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Tests/Files/FileNameUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @covers YoastCS\Yoast\Sniffs\Files\FileNameSniff
*/
class FileNameUnitTest extends AbstractSniffUnitTest {
final class FileNameUnitTest extends AbstractSniffUnitTest {

/**
* Error files with the expected nr of errors.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Tests/Files/TestDoublesUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @covers YoastCS\Yoast\Sniffs\Files\TestDoublesSniff
*/
class TestDoublesUnitTest extends AbstractSniffUnitTest {
final class TestDoublesUnitTest extends AbstractSniffUnitTest {

/**
* Set CLI values before the file is tested.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Tests/NamingConventions/NamespaceNameUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @covers YoastCS\Yoast\Sniffs\NamingConventions\NamespaceNameSniff
* @covers YoastCS\Yoast\Utils\CustomPrefixesTrait
*/
class NamespaceNameUnitTest extends AbstractSniffUnitTest {
final class NamespaceNameUnitTest extends AbstractSniffUnitTest {

/**
* Set CLI values before the file is tested.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Tests/NamingConventions/ObjectNameDepthUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @covers YoastCS\Yoast\Sniffs\NamingConventions\ObjectNameDepthSniff
*/
class ObjectNameDepthUnitTest extends AbstractSniffUnitTest {
final class ObjectNameDepthUnitTest extends AbstractSniffUnitTest {

/**
* Returns the lines where errors should occur.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Tests/NamingConventions/ValidHookNameUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @covers YoastCS\Yoast\Sniffs\NamingConventions\ValidHookNameSniff
* @covers YoastCS\Yoast\Utils\CustomPrefixesTrait
*/
class ValidHookNameUnitTest extends AbstractSniffUnitTest {
final class ValidHookNameUnitTest extends AbstractSniffUnitTest {

/**
* Set warnings level to 3 to trigger suggestions as warnings.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Tests/Tools/BrainMonkeyRaceConditionUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @covers YoastCS\Yoast\Sniffs\Tools\BrainMonkeyRaceConditionSniff
*/
class BrainMonkeyRaceConditionUnitTest extends AbstractSniffUnitTest {
final class BrainMonkeyRaceConditionUnitTest extends AbstractSniffUnitTest {

/**
* Returns the lines where errors should occur.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Tests/WhiteSpace/FunctionSpacingUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @covers YoastCS\Yoast\Sniffs\WhiteSpace\FunctionSpacingSniff
*/
class FunctionSpacingUnitTest extends AbstractSniffUnitTest {
final class FunctionSpacingUnitTest extends AbstractSniffUnitTest {

/**
* Returns the lines where errors should occur.
Expand Down
2 changes: 1 addition & 1 deletion Yoast/Tests/Yoast/AlternativeFunctionsUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @covers YoastCS\Yoast\Sniffs\Yoast\AlternativeFunctionsSniff
*/
class AlternativeFunctionsUnitTest extends AbstractSniffUnitTest {
final class AlternativeFunctionsUnitTest extends AbstractSniffUnitTest {

/**
* Returns the lines where errors should occur.
Expand Down

0 comments on commit c0c80d1

Please sign in to comment.