[10.x] Fix prompt and console component spacing when calling another command #47928
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.
When using the
call
method in a command to call another command, we pass the parent'sOutputStyle
instance to be re-used by the child command:framework/src/Illuminate/Console/Concerns/CallsCommands.php
Lines 26 to 29 in 8e98688
This results in the
OutputStyle
instance being wrapped instance inside anotherOutputStyle
instance, and any trailing newline calculation performed in the outer wrapper is not available to the inner one used by the parent process:framework/src/Illuminate/Console/Command.php
Lines 169 to 173 in 8e98688
This PR solves this by only wrapping the output interface when it's not already an
OutputStyle
instance.An alternative would be to check if the received output instance is the same instance that we already have, rather than just the same class, but I can't think of any scenario where we'd still want the double wrapping. When using
callSilent
, we pass an instance ofNullOutput
to be used in the child command, which still works as expected.