Skip to content

Commit bb9c425

Browse files
authored
Merge pull request #893 from PHPCSStandards/feature/799-ruleset-remove-support-for-standard-internal
Ruleset: hard deprecate support for standards called "Internal"
2 parents 44dd259 + 3cc4afb commit bb9c425

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Ruleset.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,13 @@ private function expandSniffDirectory($directory, $depth=0)
892892
*/
893893
private function expandRulesetReference($ref, $rulesetDir, $depth=0)
894894
{
895+
// Naming an (external) standard "Internal" is deprecated.
896+
if (strtolower($ref) === 'internal') {
897+
$message = 'The name "Internal" is reserved for internal use. A PHP_CodeSniffer standard should not be called "Internal".'.PHP_EOL;
898+
$message .= 'Contact the maintainer of the standard to fix this.';
899+
$this->msgCache->add($message, MessageCollector::DEPRECATED);
900+
}
901+
895902
// Ignore internal sniffs codes as they are used to only
896903
// hide and change internal messages.
897904
if (substr($ref, 0, 9) === 'Internal.') {

tests/Core/Ruleset/ExpandRulesetReferenceInternalTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ public function testInternalRefDoesNotGetExpanded()
5151
*/
5252
public function testInternalStandardDoesGetExpanded()
5353
{
54+
$message = 'DEPRECATED: The name "Internal" is reserved for internal use. A PHP_CodeSniffer standard should not be called "Internal".'.PHP_EOL;
55+
$message .= 'Contact the maintainer of the standard to fix this.'.PHP_EOL.PHP_EOL;
56+
57+
$this->expectOutputString($message);
58+
5459
// Set up the ruleset.
5560
$standard = __DIR__.'/ExpandRulesetReferenceInternalStandardTest.xml';
5661
$config = new ConfigDouble(["--standard=$standard"]);

0 commit comments

Comments
 (0)