From 82ece196f1c046102b470c384ff2cbcf552f7843 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Wed, 10 Apr 2024 23:35:22 +0800 Subject: [PATCH 1/7] chore: Reverts disabling custom fixers for PHP 7.4 --- .php-cs-fixer.dist.php | 18 +++++++----------- .php-cs-fixer.no-header.php | 18 +++++++----------- .php-cs-fixer.tests.php | 18 +++++++----------- .php-cs-fixer.user-guide.php | 18 +++++++----------- 4 files changed, 28 insertions(+), 44 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index b47b4d6480c9..fc47ed2f87e5 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -43,20 +43,16 @@ $overrides = []; $options = [ - 'cacheFile' => 'build/.php-cs-fixer.cache', - 'finder' => $finder, + 'cacheFile' => 'build/.php-cs-fixer.cache', + 'finder' => $finder, + 'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'), + 'customRules' => [ + NoCodeSeparatorCommentFixer::name() => true, + ], ]; -$config = Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary( +return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary( 'CodeIgniter 4 framework', 'CodeIgniter Foundation', 'admin@codeigniter.com' ); - -$config - ->registerCustomFixers(FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer')) - ->setRules(array_merge($config->getRules(), [ - NoCodeSeparatorCommentFixer::name() => true, - ])); - -return $config; diff --git a/.php-cs-fixer.no-header.php b/.php-cs-fixer.no-header.php index 3729d434acba..cd10717aa5a2 100644 --- a/.php-cs-fixer.no-header.php +++ b/.php-cs-fixer.no-header.php @@ -32,16 +32,12 @@ $overrides = []; $options = [ - 'cacheFile' => 'build/.php-cs-fixer.no-header.cache', - 'finder' => $finder, -]; - -$config = Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects(); - -$config - ->registerCustomFixers(FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer')) - ->setRules(array_merge($config->getRules(), [ + 'cacheFile' => 'build/.php-cs-fixer.no-header.cache', + 'finder' => $finder, + 'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'), + 'customRules' => [ NoCodeSeparatorCommentFixer::name() => true, - ])); + ], +]; -return $config; +return Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects(); diff --git a/.php-cs-fixer.tests.php b/.php-cs-fixer.tests.php index c6b13a135a7c..7d5c1fad5e67 100644 --- a/.php-cs-fixer.tests.php +++ b/.php-cs-fixer.tests.php @@ -38,20 +38,16 @@ ]; $options = [ - 'cacheFile' => 'build/.php-cs-fixer.tests.cache', - 'finder' => $finder, + 'cacheFile' => 'build/.php-cs-fixer.tests.cache', + 'finder' => $finder, + 'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'), + 'customRules' => [ + NoCodeSeparatorCommentFixer::name() => true, + ], ]; -$config = Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary( +return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary( 'CodeIgniter 4 framework', 'CodeIgniter Foundation', 'admin@codeigniter.com' ); - -$config - ->registerCustomFixers(FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer')) - ->setRules(array_merge($config->getRules(), [ - NoCodeSeparatorCommentFixer::name() => true, - ])); - -return $config; diff --git a/.php-cs-fixer.user-guide.php b/.php-cs-fixer.user-guide.php index 9f9f9b79a464..6382201525e4 100644 --- a/.php-cs-fixer.user-guide.php +++ b/.php-cs-fixer.user-guide.php @@ -42,16 +42,12 @@ ]; $options = [ - 'cacheFile' => 'build/.php-cs-fixer.user-guide.cache', - 'finder' => $finder, -]; - -$config = Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects(); - -$config - ->registerCustomFixers(FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer')) - ->setRules(array_merge($config->getRules(), [ + 'cacheFile' => 'build/.php-cs-fixer.user-guide.cache', + 'finder' => $finder, + 'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'), + 'customRules' => [ NoCodeSeparatorCommentFixer::name() => true, - ])); + ], +]; -return $config; +return Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects(); From acdbc5dd0fb02bba0b87ef254d3d8b9ad2636796 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Thu, 11 Apr 2024 00:33:34 +0800 Subject: [PATCH 2/7] style: enable modernize_strpos --- .php-cs-fixer.dist.php | 5 ++++- .php-cs-fixer.no-header.php | 5 ++++- .php-cs-fixer.tests.php | 2 ++ .php-cs-fixer.user-guide.php | 2 ++ spark | 2 +- user_guide_src/source/libraries/curlrequest/012.php | 2 +- 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index b47b4d6480c9..dfd23faaf463 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -40,7 +40,10 @@ __DIR__ . '/spark', ]); -$overrides = []; +$overrides = [ + // for updating to coding-standard + 'modernize_strpos' => true, +]; $options = [ 'cacheFile' => 'build/.php-cs-fixer.cache', diff --git a/.php-cs-fixer.no-header.php b/.php-cs-fixer.no-header.php index 3729d434acba..34c4c3819f86 100644 --- a/.php-cs-fixer.no-header.php +++ b/.php-cs-fixer.no-header.php @@ -29,7 +29,10 @@ __DIR__ . '/admin/starter/builds', ]); -$overrides = []; +$overrides = [ + // for updating to coding-standard + 'modernize_strpos' => true, +]; $options = [ 'cacheFile' => 'build/.php-cs-fixer.no-header.cache', diff --git a/.php-cs-fixer.tests.php b/.php-cs-fixer.tests.php index c6b13a135a7c..e72378587e83 100644 --- a/.php-cs-fixer.tests.php +++ b/.php-cs-fixer.tests.php @@ -35,6 +35,8 @@ $overrides = [ 'void_return' => true, + // for updating to coding-standard + 'modernize_strpos' => true, ]; $options = [ diff --git a/.php-cs-fixer.user-guide.php b/.php-cs-fixer.user-guide.php index 9f9f9b79a464..a95fd5f1c0ff 100644 --- a/.php-cs-fixer.user-guide.php +++ b/.php-cs-fixer.user-guide.php @@ -39,6 +39,8 @@ 'import_symbols' => false, 'leading_backslash_in_global_namespace' => true, ], + // for updating to coding-standard + 'modernize_strpos' => true, ]; $options = [ diff --git a/spark b/spark index a56fbc1bd7b6..992d044c9ee2 100755 --- a/spark +++ b/spark @@ -25,7 +25,7 @@ */ // Refuse to run when called from php-cgi -if (strpos(PHP_SAPI, 'cgi') === 0) { +if (str_starts_with(PHP_SAPI, 'cgi')) { exit("The cli tool is not supported when running php-cgi. It needs php-cli to function!\n\n"); } diff --git a/user_guide_src/source/libraries/curlrequest/012.php b/user_guide_src/source/libraries/curlrequest/012.php index 59439c17d569..dfb37fa57bcc 100644 --- a/user_guide_src/source/libraries/curlrequest/012.php +++ b/user_guide_src/source/libraries/curlrequest/012.php @@ -1,5 +1,5 @@ header('content-type'), 'application/json') !== false) { +if (str_contains($response->header('content-type'), 'application/json')) { $body = json_decode($body); } From 55e0a3a3507d9537ba7a66c9c95bd596906c53f8 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 17 Apr 2024 09:05:10 +0900 Subject: [PATCH 3/7] docs: fix/add @return types --- phpstan-baseline.php | 25 ------------------------- system/Database/BaseConnection.php | 2 +- system/Database/MySQLi/Connection.php | 2 ++ system/Database/Postgre/Connection.php | 2 ++ system/Database/SQLSRV/Connection.php | 2 ++ system/Database/SQLite3/Connection.php | 2 ++ system/Test/Mock/MockConnection.php | 2 ++ 7 files changed, 11 insertions(+), 26 deletions(-) diff --git a/phpstan-baseline.php b/phpstan-baseline.php index cfee07815e8a..caaad61d6e84 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -3001,11 +3001,6 @@ 'count' => 11, 'path' => __DIR__ . '/system/Database/MySQLi/Connection.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\MySQLi\\\\Connection\\:\\:_close\\(\\) should return mixed but return statement is missing\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/MySQLi/Connection.php', -]; $ignoreErrors[] = [ 'message' => '#^Only booleans are allowed in &&, int given on the left side\\.$#', 'count' => 1, @@ -3391,11 +3386,6 @@ 'count' => 2, 'path' => __DIR__ . '/system/Database/Postgre/Connection.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Connection\\:\\:_close\\(\\) should return mixed but return statement is missing\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/Postgre/Connection.php', -]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Connection\\:\\:buildDSN\\(\\) has no return type specified\\.$#', 'count' => 1, @@ -3756,11 +3746,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/SQLSRV/Connection.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\SQLSRV\\\\Connection\\:\\:_close\\(\\) should return mixed but return statement is missing\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/SQLSRV/Connection.php', -]; $ignoreErrors[] = [ 'message' => '#^PHPDoc type string of property CodeIgniter\\\\Database\\\\SQLSRV\\\\Connection\\:\\:\\$escapeChar is not the same as PHPDoc type array\\|string of overridden property CodeIgniter\\\\Database\\\\BaseConnection\\\\:\\:\\$escapeChar\\.$#', 'count' => 1, @@ -3951,11 +3936,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/SQLite3/Connection.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\SQLite3\\\\Connection\\:\\:_close\\(\\) should return mixed but return statement is missing\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/SQLite3/Connection.php', -]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\Database\\\\SQLite3\\\\Connection\\:\\:getFieldNames\\(\\) return type has no value type specified in iterable type array\\.$#', 'count' => 1, @@ -8661,11 +8641,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Test/Mock/MockConnection.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockConnection\\:\\:_close\\(\\) should return mixed but return statement is missing\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Test/Mock/MockConnection.php', -]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockConnection\\:\\:_fieldData\\(\\) return type has no value type specified in iterable type array\\.$#', 'count' => 1, diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index b597c6d6cd10..77c9bd39ef3e 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -479,7 +479,7 @@ public function close() /** * Platform dependent way method for closing the connection. * - * @return mixed + * @return void */ abstract protected function _close(); diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index c2ef98adb0b3..b25f2e1af390 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -246,6 +246,8 @@ public function reconnect() /** * Close the database connection. + * + * @return void */ protected function _close() { diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php index bce4209c64d2..126aa98bb1c2 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -146,6 +146,8 @@ public function reconnect() /** * Close the database connection. + * + * @return void */ protected function _close() { diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php index 411470d8e34c..0626a63c998b 100755 --- a/system/Database/SQLSRV/Connection.php +++ b/system/Database/SQLSRV/Connection.php @@ -173,6 +173,8 @@ public function reconnect() /** * Close the database connection. + * + * @return void */ protected function _close() { diff --git a/system/Database/SQLite3/Connection.php b/system/Database/SQLite3/Connection.php index d15c64213952..945434184f33 100644 --- a/system/Database/SQLite3/Connection.php +++ b/system/Database/SQLite3/Connection.php @@ -110,6 +110,8 @@ public function reconnect() /** * Close the database connection. + * + * @return void */ protected function _close() { diff --git a/system/Test/Mock/MockConnection.php b/system/Test/Mock/MockConnection.php index 83826c347c98..020d6e3dd340 100644 --- a/system/Test/Mock/MockConnection.php +++ b/system/Test/Mock/MockConnection.php @@ -220,6 +220,8 @@ protected function _foreignKeyData(string $table): array /** * Close the connection. + * + * @return void */ protected function _close() { From 97f63ff041a5659a1fecbccf88e3b5bd7a80ccc7 Mon Sep 17 00:00:00 2001 From: obozdag Date: Wed, 17 Apr 2024 06:54:21 +0200 Subject: [PATCH 4/7] docs: Fix typo in table.rst Fix typo in table.rst, clear function description. --- user_guide_src/source/outgoing/table.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/outgoing/table.rst b/user_guide_src/source/outgoing/table.rst index bec15f86dbbf..0da5d1971d3d 100644 --- a/user_guide_src/source/outgoing/table.rst +++ b/user_guide_src/source/outgoing/table.rst @@ -210,7 +210,7 @@ Class Reference Lets you clear the table heading, row data and caption. If you need to show multiple tables with different data you - should to call this method after each table has been + should call this method after each table has been generated to clear the previous table information. Example From e3ada75a5b3f0615877205e77e5467eebc0b0233 Mon Sep 17 00:00:00 2001 From: obozdag Date: Wed, 17 Apr 2024 06:56:07 +0200 Subject: [PATCH 5/7] docs: Fix typo view_parser.rst Fix typo view_parser.rst. --- user_guide_src/source/outgoing/view_parser.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/outgoing/view_parser.rst b/user_guide_src/source/outgoing/view_parser.rst index a439d907a1de..dc2a702fe000 100644 --- a/user_guide_src/source/outgoing/view_parser.rst +++ b/user_guide_src/source/outgoing/view_parser.rst @@ -495,7 +495,7 @@ You can also use closures, but these can only be defined in the config file's co .. literalinclude:: view_parser/015.php -If the callable is on its own, it is treated as a single tag, not a open/close one. It will be replaced by +If the callable is on its own, it is treated as a single tag, not an open/close one. It will be replaced by the return value from the plugin: .. literalinclude:: view_parser/016.php From cc31b09d4ed431d66cfe10af60c73053272711f0 Mon Sep 17 00:00:00 2001 From: obozdag Date: Wed, 17 Apr 2024 07:23:16 +0200 Subject: [PATCH 6/7] docs: Small change in Class Reference description in response.rst Small change in Class Reference description in response.rst. --- user_guide_src/source/outgoing/response.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/outgoing/response.rst b/user_guide_src/source/outgoing/response.rst index 043ce61133e1..721956fbff1e 100644 --- a/user_guide_src/source/outgoing/response.rst +++ b/user_guide_src/source/outgoing/response.rst @@ -255,7 +255,7 @@ Class Reference .. note:: In addition to the methods listed here, this class inherits the methods from the :doc:`Message Class `. -The methods provided by the parent class that are available are: +The methods inherited from the Message Class are: * :meth:`CodeIgniter\\HTTP\\Message::body` * :meth:`CodeIgniter\\HTTP\\Message::setBody` From 3a70a22b06913be7fa57598f8bb8ee9d88fca6cc Mon Sep 17 00:00:00 2001 From: obozdag Date: Thu, 18 Apr 2024 16:12:10 +0200 Subject: [PATCH 7/7] docs: Fix typo in response.rst Fix typo in response.rst "This are" to "This is" --- user_guide_src/source/outgoing/response.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/outgoing/response.rst b/user_guide_src/source/outgoing/response.rst index 043ce61133e1..8557f6d38f30 100644 --- a/user_guide_src/source/outgoing/response.rst +++ b/user_guide_src/source/outgoing/response.rst @@ -234,7 +234,7 @@ Built into the HTTP specification are tools help the client (often the web brows this can lead to a huge performance boost to your application because it will tell the client that they don't need to contact the server at all since nothing has changed. And you can't get faster than that. -This are handled through the ``Cache-Control`` and ``ETag`` headers. This guide is not the proper place for a thorough +This is handled through the ``Cache-Control`` and ``ETag`` headers. This guide is not the proper place for a thorough introduction to all of the cache headers power, but you can get a good understanding over at `Google Developers `_.