Skip to content

[Console] TableCell Helper throws error if value is numeric #21429

Closed
@jaydiablo

Description

@jaydiablo
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 2.7+

When using the TableCell helper in the Console Component, if I pass a numeric value as the first parameter of the constructor, then render the table, PHP throws an error:

Method Symfony\Component\Console\Helper\TableCell::__toString() must return a string value

Sample code:

$table = new Table($output);
$table->setRows([[new TableCell(12345)]]);
$table->render();

Casting to a string (either in the TableCell helper, or before the value is passed to the constructor) fixes it.

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