Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Ruleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.') {
Expand Down
5 changes: 5 additions & 0 deletions tests/Core/Ruleset/ExpandRulesetReferenceInternalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
Expand Down