diff --git a/src/Illuminate/Console/Parser.php b/src/Illuminate/Console/Parser.php index d70088e61beb..60ec1151417a 100644 --- a/src/Illuminate/Console/Parser.php +++ b/src/Illuminate/Console/Parser.php @@ -112,18 +112,13 @@ protected static function parseOption(string $token) $token = $matches[1]; } - switch (true) { - case str_ends_with($token, '='): - return new InputOption(trim($token, '='), $shortcut, InputOption::VALUE_OPTIONAL, $description); - case str_ends_with($token, '=*'): - return new InputOption(trim($token, '=*'), $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description); - case preg_match('/(.+)\=\*(.+)/', $token, $matches): - return new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description, preg_split('/,\s?/', $matches[2])); - case preg_match('/(.+)\=(.+)/', $token, $matches): - return new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL, $description, $matches[2]); - default: - return new InputOption($token, $shortcut, InputOption::VALUE_NONE, $description); - } + return match (true) { + str_ends_with($token, '=') => new InputOption(trim($token, '='), $shortcut, InputOption::VALUE_OPTIONAL, $description), + str_ends_with($token, '=*') => new InputOption(trim($token, '=*'), $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description), + (bool) preg_match('/(.+)\=\*(.+)/', $token, $matches) => new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description, preg_split('/,\s?/', $matches[2])), + (bool) preg_match('/(.+)\=(.+)/', $token, $matches) => new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL, $description, $matches[2]), + default => new InputOption($token, $shortcut, InputOption::VALUE_NONE, $description), + }; } /**