diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index 52102c26ff..b252ee274c 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -16,7 +16,6 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Finder\Finder; diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php index 4666d7bd12..685194fd7b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php @@ -74,9 +74,9 @@ EOF protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); + $errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io; if (null === $name = $input->getArgument('name')) { - $errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io; $this->listBundles($errorIo); $errorIo->comment(array( 'Provide the name of a bundle as the first argument of this command to dump its default configuration. (e.g. config:dump-reference FrameworkBundle)', @@ -96,7 +96,7 @@ EOF $path = $input->getArgument('path'); if ($path !== null && 'yaml' !== $format) { - $io->error('The "path" option is only available for the "yaml" format.'); + $errorIo->error('The "path" option is only available for the "yaml" format.'); return 1; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php index 299045d126..5bd23c5f5b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php @@ -12,6 +12,7 @@ namespace Symfony\Bundle\FrameworkBundle\Command; use Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader; +use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; @@ -159,7 +160,8 @@ EOF $outputMessage .= sprintf(' and domain "%s"', $domain); } - $io->warning($outputMessage); + $errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io; + $errorIo->warning($outputMessage); return; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index c2083e034e..67ceac02eb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -11,6 +11,7 @@ namespace Symfony\Bundle\FrameworkBundle\Command; +use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Translation\Catalogue\TargetOperation; use Symfony\Component\Translation\Catalogue\MergeOperation; @@ -85,10 +86,11 @@ EOF protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); + $errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io; // check presence of force or dump-message if ($input->getOption('force') !== true && $input->getOption('dump-messages') !== true) { - $io->error('You must choose one of --force or --dump-messages'); + $errorIo->error('You must choose one of --force or --dump-messages'); return 1; } @@ -97,7 +99,7 @@ EOF $writer = $this->getContainer()->get('translation.writer'); $supportedFormats = $writer->getFormats(); if (!in_array($input->getOption('output-format'), $supportedFormats)) { - $io->error(array('Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.')); + $errorIo->error(array('Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.')); return 1; } @@ -127,12 +129,12 @@ EOF } } - $io->title('Translation Messages Extractor and Dumper'); - $io->comment(sprintf('Generating "%s" translation files for "%s"', $input->getArgument('locale'), $currentName)); + $errorIo->title('Translation Messages Extractor and Dumper'); + $errorIo->comment(sprintf('Generating "%s" translation files for "%s"', $input->getArgument('locale'), $currentName)); // load any messages from templates $extractedCatalogue = new MessageCatalogue($input->getArgument('locale')); - $io->comment('Parsing templates...'); + $errorIo->comment('Parsing templates...'); $extractor = $this->getContainer()->get('translation.extractor'); $extractor->setPrefix($input->getOption('no-prefix') ? '' : $input->getOption('prefix')); foreach ($transPaths as $path) { @@ -144,7 +146,7 @@ EOF // load any existing messages from the translation files $currentCatalogue = new MessageCatalogue($input->getArgument('locale')); - $io->comment('Loading translation files...'); + $errorIo->comment('Loading translation files...'); $loader = $this->getContainer()->get('translation.loader'); foreach ($transPaths as $path) { $path .= 'translations'; @@ -165,7 +167,7 @@ EOF // Exit if no messages found. if (!count($operation->getDomains())) { - $io->warning('No translation messages were found.'); + $errorIo->warning('No translation messages were found.'); return; } @@ -199,7 +201,7 @@ EOF } if ($input->getOption('output-format') == 'xlf') { - $io->comment('Xliff output version is 1.2'); + $errorIo->comment('Xliff output version is 1.2'); } $resultMessage = sprintf('%d message%s successfully extracted', $extractedMessagesCount, $extractedMessagesCount > 1 ? 's were' : ' was'); @@ -211,7 +213,7 @@ EOF // save the files if ($input->getOption('force') === true) { - $io->comment('Writing files...'); + $errorIo->comment('Writing files...'); $bundleTransPath = false; foreach ($transPaths as $path) { @@ -232,7 +234,7 @@ EOF } } - $io->success($resultMessage.'.'); + $errorIo->success($resultMessage.'.'); } private function filterCatalogue(MessageCatalogue $catalogue, $domain) diff --git a/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php b/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php index 7151175d93..f9986ba9be 100644 --- a/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php +++ b/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php @@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Style\SymfonyStyle; @@ -85,8 +86,9 @@ EOF protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); + $errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io; - $input->isInteractive() ? $io->title('Symfony Password Encoder Utility') : $io->newLine(); + $input->isInteractive() ? $errorIo->title('Symfony Password Encoder Utility') : $errorIo->newLine(); $password = $input->getArgument('password'); $userClass = $input->getArgument('user-class'); @@ -101,12 +103,12 @@ EOF if (!$password) { if (!$input->isInteractive()) { - $io->error('The password must not be empty.'); + $errorIo->error('The password must not be empty.'); return 1; } $passwordQuestion = $this->createPasswordQuestion(); - $password = $io->askQuestion($passwordQuestion); + $password = $errorIo->askQuestion($passwordQuestion); } $salt = null; @@ -114,9 +116,9 @@ EOF if ($input->isInteractive() && !$emptySalt) { $emptySalt = true; - $io->note('The command will take care of generating a salt for you. Be aware that some encoders advise to let them generate their own salt. If you\'re using one of those encoders, please answer \'no\' to the question below. '.PHP_EOL.'Provide the \'empty-salt\' option in order to let the encoder handle the generation itself.'); + $errorIo->note('The command will take care of generating a salt for you. Be aware that some encoders advise to let them generate their own salt. If you\'re using one of those encoders, please answer \'no\' to the question below. '.PHP_EOL.'Provide the \'empty-salt\' option in order to let the encoder handle the generation itself.'); - if ($io->confirm('Confirm salt generation ?')) { + if ($errorIo->confirm('Confirm salt generation ?')) { $salt = $this->generateSalt(); $emptySalt = false; } @@ -136,12 +138,12 @@ EOF $io->table(array('Key', 'Value'), $rows); if (!$emptySalt) { - $io->note(sprintf('Make sure that your salt storage field fits the salt length: %s chars', strlen($salt))); + $errorIo->note(sprintf('Make sure that your salt storage field fits the salt length: %s chars', strlen($salt))); } elseif ($bcryptWithoutEmptySalt) { - $io->note('Bcrypt encoder used: the encoder generated its own built-in salt.'); + $errorIo->note('Bcrypt encoder used: the encoder generated its own built-in salt.'); } - $io->success('Password encoding succeeded'); + $errorIo->success('Password encoding succeeded'); } /**