Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2207831

Browse files
committed
[FrameworkBundle] Make use of stderr for non reliable output
1 parent a4edafb commit 2207831

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

src/Symfony/Bridge/Twig/Command/LintCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Console\Input\InputInterface;
1717
use Symfony\Component\Console\Input\InputOption;
1818
use Symfony\Component\Console\Output\OutputInterface;
19+
use Symfony\Component\Console\Output\ConsoleOutputInterface;
1920
use Symfony\Component\Console\Style\SymfonyStyle;
2021
use Symfony\Component\Finder\Finder;
2122

@@ -88,7 +89,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
8889
$io = new SymfonyStyle($input, $output);
8990

9091
if (null === $twig = $this->getTwigEnvironment()) {
91-
$io->error('The Twig environment needs to be set.');
92+
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
93+
$errorIo->error('The Twig environment needs to be set.');
9294

9395
return 1;
9496
}

src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Console\Input\InputArgument;
1616
use Symfony\Component\Console\Input\InputInterface;
1717
use Symfony\Component\Console\Output\OutputInterface;
18+
use Symfony\Component\Console\Output\ConsoleOutputInterface;
1819
use Symfony\Component\Console\Style\SymfonyStyle;
1920
use Symfony\Component\Console\Exception\LogicException;
2021
use Symfony\Component\Yaml\Yaml;
@@ -58,11 +59,12 @@ protected function configure()
5859
protected function execute(InputInterface $input, OutputInterface $output)
5960
{
6061
$io = new SymfonyStyle($input, $output);
62+
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
6163

6264
if (null === $name = $input->getArgument('name')) {
63-
$this->listBundles($io);
64-
$io->comment('Provide the name of a bundle as the first argument of this command to dump its configuration. (e.g. <comment>debug:config FrameworkBundle</comment>)');
65-
$io->comment('For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>debug:config FrameworkBundle serializer</comment> to dump the <comment>framework.serializer</comment> configuration)');
65+
$this->listBundles($errorIo);
66+
$errorIo->comment('Provide the name of a bundle as the first argument of this command to dump its configuration. (e.g. <comment>debug:config FrameworkBundle</comment>)');
67+
$errorIo->comment('For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>debug:config FrameworkBundle serializer</comment> to dump the <comment>framework.serializer</comment> configuration)');
6668

6769
return;
6870
}
@@ -94,7 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9496
try {
9597
$config = $this->getConfigForPath($config, $path, $extensionAlias);
9698
} catch (LogicException $e) {
97-
$io->error($e->getMessage());
99+
$errorIo->error($e->getMessage());
98100

99101
return;
100102
}

src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Console\Input\InputOption;
1818
use Symfony\Component\Console\Input\InputInterface;
1919
use Symfony\Component\Console\Output\OutputInterface;
20+
use Symfony\Component\Console\Output\ConsoleOutputInterface;
2021
use Symfony\Component\Console\Style\SymfonyStyle;
2122

2223
/**
@@ -70,8 +71,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
7071
$io = new SymfonyStyle($input, $output);
7172

7273
if (null === $name = $input->getArgument('name')) {
73-
$this->listBundles($io);
74-
$io->comment('Provide the name of a bundle as the first argument of this command to dump its default configuration. (e.g. <comment>config:dump-reference FrameworkBundle</comment>)');
74+
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
75+
$this->listBundles($errorIo);
76+
$errorIo->comment('Provide the name of a bundle as the first argument of this command to dump its default configuration. (e.g. <comment>config:dump-reference FrameworkBundle</comment>)');
7577

7678
return;
7779
}

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Console\Input\InputOption;
1717
use Symfony\Component\Console\Input\InputInterface;
1818
use Symfony\Component\Console\Output\OutputInterface;
19+
use Symfony\Component\Console\Output\ConsoleOutputInterface;
1920
use Symfony\Component\Console\Style\SymfonyStyle;
2021
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
2122
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -92,6 +93,8 @@ protected function configure()
9293
protected function execute(InputInterface $input, OutputInterface $output)
9394
{
9495
$io = new SymfonyStyle($input, $output);
96+
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
97+
9598
$this->validateInput($input);
9699
$object = $this->getContainerBuilder();
97100

@@ -105,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
105108
} elseif ($tag = $input->getOption('tag')) {
106109
$options = array('tag' => $tag, 'show_private' => $input->getOption('show-private'));
107110
} elseif ($name = $input->getArgument('name')) {
108-
$name = $this->findProperServiceName($input, $io, $object, $name);
111+
$name = $this->findProperServiceName($input, $errorIo, $object, $name);
109112
$options = array('id' => $name);
110113
} else {
111114
$options = array('show_private' => $input->getOption('show-private'));
@@ -115,15 +118,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
115118
$options['format'] = $input->getOption('format');
116119
$options['raw_text'] = $input->getOption('raw');
117120
$options['output'] = $io;
118-
$helper->describe($output, $object, $options);
121+
$helper->describe($io, $object, $options);
119122

120123
if (!$input->getArgument('name') && !$input->getOption('tag') && !$input->getOption('parameter') && $input->isInteractive()) {
121124
if ($input->getOption('tags')) {
122-
$io->comment('To search for a specific tag, re-run this command with a search term. (e.g. <comment>debug:container --tag=form.type</comment>)');
125+
$errorIo->comment('To search for a specific tag, re-run this command with a search term. (e.g. <comment>debug:container --tag=form.type</comment>)');
123126
} elseif ($input->getOption('parameters')) {
124-
$io->comment('To search for a specific parameter, re-run this command with a search term. (e.g. <comment>debug:container --parameter=kernel.debug</comment>)');
127+
$errorIo->comment('To search for a specific parameter, re-run this command with a search term. (e.g. <comment>debug:container --parameter=kernel.debug</comment>)');
125128
} else {
126-
$io->comment('To search for a specific service, re-run this command with a search term. (e.g. <comment>debug:container log</comment>)');
129+
$errorIo->comment('To search for a specific service, re-run this command with a search term. (e.g. <comment>debug:container log</comment>)');
127130
}
128131
}
129132
}

src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Console\Input\InputOption;
1717
use Symfony\Component\Console\Input\InputInterface;
1818
use Symfony\Component\Console\Output\OutputInterface;
19+
use Symfony\Component\Console\Output\ConsoleOutputInterface;
1920
use Symfony\Component\Console\Style\SymfonyStyle;
2021
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
2122

@@ -65,7 +66,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
6566
$options = array();
6667
if ($event = $input->getArgument('event')) {
6768
if (!$dispatcher->hasListeners($event)) {
68-
$io->warning(sprintf('The event "%s" does not have any registered listeners.', $event));
69+
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
70+
$errorIo->warning(sprintf('The event "%s" does not have any registered listeners.', $event));
6971

7072
return;
7173
}

0 commit comments

Comments
 (0)