Skip to content

Commit e797e5d

Browse files
committed
Ruleset: remove support for standards called "Internal"
Standards called "Internal" were never really supported anyhow. This is now formalized. Fixes 799 Related to 6
1 parent d27a8c8 commit e797e5d

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/Ruleset.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -892,11 +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.
895+
// Naming an (external) standard "Internal" is not supported.
896896
if (strtolower($ref) === 'internal') {
897897
$message = 'The name "Internal" is reserved for internal use. A PHP_CodeSniffer standard should not be called "Internal".'.PHP_EOL;
898898
$message .= 'Contact the maintainer of the standard to fix this.';
899-
$this->msgCache->add($message, MessageCollector::DEPRECATED);
899+
$this->msgCache->add($message, MessageCollector::ERROR);
900+
901+
return [];
900902
}
901903

902904
// Ignore internal sniffs codes as they are used to only

tests/Core/Ruleset/ExpandRulesetReferenceInternalStandardTest.xml

+2
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55

66
<rule ref="Internal"/>
77

8+
<!-- Prevent a "no sniffs were registered" error. -->
9+
<rule ref="Generic.PHP.BacktickOperator"/>
810
</ruleset>

tests/Core/Ruleset/ExpandRulesetReferenceInternalTest.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,30 @@ public function testInternalRefDoesNotGetExpanded()
4242

4343

4444
/**
45-
* While definitely not recommended, including a standard named "Internal", _does_ allow for sniffs to be registered.
45+
* As of PHPCS 4.0, a standard can no longer be named "Internal".
4646
*
47-
* Note: customizations (exclusions/property setting etc) for individual sniffs may not always be handled correctly,
48-
* which is why naming a standard "Internal" is definitely not recommended.
47+
* Standards with this name will be ignored.
4948
*
5049
* @return void
5150
*/
52-
public function testInternalStandardDoesGetExpanded()
51+
public function testInternalStandardIsNotSupported()
5352
{
54-
$message = 'DEPRECATED: The name "Internal" is reserved for internal use. A PHP_CodeSniffer standard should not be called "Internal".'.PHP_EOL;
53+
$message = 'ERROR: The name "Internal" is reserved for internal use. A PHP_CodeSniffer standard should not be called "Internal".'.PHP_EOL;
5554
$message .= 'Contact the maintainer of the standard to fix this.'.PHP_EOL.PHP_EOL;
5655

57-
$this->expectOutputString($message);
56+
$this->expectRuntimeExceptionMessage($message);
5857

5958
// Set up the ruleset.
6059
$standard = __DIR__.'/ExpandRulesetReferenceInternalStandardTest.xml';
6160
$config = new ConfigDouble(["--standard=$standard"]);
6261
$ruleset = new Ruleset($config);
6362

64-
$expected = ['Internal.Valid.Valid' => 'Fixtures\\Internal\\Sniffs\\Valid\\ValidSniff'];
63+
$expected = ['Generic.PHP.BacktickOperator' => 'PHP_CodeSniffer\\Standards\\Generic\\Sniffs\\PHP\\BacktickOperatorSniff'];
6564

65+
// This assertion will only take effect for PHPUnit 10+.
6666
$this->assertSame($expected, $ruleset->sniffCodes);
6767

68-
}//end testInternalStandardDoesGetExpanded()
68+
}//end testInternalStandardIsNotSupported()
6969

7070

7171
}//end class

0 commit comments

Comments
 (0)