Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 514410c

Browse filesBrowse files
committed
minor #1654 Split output to stderr and stdout (SpacePossum)
This PR was merged into the 1.12 branch. Discussion ---------- Split output to stderr and stdout For more correct testing I need symfony/symfony#17255 to be resolved. issue: #1579 (and others) Commits ------- 880f58d Split output to stderr and stdout.
2 parents c80959b + 880f58d commit 514410c
Copy full SHA for 514410c

File tree

1 file changed

+18
-14
lines changed
Filter options

1 file changed

+18
-14
lines changed

‎Symfony/CS/Console/Command/FixCommand.php

Copy file name to clipboardExpand all lines: Symfony/CS/Console/Command/FixCommand.php
+18-14Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,12 @@ protected function configure()
287287
protected function execute(InputInterface $input, OutputInterface $output)
288288
{
289289
// setup output
290-
$stdErr = ($output instanceof ConsoleOutputInterface) ? $output->getErrorOutput() : null;
291-
if ($stdErr && extension_loaded('xdebug')) {
290+
$stdErr = $output instanceof ConsoleOutputInterface
291+
? $output->getErrorOutput()
292+
: ('txt' === $reporter->getFormat() ? $output : null)
293+
;
294+
295+
if (null !== $stdErr && extension_loaded('xdebug')) {
292296
$stdErr->writeln(sprintf($stdErr->isDecorated() ? '<bg=yellow;fg=black;>%s</>' : '%s', 'You are running php-cs-fixer with xdebug enabled. This has a major impact on runtime performance.'));
293297
}
294298

@@ -346,8 +350,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
346350
throw new InvalidConfigurationException(sprintf('The config file "%s" does not return a "Symfony\CS\ConfigInterface" instance. Got: "%s".', $configFile, is_object($config) ? get_class($config) : gettype($config)));
347351
}
348352

349-
if ('txt' === $input->getOption('format')) {
350-
$output->writeln(sprintf('Loaded config from "%s"', $configFile));
353+
if (null !== $stdErr && $configFile) {
354+
$stdErr->writeln(sprintf('Loaded config from "%s".', $configFile));
351355
}
352356
} else {
353357
$config = $this->defaultConfig;
@@ -383,11 +387,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
383387
->resolve();
384388

385389
$config->fixers($resolver->getFixers());
386-
$showProgress = $resolver->getProgress();
390+
$showProgress = null !== $stdErr && $resolver->getProgress();
387391

388392
if ($showProgress) {
389-
$fileProcessedEventListener = function (FixerFileProcessedEvent $event) use ($output) {
390-
$output->write($event->getStatusAsString());
393+
$fileProcessedEventListener = function (FixerFileProcessedEvent $event) use ($stdErr) {
394+
$stdErr->write($event->getStatusAsString());
391395
};
392396

393397
$this->fixer->setEventDispatcher($this->eventDispatcher);
@@ -401,7 +405,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
401405
if ($showProgress) {
402406
$this->fixer->setEventDispatcher(null);
403407
$this->eventDispatcher->removeListener(FixerFileProcessedEvent::NAME, $fileProcessedEventListener);
404-
$output->writeln('');
408+
$stdErr->writeln('');
405409

406410
$legend = array();
407411
foreach (FixerFileProcessedEvent::getStatusMap() as $status) {
@@ -410,7 +414,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
410414
}
411415
}
412416

413-
$output->writeln('Legend: '.implode(', ', array_unique($legend)));
417+
$stdErr->writeln('Legend: '.implode(', ', array_unique($legend)));
414418
}
415419

416420
$i = 1;
@@ -534,16 +538,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
534538
break;
535539
}
536540

537-
if (!$this->errorsManager->isEmpty()) {
538-
$output->writeln('');
539-
$output->writeln('Files that were not fixed due to internal error:');
541+
if (null !== $stdErr && !$this->errorsManager->isEmpty()) {
542+
$stdErr->writeln('');
543+
$stdErr->writeln('Files that were not fixed due to internal error:');
540544

541545
foreach ($this->errorsManager->getErrors() as $i => $error) {
542-
$output->writeln(sprintf('%4d) %s', $i + 1, $error['filepath']));
546+
$stdErr->writeln(sprintf('%4d) %s', $i + 1, $error['filepath']));
543547
}
544548
}
545549

546-
return empty($changed) ? 0 : 1;
550+
return 0 === count($changed) ? 0 : 1;
547551
}
548552

549553
protected function getFixersHelp()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.