Skip to content

Commit f12b650

Browse files
authored
Fix null array access in Colors.php (#188)
1 parent 3be67d9 commit f12b650

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/cli/Colors.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static public function color($color) {
9292
$colors = array();
9393
foreach (array('color', 'style', 'background') as $type) {
9494
$code = $color[$type];
95-
if (isset(self::$_colors[$type][$code])) {
95+
if (isset($code) && isset(self::$_colors[$type][$code])) {
9696
$colors[] = self::$_colors[$type][$code];
9797
}
9898
}
@@ -147,7 +147,7 @@ static public function colorize($string, $colored = null) {
147147
*/
148148
static public function decolorize( $string, $keep = 0 ) {
149149
$string = (string) $string;
150-
150+
151151
if ( ! ( $keep & 1 ) ) {
152152
// Get rid of color tokens if they exist
153153
$string = str_replace('%%', '', $string);
@@ -214,7 +214,7 @@ static public function width( $string, $pre_colorized = false, $encoding = false
214214
*/
215215
static public function pad( $string, $length, $pre_colorized = false, $encoding = false, $pad_type = STR_PAD_RIGHT ) {
216216
$string = (string) $string;
217-
217+
218218
$real_length = self::width( $string, $pre_colorized, $encoding );
219219
$diff = strlen( $string ) - $real_length;
220220
$length += $diff;

0 commit comments

Comments
 (0)