diff --git a/src/Ruleset.php b/src/Ruleset.php
index 7a25bf31ca..26731e0002 100644
--- a/src/Ruleset.php
+++ b/src/Ruleset.php
@@ -1418,24 +1418,9 @@ public function registerSniffs($files, $restrictions, $exclusions)
$message = 'All sniffs must implement the PHP_CodeSniffer\\Sniffs\\Sniff interface.'.PHP_EOL;
$message .= "Interface not implemented for sniff $className.".PHP_EOL;
$message .= 'Contact the sniff author to fix the sniff.';
- $this->msgCache->add($message, MessageCollector::DEPRECATED);
-
- // Skip classes which don't implement the register() or process() methods.
- if (method_exists($className, 'register') === false
- || method_exists($className, 'process') === false
- ) {
- $errorMsg = 'Sniff class %s is missing required method %s().';
- if (method_exists($className, 'register') === false) {
- $this->msgCache->add(sprintf($errorMsg, $className, 'register'), MessageCollector::ERROR);
- }
-
- if (method_exists($className, 'process') === false) {
- $this->msgCache->add(sprintf($errorMsg, $className, 'process'), MessageCollector::ERROR);
- }
-
- continue;
- }
- }//end if
+ $this->msgCache->add($message, MessageCollector::ERROR);
+ continue;
+ }
$listeners[$className] = $className;
diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/InvalidSniffError/NoImplementsNoProcessSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/InvalidSniffError/NoImplementsNoProcessSniff.php
deleted file mode 100644
index d6aa4ee6a8..0000000000
--- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/InvalidSniffError/NoImplementsNoProcessSniff.php
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
diff --git a/tests/Core/Ruleset/RegisterSniffsMissingInterfaceTest.php b/tests/Core/Ruleset/RegisterSniffsMissingInterfaceTest.php
index 89c82c028a..7b99034738 100644
--- a/tests/Core/Ruleset/RegisterSniffsMissingInterfaceTest.php
+++ b/tests/Core/Ruleset/RegisterSniffsMissingInterfaceTest.php
@@ -1,6 +1,6 @@
* @copyright 2025 PHPCSStandards and contributors
@@ -11,14 +11,14 @@
use PHP_CodeSniffer\Ruleset;
use PHP_CodeSniffer\Tests\ConfigDouble;
-use PHPUnit\Framework\TestCase;
+use PHP_CodeSniffer\Tests\Core\Ruleset\AbstractRulesetTestCase;
/**
- * Tests deprecation of support for sniffs not implementing the PHPCS `Sniff` interface.
+ * Tests removed support for sniffs not implementing the PHPCS `Sniff` interface.
*
* @covers \PHP_CodeSniffer\Ruleset::registerSniffs
*/
-final class RegisterSniffsMissingInterfaceTest extends TestCase
+final class RegisterSniffsMissingInterfaceTest extends AbstractRulesetTestCase
{
@@ -41,25 +41,25 @@ public function testNoNoticesForSniffsImplementingInterface()
/**
- * Test that a deprecation notice is shown if a sniff doesn't implement the Sniff interface.
+ * Test that an error is shown if a sniff doesn't implement the Sniff interface.
*
* @return void
*/
- public function testDeprecationNoticeWhenSniffDoesntImplementInterface()
+ public function testErrorWhenSniffDoesntImplementInterface()
{
// Set up the ruleset.
$standard = __DIR__.'/RegisterSniffsMissingInterfaceInvalidTest.xml';
$config = new ConfigDouble(["--standard=$standard"]);
- $expected = 'DEPRECATED: All sniffs must implement the PHP_CodeSniffer\\Sniffs\\Sniff interface.'.PHP_EOL;
+ $expected = 'ERROR: All sniffs must implement the PHP_CodeSniffer\\Sniffs\\Sniff interface.'.PHP_EOL;
$expected .= 'Interface not implemented for sniff Fixtures\\TestStandard\\Sniffs\\MissingInterface\\InvalidImplementsWithoutImplementSniff.'.PHP_EOL;
$expected .= 'Contact the sniff author to fix the sniff.'.PHP_EOL.PHP_EOL;
- $this->expectOutputString($expected);
+ $this->expectRuntimeExceptionMessage($expected);
new Ruleset($config);
- }//end testDeprecationNoticeWhenSniffDoesntImplementInterface()
+ }//end testErrorWhenSniffDoesntImplementInterface()
}//end class
diff --git a/tests/Core/Ruleset/RegisterSniffsRejectsInvalidSniffNoImplementsNoProcessTest.xml b/tests/Core/Ruleset/RegisterSniffsRejectsInvalidSniffNoImplementsNoProcessTest.xml
deleted file mode 100644
index d12d435b64..0000000000
--- a/tests/Core/Ruleset/RegisterSniffsRejectsInvalidSniffNoImplementsNoProcessTest.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/tests/Core/Ruleset/RegisterSniffsRejectsInvalidSniffNoImplementsNoRegisterOrProcessTest.xml b/tests/Core/Ruleset/RegisterSniffsRejectsInvalidSniffNoImplementsNoRegisterOrProcessTest.xml
deleted file mode 100644
index 3f03d1a2ea..0000000000
--- a/tests/Core/Ruleset/RegisterSniffsRejectsInvalidSniffNoImplementsNoRegisterOrProcessTest.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/tests/Core/Ruleset/RegisterSniffsRejectsInvalidSniffNoImplementsNoRegisterTest.xml b/tests/Core/Ruleset/RegisterSniffsRejectsInvalidSniffNoImplementsNoRegisterTest.xml
deleted file mode 100644
index 699628e232..0000000000
--- a/tests/Core/Ruleset/RegisterSniffsRejectsInvalidSniffNoImplementsNoRegisterTest.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/tests/Core/Ruleset/RegisterSniffsRejectsInvalidSniffTest.php b/tests/Core/Ruleset/RegisterSniffsRejectsInvalidSniffTest.php
deleted file mode 100644
index 1efe5cdba0..0000000000
--- a/tests/Core/Ruleset/RegisterSniffsRejectsInvalidSniffTest.php
+++ /dev/null
@@ -1,80 +0,0 @@
-
- * @copyright 2025 PHPCSStandards and contributors
- * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
- */
-
-namespace PHP_CodeSniffer\Tests\Core\Ruleset;
-
-use PHP_CodeSniffer\Ruleset;
-use PHP_CodeSniffer\Tests\ConfigDouble;
-use PHP_CodeSniffer\Tests\Core\Ruleset\AbstractRulesetTestCase;
-
-/**
- * Tests that invalid sniffs will be rejected with an informative error message.
- *
- * @covers \PHP_CodeSniffer\Ruleset::registerSniffs
- */
-final class RegisterSniffsRejectsInvalidSniffTest extends AbstractRulesetTestCase
-{
-
-
- /**
- * Verify that an error is thrown if an invalid sniff class is loaded.
- *
- * @param string $standard The standard to use for the test.
- * @param string $methodName The name of the missing method.
- *
- * @dataProvider dataExceptionIsThrownOnMissingInterfaceMethod
- *
- * @return void
- */
- public function testExceptionIsThrownOnMissingInterfaceMethod($standard, $methodName)
- {
- // Set up the ruleset.
- $standard = __DIR__.'/'.$standard;
- $config = new ConfigDouble(["--standard=$standard"]);
-
- $regex = "`(^|\R)ERROR: Sniff class \S+Sniff is missing required method $methodName\(\)\.\R`";
- $this->expectRuntimeExceptionRegex($regex);
-
- new Ruleset($config);
-
- }//end testExceptionIsThrownOnMissingInterfaceMethod()
-
-
- /**
- * Data provider.
- *
- * @see testExceptionIsThrownOnMissingInterfaceMethod()
- *
- * @return array>
- */
- public static function dataExceptionIsThrownOnMissingInterfaceMethod()
- {
- return [
- 'Missing register() method' => [
- 'standard' => 'RegisterSniffsRejectsInvalidSniffNoImplementsNoRegisterTest.xml',
- 'methodName' => 'register',
- ],
- 'Missing process() method' => [
- 'standard' => 'RegisterSniffsRejectsInvalidSniffNoImplementsNoProcessTest.xml',
- 'methodName' => 'process',
- ],
- 'Missing both, checking register() method' => [
- 'standard' => 'RegisterSniffsRejectsInvalidSniffNoImplementsNoRegisterOrProcessTest.xml',
- 'methodName' => 'register',
- ],
- 'Missing both, checking process() method' => [
- 'standard' => 'RegisterSniffsRejectsInvalidSniffNoImplementsNoRegisterOrProcessTest.xml',
- 'methodName' => 'process',
- ],
- ];
-
- }//end dataExceptionIsThrownOnMissingInterfaceMethod()
-
-
-}//end class
diff --git a/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml b/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml
index 3ae834c76c..20e4a1ef0f 100644
--- a/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml
+++ b/tests/Core/Ruleset/ShowSniffDeprecationsTest.xml
@@ -7,7 +7,6 @@
-