@@ -225,12 +225,12 @@ public static function prompt(string $field, $options = null, $validation = null
225225 $ extraOutput = '' ;
226226 $ default = '' ;
227227
228- if ($ validation && ! is_array ($ validation ) && ! is_string ($ validation )) {
228+ if (isset ( $ validation) && ! is_array ($ validation ) && ! is_string ($ validation )) {
229229 throw new InvalidArgumentException ('$rules can only be of type string|array ' );
230230 }
231231
232232 if (! is_array ($ validation )) {
233- $ validation = $ validation ? explode ('| ' , $ validation ) : [];
233+ $ validation = ( $ validation !== null && $ 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 || $ background ) {
444+ if ($ foreground !== null || $ background !== null ) {
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 || $ background ) {
460+ if ($ foreground !== null || $ background !== null ) {
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 ) {
483+ if ($ foreground !== '' || $ background !== null ) {
484484 $ text = static ::color ($ text , $ foreground , $ background );
485485 }
486486
@@ -768,7 +768,7 @@ public static function generateDimensions()
768768
769769 // Look for the next lines ending in ": <number>"
770770 // Searching for "Columns:" or "Lines:" will fail on non-English locales
771- if ($ return === 0 && $ output && preg_match ('/:\s*(\d+)\n[^:]+:\s*(\d+)\n/ ' , implode ("\n" , $ output ), $ matches )) {
771+ if ($ return === 0 && $ output !== [] && preg_match ('/:\s*(\d+)\n[^:]+:\s*(\d+)\n/ ' , implode ("\n" , $ output ), $ matches )) {
772772 static ::$ height = (int ) $ matches [1 ];
773773 static ::$ width = (int ) $ matches [2 ];
774774 }
0 commit comments