@@ -41,17 +41,17 @@ class Table
4141 /**
4242 * Table headers.
4343 */
44- private $ headers = array () ;
44+ private $ headers = [] ;
4545
4646 /**
4747 * Table rows.
4848 */
49- private $ rows = array () ;
49+ private $ rows = [] ;
5050
5151 /**
5252 * Column widths cache.
5353 */
54- private $ effectiveColumnWidths = array () ;
54+ private $ effectiveColumnWidths = [] ;
5555
5656 /**
5757 * Number of columns cache.
@@ -73,15 +73,15 @@ class Table
7373 /**
7474 * @var array
7575 */
76- private $ columnStyles = array () ;
76+ private $ columnStyles = [] ;
7777
7878 /**
7979 * User set column widths.
8080 *
8181 * @var array
8282 */
83- private $ columnWidths = array () ;
84- private $ columnMaxWidths = array () ;
83+ private $ columnWidths = [] ;
84+ private $ columnMaxWidths = [] ;
8585
8686 private static $ styles ;
8787
@@ -212,7 +212,7 @@ public function setColumnWidth($columnIndex, $width)
212212 */
213213 public function setColumnWidths (array $ widths )
214214 {
215- $ this ->columnWidths = array () ;
215+ $ this ->columnWidths = [] ;
216216 foreach ($ widths as $ index => $ width ) {
217217 $ this ->setColumnWidth ($ index , $ width );
218218 }
@@ -243,7 +243,7 @@ public function setHeaders(array $headers)
243243 {
244244 $ headers = array_values ($ headers );
245245 if (!empty ($ headers ) && !\is_array ($ headers [0 ])) {
246- $ headers = array ( $ headers) ;
246+ $ headers = [ $ headers] ;
247247 }
248248
249249 $ this ->headers = $ headers ;
@@ -253,7 +253,7 @@ public function setHeaders(array $headers)
253253
254254 public function setRows (array $ rows )
255255 {
256- $ this ->rows = array () ;
256+ $ this ->rows = [] ;
257257
258258 return $ this ->addRows ($ rows );
259259 }
@@ -339,7 +339,7 @@ public function setFooterTitle(?string $title): self
339339 */
340340 public function render ()
341341 {
342- $ rows = array_merge ($ this ->headers , array ( $ divider = new TableSeparator ()) , $ this ->rows );
342+ $ rows = array_merge ($ this ->headers , [ $ divider = new TableSeparator ()] , $ this ->rows );
343343 $ this ->calculateNumberOfColumns ($ rows );
344344
345345 $ rows = $ this ->buildTableRows ($ rows );
@@ -400,13 +400,13 @@ private function renderRowSeparator(int $type = self::SEPARATOR_MID, string $tit
400400
401401 $ crossings = $ this ->style ->getCrossingChars ();
402402 if (self ::SEPARATOR_MID === $ type ) {
403- list ($ horizontal , $ leftChar , $ midChar , $ rightChar ) = array ( $ borders [2 ], $ crossings [8 ], $ crossings [0 ], $ crossings [4 ]) ;
403+ list ($ horizontal , $ leftChar , $ midChar , $ rightChar ) = [ $ borders [2 ], $ crossings [8 ], $ crossings [0 ], $ crossings [4 ]] ;
404404 } elseif (self ::SEPARATOR_TOP === $ type ) {
405- list ($ horizontal , $ leftChar , $ midChar , $ rightChar ) = array ( $ borders [0 ], $ crossings [1 ], $ crossings [2 ], $ crossings [3 ]) ;
405+ list ($ horizontal , $ leftChar , $ midChar , $ rightChar ) = [ $ borders [0 ], $ crossings [1 ], $ crossings [2 ], $ crossings [3 ]] ;
406406 } elseif (self ::SEPARATOR_TOP_BOTTOM === $ type ) {
407- list ($ horizontal , $ leftChar , $ midChar , $ rightChar ) = array ( $ borders [0 ], $ crossings [9 ], $ crossings [10 ], $ crossings [11 ]) ;
407+ list ($ horizontal , $ leftChar , $ midChar , $ rightChar ) = [ $ borders [0 ], $ crossings [9 ], $ crossings [10 ], $ crossings [11 ]] ;
408408 } else {
409- list ($ horizontal , $ leftChar , $ midChar , $ rightChar ) = array ( $ borders [0 ], $ crossings [7 ], $ crossings [6 ], $ crossings [5 ]) ;
409+ list ($ horizontal , $ leftChar , $ midChar , $ rightChar ) = [ $ borders [0 ], $ crossings [7 ], $ crossings [6 ], $ crossings [5 ]] ;
410410 }
411411
412412 $ markup = $ leftChar ;
@@ -500,7 +500,7 @@ private function renderCell(array $row, int $column, string $cellFormat)
500500 */
501501 private function calculateNumberOfColumns ($ rows )
502502 {
503- $ columns = array ( 0 ) ;
503+ $ columns = [ 0 ] ;
504504 foreach ($ rows as $ row ) {
505505 if ($ row instanceof TableSeparator) {
506506 continue ;
@@ -516,7 +516,7 @@ private function buildTableRows($rows)
516516 {
517517 /** @var WrappableOutputFormatterInterface $formatter */
518518 $ formatter = $ this ->output ->getFormatter ();
519- $ unmergedRows = array () ;
519+ $ unmergedRows = [] ;
520520 for ($ rowKey = 0 ; $ rowKey < \count ($ rows ); ++$ rowKey ) {
521521 $ rows = $ this ->fillNextRows ($ rows , $ rowKey );
522522
@@ -531,7 +531,7 @@ private function buildTableRows($rows)
531531 $ lines = explode ("\n" , str_replace ("\n" , "<fg=default;bg=default> \n</> " , $ cell ));
532532 foreach ($ lines as $ lineKey => $ line ) {
533533 if ($ cell instanceof TableCell) {
534- $ line = new TableCell ($ line , array ( 'colspan ' => $ cell ->getColspan ()) );
534+ $ line = new TableCell ($ line , [ 'colspan ' => $ cell ->getColspan ()] );
535535 }
536536 if (0 === $ lineKey ) {
537537 $ rows [$ rowKey ][$ column ] = $ line ;
@@ -557,7 +557,7 @@ private function buildTableRows($rows)
557557
558558 private function calculateRowCount (): int
559559 {
560- $ numberOfRows = \count (iterator_to_array ($ this ->buildTableRows (array_merge ($ this ->headers , array ( new TableSeparator ()) , $ this ->rows ))));
560+ $ numberOfRows = \count (iterator_to_array ($ this ->buildTableRows (array_merge ($ this ->headers , [ new TableSeparator ()] , $ this ->rows ))));
561561
562562 if ($ this ->headers ) {
563563 ++$ numberOfRows ; // Add row for header separator
@@ -575,27 +575,27 @@ private function calculateRowCount(): int
575575 */
576576 private function fillNextRows (array $ rows , int $ line ): array
577577 {
578- $ unmergedRows = array () ;
578+ $ unmergedRows = [] ;
579579 foreach ($ rows [$ line ] as $ column => $ cell ) {
580580 if (null !== $ cell && !$ cell instanceof TableCell && !is_scalar ($ cell ) && !(\is_object ($ cell ) && method_exists ($ cell , '__toString ' ))) {
581581 throw new InvalidArgumentException (sprintf ('A cell must be a TableCell, a scalar or an object implementing __toString, %s given. ' , \gettype ($ cell )));
582582 }
583583 if ($ cell instanceof TableCell && $ cell ->getRowspan () > 1 ) {
584584 $ nbLines = $ cell ->getRowspan () - 1 ;
585- $ lines = array ( $ cell) ;
585+ $ lines = [ $ cell] ;
586586 if (strstr ($ cell , "\n" )) {
587587 $ lines = explode ("\n" , str_replace ("\n" , "<fg=default;bg=default> \n</> " , $ cell ));
588588 $ nbLines = \count ($ lines ) > $ nbLines ? substr_count ($ cell , "\n" ) : $ nbLines ;
589589
590- $ rows [$ line ][$ column ] = new TableCell ($ lines [0 ], array ( 'colspan ' => $ cell ->getColspan ()) );
590+ $ rows [$ line ][$ column ] = new TableCell ($ lines [0 ], [ 'colspan ' => $ cell ->getColspan ()] );
591591 unset($ lines [0 ]);
592592 }
593593
594594 // create a two dimensional array (rowspan x colspan)
595- $ unmergedRows = array_replace_recursive (array_fill ($ line + 1 , $ nbLines , array () ), $ unmergedRows );
595+ $ unmergedRows = array_replace_recursive (array_fill ($ line + 1 , $ nbLines , [] ), $ unmergedRows );
596596 foreach ($ unmergedRows as $ unmergedRowKey => $ unmergedRow ) {
597597 $ value = isset ($ lines [$ unmergedRowKey - $ line ]) ? $ lines [$ unmergedRowKey - $ line ] : '' ;
598- $ unmergedRows [$ unmergedRowKey ][$ column ] = new TableCell ($ value , array ( 'colspan ' => $ cell ->getColspan ()) );
598+ $ unmergedRows [$ unmergedRowKey ][$ column ] = new TableCell ($ value , [ 'colspan ' => $ cell ->getColspan ()] );
599599 if ($ nbLines === $ unmergedRowKey - $ line ) {
600600 break ;
601601 }
@@ -608,7 +608,7 @@ private function fillNextRows(array $rows, int $line): array
608608 if (isset ($ rows [$ unmergedRowKey ]) && \is_array ($ rows [$ unmergedRowKey ]) && ($ this ->getNumberOfColumns ($ rows [$ unmergedRowKey ]) + $ this ->getNumberOfColumns ($ unmergedRows [$ unmergedRowKey ]) <= $ this ->numberOfColumns )) {
609609 foreach ($ unmergedRow as $ cellKey => $ cell ) {
610610 // insert cell into row at cellKey position
611- array_splice ($ rows [$ unmergedRowKey ], $ cellKey , 0 , array ( $ cell) );
611+ array_splice ($ rows [$ unmergedRowKey ], $ cellKey , 0 , [ $ cell] );
612612 }
613613 } else {
614614 $ row = $ this ->copyRow ($ rows , $ unmergedRowKey - 1 );
@@ -617,7 +617,7 @@ private function fillNextRows(array $rows, int $line): array
617617 $ row [$ column ] = $ unmergedRow [$ column ];
618618 }
619619 }
620- array_splice ($ rows , $ unmergedRowKey , 0 , array ( $ row) );
620+ array_splice ($ rows , $ unmergedRowKey , 0 , [ $ row] );
621621 }
622622 }
623623
@@ -629,7 +629,7 @@ private function fillNextRows(array $rows, int $line): array
629629 */
630630 private function fillCells ($ row )
631631 {
632- $ newRow = array () ;
632+ $ newRow = [] ;
633633 foreach ($ row as $ column => $ cell ) {
634634 $ newRow [] = $ cell ;
635635 if ($ cell instanceof TableCell && $ cell ->getColspan () > 1 ) {
@@ -649,7 +649,7 @@ private function copyRow(array $rows, int $line): array
649649 foreach ($ row as $ cellKey => $ cellValue ) {
650650 $ row [$ cellKey ] = '' ;
651651 if ($ cellValue instanceof TableCell) {
652- $ row [$ cellKey ] = new TableCell ('' , array ( 'colspan ' => $ cellValue ->getColspan ()) );
652+ $ row [$ cellKey ] = new TableCell ('' , [ 'colspan ' => $ cellValue ->getColspan ()] );
653653 }
654654 }
655655
@@ -691,7 +691,7 @@ private function getRowColumns(array $row): array
691691 private function calculateColumnsWidth (iterable $ rows )
692692 {
693693 for ($ column = 0 ; $ column < $ this ->numberOfColumns ; ++$ column ) {
694- $ lengths = array () ;
694+ $ lengths = [] ;
695695 foreach ($ rows as $ row ) {
696696 if ($ row instanceof TableSeparator) {
697697 continue ;
@@ -742,7 +742,7 @@ private function getCellWidth(array $row, int $column): int
742742 */
743743 private function cleanup ()
744744 {
745- $ this ->effectiveColumnWidths = array () ;
745+ $ this ->effectiveColumnWidths = [] ;
746746 $ this ->numberOfColumns = null ;
747747 }
748748
@@ -783,14 +783,14 @@ private static function initStyles()
783783 ->setCrossingChars ('┼ ' , '╔ ' , '╤ ' , '╗ ' , '╢ ' , '╝ ' , '╧ ' , '╚ ' , '╟ ' , '╠ ' , '╪ ' , '╣ ' )
784784 ;
785785
786- return array (
786+ return [
787787 'default ' => new TableStyle (),
788788 'borderless ' => $ borderless ,
789789 'compact ' => $ compact ,
790790 'symfony-style-guide ' => $ styleGuide ,
791791 'box ' => $ box ,
792792 'box-double ' => $ boxDouble ,
793- ) ;
793+ ] ;
794794 }
795795
796796 private function resolveStyle ($ name )
0 commit comments