Skip to content

[Console] [TableHelper] [SymfonyStyle] - Array to String Conversion when using IO Table #18573

Closed
@lakhman

Description

@lakhman

I found a bug with the SymfonyStyle Console IO helper relating to the TableHelper.

Let's say we're creating a new table, 2 ways, manually and with the SymfonyStyle Helper.

$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'),
);

// The following works fine (when creating a regular table via the `Table` class)
$table = new Table($output);
$table->setHeaders($headers)->setRows($rows);
$table->render();

// Notice: Array to string conversion 
$io = new SymfonyStyle($input, $output);
$io->table($headers, $rows);

The issue seems to be down to this line: (looks like an easy fix)

https://github.com/symfony/console/blob/master/Style/SymfonyStyle.php#L216

Hopefully someone can create and apply a patch for future versions.

P.S: I love the SymfonyStyle Helper! Really Awesome DX initiative. I'd love to see a DX initiative to redesign the dev error page!

ping!: @javiereguiluz

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions