Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2k
refactor: fix phpstan only boolean allowed#9302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
136dfa6beea1bca92b2be26f3fb60bae34cFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -225,12 +225,12 @@ public static function prompt(string $field, $options = null, $validation = null | ||
| $extraOutput = ''; | ||
| $default = ''; | ||
| if ($validation && ! is_array($validation) && ! is_string($validation)) { | ||
| if (isset($validation) && ! is_array($validation) && ! is_string($validation)) { | ||
| throw new InvalidArgumentException('$rules can only be of type string|array'); | ||
| } | ||
| if (! is_array($validation)) { | ||
| $validation = $validation ? explode('|', $validation) : []; | ||
| $validation = ($validation !== null) ? explode('|', $validation) : []; | ||
| } | ||
| if (is_string($options)) { | ||
| @@ -441,7 +441,7 @@ protected static function validate(string $field, string $value, $rules): bool | ||
| */ | ||
| public static function print(string $text = '', ?string $foreground = null, ?string $background = null) | ||
| { | ||
| if ($foreground || $background) { | ||
| if ((string) $foreground !== '' || (string) $background !== '') { | ||
| $text = static::color($text, $foreground, $background); | ||
| } | ||
| @@ -457,7 +457,7 @@ public static function print(string $text = '', ?string $foreground = null, ?str | ||
| */ | ||
| public static function write(string $text = '', ?string $foreground = null, ?string $background = null) | ||
| { | ||
| if ($foreground || $background) { | ||
| if ((string) $foreground !== '' || (string) $background !== '') { | ||
michalsn marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| $text = static::color($text, $foreground, $background); | ||
| } | ||
| @@ -480,7 +480,7 @@ public static function error(string $text, string $foreground = 'light_red', ?st | ||
| $stdout = static::$isColored; | ||
| static::$isColored = static::hasColorSupport(STDERR); | ||
| if ($foreground || $background) { | ||
| if ($foreground !== '' || (string) $background !== '') { | ||
michalsn marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| $text = static::color($text, $foreground, $background); | ||
| } | ||
| @@ -589,7 +589,7 @@ public static function color(string $text, string $foreground, ?string $backgrou | ||
| throw CLIException::forInvalidColor('foreground', $foreground); | ||
| } | ||
| if ($background !== null && ! array_key_exists($background, static::$background_colors)) { | ||
| if ((string) $background !== '' && ! array_key_exists($background, static::$background_colors)) { | ||
michalsn marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| throw CLIException::forInvalidColor('background', $background); | ||
| } | ||
| @@ -637,7 +637,7 @@ private static function getColoredText(string $text, string $foreground, ?string | ||
| { | ||
| $string = "\033[" . static::$foreground_colors[$foreground] . 'm'; | ||
| if ($background !== null) { | ||
| if ((string) $background !== '') { | ||
michalsn marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| $string .= "\033[" . static::$background_colors[$background] . 'm'; | ||
| } | ||
| @@ -654,7 +654,7 @@ private static function getColoredText(string $text, string $foreground, ?string | ||
| */ | ||
| public static function strlen(?string $string): int | ||
| { | ||
| if ($string === null) { | ||
| if ((string) $string === '') { | ||
| return 0; | ||
| } | ||
| @@ -768,7 +768,7 @@ public static function generateDimensions() | ||
| // Look for the next lines ending in ": <number>" | ||
| // Searching for "Columns:" or "Lines:" will fail on non-English locales | ||
| if ($return === 0 && $output && preg_match('/:\s*(\d+)\n[^:]+:\s*(\d+)\n/', implode("\n", $output), $matches)) { | ||
| if ($return === 0 && $output !== [] && preg_match('/:\s*(\d+)\n[^:]+:\s*(\d+)\n/', implode("\n", $output), $matches)) { | ||
| static::$height = (int) $matches[1]; | ||
| static::$width = (int) $matches[2]; | ||
| } | ||
| @@ -835,7 +835,7 @@ public static function showProgress($thisStep = 1, int $totalSteps = 10) | ||
| */ | ||
| public static function wrap(?string $string = null, int $max = 0, int $padLeft = 0): string | ||
| { | ||
| if ($string === null || $string === '') { | ||
| if ((string) $string === '') { | ||
| return ''; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.