Skip to content

Commit 519d710

Browse files
committed
Ruleset: hard deprecate support for standards called "Internal"
Support for standards called `Internal` was soft deprecated in PHPCS 3.12.0 This PR adds a new Ruleset deprecation notice for when such a standard would be requested from a ruleset. Support for sniffs not following the naming conventions will be removed in PHPCS 4.0. Includes test. Related to 799
1 parent 7139974 commit 519d710

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
@@ -875,6 +875,13 @@ private function expandSniffDirectory($directory, $depth=0)
875875
*/
876876
private function expandRulesetReference($ref, $rulesetDir, $depth=0)
877877
{
878+
// Naming an (external) standard "Internal" is deprecated.
879+
if (strtolower($ref) === 'internal') {
880+
$message = 'The name "Internal" is reserved for internal use. A PHP_CodeSniffer standard should not be called "Internal".'.PHP_EOL;
881+
$message .= 'Contact the maintainer of the standard to fix this.';
882+
$this->msgCache->add($message, MessageCollector::DEPRECATED);
883+
}
884+
878885
// Ignore internal sniffs codes as they are used to only
879886
// hide and change internal messages.
880887
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)