Skip to content

Conversation

lyrixx
Copy link
Member

@lyrixx lyrixx commented Jul 4, 2025

Q A
Branch? 7.2
Bug fix? yes
New feature? no
Deprecations? no
Issues
License MIT

Considereing the following code:

require __DIR__.'/vendor/autoload.php';

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand('a')]
class A
{
    public function __invoke(OutputInterface $output)
    {
        $output->writeln('Command A executed');

        return 0;
    }
}

#[AsCommand('b')]
class B
{
    public function __invoke(OutputInterface $output)
    {
        $output->writeln('Command B executed');

        return 0;
    }
}

#[AsCommand('main')]
class Main
{
    public function __construct(
        private Application $app
    ) {}

    public function __invoke(OutputInterface $output)
    {
        $this->app->setAutoExit(false);

        $this->app->run(new ArgvInput([__FILE__, 'a', '--quiet']));

        $this->app->run(new ArgvInput([__FILE__, 'b']));

        $output->writeln('Main command executed');

        return 0;
    }
}

$app = new Application();
$app->addCommand(new A());
$app->addCommand(new B());
$app->addCommand(new Main($app));

$app->run();

Without this patch,

  • the output of B command is not displayed. It should be!
  • But the output Main command executed is. It should be, it's correct. But it's hard to understand. the current $output has already been configured, and it's not silenced by --quiet yet

@lyrixx lyrixx requested a review from chalasr as a code owner July 4, 2025 08:54
@carsonbot carsonbot added this to the 7.2 milestone Jul 4, 2025
@OskarStark OskarStark changed the title [Console] Restore SHELL_VERBOSITY after a command is ran [Console] Restore SHELL_VERBOSITY after a command is ran Jul 4, 2025
@lyrixx lyrixx force-pushed the shell-verbosity branch from 236c06a to 1d0837c Compare July 4, 2025 15:42
@lyrixx
Copy link
Member Author

lyrixx commented Aug 6, 2025

ping @GromNaN & @chalasr

@chalasr
Copy link
Member

chalasr commented Aug 6, 2025

Looks good. Can you think of a test case that would help avoiding regressions?

@lyrixx lyrixx changed the base branch from 7.2 to 7.3 August 6, 2025 16:14
@lyrixx
Copy link
Member Author

lyrixx commented Aug 6, 2025

I added tests + rebased + targeted branch 7.3

@chalasr
Copy link
Member

chalasr commented Aug 6, 2025

👍 push needed to re-trigger the pipeline

@lyrixx lyrixx force-pushed the shell-verbosity branch 4 times, most recently from d53e95b to 3531989 Compare August 7, 2025 08:48
@lyrixx
Copy link
Member Author

lyrixx commented Aug 7, 2025

All green 🎉 Thanks for the review

@xabbuh xabbuh modified the milestones: 7.2, 7.3 Aug 14, 2025
@fabpot
Copy link
Member

fabpot commented Aug 23, 2025

Thank you @lyrixx.

@fabpot fabpot merged commit 7c54399 into symfony:7.3 Aug 23, 2025
11 checks passed
@lyrixx lyrixx deleted the shell-verbosity branch August 25, 2025 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants