From e792d438cf6d5490905ed0c0b26ab316dc5541f2 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 30 Jun 2024 14:39:29 +0700 Subject: [PATCH 1/2] refactor: enable AddFunctionVoidReturnTypeWhereNoReturnRector to add void to functions --- rector.php | 2 ++ system/Common.php | 4 +--- system/Helpers/cookie_helper.php | 6 ++---- system/Helpers/kint_helper.php | 6 ++---- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/rector.php b/rector.php index c3c43879019d..df89a98bf808 100644 --- a/rector.php +++ b/rector.php @@ -58,6 +58,7 @@ use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector; use Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector; use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector; +use Rector\TypeDeclaration\Rector\Function_\AddFunctionVoidReturnTypeWhereNoReturnRector; use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector; use Utils\Rector\PassStrictParameterToFunctionParameterRector; use Utils\Rector\RemoveErrorSuppressInTryCatchStmtsRector; @@ -219,6 +220,7 @@ VersionCompareFuncCallToConstantRector::class, ExplicitBoolCompareRector::class, AddClosureVoidReturnTypeWhereNoReturnRector::class, + AddFunctionVoidReturnTypeWhereNoReturnRector::class, ]) ->withConfiguredRule(StringClassNameToClassConstantRector::class, [ // keep '\\' prefix string on string '\Foo\Bar' diff --git a/system/Common.php b/system/Common.php index f96e9f100f00..49b3d2896753 100644 --- a/system/Common.php +++ b/system/Common.php @@ -766,10 +766,8 @@ function lang(string $line, array $args = [], ?string $locale = null) * - notice * - info * - debug - * - * @return void */ - function log_message(string $level, string $message, array $context = []) + function log_message(string $level, string $message, array $context = []): void { // When running tests, we want to always ensure that the // TestLogger is running, which provides utilities for diff --git a/system/Helpers/cookie_helper.php b/system/Helpers/cookie_helper.php index 49e568346b68..f19ee0147eb4 100644 --- a/system/Helpers/cookie_helper.php +++ b/system/Helpers/cookie_helper.php @@ -35,7 +35,6 @@ * @param bool|null $httpOnly True makes the cookie accessible via http(s) only (no javascript) * @param string|null $sameSite The cookie SameSite value * - * @return void * * @see \CodeIgniter\HTTP\Response::setCookie() */ @@ -49,7 +48,7 @@ function set_cookie( ?bool $secure = null, ?bool $httpOnly = null, ?string $sameSite = null - ) { + ): void { $response = service('response'); $response->setCookie($name, $value, $expire, $domain, $path, $prefix, $secure, $httpOnly, $sameSite); } @@ -92,11 +91,10 @@ function get_cookie($index, bool $xssClean = false, ?string $prefix = '') * @param string $path the cookie path * @param string $prefix the cookie prefix * - * @return void * * @see \CodeIgniter\HTTP\Response::deleteCookie() */ - function delete_cookie($name, string $domain = '', string $path = '/', string $prefix = '') + function delete_cookie($name, string $domain = '', string $path = '/', string $prefix = ''): void { service('response')->deleteCookie($name, $domain, $path, $prefix); } diff --git a/system/Helpers/kint_helper.php b/system/Helpers/kint_helper.php index 075c162315aa..1f89dc78c55b 100644 --- a/system/Helpers/kint_helper.php +++ b/system/Helpers/kint_helper.php @@ -24,7 +24,7 @@ * * @codeCoverageIgnore Can't be tested ... exits */ - function dd(...$vars) + function dd(...$vars): void { // @codeCoverageIgnoreStart Kint::$aliases[] = 'dd'; @@ -71,10 +71,8 @@ function d(...$vars) */ /** * trace function - * - * @return void */ - function trace() + function trace(): void { Kint::$aliases[] = 'trace'; Kint::trace(); From acefa3c2148226dc0e9cb9da7ef3d7ae4d35dae6 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 30 Jun 2024 14:41:31 +0700 Subject: [PATCH 2/2] cs fix --- system/Helpers/cookie_helper.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/system/Helpers/cookie_helper.php b/system/Helpers/cookie_helper.php index f19ee0147eb4..27007104e68e 100644 --- a/system/Helpers/cookie_helper.php +++ b/system/Helpers/cookie_helper.php @@ -35,7 +35,6 @@ * @param bool|null $httpOnly True makes the cookie accessible via http(s) only (no javascript) * @param string|null $sameSite The cookie SameSite value * - * * @see \CodeIgniter\HTTP\Response::setCookie() */ function set_cookie( @@ -91,7 +90,6 @@ function get_cookie($index, bool $xssClean = false, ?string $prefix = '') * @param string $path the cookie path * @param string $prefix the cookie prefix * - * * @see \CodeIgniter\HTTP\Response::deleteCookie() */ function delete_cookie($name, string $domain = '', string $path = '/', string $prefix = ''): void