Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config::processLongArgument(): fix storing of unknown arguments #97

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
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