From b23ed18b5a8bce3df926fd554c9dcbfe727c5eeb Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 28 Oct 2023 19:55:57 +0200 Subject: [PATCH] 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. --- CHANGELOG.md | 2 ++ src/Config.php | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 504590d55b..5899e1e894 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -161,6 +161,8 @@ The file documents changes to the PHP_CodeSniffer project. - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch - Fixed bug #3906 : Tokenizer/CSS: fixed a bug related to the unsupported slash comment syntax - Thanks to Dan Wallis (@fredden) for the patch +- Fixed bug #3913 : Config stored unknown "long" arguments in a (dynamic) `$values` property + - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch Props also to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) for reviewing quite a few of the PRs for this release. diff --git a/src/Config.php b/src/Config.php index 55c7598f2b..ee50bc79d9 100644 --- a/src/Config.php +++ b/src/Config.php @@ -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. }