From 7f2207615ea381552ebd88940b6a2b00d7064d7b Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 11 Sep 2025 14:39:49 +0200 Subject: [PATCH] Fix `null` array access in `Colors.php` Using null as an array offset is deprecated in PHP 85 --- lib/cli/Colors.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cli/Colors.php b/lib/cli/Colors.php index 2c15d9d..c8f5ab4 100644 --- a/lib/cli/Colors.php +++ b/lib/cli/Colors.php @@ -92,7 +92,7 @@ static public function color($color) { $colors = array(); foreach (array('color', 'style', 'background') as $type) { $code = $color[$type]; - if (isset(self::$_colors[$type][$code])) { + if (isset($code) && isset(self::$_colors[$type][$code])) { $colors[] = self::$_colors[$type][$code]; } } @@ -147,7 +147,7 @@ static public function colorize($string, $colored = null) { */ static public function decolorize( $string, $keep = 0 ) { $string = (string) $string; - + if ( ! ( $keep & 1 ) ) { // Get rid of color tokens if they exist $string = str_replace('%%', '%¾', $string); @@ -214,7 +214,7 @@ static public function width( $string, $pre_colorized = false, $encoding = false */ static public function pad( $string, $length, $pre_colorized = false, $encoding = false, $pad_type = STR_PAD_RIGHT ) { $string = (string) $string; - + $real_length = self::width( $string, $pre_colorized, $encoding ); $diff = strlen( $string ) - $real_length; $length += $diff;