Skip to content

Commit

Permalink
Config::processLongArgument(): fix storing of unknown arguments
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrfnl committed Dec 5, 2023
1 parent 103a84d commit abd4bfc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1232,13 +1232,17 @@ public function processLongArgument($arg, $pos)
if ($this->dieOnUnknownArg === false) {
$eqPos = strpos($arg, '=');
try {
$unknown = $this->unknown;

if ($eqPos === false) {
$this->values[$arg] = $arg;
$unknown[$arg] = $arg;
} else {
$value = substr($arg, ($eqPos + 1));
$arg = substr($arg, 0, $eqPos);
$this->values[$arg] = $value;
$value = substr($arg, ($eqPos + 1));
$arg = substr($arg, 0, $eqPos);
$unknown[$arg] = $value;
}

$this->unknown = $unknown;
} catch (RuntimeException $e) {
// Value is not valid, so just ignore it.
}
Expand Down

0 comments on commit abd4bfc

Please sign in to comment.