Skip to content

Commit

Permalink
Fix parsing error in console when parameter description contains -- (
Browse files Browse the repository at this point in the history
  • Loading branch information
rxrw committed Aug 11, 2023
1 parent e95dc82 commit d522b86
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Illuminate/Console/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Parser
*
* @throws \InvalidArgumentException
*/
public static function parse($expression)
public static function parse(string $expression)
{
$name = static::name($expression);

Expand All @@ -35,7 +35,7 @@ public static function parse($expression)
*
* @throws \InvalidArgumentException
*/
protected static function name($expression)
protected static function name(string $expression)
{
if (! preg_match('/[^\s]+/', $expression, $matches)) {
throw new InvalidArgumentException('Unable to determine command name from signature.');
Expand All @@ -45,7 +45,7 @@ protected static function name($expression)
}

/**
* Extract all of the parameters from the tokens.
* Extract all parameters from the tokens.
*
* @param array $tokens
* @return array
Expand All @@ -57,7 +57,7 @@ protected static function parameters(array $tokens)
$options = [];

foreach ($tokens as $token) {
if (preg_match('/-{2,}(.*)/', $token, $matches)) {
if (preg_match('/^-{2,}(.*)/', $token, $matches)) {
$options[] = static::parseOption($matches[1]);
} else {
$arguments[] = static::parseArgument($token);
Expand All @@ -73,7 +73,7 @@ protected static function parameters(array $tokens)
* @param string $token
* @return \Symfony\Component\Console\Input\InputArgument
*/
protected static function parseArgument($token)
protected static function parseArgument(string $token)
{
[$token, $description] = static::extractDescription($token);

Expand All @@ -99,7 +99,7 @@ protected static function parseArgument($token)
* @param string $token
* @return \Symfony\Component\Console\Input\InputOption
*/
protected static function parseOption($token)
protected static function parseOption(string $token)
{
[$token, $description] = static::extractDescription($token);

Expand Down Expand Up @@ -132,7 +132,7 @@ protected static function parseOption($token)
* @param string $token
* @return array
*/
protected static function extractDescription($token)
protected static function extractDescription(string $token)
{
$parts = preg_split('/\s+:\s+/', trim($token), 2);

Expand Down

0 comments on commit d522b86

Please sign in to comment.