From 64328d967d130ba5950a98b1d434fe317684c2c7 Mon Sep 17 00:00:00 2001 From: akimsko Date: Wed, 2 Jul 2014 11:31:46 +0200 Subject: [PATCH] [Console] Make sure formatter is the same The parent constructor will create a new formatter if the $formatter parameter is null This fix avoids that the formatter becomes 2 different instances in $this and $this->stderr --- src/Symfony/Component/Console/Output/ConsoleOutput.php | 2 +- .../Component/Console/Tests/Output/ConsoleOutputTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Output/ConsoleOutput.php b/src/Symfony/Component/Console/Output/ConsoleOutput.php index b5eaf154fa..3560f1c6fc 100644 --- a/src/Symfony/Component/Console/Output/ConsoleOutput.php +++ b/src/Symfony/Component/Console/Output/ConsoleOutput.php @@ -50,7 +50,7 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface parent::__construct(fopen($outputStream, 'w'), $verbosity, $decorated, $formatter); - $this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $formatter); + $this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $this->getFormatter()); } /** diff --git a/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php b/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php index 7a3ede3ba8..1afbbb6e6c 100644 --- a/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php @@ -20,5 +20,6 @@ class ConsoleOutputTest extends \PHPUnit_Framework_TestCase { $output = new ConsoleOutput(Output::VERBOSITY_QUIET, true); $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument'); + $this->assertSame($output->getFormatter(), $output->getErrorOutput()->getFormatter(), '__construct() takes a formatter or null as the third argument'); } }