Skip to content

Commit 24c7a7f

Browse files
committed
Disable caching during test runs + allow -w to override -n from a ruleset
1 parent b469e78 commit 24c7a7f

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/Config.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,11 @@ public function restoreDefaults()
472472
$this->colors = (bool) $colors;
473473
}
474474

475-
$cache = self::getConfigData('cache');
476-
if ($cache !== null) {
477-
$this->cache = (bool) $cache;
475+
if (defined('PHP_CODESNIFFER_IN_TESTS') === false) {
476+
$cache = self::getConfigData('cache');
477+
if ($cache !== null) {
478+
$this->cache = (bool) $cache;
479+
}
478480
}
479481

480482
}//end restoreDefaults()
@@ -534,12 +536,16 @@ public function processShortArgument($arg, $pos)
534536
}
535537
break;
536538
case 'n' :
537-
$this->warningSeverity = 0;
538-
$this->overriddenDefaults['warningSeverity'] = true;
539+
if (isset($this->overriddenDefaults['warningSeverity']) === false) {
540+
$this->warningSeverity = 0;
541+
$this->overriddenDefaults['warningSeverity'] = true;
542+
}
539543
break;
540544
case 'w' :
541-
$this->warningSeverity = $this->errorSeverity;
542-
$this->overriddenDefaults['warningSeverity'] = true;
545+
if (isset($this->overriddenDefaults['warningSeverity']) === false) {
546+
$this->warningSeverity = $this->errorSeverity;
547+
$this->overriddenDefaults['warningSeverity'] = true;
548+
}
543549
break;
544550
default:
545551
if ($this->dieOnUnknownArg === false) {
@@ -579,8 +585,10 @@ public function processLongArgument($arg, $pos)
579585
$this->overriddenDefaults['colors'] = true;
580586
break;
581587
case 'cache':
582-
$this->cache = true;
583-
$this->overriddenDefaults['cache'] = true;
588+
if (defined('PHP_CODESNIFFER_IN_TESTS') === false) {
589+
$this->cache = true;
590+
$this->overriddenDefaults['cache'] = true;
591+
}
584592
break;
585593
case 'no-cache':
586594
$this->cache = false;

0 commit comments

Comments
 (0)