From 52ebe5b49186a15b1f83b0e71f6b513f8cc05293 Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Sun, 30 Jul 2023 22:56:35 +0700 Subject: [PATCH] fix: phpstan CLI no type specified --- phpstan-baseline.php | 85 -------------------------------------- system/CLI/BaseCommand.php | 4 ++ system/CLI/CLI.php | 26 ++++++++++++ system/CLI/Commands.php | 2 + system/CLI/Console.php | 2 + 5 files changed, 34 insertions(+), 85 deletions(-) diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 5302862f143a..edf7e2771bfb 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -31,91 +31,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/BaseModel.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\BaseCommand\\:\\:showError\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/BaseCommand.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\BaseCommand\\:\\:showHelp\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/BaseCommand.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\CLI\\:\\:beep\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/CLI.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\CLI\\:\\:clearScreen\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/CLI.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\CLI\\:\\:error\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/CLI.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\CLI\\:\\:fwrite\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/CLI.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\CLI\\:\\:generateDimensions\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/CLI.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\CLI\\:\\:init\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/CLI.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\CLI\\:\\:newLine\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/CLI.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\CLI\\:\\:parseCommandLine\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/CLI.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\CLI\\:\\:print\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/CLI.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\CLI\\:\\:showProgress\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/CLI.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\CLI\\:\\:table\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/CLI.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\CLI\\:\\:wait\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/CLI.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\CLI\\:\\:write\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/CLI.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\Commands\\:\\:discoverCommands\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/Commands.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\CLI\\\\Console\\:\\:showHeader\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/CLI/Console.php', -]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\Cache\\\\CacheInterface\\:\\:initialize\\(\\) has no return type specified\\.$#', 'count' => 1, diff --git a/system/CLI/BaseCommand.php b/system/CLI/BaseCommand.php index 0c4abd2cea98..c4448d56b01a 100644 --- a/system/CLI/BaseCommand.php +++ b/system/CLI/BaseCommand.php @@ -117,6 +117,8 @@ protected function call(string $command, array $params = []) /** * A simple method to display an error with line/file, in child commands. + * + * @return void */ protected function showError(Throwable $e) { @@ -129,6 +131,8 @@ protected function showError(Throwable $e) /** * Show Help includes (Usage, Arguments, Description, Options). + * + * @return void */ public function showHelp() { diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index 2798319b057d..044f9dbbc8fd 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -142,6 +142,8 @@ class CLI /** * Static "constructor". + * + * @return void */ public static function init() { @@ -429,6 +431,8 @@ protected static function validate(string $field, string $value, $rules): bool /** * Outputs a string to the CLI without any surrounding newlines. * Useful for showing repeating elements on a single line. + * + * @return void */ public static function print(string $text = '', ?string $foreground = null, ?string $background = null) { @@ -443,6 +447,8 @@ public static function print(string $text = '', ?string $foreground = null, ?str /** * Outputs a string to the cli on it's own line. + * + * @return void */ public static function write(string $text = '', ?string $foreground = null, ?string $background = null) { @@ -460,6 +466,8 @@ public static function write(string $text = '', ?string $foreground = null, ?str /** * Outputs an error to the CLI using STDERR instead of STDOUT + * + * @return void */ public static function error(string $text, string $foreground = 'light_red', ?string $background = null) { @@ -481,6 +489,8 @@ public static function error(string $text, string $foreground = 'light_red', ?st * Beeps a certain number of times. * * @param int $num The number of times to beep + * + * @return void */ public static function beep(int $num = 1) { @@ -493,6 +503,8 @@ public static function beep(int $num = 1) * * @param int $seconds Number of seconds * @param bool $countdown Show a countdown or not + * + * @return void */ public static function wait(int $seconds, bool $countdown = false) { @@ -529,6 +541,8 @@ public static function isWindows(): bool /** * Enter a number of empty lines + * + * @return void */ public static function newLine(int $num = 1) { @@ -542,6 +556,8 @@ public static function newLine(int $num = 1) * Clears the screen of output * * @codeCoverageIgnore + * + * @return void */ public static function clearScreen() { @@ -735,6 +751,8 @@ public static function getHeight(int $default = 32): int * Populates the CLI's dimensions. * * @codeCoverageIgnore + * + * @return void */ public static function generateDimensions() { @@ -778,6 +796,8 @@ public static function generateDimensions() * to update it. Set $thisStep = false to erase the progress bar. * * @param bool|int $thisStep + * + * @return void */ public static function showProgress($thisStep = 1, int $totalSteps = 10) { @@ -859,6 +879,8 @@ public static function wrap(?string $string = null, int $max = 0, int $padLeft = /** * Parses the command line it was called from and collects all * options and valid segments. + * + * @return void */ protected static function parseCommandLine() { @@ -998,6 +1020,8 @@ public static function getOptionString(bool $useLongOpts = false, bool $trim = f * * @param array $tbody List of rows * @param array $thead List of columns + * + * @return void */ public static function table(array $tbody, array $thead = []) { @@ -1096,6 +1120,8 @@ public static function table(array $tbody, array $thead = []) * solution down the road. * * @param resource $handle + * + * @return void */ protected static function fwrite($handle, string $string) { diff --git a/system/CLI/Commands.php b/system/CLI/Commands.php index 0358e8ad2e18..df28e533a354 100644 --- a/system/CLI/Commands.php +++ b/system/CLI/Commands.php @@ -78,6 +78,8 @@ public function getCommands() /** * Discovers all commands in the framework and within user code, * and collects instances of them to work with. + * + * @return void */ public function discoverCommands() { diff --git a/system/CLI/Console.php b/system/CLI/Console.php index 7f396ef2af0c..01c15eea3fad 100644 --- a/system/CLI/Console.php +++ b/system/CLI/Console.php @@ -39,6 +39,8 @@ public function run() /** * Displays basic information about the Console. + * + * @return void */ public function showHeader(bool $suppress = false) {