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

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

merged 1 commit into from
Aug 11, 2023

Conversation

rxrw
Copy link
Contributor

@rxrw rxrw commented Aug 10, 2023

Overview

This PR addresses an issue in the Laravel Console's signature parser where it would produce incorrect results if a parameter description contained --.

Problem

When defining a command's signature in Laravel Console, if a parameter description included --, it would lead to incorrect parsing of the command. This could cause unexpected behavior or even application errors depending on how the command was defined.

Example

When I generate a new command with signature:

protected $signature = 'check:api-routing {route_file : The file containing the main api routes generated by `php artisan route:list --json`}';

This is will produce following result:

Description:
  Check the differences between the api routing and the api routing file

Usage:
  check:api-routing [options]

Options:
      --json`
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --env[=ENV]       The environment the command should run under
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Solution

I've made a targeted change to the regular expression used in the parameters method, specifically by adding a ^ to ensure that -- within a description does not interfere with the parsing process.

Here's a brief summary of the change:

  • Updated the regular expression in the parameters method to include ^, ensuring proper handling of -- within parameter descriptions.

Impact

This minor yet crucial fix ensures that developers can include -- in parameter descriptions without any parsing issues. It improves the robustness of Laravel Console's command definition and parsing capabilities.

Please review and let me know if you have any questions or need further changes.

@taylorotwell taylorotwell merged commit d522b86 into laravel:10.x Aug 11, 2023
35 of 41 checks passed
@rxrw rxrw deleted the fix-parsing-error-in-console-parameter-description branch August 12, 2023 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants