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 d93b16f

Browse filesBrowse files
aitboudadfabpot
authored andcommitted
[console][TableCell] get cell width without decoration.
1 parent dc296cc commit d93b16f
Copy full SHA for d93b16f

File tree

Expand file treeCollapse file tree

1 file changed

+8
-7
lines changed
Filter options
  • src/Symfony/Component/Console/Helper
Expand file treeCollapse file tree

1 file changed

+8
-7
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/Table.php
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ private function fillNextRows($rows, $line)
385385
$unmergedRows = array();
386386
foreach ($rows[$line] as $column => $cell) {
387387
if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
388-
$nbLines = $cell->getRowspan()-1;
388+
$nbLines = $cell->getRowspan() - 1;
389389
$lines = array($cell);
390390
if (strstr($cell, "\n")) {
391391
$lines = explode("\n", $cell);
@@ -412,7 +412,7 @@ private function fillNextRows($rows, $line)
412412
array_splice($rows[$unmergedRowKey], $cellKey, 0, array($cell));
413413
}
414414
} else {
415-
$row = $this->copyRow($rows, $unmergedRowKey-1);
415+
$row = $this->copyRow($rows, $unmergedRowKey - 1);
416416
foreach ($unmergedRow as $column => $cell) {
417417
if (!empty($cell)) {
418418
$row[$column] = $unmergedRow[$column];
@@ -476,7 +476,7 @@ private function getNumberOfColumns(array $row)
476476
{
477477
$columns = count($row);
478478
foreach ($row as $column) {
479-
$columns += $column instanceof TableCell ? ($column->getColspan()-1) : 0;
479+
$columns += $column instanceof TableCell ? ($column->getColspan() - 1) : 0;
480480
}
481481

482482
return $columns;
@@ -491,11 +491,11 @@ private function getNumberOfColumns(array $row)
491491
*/
492492
private function getRowColumns($row)
493493
{
494-
$columns = range(0, $this->numberOfColumns-1);
494+
$columns = range(0, $this->numberOfColumns - 1);
495495
foreach ($row as $cellKey => $cell) {
496496
if ($cell instanceof TableCell && $cell->getColspan() > 1) {
497497
// exclude grouped columns.
498-
$columns = array_diff($columns, range($cellKey+1, $cellKey + $cell->getColspan()-1));
498+
$columns = array_diff($columns, range($cellKey + 1, $cellKey + $cell->getColspan() - 1));
499499
}
500500
}
501501

@@ -550,12 +550,13 @@ private function getCellWidth(array $row, $column)
550550
{
551551
if (isset($row[$column])) {
552552
$cell = $row[$column];
553+
$cellWidth = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
553554
if ($cell instanceof TableCell && $cell->getColspan() > 1) {
554555
// we assume that cell value will be across more than one column.
555-
$cell = substr($cell, 0, strlen($cell)/$cell->getColspan());
556+
$cellWidth = $cellWidth / $cell->getColspan();
556557
}
557558

558-
return Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
559+
return $cellWidth;
559560
}
560561

561562
return 0;

0 commit comments

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