fix: do not read an undefined offset when a value argument is last
The argument parser looked up the next command-line token via $argv[$key + 1] guarded only by count($argv) === 0. The remaining arguments array is not reindexed after earlier arguments are removed, so a value-taking argument placed last (after an unconsumed token) read an undefined offset and raised an Undefined array key warning under PHP 8, and the argument was set to empty instead of falling back to its default. Check that the next offset exists with isset().
This commit is contained in:
1 parent
e8a9b69c46
commit
06b3825ee5
2 files changed
+26
-1
No files matched your search
@@ -261,7 +261,9 @@ class Parser
|
||||
}
|
||||
|
||||
if (is_null($value)) {
|
||||
if (count($argv) === 0) {
|
||||
// The array is not reindexed as arguments are removed, so check the next
|
||||
// offset itself rather than the overall count.
|
||||
if (!isset($argv[$key + 1])) {
|
||||
return $argv;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user