Skip to content

Commit 5f8ee9d

Browse files
committed
bug symfony#11272 [Console] Make sure formatter is the same. (akimsko)
This PR was submitted for the 2.5 branch but it was merged into the 2.3 branch instead (closes symfony#11272). Discussion ---------- [Console] Make sure formatter is the same. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | 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, if null was passed to the constructor. Commits ------- 64328d9 [Console] Make sure formatter is the same
2 parents 85af997 + 64328d9 commit 5f8ee9d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Symfony/Component/Console/Output/ConsoleOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = nu
5050

5151
parent::__construct(fopen($outputStream, 'w'), $verbosity, $decorated, $formatter);
5252

53-
$this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $formatter);
53+
$this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $this->getFormatter());
5454
}
5555

5656
/**

src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ public function testConstructor()
2020
{
2121
$output = new ConsoleOutput(Output::VERBOSITY_QUIET, true);
2222
$this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument');
23+
$this->assertSame($output->getFormatter(), $output->getErrorOutput()->getFormatter(), '__construct() takes a formatter or null as the third argument');
2324
}
2425
}

0 commit comments

Comments
 (0)