[9.x] Improve input argument parsing for commands - #44662
Merged
Conversation
Member
|
Hi there. We fixed the failing tests on 9.x which are causing this PR to fail as well. Can you please rebase your PR with 9.x? Thanks |
Member
|
Please mark this as ready once you're done as draft PR's aren't reviewed. |
bert-w
marked this pull request as ready for review
October 27, 2022 12:53
crynobone
added a commit
to crynobone/framework
that referenced
this pull request
Nov 3, 2022
Calling `php artisan --version` now going to failed. Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
taylorotwell
pushed a commit
that referenced
this pull request
Nov 3, 2022
Member
|
I've decided to revert this PR. Please see #44888 for more info. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I noticed that whenever I would listen to the
CommandStarting/CommandFinishedevents, there was some functionality missing with theinputproperty on this event (\Symfony\Component\Console\Input\InputInterface). It appears that the input definition is not loaded at all and it causes thegetArguments()/getOptions()functions to be empty. So the following code would never work:Therefore I've added a few lines of code to
Illuminate\Console\Applicationto load the input definition directly from the command that is being called. Thecatchblock around calling$input->bind()appears to be a common thing judging by the occurrences in the Symfony codebase, I'm not sure why this is necessary.I've also just noticed by looking at this application structure, that Laravel is basically overriding some Symfony events (which DO work properly). Laravel calls its own
CommandStarting/CommandFinishedevents while there already is existing code in Symfony that uses their own (for instance https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/Console/Application.php#L1006 and https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/Console/Application.php#L1034). However, the Symfony commands cannot be listened to because there apparently is no event dispatcher attached in the Laravel override so these events are never sent.I'm not sure of the downsides of my addition so I've submitted this as a draft. Someone with more knowledge about the bootstrapping logic should have a look at this.