Skip to content

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

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy