Skip to content

Commit d522b86

Browse files
authored
Fix parsing error in console when parameter description contains -- (#48021)
1 parent e95dc82 commit d522b86

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Illuminate/Console/Parser.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Parser
1616
*
1717
* @throws \InvalidArgumentException
1818
*/
19-
public static function parse($expression)
19+
public static function parse(string $expression)
2020
{
2121
$name = static::name($expression);
2222

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

4747
/**
48-
* Extract all of the parameters from the tokens.
48+
* Extract all parameters from the tokens.
4949
*
5050
* @param array $tokens
5151
* @return array
@@ -57,7 +57,7 @@ protected static function parameters(array $tokens)
5757
$options = [];
5858

5959
foreach ($tokens as $token) {
60-
if (preg_match('/-{2,}(.*)/', $token, $matches)) {
60+
if (preg_match('/^-{2,}(.*)/', $token, $matches)) {
6161
$options[] = static::parseOption($matches[1]);
6262
} else {
6363
$arguments[] = static::parseArgument($token);
@@ -73,7 +73,7 @@ protected static function parameters(array $tokens)
7373
* @param string $token
7474
* @return \Symfony\Component\Console\Input\InputArgument
7575
*/
76-
protected static function parseArgument($token)
76+
protected static function parseArgument(string $token)
7777
{
7878
[$token, $description] = static::extractDescription($token);
7979

@@ -99,7 +99,7 @@ protected static function parseArgument($token)
9999
* @param string $token
100100
* @return \Symfony\Component\Console\Input\InputOption
101101
*/
102-
protected static function parseOption($token)
102+
protected static function parseOption(string $token)
103103
{
104104
[$token, $description] = static::extractDescription($token);
105105

@@ -132,7 +132,7 @@ protected static function parseOption($token)
132132
* @param string $token
133133
* @return array
134134
*/
135-
protected static function extractDescription($token)
135+
protected static function extractDescription(string $token)
136136
{
137137
$parts = preg_split('/\s+:\s+/', trim($token), 2);
138138

0 commit comments

Comments
 (0)