Skip to content

Commit ad0926b

Browse files
committed
Fix usage of parameter --standard
1 parent 440d99d commit ad0926b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

CodeSniffer.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@ public static function autoload($className)
262262
} else if (is_file(dirname(__FILE__).'/CodeSniffer/Standards/'.$path) === true) {
263263
// Check for included sniffs.
264264
include dirname(__FILE__).'/CodeSniffer/Standards/'.$path;
265+
} else if (!empty($GLOBALS['phpcs'])
266+
&& ($values = $GLOBALS['phpcs']->getCommandLineValues())
267+
&& !empty($values['standard'])
268+
&& is_file(dirname($values['standard']).'/'.$path) === true
269+
) {
270+
// Check if this is a CLI run and the standard dir parameter is set.
271+
include dirname($values['standard']).'/'.$path;
265272
} else {
266273
// Everything else.
267274
@include $path;
@@ -796,6 +803,11 @@ private function _expandRulesetReference($sniff)
796803

797804
$path = $parts[0].'/Sniffs/'.$parts[1].'/'.$parts[2].'Sniff.php';
798805
$path = realpath(dirname(__FILE__).'/CodeSniffer/Standards/'.$path);
806+
807+
// Check if the standardDir parameter is set.
808+
if (!$path && !empty($this->standardDir)) {
809+
$path = realpath($this->standardDir.'/Sniffs/'.$parts[1].'/'.$parts[2].'Sniff.php');
810+
}
799811
}
800812
}//end if
801813

0 commit comments

Comments
 (0)