diff --git a/src/Ruleset.php b/src/Ruleset.php index 57e10e8464..7169f0f452 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -892,6 +892,13 @@ private function expandSniffDirectory($directory, $depth=0) */ private function expandRulesetReference($ref, $rulesetDir, $depth=0) { + // Naming an (external) standard "Internal" is deprecated. + 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); + } + // Ignore internal sniffs codes as they are used to only // hide and change internal messages. if (substr($ref, 0, 9) === 'Internal.') { diff --git a/tests/Core/Ruleset/ExpandRulesetReferenceInternalTest.php b/tests/Core/Ruleset/ExpandRulesetReferenceInternalTest.php index edac7490d0..5f0180dacb 100644 --- a/tests/Core/Ruleset/ExpandRulesetReferenceInternalTest.php +++ b/tests/Core/Ruleset/ExpandRulesetReferenceInternalTest.php @@ -51,6 +51,11 @@ public function testInternalRefDoesNotGetExpanded() */ public function testInternalStandardDoesGetExpanded() { + $message = 'DEPRECATED: 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); + // Set up the ruleset. $standard = __DIR__.'/ExpandRulesetReferenceInternalStandardTest.xml'; $config = new ConfigDouble(["--standard=$standard"]);