diff --git a/package.xml b/package.xml index 7d9a17dd8d..5767e2b818 100644 --- a/package.xml +++ b/package.xml @@ -68,6 +68,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> -- The new error code is Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure -- All other multiple assignment cases use the existing error code Squiz.PHP.DisallowMultipleAssignments.Found -- Thanks to Juliette Reinders Folmer for the patch + - Fixed bug #2391 : Sniff-specific ignore rules inside rulesets are filtering out too many files + -- Thanks to Willington Vega for the patch - Fixed bug #2478 : FunctionCommentThrowTag.WrongNumber when exception is thrown once but built conditionally - Fixed bug #2479 : Generic.WhiteSpace.ScopeIndent error when using array destructing with exact indent checking - Fixed bug #2498 : Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed autofix breaks heredoc diff --git a/src/Filters/Filter.php b/src/Filters/Filter.php index 013e839492..ac39be29b6 100644 --- a/src/Filters/Filter.php +++ b/src/Filters/Filter.php @@ -199,7 +199,17 @@ protected function shouldIgnorePath($path) $this->ignoreDirPatterns = []; $this->ignoreFilePatterns = []; - $ignorePatterns = array_merge($this->config->ignored, $this->ruleset->getIgnorePatterns()); + $ignorePatterns = $this->config->ignored; + $rulesetIgnorePatterns = $this->ruleset->getIgnorePatterns(); + foreach ($rulesetIgnorePatterns as $pattern => $type) { + // Ignore standard/sniff specific exclude rules. + if (is_array($type) === true) { + continue; + } + + $ignorePatterns[$pattern] = $type; + } + foreach ($ignorePatterns as $pattern => $type) { // If the ignore pattern ends with /* then it is ignoring an entire directory. if (substr($pattern, -2) === '/*') { @@ -214,7 +224,7 @@ protected function shouldIgnorePath($path) $this->ignoreFilePatterns[$pattern] = $type; } } - } + }//end if $relativePath = $path; if (strpos($path, $this->basedir) === 0) { @@ -229,11 +239,6 @@ protected function shouldIgnorePath($path) } foreach ($ignorePatterns as $pattern => $type) { - // Ignore standard/sniff specific exclude rules. - if (is_array($type) === true) { - continue; - } - // Maintains backwards compatibility in case the ignore pattern does // not have a relative/absolute value. if (is_int($pattern) === true) { diff --git a/tests/Core/Filters/Filter/AcceptTest.php b/tests/Core/Filters/Filter/AcceptTest.php index d988b8ccbb..51e41a023e 100644 --- a/tests/Core/Filters/Filter/AcceptTest.php +++ b/tests/Core/Filters/Filter/AcceptTest.php @@ -41,7 +41,7 @@ class AcceptTest extends TestCase public static function setUpBeforeClass() { $standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml'; - self::$config = new Config(["--standard=$standard"]); + self::$config = new Config(["--standard=$standard", "--ignore=*/somethingelse/*"]); self::$ruleset = new Ruleset(self::$config); }//end setUpBeforeClass() @@ -88,6 +88,7 @@ public function dataExcludePatterns() [ '/path/to/src/Main.php', '/path/to/src/Something/Main.php', + '/path/to/src/Somethingelse/Main.php', '/path/to/src/Other/Main.php', ], ['/path/to/src/Main.php'], diff --git a/tests/Core/Filters/Filter/AcceptTest.xml b/tests/Core/Filters/Filter/AcceptTest.xml index 73595ba3a7..3d3e1de080 100644 --- a/tests/Core/Filters/Filter/AcceptTest.xml +++ b/tests/Core/Filters/Filter/AcceptTest.xml @@ -2,15 +2,15 @@ Ruleset to test the filtering based on exclude patterns. - - */something/* - - */Other/Main\.php$ + + */something/* + + */Other/Main\.php$ - + /anything/* - + /YetAnother/Main\.php