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 f4066a6

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

File tree

Expand file treeCollapse file tree

2 files changed

+22
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+22
-1
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_string($cell) && !$cell instanceof TableCell) {
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
+17-1Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ public function testRenderMultiByte()
552552
$table = new Table($output = $this->getOutputStream());
553553
$table
554554
->setHeaders(array('■■'))
555-
->setRows(array(array(1234)))
555+
->setRows(array(array(new TableCell(1234))))
556556
->setStyle('default')
557557
;
558558
$table->render();
@@ -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.