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 prompt and console component spacing when calling another command #47928

Merged
merged 1 commit into from
Aug 2, 2023

Conversation

jessarcher
Copy link
Member

When using the call method in a command to call another command, we pass the parent's OutputStyle instance to be re-used by the child command:

public function call($command, array $arguments = [])
{
return $this->runCommand($command, $arguments, $this->output);
}

This results in the OutputStyle instance being wrapped instance inside another OutputStyle instance, and any trailing newline calculation performed in the outer wrapper is not available to the inner one used by the parent process:

public function run(InputInterface $input, OutputInterface $output): int
{
$this->output = $this->laravel->make(
OutputStyle::class, ['input' => $input, 'output' => $output]
);

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 of NullOutput to be used in the child command, which still works as expected.

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.

2 participants