From 5c6298d7f7493017cce77d73362d110f9a6a23f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Tue, 8 Aug 2023 14:21:25 +0800 Subject: [PATCH 1/4] Fix: Remove the system-Format ignore errors. --- phpstan-baseline.php | 5 ----- system/Format/XMLFormatter.php | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 6d22593ffcab..005c075df5f5 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -956,11 +956,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Filters/Filters.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Format\\\\XMLFormatter\\:\\:arrayToXML\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Format/XMLFormatter.php', -]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\HTTP\\\\CLIRequest\\:\\:parseCommand\\(\\) has no return type specified\\.$#', 'count' => 1, diff --git a/system/Format/XMLFormatter.php b/system/Format/XMLFormatter.php index 322ac32d2abd..23ed57fadf84 100644 --- a/system/Format/XMLFormatter.php +++ b/system/Format/XMLFormatter.php @@ -53,6 +53,8 @@ public function format($data) * @see http://www.codexworld.com/convert-array-to-xml-in-php/ * * @param SimpleXMLElement $output + * + * @return void */ protected function arrayToXML(array $data, &$output) { From 9f7e031c4bc5689359b8d642bd10ca897740af72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Tue, 8 Aug 2023 14:26:06 +0800 Subject: [PATCH 2/4] Fix: Remove the system-Log ignore errors. --- phpstan-baseline.php | 15 --------------- system/Log/Exceptions/LogException.php | 6 ++++++ system/Log/Handlers/ChromeLoggerHandler.php | 2 ++ 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 005c075df5f5..7850a2ffd08d 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -1146,21 +1146,6 @@ 'count' => 4, 'path' => __DIR__ . '/system/Images/Handlers/ImageMagickHandler.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Log\\\\Exceptions\\\\LogException\\:\\:forInvalidLogLevel\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Log/Exceptions/LogException.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Log\\\\Exceptions\\\\LogException\\:\\:forInvalidMessageType\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Log/Exceptions/LogException.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Log\\\\Handlers\\\\ChromeLoggerHandler\\:\\:sendLogs\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Log/Handlers/ChromeLoggerHandler.php', -]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\Model\\:\\:chunk\\(\\) has parameter \\$userFunc with no signature specified for Closure\\.$#', 'count' => 1, diff --git a/system/Log/Exceptions/LogException.php b/system/Log/Exceptions/LogException.php index f79763622cc7..e90cd1a05c80 100644 --- a/system/Log/Exceptions/LogException.php +++ b/system/Log/Exceptions/LogException.php @@ -15,11 +15,17 @@ class LogException extends FrameworkException { + /** + * @return LogException + */ public static function forInvalidLogLevel(string $level) { return new static(lang('Log.invalidLogLevel', [$level])); } + /** + * @return LogException + */ public static function forInvalidMessageType(string $messageType) { return new static(lang('Log.invalidMessageType', [$messageType])); diff --git a/system/Log/Handlers/ChromeLoggerHandler.php b/system/Log/Handlers/ChromeLoggerHandler.php index b2c6d28fdfb4..9ce30a822364 100644 --- a/system/Log/Handlers/ChromeLoggerHandler.php +++ b/system/Log/Handlers/ChromeLoggerHandler.php @@ -150,6 +150,8 @@ protected function format($object) * Attaches the header and the content to the passed in request object. * * @param ResponseInterface $response + * + * @return void */ public function sendLogs(?ResponseInterface &$response = null) { From 0a642941acb1556504595fcf67378285ad77cd83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Tue, 8 Aug 2023 14:30:20 +0800 Subject: [PATCH 3/4] Fix: Remove the system-Controller ignore errors. --- phpstan-baseline.php | 20 -------------------- system/Controller.php | 8 ++++++++ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 7850a2ffd08d..71a56d4bfa60 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -346,26 +346,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Config/View.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Controller\\:\\:cachePage\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Controller.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Controller\\:\\:forceHTTPS\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Controller.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Controller\\:\\:initController\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Controller.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Controller\\:\\:loadHelpers\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Controller.php', -]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_whereIn\\(\\) has parameter \\$values with no signature specified for Closure\\.$#', 'count' => 1, diff --git a/system/Controller.php b/system/Controller.php index 64de91ab2938..070cc76b88f5 100644 --- a/system/Controller.php +++ b/system/Controller.php @@ -70,6 +70,8 @@ class Controller /** * Constructor. * + * @return void + * * @throws HTTPException */ public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) @@ -96,6 +98,8 @@ public function initController(RequestInterface $request, ResponseInterface $res * considered secure for. Only with HSTS header. * Default value is 1 year. * + * @return void + * * @throws HTTPException */ protected function forceHTTPS(int $duration = 31_536_000) @@ -106,6 +110,8 @@ protected function forceHTTPS(int $duration = 31_536_000) /** * Provides a simple way to tie into the main CodeIgniter class and * tell it how long to cache the current page for. + * + * @return void */ protected function cachePage(int $time) { @@ -118,6 +124,8 @@ protected function cachePage(int $time) * @deprecated Use `helper` function instead of using this method. * * @codeCoverageIgnore + * + * @return void */ protected function loadHelpers() { From 7515670acdadfbc022f8574cd1604910eb3963f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E9=8A=98=E5=87=B1?= Date: Tue, 8 Aug 2023 20:23:47 +0800 Subject: [PATCH 4/4] Fix: Changed the FormatException and LogException return type to static. --- system/Format/Exceptions/FormatException.php | 8 ++++---- system/Log/Exceptions/LogException.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/system/Format/Exceptions/FormatException.php b/system/Format/Exceptions/FormatException.php index 5fef64eae2a1..cfe39d3b8307 100644 --- a/system/Format/Exceptions/FormatException.php +++ b/system/Format/Exceptions/FormatException.php @@ -25,7 +25,7 @@ class FormatException extends RuntimeException implements ExceptionInterface /** * Thrown when the instantiated class does not exist. * - * @return FormatException + * @return static */ public static function forInvalidFormatter(string $class) { @@ -38,7 +38,7 @@ public static function forInvalidFormatter(string $class) * * @param string $error * - * @return FormatException + * @return static */ public static function forInvalidJSON(?string $error = null) { @@ -49,7 +49,7 @@ public static function forInvalidJSON(?string $error = null) * Thrown when the supplied MIME type has no * defined Formatter class. * - * @return FormatException + * @return static */ public static function forInvalidMime(string $mime) { @@ -60,7 +60,7 @@ public static function forInvalidMime(string $mime) * Thrown on XMLFormatter when the `simplexml` extension * is not installed. * - * @return FormatException + * @return static * * @codeCoverageIgnore */ diff --git a/system/Log/Exceptions/LogException.php b/system/Log/Exceptions/LogException.php index e90cd1a05c80..c5f8b97999af 100644 --- a/system/Log/Exceptions/LogException.php +++ b/system/Log/Exceptions/LogException.php @@ -16,7 +16,7 @@ class LogException extends FrameworkException { /** - * @return LogException + * @return static */ public static function forInvalidLogLevel(string $level) { @@ -24,7 +24,7 @@ public static function forInvalidLogLevel(string $level) } /** - * @return LogException + * @return static */ public static function forInvalidMessageType(string $messageType) {