8000 bug #14654 [Console] SymfonyStyle : fix blocks failed when $messages … · symfony/symfony@3331f0a · GitHub
[go: up one dir, main page]

Skip to content

Commit 3331f0a

Browse files
committed
bug #14654 [Console] SymfonyStyle : fix blocks failed when $messages is null (ogizanagi)
This PR was merged into the 2.7 branch. Discussion ---------- [Console] SymfonyStyle : fix blocks failed when $messages is null | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Using `SymfonyStyle:block` method with `null` as first argument failed, where most of other methods accepting both string and array arguments will simply output an empty string. At first I wanted to output nothing, or even throw a proper exception. But then I realized how behaves other methods like text or write. I encountered this issue while executing a console application, in non-interactive mode, that asks questions (without default value) and prints the result immediately using a note block: ```php $output->note($output->choice('Choice question', array('choice 1', 'choice 2')); ``` ![screenshot 2015-05-16 a 11 42 47](https://cloud.githubusercontent.com/assets/2211145/7665616/ba5f343c-fbc0-11e4-811d-6b109aaa8d27.PNG) Commits ------- cfd1022 [Console] SymfonyStyle : fix blocks failed when $messages is null.
2 parents b248bd1 + cfd1022 commit 3331f0a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Console/Style/SymfonyStyle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(InputInterface $input, OutputInterface $output)
6060
*/
6161
public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
6262
{
63-
$messages = array_values((array) $messages);
63+
$messages = is_array($messages) ? array_values($messages) : array($messages);
6464
$lines = array();
6565

6666
// add type

0 commit comments

Comments
 (0)
0