diff --git a/CodeSniffer.php b/CodeSniffer.php index e6ee68fccb..bc5fb5a010 100644 --- a/CodeSniffer.php +++ b/CodeSniffer.php @@ -794,6 +794,17 @@ private function _expandRulesetReference($sniff) return $referencedSniffs; } + // As sniffs can't begin with a full stop, assume sniffs in + // this format are relative paths and attempt to convert them + // to absolute paths. If this fails, let the sniff path run through + // the normal checks and have it fail as normal. + if (substr($sniff, 0, 1) === '.') { + $realpath = realpath(dirname(self::$standardDir).'/'.$sniff); + if ($realpath !== false) { + $sniff = $realpath; + } + } + $isDir = false; $path = $sniff; if (is_dir($sniff) === true) { diff --git a/package.xml b/package.xml index 42bf02dba8..83854fd489 100644 --- a/package.xml +++ b/package.xml @@ -34,6 +34,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> - Standards designed to be installed in the PHPCS Standards dir will now work outside this dir as well -- In particular, allows the Drupal CS to work without needing to symlink it into the PHPCS install -- Thanks to Peter Philipp for the patch + - Rule references for standards, directories and specific sniffs can now be relative in ruleset.xml files + -- For example: ref="../MyStandard/Sniffs/Commenting/DisallowHashCommentsSniff.php" - Squiz ObjectInstantiationSniff now allows objects to be returned without assinging them to a variable - Debug option -vv now shows tokenizer status for CSS files - Added support for new gjslint error formats