Skip to content

Commit bb906ff

Browse files
committed
Fixed bug #2992 : Enabling caching using a ruleset produces invalid cache files when using --sniffs and --exclude CLI args
1 parent c5d48fc commit bb906ff

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
6262
-- This works around a long-standing PHP bug with is_readable()
6363
-- Thanks to Michael S for the patch
6464
- Fixed bug #2913 : Generic.WhiteSpace.ScopeIndent false positive when opening and closing tag on same line inside conditional
65+
- Fixed bug #2992 : Enabling caching using a ruleset produces invalid cache files when using --sniffs and --exclude CLI args
6566
- Fixed bug #3157 : PSR2.ControlStructures.SwitchDeclaration.BreakIndent false positive when case keyword is not indented
6667
- Fixed bug #3165 : Squiz.PHP.DisallowComparisonAssignment false positive when comparison inside closure
6768
- Fixed bug #3167 : Generic.WhiteSpace.ScopeIndent false positive when using PHP 8.0 constructor property promotion

src/Ruleset.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,9 @@ class Ruleset
126126
*/
127127
public function __construct(Config $config)
128128
{
129-
// Ignore sniff restrictions if caching is on.
130-
$restrictions = [];
131-
$exclusions = [];
132-
if ($config->cache === false) {
133-
$restrictions = $config->sniffs;
134-
$exclusions = $config->exclude;
135-
}
136-
137129
$this->config = $config;
130+
$restrictions = $config->sniffs;
131+
$exclusions = $config->exclude;
138132
$sniffs = [];
139133

140134
$standardPaths = [];
@@ -200,6 +194,12 @@ public function __construct(Config $config)
200194
$sniffs = array_merge($sniffs, $this->processRuleset($standard));
201195
}//end foreach
202196

197+
// Ignore sniff restrictions if caching is on.
198+
if ($config->cache === true) {
199+
$restrictions = [];
200+
$exclusions = [];
201+
}
202+
203203
$sniffRestrictions = [];
204204
foreach ($restrictions as $sniffCode) {
205205
$parts = explode('.', strtolower($sniffCode));

0 commit comments

Comments
 (0)