@@ -334,30 +334,31 @@ public function render()
334
334
}
335
335
}
336
336
} elseif ($ vertical ) {
337
- $ maxHeaderLength = array_reduce ($ this ->headers [0 ] ?? [], static fn (int $ max , string $ header ) => max ($ max , mb_strlen ($ header )), 0 );
337
+ $ formatter = $ this ->output ->getFormatter ();
338
+ $ maxHeaderLength = array_reduce ($ this ->headers [0 ] ?? [], static fn ($ max , $ header ) => max ($ max , Helper::width (Helper::removeDecoration ($ formatter , $ header ))), 0 );
338
339
339
340
foreach ($ this ->rows as $ row ) {
340
341
if ($ row instanceof TableSeparator) {
341
342
continue ;
342
343
}
343
344
344
- if (0 < \count ( $ rows) ) {
345
+ if ($ rows ) {
345
346
$ rows [] = [$ divider ];
346
347
}
347
348
348
- $ containsColspan = 0 < \count (array_filter ($ row , $ isCellWithColspan ));
349
+ $ containsColspan = \count (array_filter ($ row , $ isCellWithColspan ));
349
350
350
351
$ headers = $ this ->headers [0 ] ?? [];
351
352
$ maxRows = max (\count ($ headers ), \count ($ row ));
352
353
for ($ i = 0 ; $ i < $ maxRows ; ++$ i ) {
353
354
$ cell = (string ) ($ row [$ i ] ?? '' );
354
- if ([] !== $ headers && !$ containsColspan ) {
355
+ if ($ headers && !$ containsColspan ) {
355
356
$ rows [] = [sprintf (
356
357
'<comment>%s</>: %s ' ,
357
358
str_pad ($ headers [$ i ] ?? '' , $ maxHeaderLength , ' ' , \STR_PAD_LEFT ),
358
359
$ cell
359
360
)];
360
- } elseif (! empty ( $ cell) ) {
361
+ } elseif ('' !== $ cell ) {
361
362
$ rows [] = [$ cell ];
362
363
}
363
364
}
@@ -443,7 +444,7 @@ public function render()
443
444
*/
444
445
private function renderRowSeparator (int $ type = self ::SEPARATOR_MID , string $ title = null , string $ titleFormat = null )
445
446
{
446
- if (0 === $ count = $ this ->numberOfColumns ) {
447
+ if (! $ count = $ this ->numberOfColumns ) {
447
448
return ;
448
449
}
449
450
@@ -652,7 +653,7 @@ private function calculateRowCount(): int
652
653
++$ numberOfRows ; // Add row for header separator
653
654
}
654
655
655
- if (\count ( $ this ->rows ) > 0 ) {
656
+ if ($ this ->rows ) {
656
657
++$ numberOfRows ; // Add row for footer separator
657
658
}
658
659
0 commit comments