Skip to content

Commit

Permalink
Fixed bug #2992 : Enabling caching using a ruleset produces invalid c…
Browse files Browse the repository at this point in the history
…ache files when using --sniffs and --exclude CLI args
  • Loading branch information
gsherwood committed Nov 20, 2020
1 parent c5d48fc commit bb906ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
-- This works around a long-standing PHP bug with is_readable()
-- Thanks to Michael S for the patch
- Fixed bug #2913 : Generic.WhiteSpace.ScopeIndent false positive when opening and closing tag on same line inside conditional
- Fixed bug #2992 : Enabling caching using a ruleset produces invalid cache files when using --sniffs and --exclude CLI args
- Fixed bug #3157 : PSR2.ControlStructures.SwitchDeclaration.BreakIndent false positive when case keyword is not indented
- Fixed bug #3165 : Squiz.PHP.DisallowComparisonAssignment false positive when comparison inside closure
- Fixed bug #3167 : Generic.WhiteSpace.ScopeIndent false positive when using PHP 8.0 constructor property promotion
Expand Down
16 changes: 8 additions & 8 deletions src/Ruleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,9 @@ class Ruleset
*/
public function __construct(Config $config)
{
// Ignore sniff restrictions if caching is on.
$restrictions = [];
$exclusions = [];
if ($config->cache === false) {
$restrictions = $config->sniffs;
$exclusions = $config->exclude;
}

$this->config = $config;
$restrictions = $config->sniffs;
$exclusions = $config->exclude;
$sniffs = [];

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

// Ignore sniff restrictions if caching is on.
if ($config->cache === true) {
$restrictions = [];
$exclusions = [];
}

$sniffRestrictions = [];
foreach ($restrictions as $sniffCode) {
$parts = explode('.', strtolower($sniffCode));
Expand Down

0 comments on commit bb906ff

Please sign in to comment.