@@ -78,7 +78,7 @@ public function setWidths(array $widths) {
7878 }
7979
8080 /**
81- * Set the contraint width for the table
81+ * Set the constraint width for the table
8282 *
8383 * @param int $constraintWidth
8484 */
@@ -123,32 +123,36 @@ public function border() {
123123 */
124124 public function row ( array $ row ) {
125125
126- $ extra_rows = array_fill ( 0 , count ( $ row ), array () );
127126 $ extra_row_count = 0 ;
128- foreach ( $ row as $ col => $ value ) {
129-
130- $ value = str_replace ( PHP_EOL , ' ' , $ value );
131-
132- $ col_width = $ this ->_widths [ $ col ];
133- $ original_val_width = Colors::length ( $ value );
134- if ( $ original_val_width > $ col_width ) {
135- $ row [ $ col ] = \cli \safe_substr ( $ value , 0 , $ col_width );
136- $ value = \cli \safe_substr ( $ value , $ col_width , $ original_val_width );
137- $ i = 0 ;
138- do {
139- $ extra_value = \cli \safe_substr ( $ value , 0 , $ col_width );
140- $ val_width = \cli \safe_strlen ( $ extra_value );
141- if ( $ val_width ) {
142- $ extra_rows [ $ col ][] = $ extra_value ;
143- $ value = \cli \safe_substr ( $ value , $ col_width , $ original_val_width );
144- $ i ++;
145- if ( $ i > $ extra_row_count ) {
146- $ extra_row_count = $ i ;
127+
128+ if ( count ( $ row ) > 0 ) {
129+ $ extra_rows = array_fill ( 0 , count ( $ row ), array () );
130+
131+ foreach ( $ row as $ col => $ value ) {
132+
133+ $ value = str_replace ( PHP_EOL , ' ' , $ value );
134+
135+ $ col_width = $ this ->_widths [ $ col ];
136+ $ original_val_width = Colors::length ( $ value );
137+ if ( $ original_val_width > $ col_width ) {
138+ $ row [ $ col ] = \cli \safe_substr ( $ value , 0 , $ col_width );
139+ $ value = \cli \safe_substr ( $ value , $ col_width , $ original_val_width );
140+ $ i = 0 ;
141+ do {
142+ $ extra_value = \cli \safe_substr ( $ value , 0 , $ col_width );
143+ $ val_width = \cli \safe_strlen ( $ extra_value );
144+ if ( $ val_width ) {
145+ $ extra_rows [ $ col ][] = $ extra_value ;
146+ $ value = \cli \safe_substr ( $ value , $ col_width , $ original_val_width );
147+ $ i ++;
148+ if ( $ i > $ extra_row_count ) {
149+ $ extra_row_count = $ i ;
150+ }
147151 }
148- }
149- } while ( $ value );
150- }
152+ } while ( $ value );
153+ }
151154
155+ }
152156 }
153157
154158 $ row = array_map (array ($ this , 'padColumn ' ), $ row , array_keys ($ row ));
0 commit comments