diff --git a/src/Ruleset.php b/src/Ruleset.php index 7a25bf31ca..f86716e120 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -892,11 +892,13 @@ private function expandSniffDirectory($directory, $depth=0) */ private function expandRulesetReference($ref, $rulesetDir, $depth=0) { - // Naming an (external) standard "Internal" is deprecated. + // Naming an (external) standard "Internal" is not supported. if (strtolower($ref) === 'internal') { $message = 'The name "Internal" is reserved for internal use. A PHP_CodeSniffer standard should not be called "Internal".'.PHP_EOL; $message .= 'Contact the maintainer of the standard to fix this.'; - $this->msgCache->add($message, MessageCollector::DEPRECATED); + $this->msgCache->add($message, MessageCollector::ERROR); + + return []; } // Ignore internal sniffs codes as they are used to only diff --git a/tests/Core/Ruleset/ExpandRulesetReferenceInternalStandardTest.xml b/tests/Core/Ruleset/ExpandRulesetReferenceInternalStandardTest.xml index 0493e253c6..7f70917de9 100644 --- a/tests/Core/Ruleset/ExpandRulesetReferenceInternalStandardTest.xml +++ b/tests/Core/Ruleset/ExpandRulesetReferenceInternalStandardTest.xml @@ -5,4 +5,6 @@ + + diff --git a/tests/Core/Ruleset/ExpandRulesetReferenceInternalTest.php b/tests/Core/Ruleset/ExpandRulesetReferenceInternalTest.php index 5f0180dacb..6658bd9377 100644 --- a/tests/Core/Ruleset/ExpandRulesetReferenceInternalTest.php +++ b/tests/Core/Ruleset/ExpandRulesetReferenceInternalTest.php @@ -42,30 +42,30 @@ public function testInternalRefDoesNotGetExpanded() /** - * While definitely not recommended, including a standard named "Internal", _does_ allow for sniffs to be registered. + * As of PHPCS 4.0, a standard can no longer be named "Internal". * - * Note: customizations (exclusions/property setting etc) for individual sniffs may not always be handled correctly, - * which is why naming a standard "Internal" is definitely not recommended. + * Standards with this name will be ignored. * * @return void */ - public function testInternalStandardDoesGetExpanded() + public function testInternalStandardIsNotSupported() { - $message = 'DEPRECATED: The name "Internal" is reserved for internal use. A PHP_CodeSniffer standard should not be called "Internal".'.PHP_EOL; + $message = 'ERROR: The name "Internal" is reserved for internal use. A PHP_CodeSniffer standard should not be called "Internal".'.PHP_EOL; $message .= 'Contact the maintainer of the standard to fix this.'.PHP_EOL.PHP_EOL; - $this->expectOutputString($message); + $this->expectRuntimeExceptionMessage($message); // Set up the ruleset. $standard = __DIR__.'/ExpandRulesetReferenceInternalStandardTest.xml'; $config = new ConfigDouble(["--standard=$standard"]); $ruleset = new Ruleset($config); - $expected = ['Internal.Valid.Valid' => 'Fixtures\\Internal\\Sniffs\\Valid\\ValidSniff']; + $expected = ['Generic.PHP.BacktickOperator' => 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\BacktickOperatorSniff']; + // This assertion will only take effect for PHPUnit 10+. $this->assertSame($expected, $ruleset->sniffCodes); - }//end testInternalStandardDoesGetExpanded() + }//end testInternalStandardIsNotSupported() }//end class