From 0daf54478607016ea6a3260e8a53d96a882938af Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 3 Mar 2025 15:48:39 +0100 Subject: [PATCH 1/3] Replace tabs in tables with 4 spaces --- lib/cli/table/Ascii.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/cli/table/Ascii.php b/lib/cli/table/Ascii.php index b2505e6..0bf9862 100644 --- a/lib/cli/table/Ascii.php +++ b/lib/cli/table/Ascii.php @@ -138,6 +138,7 @@ public function row( array $row ) { foreach ( $row as $col => $value ) { $value = $value ?: ''; + $value = str_replace( "\t", ' ', $value ); $col_width = $this->_widths[ $col ]; $encoding = function_exists( 'mb_detect_encoding' ) ? mb_detect_encoding( $value, null, true /*strict*/ ) : false; $original_val_width = Colors::width( $value, self::isPreColorized( $col ), $encoding ); From ab44ee39335b15350332a397319947d78ff40300 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 3 Mar 2025 16:58:20 +0100 Subject: [PATCH 2/3] Move to `padColumn` --- lib/cli/table/Ascii.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cli/table/Ascii.php b/lib/cli/table/Ascii.php index 0bf9862..525995b 100644 --- a/lib/cli/table/Ascii.php +++ b/lib/cli/table/Ascii.php @@ -138,7 +138,6 @@ public function row( array $row ) { foreach ( $row as $col => $value ) { $value = $value ?: ''; - $value = str_replace( "\t", ' ', $value ); $col_width = $this->_widths[ $col ]; $encoding = function_exists( 'mb_detect_encoding' ) ? mb_detect_encoding( $value, null, true /*strict*/ ) : false; $original_val_width = Colors::width( $value, self::isPreColorized( $col ), $encoding ); @@ -199,6 +198,7 @@ public function row( array $row ) { } private function padColumn($content, $column) { + $content = str_replace( "\t", ' ', $content ); return $this->_characters['padding'] . Colors::pad( $content, $this->_widths[ $column ], $this->isPreColorized( $column ) ) . $this->_characters['padding']; } From bc28236be22be7abfcf1f24a3014952106d5540f Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 3 Mar 2025 17:12:08 +0100 Subject: [PATCH 3/3] Cast to string --- lib/cli/table/Ascii.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cli/table/Ascii.php b/lib/cli/table/Ascii.php index 525995b..113c092 100644 --- a/lib/cli/table/Ascii.php +++ b/lib/cli/table/Ascii.php @@ -198,7 +198,7 @@ public function row( array $row ) { } private function padColumn($content, $column) { - $content = str_replace( "\t", ' ', $content ); + $content = str_replace( "\t", ' ', (string) $content ); return $this->_characters['padding'] . Colors::pad( $content, $this->_widths[ $column ], $this->isPreColorized( $column ) ) . $this->_characters['padding']; }