diff --git a/src/Illuminate/Console/Parser.php b/src/Illuminate/Console/Parser.php index d70088e61beb..454d74c7d3a0 100644 --- a/src/Illuminate/Console/Parser.php +++ b/src/Illuminate/Console/Parser.php @@ -77,20 +77,14 @@ protected static function parseArgument(string $token) { [$token, $description] = static::extractDescription($token); - switch (true) { - case str_ends_with($token, '?*'): - return new InputArgument(trim($token, '?*'), InputArgument::IS_ARRAY, $description); - case str_ends_with($token, '*'): - return new InputArgument(trim($token, '*'), InputArgument::IS_ARRAY | InputArgument::REQUIRED, $description); - case str_ends_with($token, '?'): - return new InputArgument(trim($token, '?'), InputArgument::OPTIONAL, $description); - case preg_match('/(.+)\=\*(.+)/', $token, $matches): - return new InputArgument($matches[1], InputArgument::IS_ARRAY, $description, preg_split('/,\s?/', $matches[2])); - case preg_match('/(.+)\=(.+)/', $token, $matches): - return new InputArgument($matches[1], InputArgument::OPTIONAL, $description, $matches[2]); - default: - return new InputArgument($token, InputArgument::REQUIRED, $description); - } + return match (true) { + str_ends_with($token, '?*') => new InputArgument(trim($token, '?*'), InputArgument::IS_ARRAY, $description), + str_ends_with($token, '*') => new InputArgument(trim($token, '*'), InputArgument::IS_ARRAY | InputArgument::REQUIRED, $description), + str_ends_with($token, '?') => new InputArgument(trim($token, '?'), InputArgument::OPTIONAL, $description), + (bool) preg_match('/(.+)\=\*(.+)/', $token, $matches) => new InputArgument($matches[1], InputArgument::IS_ARRAY, $description, preg_split('/,\s?/', $matches[2])), + (bool) preg_match('/(.+)\=(.+)/', $token, $matches) => new InputArgument($matches[1], InputArgument::OPTIONAL, $description, $matches[2]), + default => new InputArgument($token, InputArgument::REQUIRED, $description), + }; } /**