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.
This commit is contained in:
commit
3331f0adcd
@ -60,7 +60,7 @@ class SymfonyStyle extends OutputStyle
|
|||||||
*/
|
*/
|
||||||
public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
|
public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
|
||||||
{
|
{
|
||||||
$messages = array_values((array) $messages);
|
$messages = is_array($messages) ? array_values($messages) : array($messages);
|
||||||
$lines = array();
|
$lines = array();
|
||||||
|
|
||||||
// add type
|
// add type
|
||||||
|
Reference in New Issue
Block a user