Skip to content

Commit b23ed18

Browse files
committed
Config::processLongArgument(): fix storing of unknown arguments
These arguments should be stored in the `unknown` property. There is no `values` property. Note: the read/write logic is to prevent a `Indirect modification of overloaded property PHP_CodeSniffer\Config::$unknown has no effect` PHP notice.
1 parent 103a84d commit b23ed18

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ The file documents changes to the PHP_CodeSniffer project.
161161
- Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
162162
- Fixed bug #3906 : Tokenizer/CSS: fixed a bug related to the unsupported slash comment syntax
163163
- Thanks to Dan Wallis (@fredden) for the patch
164+
- Fixed bug #3913 : Config stored unknown "long" arguments in a (dynamic) `$values` property
165+
- Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
164166

165167
Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) for reviewing quite a few of the PRs for this release.
166168

src/Config.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,13 +1232,17 @@ public function processLongArgument($arg, $pos)
12321232
if ($this->dieOnUnknownArg === false) {
12331233
$eqPos = strpos($arg, '=');
12341234
try {
1235+
$unknown = $this->unknown;
1236+
12351237
if ($eqPos === false) {
1236-
$this->values[$arg] = $arg;
1238+
$unknown[$arg] = $arg;
12371239
} else {
1238-
$value = substr($arg, ($eqPos + 1));
1239-
$arg = substr($arg, 0, $eqPos);
1240-
$this->values[$arg] = $value;
1240+
$value = substr($arg, ($eqPos + 1));
1241+
$arg = substr($arg, 0, $eqPos);
1242+
$unknown[$arg] = $value;
12411243
}
1244+
1245+
$this->unknown = $unknown;
12421246
} catch (RuntimeException $e) {
12431247
// Value is not valid, so just ignore it.
12441248
}

0 commit comments

Comments
 (0)