@@ -230,7 +230,7 @@ public static function prompt(string $field, $options = null, $validation = null
230230 }
231231
232232 if (! is_array ($ validation )) {
233- $ validation = ($ validation !== null && $ validation !== '' ) ? explode ('| ' , $ validation ) : [];
233+ $ validation = (( string ) $ validation !== '' ) ? explode ('| ' , $ validation ) : [];
234234 }
235235
236236 if (is_string ($ options )) {
@@ -441,7 +441,7 @@ protected static function validate(string $field, string $value, $rules): bool
441441 */
442442 public static function print (string $ text = '' , ?string $ foreground = null , ?string $ background = null )
443443 {
444- if ($ foreground !== null || $ background !== null ) {
444+ if (( string ) $ foreground !== '' || ( string ) $ background !== '' ) {
445445 $ text = static ::color ($ text , $ foreground , $ background );
446446 }
447447
@@ -457,7 +457,7 @@ public static function print(string $text = '', ?string $foreground = null, ?str
457457 */
458458 public static function write (string $ text = '' , ?string $ foreground = null , ?string $ background = null )
459459 {
460- if ($ foreground !== null || $ background !== null ) {
460+ if (( string ) $ foreground !== '' || ( string ) $ background !== '' ) {
461461 $ text = static ::color ($ text , $ foreground , $ background );
462462 }
463463
@@ -480,7 +480,7 @@ public static function error(string $text, string $foreground = 'light_red', ?st
480480 $ stdout = static ::$ isColored ;
481481 static ::$ isColored = static ::hasColorSupport (STDERR );
482482
483- if ($ foreground !== '' || $ background !== null ) {
483+ if ($ foreground !== '' || ( string ) $ background !== '' ) {
484484 $ text = static ::color ($ text , $ foreground , $ background );
485485 }
486486
@@ -589,7 +589,7 @@ public static function color(string $text, string $foreground, ?string $backgrou
589589 throw CLIException::forInvalidColor ('foreground ' , $ foreground );
590590 }
591591
592- if ($ background !== null && ! array_key_exists ($ background , static ::$ background_colors )) {
592+ if (( string ) $ background !== '' && ! array_key_exists ($ background , static ::$ background_colors )) {
593593 throw CLIException::forInvalidColor ('background ' , $ background );
594594 }
595595
@@ -637,7 +637,7 @@ private static function getColoredText(string $text, string $foreground, ?string
637637 {
638638 $ string = "\033[ " . static ::$ foreground_colors [$ foreground ] . 'm ' ;
639639
640- if ($ background !== null ) {
640+ if (( string ) $ background !== '' ) {
641641 $ string .= "\033[ " . static ::$ background_colors [$ background ] . 'm ' ;
642642 }
643643
@@ -654,7 +654,7 @@ private static function getColoredText(string $text, string $foreground, ?string
654654 */
655655 public static function strlen (?string $ string ): int
656656 {
657- if ($ string === null ) {
657+ if (( string ) $ string === '' ) {
658658 return 0 ;
659659 }
660660
@@ -835,7 +835,7 @@ public static function showProgress($thisStep = 1, int $totalSteps = 10)
835835 */
836836 public static function wrap (?string $ string = null , int $ max = 0 , int $ padLeft = 0 ): string
837837 {
838- if ($ string === null || $ string === '' ) {
838+ if (( string ) $ string === '' ) {
839839 return '' ;
840840 }
841841
0 commit comments