8000 [Console] Fix array to string conversion when using IO table by JhonnyL · Pull Request #18580 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console] Fix array to string conversion when using IO table #18580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Console] Fix array to string conversion when using IO table
  • Loading branch information
JhonnyL committed Apr 18, 2016
commit f18fd0dc240f52c8f96dbc82b123c60e9348a55d
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Style/SymfonyStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function caution($message)
*/
public function table(array $headers, array $rows)
{
$headers = array_map(function ($value) { return sprintf('<info>%s</>', $value); }, $headers);
$headers = array_map(function ($value) { return sprintf('<info>%s</>', is_array($value) ? (string) $value[0] : $value); }, $headers);

$table = new Table($this);
$table->setHeaders($headers);
Expand D DBDA own
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use Symfony\Component\Console\Helper\TableCell;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;

return function (InputInterface $input, OutputInterface $output) {
$headers = array(
array(new TableCell('Main table title', array('colspan' => 3))),
array('ISBN', 'Title', 'Author'),
);

$rows = array(
array(
'978-0521567817',
'De Monarchia',
new TableCell("Dante Alighieri\nspans multiple rows", array('rowspan' => 2)),
),
array('978-0804169127', 'Divine Comedy'),
);

$output = new SymfonyStyleWithForcedLineLength($input, $output);
$output->table($headers, $rows);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
------------------ --------------- ---------------------
Main table title ISBN
------------------ --------------- ---------------------
978-0521567817 De Monarchia Dante Alighieri
978-0804169127 Divine Comedy spans multiple rows
------------------ --------------- ---------------------

0