Commit
…'s ruleset so that exclude rules do not get applied (ref #1169)
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -533,34 +533,51 @@ public function initStandard($standards, array $restrictions=array(), array $exc | |
// be detected properly for files created on a Mac with the /r line ending. | ||
ini_set('auto_detect_line_endings', true); | ||
|
||
$sniffs = array(); | ||
foreach ($standards as $standard) { | ||
$installed = $this->getInstalledStandardPath($standard); | ||
if (defined('PHP_CODESNIFFER_IN_TESTS') === true) { | ||
// Should be one standard and one sniff being tested at a time. | ||
$installed = $this->getInstalledStandardPath($standards[0]); | ||
if ($installed !== null) { | ||
$standard = $installed; | ||
} else { | ||
$standard = self::realpath($standard); | ||
$standard = self::realpath($standards[0]); | ||
if (is_dir($standard) === true | ||
&& is_file(self::realpath($standard.DIRECTORY_SEPARATOR.'ruleset.xml')) === true | ||
) { | ||
$standard = self::realpath($standard.DIRECTORY_SEPARATOR.'ruleset.xml'); | ||
} | ||
} | ||
|
||
if (PHP_CODESNIFFER_VERBOSITY === 1) { | ||
$ruleset = simplexml_load_string(file_get_contents($standard)); | ||
if ($ruleset !== false) { | ||
$standardName = (string) $ruleset['name']; | ||
$sniffs = $this->_expandRulesetReference($restrictions[0], dirname($standard)); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jrfnl
Contributor
|
||
} else { | ||
$sniffs = array(); | ||
foreach ($standards as $standard) { | ||
$installed = $this->getInstalledStandardPath($standard); | ||
if ($installed !== null) { | ||
$standard = $installed; | ||
} else { | ||
$standard = self::realpath($standard); | ||
if (is_dir($standard) === true | ||
&& is_file(self::realpath($standard.DIRECTORY_SEPARATOR.'ruleset.xml')) === true | ||
) { | ||
$standard = self::realpath($standard.DIRECTORY_SEPARATOR.'ruleset.xml'); | ||
} | ||
} | ||
|
||
echo "Registering sniffs in the $standardName standard... "; | ||
if (count($standards) > 1 || PHP_CODESNIFFER_VERBOSITY > 2) { | ||
echo PHP_EOL; | ||
if (PHP_CODESNIFFER_VERBOSITY === 1) { | ||
$ruleset = simplexml_load_string(file_get_contents($standard)); | ||
if ($ruleset !== false) { | ||
$standardName = (string) $ruleset['name']; | ||
} | ||
|
||
echo "Registering sniffs in the $standardName standard... "; | ||
if (count($standards) > 1 || PHP_CODESNIFFER_VERBOSITY > 2) { | ||
echo PHP_EOL; | ||
} | ||
} | ||
} | ||
|
||
$sniffs = array_merge($sniffs, $this->processRuleset($standard)); | ||
}//end foreach | ||
$sniffs = array_merge($sniffs, $this->processRuleset($standard)); | ||
}//end foreach | ||
}//end if | ||
|
||
$sniffRestrictions = array(); | ||
foreach ($restrictions as $sniffCode) { | ||
|
Uh oh... this will break when the default values are used with an
Undefined offset 0
notice.