Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e6bdca2

Browse filesBrowse files
author
Amrouche Hamza
committed
[Console] Provide a bugfix where an array could be passed
1 parent 17b5a2c commit e6bdca2
Copy full SHA for e6bdca2

File tree

2 files changed

+21
-0
lines changed
Filter options

2 files changed

+21
-0
lines changed

‎src/Symfony/Component/Console/Helper/Table.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/Table.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,16 @@ private function buildTableRows($rows)
454454
* @param int $line
455455
*
456456
* @return array
457+
*
458+
* @throws \UnexpectedValueException
457459
*/
458460
private function fillNextRows(array $rows, $line)
459461
{
460462
$unmergedRows = array();
461463
foreach ($rows[$line] as $column => $cell) {
464+
if (is_array($cell)) {
465+
throw new \UnexpectedValueException('The cell should always be a string, array given.');
466+
}
462467
if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
463468
$nbLines = $cell->getRowspan() - 1;
464469
$lines = array($cell);

‎src/Symfony/Component/Console/Tests/Helper/TableTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Helper/TableTest.php
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,22 @@ public function testColumnStyle()
726726
$this->assertEquals($expected, $this->getOutputContent($output));
727727
}
728728

729+
/**
730+
* @expectedException \UnexpectedValueException
731+
* @expectedExceptionMessage The cell should always be a string, array given.
732+
*/
733+
public function testThrows()
734+
{
735+
$table = new Table($output = $this->getOutputStream());
736+
$table
737+
->setHeaders(array('ISBN', 'Title', 'Author', 'Price'))
738+
->setRows(array(
739+
array('99921-58-10-7', array(), 'Dante Alighieri', '9.95'),
740+
));
741+
742+
$table->render();
743+
}
744+
729745
public function testColumnWith()
730746
{
731747
$table = new Table($output = $this->getOutputStream());

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.