Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Fix parsing error in console when parameter description contains -- #48021

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading