Skip to content

Commit 3c16453

Browse files
committed
fix: ensure strict comparison in preg_match calls and correct regex pattern
1 parent dad2b7b commit 3c16453

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/Parser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected static function parameters(array $tokens): array
5454
$options = [];
5555

5656
foreach ($tokens as $token) {
57-
if (preg_match('/-{2,}(.*)/', $token, $matches)) {
57+
if (preg_match('/^-{2,}(.*)/', $token, $matches)) {
5858
$options[] = static::parseOption($matches[1]);
5959
} else {
6060
$arguments[] = static::parseArgument($token);
@@ -79,13 +79,13 @@ protected static function parseArgument(string $token): InputArgument
7979
$description,
8080
),
8181
str_ends_with($token, '?') => new InputArgument(trim($token, '?'), InputArgument::OPTIONAL, $description),
82-
preg_match('/(.+)\=\*(.+)/', $token, $matches) => new InputArgument(
82+
preg_match('/(.+)\=\*(.+)/', $token, $matches) === 1 => new InputArgument(
8383
$matches[1],
8484
InputArgument::IS_ARRAY,
8585
$description,
8686
preg_split('/,\s?/', $matches[2]),
8787
),
88-
preg_match('/(.+)\=(.+)/', $token, $matches) => new InputArgument(
88+
preg_match('/(.+)\=(.+)/', $token, $matches) === 1 => new InputArgument(
8989
$matches[1],
9090
InputArgument::OPTIONAL,
9191
$description,

0 commit comments

Comments
 (0)