diff --git a/.gitattributes b/.gitattributes
index 4b9a73d9d0e7..e2219ef90a4e 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -5,31 +5,33 @@
# git files
.gitattributes export-ignore
-.gitignore export-ignore
+.gitignore export-ignore
-# Don't give admin files
-.github/ export-ignore
-admin/ export-ignore
-contributing/ export-ignore
-.editorconfig export-ignore
-.nojekyll export-ignore
+# admin files
+.github/ export-ignore
+admin/ export-ignore
+contributing/ export-ignore
+.editorconfig export-ignore
CODE_OF_CONDUCT.md export-ignore
-CONTRIBUTING.md export-ignore
+CONTRIBUTING.md export-ignore
-# They don't want our test files
-tests/AutoReview/ export-ignore
-tests/system/ export-ignore
-utils/ export-ignore
-deptrac.yaml export-ignore
-rector.php export-ignore
-phpunit.xml.dist export-ignore
-phpstan-baseline.neon.dist export-ignore
-phpstan.neon.dist export-ignore
-phpstan-bootstrap.php export-ignore
-.php-cs-fixer.dist.php export-ignore
-.php-cs-fixer.no-header.php export-ignore
+# contributor/development files
+tests/ export-ignore
+utils/ export-ignore
+.php-cs-fixer.dist.php export-ignore
+.php-cs-fixer.no-header.php export-ignore
.php-cs-fixer.user-guide.php export-ignore
+deptrac.yaml export-ignore
+phpstan-baseline.neon.dist export-ignore
+phpstan-bootstrap.php export-ignore
+phpstan.neon.dist export-ignore
+phpunit.xml.dist export-ignore
+psalm_autoload.php export-ignore
+psalm-baseline.php export-ignore
+psalm.xml export-ignore
+rector.php export-ignore
-# The source user guide, either
+# source user guide
user_guide_src/ export-ignore
+.nojekyll export-ignore
phpdoc.dist.xml export-ignore
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4f9393d2b215..f0147f72b57b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,8 +1,37 @@
# Changelog
+## [v4.4.8](https://github.com/codeigniter4/CodeIgniter4/tree/v4.4.8) (2024-04-07)
+[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.4.7...v4.4.8)
+
+### Fixed Bugs
+
+* fix: [ImageMagickHandler] early terminate processing of invalid library path by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/8680
+* docs: fix PHPDoc types in BaseModel by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8679
+* fix: the error view is determined by Exception code by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8689
+* fix: `Pager::only([])` does not work by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8702
+* refactor: remove unneeded code in SQLite3\Table and fix PHPDoc types in Database by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8703
+* docs: fix return type in BaseResult by @Pebryan354 in https://github.com/codeigniter4/CodeIgniter4/pull/8709
+
+### Refactoring
+
+* refactor: simplify ImageMagickHandler::getVersion() by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/8681
+* refactor: [Rector] Apply ExplicitBoolCompareRector by @samsonasik in https://github.com/codeigniter4/CodeIgniter4/pull/8704
+
## [v4.4.7](https://github.com/codeigniter4/CodeIgniter4/tree/v4.4.7) (2024-03-29)
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.4.6...v4.4.7)
+### SECURITY
+
+* **Language:** *Language class DoS Vulnerability* was fixed. See the
+ [Security advisory](https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-39fp-mqmm-gxj6)
+ for more information.
+* **URI Security:** The feature to check if URIs do not contain not permitted
+ strings has been added. This check is equivalent to the URI Security found in
+ CodeIgniter 3. This is enabled by default, but upgraded users need to add
+ a setting to enable it.
+* **Filters:** A bug where URI paths processed by Filters were not URL-decoded
+ has been fixed.
+
### Breaking Changes
* fix: Time::difference() DST bug by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8661
diff --git a/admin/RELEASE.md b/admin/RELEASE.md
index b168f7856354..37173c4e97b0 100644
--- a/admin/RELEASE.md
+++ b/admin/RELEASE.md
@@ -88,7 +88,7 @@ Work off direct clones of the repos so the release branches persist for a time.
> generating much new content.
* [ ] Replace **CHANGELOG.md** with the new version generated above
-* [ ] Update **user_guide_src/source/changelogs/{version}.rst**
+* [ ] Update **user_guide_src/source/changelogs/v4.x.x.rst**
* Remove the section titles that have no items
* [ ] Update **user_guide_src/source/installation/upgrade_{ver}.rst**
* fill in the "All Changes" section, and add it to **upgrading.rst**
@@ -150,10 +150,10 @@ Work off direct clones of the repos so the release branches persist for a time.
composer test && composer info codeigniter4/framework
```
* [ ] Verify that the user guide actions succeeded:
- * "[Deploy Distributable Repos](https://github.com/codeigniter4/CodeIgniter4/actions/workflows/deploy-distributables.yml)", the main repo
- * "[Deploy Production](https://github.com/codeigniter4/userguide/actions/workflows/deploy.yml)", UG repo
- * "[pages-build-deployment](https://github.com/codeigniter4/userguide/actions/workflows/pages/pages-build-deployment)", UG repo
- * Check if "CodeIgniter4.x.x.epub" is added to UG repo. "CodeIgniter.epub" was
+ * [ ] "[Deploy Distributable Repos](https://github.com/codeigniter4/CodeIgniter4/actions/workflows/deploy-distributables.yml)", the main repo
+ * [ ] "[Deploy Production](https://github.com/codeigniter4/userguide/actions/workflows/deploy.yml)", UG repo
+ * [ ] "[pages-build-deployment](https://github.com/codeigniter4/userguide/actions/workflows/pages/pages-build-deployment)", UG repo
+ * [ ] Check if "CodeIgniter4.x.x.epub" is added to UG repo. "CodeIgniter.epub" was
created when v4.3.8 was released.
* [ ] Fast-forward `develop` branch to catch the merge commit from `master`
```console
diff --git a/admin/prepare-release.php b/admin/prepare-release.php
index 374e37b313eb..c0dcab6866ce 100644
--- a/admin/prepare-release.php
+++ b/admin/prepare-release.php
@@ -26,6 +26,7 @@ function replace_file_content(string $path, string $pattern, string $replace): v
// Creates a branch for release.
system('git switch develop');
+system('git branch -D release-' . $version);
system('git switch -c release-' . $version);
// Updates version number in "CodeIgniter.php".
diff --git a/app/.htaccess b/app/.htaccess
index f24db0accc73..3462048add78 100644
--- a/app/.htaccess
+++ b/app/.htaccess
@@ -1,6 +1,6 @@
- Require all denied
+ Require all denied
- Deny from all
+ Deny from all
diff --git a/composer.json b/composer.json
index 4021508a3a87..b5baf427017a 100644
--- a/composer.json
+++ b/composer.json
@@ -34,7 +34,7 @@
"phpunit/phpcov": "^8.2",
"phpunit/phpunit": "^9.1",
"predis/predis": "^1.1 || ^2.0",
- "rector/rector": "1.0.3",
+ "rector/rector": "1.0.4",
"vimeo/psalm": "^5.0"
},
"replace": {
diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml
index ad7f3f7d8066..616f6aeae98d 100644
--- a/phpdoc.dist.xml
+++ b/phpdoc.dist.xml
@@ -10,7 +10,7 @@
api/build/
api/cache/
-
+
system
diff --git a/phpstan-baseline.php b/phpstan-baseline.php
index 3380da0b8733..8dd1905e6b96 100644
--- a/phpstan-baseline.php
+++ b/phpstan-baseline.php
@@ -226,11 +226,6 @@
'count' => 1,
'path' => __DIR__ . '/system/BaseModel.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Method CodeIgniter\\\\BaseModel\\:\\:setValidationRules\\(\\) has parameter \\$validationRules with no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/BaseModel.php',
-];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\BaseModel\\:\\:transformDataToArray\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
@@ -266,66 +261,6 @@
'count' => 1,
'path' => __DIR__ . '/system/BaseModel.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Property CodeIgniter\\\\BaseModel\\:\\:\\$afterDelete type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/BaseModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property CodeIgniter\\\\BaseModel\\:\\:\\$afterFind type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/BaseModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property CodeIgniter\\\\BaseModel\\:\\:\\$afterInsert type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/BaseModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property CodeIgniter\\\\BaseModel\\:\\:\\$afterInsertBatch type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/BaseModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property CodeIgniter\\\\BaseModel\\:\\:\\$afterUpdate type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/BaseModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property CodeIgniter\\\\BaseModel\\:\\:\\$afterUpdateBatch type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/BaseModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property CodeIgniter\\\\BaseModel\\:\\:\\$beforeDelete type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/BaseModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property CodeIgniter\\\\BaseModel\\:\\:\\$beforeFind type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/BaseModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property CodeIgniter\\\\BaseModel\\:\\:\\$beforeInsert type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/BaseModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property CodeIgniter\\\\BaseModel\\:\\:\\$beforeInsertBatch type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/BaseModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property CodeIgniter\\\\BaseModel\\:\\:\\$beforeUpdate type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/BaseModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property CodeIgniter\\\\BaseModel\\:\\:\\$beforeUpdateBatch type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/BaseModel.php',
-];
$ignoreErrors[] = [
'message' => '#^Strict comparison using \\!\\=\\= between mixed and null will always evaluate to true\\.$#',
'count' => 1,
@@ -451,16 +386,6 @@
'count' => 1,
'path' => __DIR__ . '/system/CLI/CLI.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a negated boolean, array given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/CLI/CLI.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, string given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/CLI/CLI.php',
-];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in a ternary operator condition, string\\|null given\\.$#',
'count' => 1,
@@ -771,11 +696,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Commands/Database/MigrateStatus.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a negated boolean, array\\, array\\\\> given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Commands/Database/MigrateStatus.php',
-];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$params \\(array\\\\) of method CodeIgniter\\\\Commands\\\\Database\\\\MigrateStatus\\:\\:run\\(\\) should be contravariant with parameter \\$params \\(array\\\\) of method CodeIgniter\\\\CLI\\\\BaseCommand\\:\\:run\\(\\)$#',
'count' => 1,
@@ -2136,11 +2056,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Config/DotEnv.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a negated boolean, string given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Config/DotEnv.php',
-];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Config\\\\Factories\\:\\:__callStatic\\(\\) has parameter \\$arguments with no value type specified in iterable type array\\.$#',
'count' => 1,
@@ -2291,11 +2206,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Controller.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a negated boolean, array given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Controller.php',
-];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Controller\\:\\:\\$request \\(CodeIgniter\\\\HTTP\\\\CLIRequest\\|CodeIgniter\\\\HTTP\\\\IncomingRequest\\) does not accept CodeIgniter\\\\HTTP\\\\RequestInterface\\.$#',
'count' => 1,
@@ -2856,16 +2766,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Database/BaseConnection.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:_foreignKeyData\\(\\) return type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Database/BaseConnection.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:_indexData\\(\\) return type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Database/BaseConnection.php',
-];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:callFunction\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#',
'count' => 1,
@@ -2901,11 +2801,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Database/BaseConnection.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:foreignKeyDataToObjects\\(\\) return type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Database/BaseConnection.php',
-];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:getFieldNames\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
@@ -2916,11 +2811,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Database/BaseConnection.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:getIndexData\\(\\) return type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Database/BaseConnection.php',
-];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:listTables\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
@@ -3736,11 +3626,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Database/OCI8/Builder.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, int given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Database/OCI8/Builder.php',
-];
$ignoreErrors[] = [
'message' => '#^PHPDoc type CodeIgniter\\\\Database\\\\OCI8\\\\Connection of property CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:\\$db is not the same as PHPDoc type CodeIgniter\\\\Database\\\\BaseConnection of overridden property CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:\\$db\\.$#',
'count' => 1,
@@ -6221,11 +6106,6 @@
'count' => 1,
'path' => __DIR__ . '/system/HTTP/DownloadResponse.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in an if condition, string given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/HTTP/DownloadResponse.php',
-];
$ignoreErrors[] = [
'message' => '#^Return type \\(CodeIgniter\\\\HTTP\\\\DownloadResponse\\) of method CodeIgniter\\\\HTTP\\\\DownloadResponse\\:\\:sendBody\\(\\) should be covariant with return type \\(\\$this\\(CodeIgniter\\\\HTTP\\\\Response\\)\\) of method CodeIgniter\\\\HTTP\\\\Response\\:\\:sendBody\\(\\)$#',
'count' => 1,
@@ -7121,66 +7001,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Helpers/filesystem_helper.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, int\\<0, 1024\\> given\\.$#',
- 'count' => 2,
- 'path' => __DIR__ . '/system/Helpers/filesystem_helper.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, int\\<0, 128\\> given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Helpers/filesystem_helper.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, int\\<0, 16\\> given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Helpers/filesystem_helper.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, int\\<0, 1\\> given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Helpers/filesystem_helper.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, int\\<0, 2048\\> given\\.$#',
- 'count' => 2,
- 'path' => __DIR__ . '/system/Helpers/filesystem_helper.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, int\\<0, 256\\> given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Helpers/filesystem_helper.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, int\\<0, 2\\> given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Helpers/filesystem_helper.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, int\\<0, 32\\> given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Helpers/filesystem_helper.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, int\\<0, 4\\> given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Helpers/filesystem_helper.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, int\\<0, 512\\> given\\.$#',
- 'count' => 2,
- 'path' => __DIR__ . '/system/Helpers/filesystem_helper.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, int\\<0, 64\\> given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Helpers/filesystem_helper.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, int\\<0, 8\\> given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Helpers/filesystem_helper.php',
-];
$ignoreErrors[] = [
'message' => '#^Right side of && is always true\\.$#',
'count' => 1,
@@ -7391,11 +7211,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Helpers/form_helper.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a negated boolean, string given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Helpers/form_helper.php',
-];
$ignoreErrors[] = [
'message' => '#^Function _list\\(\\) has parameter \\$attributes with no value type specified in iterable type array\\.$#',
'count' => 1,
@@ -7476,11 +7291,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Helpers/html_helper.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, string given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Helpers/html_helper.php',
-];
$ignoreErrors[] = [
'message' => '#^Function d\\(\\) has parameter \\$vars with no value type specified in iterable type array\\.$#',
'count' => 1,
@@ -7581,11 +7391,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Helpers/url_helper.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, string given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Helpers/url_helper.php',
-];
$ignoreErrors[] = [
'message' => '#^Variable \\$atts might not be defined\\.$#',
'count' => 1,
@@ -7723,7 +7528,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
- 'count' => 9,
+ 'count' => 8,
'path' => __DIR__ . '/system/Images/Handlers/ImageMagickHandler.php',
];
$ignoreErrors[] = [
@@ -8046,21 +7851,11 @@
'count' => 1,
'path' => __DIR__ . '/system/Pager/Pager.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in an if condition, array given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Pager/Pager.php',
-];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Pager\\\\Pager\\:\\:\\$groups type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Pager/Pager.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Property CodeIgniter\\\\Pager\\\\Pager\\:\\:\\$only type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Pager/Pager.php',
-];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Pager\\\\Pager\\:\\:\\$segment type has no value type specified in iterable type array\\.$#',
'count' => 1,
@@ -8391,11 +8186,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Router/RouteCollection.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, string given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Router/RouteCollection.php',
-];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in a ternary operator condition, string\\|null given\\.$#',
'count' => 1,
@@ -8646,11 +8436,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Session/Handlers/FileHandler.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a negated boolean, string given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Session/Handlers/FileHandler.php',
-];
$ignoreErrors[] = [
'message' => '#^PHPDoc type string of property CodeIgniter\\\\Session\\\\Handlers\\\\FileHandler\\:\\:\\$savePath is not the same as PHPDoc type array\\|string of overridden property CodeIgniter\\\\Session\\\\Handlers\\\\BaseHandler\\:\\:\\$savePath\\.$#',
'count' => 1,
@@ -9396,16 +9181,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Test/Mock/MockConnection.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockConnection\\:\\:_foreignKeyData\\(\\) return type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Test/Mock/MockConnection.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockConnection\\:\\:_indexData\\(\\) return type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/Test/Mock/MockConnection.php',
-];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockConnection\\:\\:shouldReturn\\(\\) has no return type specified\\.$#',
'count' => 1,
@@ -10611,11 +10386,6 @@
'count' => 1,
'path' => __DIR__ . '/system/View/Table.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, float given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/system/View/Table.php',
-];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in an if condition, string\\|null given\\.$#',
'count' => 1,
@@ -11286,71 +11056,11 @@
'count' => 1,
'path' => __DIR__ . '/tests/_support/Models/EventModel.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Property Tests\\\\Support\\\\Models\\\\EventModel\\:\\:\\$afterDelete type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/_support/Models/EventModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property Tests\\\\Support\\\\Models\\\\EventModel\\:\\:\\$afterFind type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/_support/Models/EventModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property Tests\\\\Support\\\\Models\\\\EventModel\\:\\:\\$afterInsert type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/_support/Models/EventModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property Tests\\\\Support\\\\Models\\\\EventModel\\:\\:\\$afterInsertBatch type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/_support/Models/EventModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property Tests\\\\Support\\\\Models\\\\EventModel\\:\\:\\$afterUpdate type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/_support/Models/EventModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property Tests\\\\Support\\\\Models\\\\EventModel\\:\\:\\$afterUpdateBatch type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/_support/Models/EventModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property Tests\\\\Support\\\\Models\\\\EventModel\\:\\:\\$beforeDelete type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/_support/Models/EventModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property Tests\\\\Support\\\\Models\\\\EventModel\\:\\:\\$beforeFind type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/_support/Models/EventModel.php',
-];
$ignoreErrors[] = [
'message' => '#^Property Tests\\\\Support\\\\Models\\\\EventModel\\:\\:\\$beforeFindReturnData has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/_support/Models/EventModel.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Property Tests\\\\Support\\\\Models\\\\EventModel\\:\\:\\$beforeInsert type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/_support/Models/EventModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property Tests\\\\Support\\\\Models\\\\EventModel\\:\\:\\$beforeInsertBatch type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/_support/Models/EventModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property Tests\\\\Support\\\\Models\\\\EventModel\\:\\:\\$beforeUpdate type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/_support/Models/EventModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property Tests\\\\Support\\\\Models\\\\EventModel\\:\\:\\$beforeUpdateBatch type has no value type specified in iterable type array\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/_support/Models/EventModel.php',
-];
$ignoreErrors[] = [
'message' => '#^Property Tests\\\\Support\\\\Models\\\\EventModel\\:\\:\\$eventData has no type specified\\.$#',
'count' => 1,
@@ -11391,16 +11101,6 @@
'count' => 1,
'path' => __DIR__ . '/tests/_support/Models/UserModel.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Property Tests\\\\Support\\\\Models\\\\ValidErrorsModel\\:\\:\\$validationRules \\(array\\\\|string\\) does not accept default value of type array\\\\|string\\>\\|string\\>\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/_support/Models/ValidErrorsModel.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property Tests\\\\Support\\\\Models\\\\ValidModel\\:\\:\\$validationRules \\(array\\\\|string\\) does not accept default value of type array\\\\|string\\>\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/_support/Models/ValidModel.php',
-];
$ignoreErrors[] = [
'message' => '#^Property Tests\\\\Support\\\\SomeEntity\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
'count' => 1,
@@ -12051,11 +11751,6 @@
'count' => 1,
'path' => __DIR__ . '/tests/system/Cache/ResponseCacheTest.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Only booleans are allowed in a ternary operator condition, array given\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/system/Cache/ResponseCacheTest.php',
-];
$ignoreErrors[] = [
'message' => '#^Re\\-assigning arrays to \\$_GET directly is discouraged\\.$#',
'count' => 3,
@@ -16301,41 +15996,11 @@
'count' => 1,
'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Property class@anonymous/tests/system/Models/ValidationModelRuleGroupTest\\.php\\:368\\:\\:\\$validationRules \\(array\\\\|string\\) does not accept default value of type array\\\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/system/Models/ValidationModelRuleGroupTest.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property class@anonymous/tests/system/Models/ValidationModelRuleGroupTest\\.php\\:406\\:\\:\\$validationRules \\(array\\\\|string\\) does not accept default value of type array\\\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/system/Models/ValidationModelRuleGroupTest.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property class@anonymous/tests/system/Models/ValidationModelRuleGroupTest\\.php\\:446\\:\\:\\$validationRules \\(array\\\\|string\\) does not accept default value of type array\\\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/system/Models/ValidationModelRuleGroupTest.php',
-];
$ignoreErrors[] = [
'message' => '#^Property class@anonymous/tests/system/Models/ValidationModelTest\\.php\\:243\\:\\:\\$grouptest has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Models/ValidationModelTest.php',
];
-$ignoreErrors[] = [
- 'message' => '#^Property class@anonymous/tests/system/Models/ValidationModelTest\\.php\\:380\\:\\:\\$validationRules \\(array\\\\|string\\) does not accept default value of type array\\\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/system/Models/ValidationModelTest.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property class@anonymous/tests/system/Models/ValidationModelTest\\.php\\:418\\:\\:\\$validationRules \\(array\\\\|string\\) does not accept default value of type array\\\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/system/Models/ValidationModelTest.php',
-];
-$ignoreErrors[] = [
- 'message' => '#^Property class@anonymous/tests/system/Models/ValidationModelTest\\.php\\:458\\:\\:\\$validationRules \\(array\\\\|string\\) does not accept default value of type array\\\\.$#',
- 'count' => 1,
- 'path' => __DIR__ . '/tests/system/Models/ValidationModelTest.php',
-];
$ignoreErrors[] = [
'message' => '#^Cannot access property \\$key on array\\.$#',
'count' => 7,
diff --git a/public/.htaccess b/public/.htaccess
index dbed322fdc1e..abac3cb6b949 100644
--- a/public/.htaccess
+++ b/public/.htaccess
@@ -45,5 +45,5 @@ Options -Indexes
# Disable server signature start
- ServerSignature Off
+ServerSignature Off
# Disable server signature end
diff --git a/rector.php b/rector.php
index 321bf3930b06..e52be465b4e5 100644
--- a/rector.php
+++ b/rector.php
@@ -21,6 +21,7 @@
use Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector;
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\CodeQuality\Rector\If_\CombineIfRector;
+use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
use Rector\CodeQuality\Rector\If_\ShortenElseIfRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
@@ -158,6 +159,7 @@
$rectorConfig->rule(BooleanInIfConditionRuleFixerRector::class);
$rectorConfig->rule(SingleInArrayToCompareRector::class);
$rectorConfig->rule(VersionCompareFuncCallToConstantRector::class);
+ $rectorConfig->rule(ExplicitBoolCompareRector::class);
$rectorConfig
->ruleWithConfiguration(StringClassNameToClassConstantRector::class, [
diff --git a/system/BaseModel.php b/system/BaseModel.php
index 24479ec69362..cd2bdd6beb22 100644
--- a/system/BaseModel.php
+++ b/system/BaseModel.php
@@ -173,11 +173,14 @@ abstract class BaseModel
protected $db;
/**
- * Rules used to validate data in insert, update, and save methods.
+ * Rules used to validate data in insert(), update(), and save() methods.
+ *
* The array must match the format of data passed to the Validation
* library.
*
- * @var list|string
+ * @see https://codeigniter4.github.io/userguide/models/model.html#setting-validation-rules
+ *
+ * @var array|string>|string>|string
*/
protected $validationRules = [];
@@ -243,84 +246,84 @@ abstract class BaseModel
/**
* Callbacks for beforeInsert
*
- * @var array
+ * @var list
*/
protected $beforeInsert = [];
/**
* Callbacks for afterInsert
*
- * @var array
+ * @var list
*/
protected $afterInsert = [];
/**
* Callbacks for beforeUpdate
*
- * @var array
+ * @var list
*/
protected $beforeUpdate = [];
/**
* Callbacks for afterUpdate
*
- * @var array
+ * @var list
*/
protected $afterUpdate = [];
/**
* Callbacks for beforeInsertBatch
*
- * @var array
+ * @var list
*/
protected $beforeInsertBatch = [];
/**
* Callbacks for afterInsertBatch
*
- * @var array
+ * @var list
*/
protected $afterInsertBatch = [];
/**
* Callbacks for beforeUpdateBatch
*
- * @var array
+ * @var list
*/
protected $beforeUpdateBatch = [];
/**
* Callbacks for afterUpdateBatch
*
- * @var array
+ * @var list
*/
protected $afterUpdateBatch = [];
/**
* Callbacks for beforeFind
*
- * @var array
+ * @var list
*/
protected $beforeFind = [];
/**
* Callbacks for afterFind
*
- * @var array
+ * @var list
*/
protected $afterFind = [];
/**
* Callbacks for beforeDelete
*
- * @var array
+ * @var list
*/
protected $beforeDelete = [];
/**
* Callbacks for afterDelete
*
- * @var array
+ * @var list
*/
protected $afterDelete = [];
@@ -1448,7 +1451,7 @@ public function setValidationMessage(string $field, array $fieldMessages)
* Allows to set (and reset) validation rules.
* It could be used when you have to change default or override current validate rules.
*
- * @param array $validationRules Value
+ * @param array|string>|string> $validationRules Value
*
* @return $this
*/
diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php
index 9a50e4038184..5bd8543896ef 100644
--- a/system/CLI/CLI.php
+++ b/system/CLI/CLI.php
@@ -262,7 +262,7 @@ public static function prompt(string $field, $options = null, $validation = null
$default = $options[0];
}
- static::fwrite(STDOUT, $field . (trim($field) ? ' ' : '') . $extraOutput . ': ');
+ static::fwrite(STDOUT, $field . (trim($field) !== '' ? ' ' : '') . $extraOutput . ': ');
// Read the input from keyboard.
$input = trim(static::input()) ?: $default;
@@ -386,7 +386,7 @@ public static function promptByMultipleKeys(string $text, array $options): array
*/
private static function isZeroOptions(array $options): void
{
- if (! $options) {
+ if ($options === []) {
throw new InvalidArgumentException('No options to select from were provided');
}
}
diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php
index 760a71f29259..6a2dca68c1e5 100644
--- a/system/CodeIgniter.php
+++ b/system/CodeIgniter.php
@@ -54,7 +54,7 @@ class CodeIgniter
/**
* The current version of CodeIgniter Framework
*/
- public const CI_VERSION = '4.4.7';
+ public const CI_VERSION = '4.4.8';
/**
* App startup time.
diff --git a/system/Commands/Database/MigrateStatus.php b/system/Commands/Database/MigrateStatus.php
index cbbe2f70ce47..ecd074278d47 100644
--- a/system/Commands/Database/MigrateStatus.php
+++ b/system/Commands/Database/MigrateStatus.php
@@ -144,7 +144,7 @@ public function run(array $params)
}
}
- if (! $status) {
+ if ($status === []) {
// @codeCoverageIgnoreStart
CLI::error(lang('Migrations.noneFound'), 'light_gray', 'red');
CLI::newLine();
diff --git a/system/Config/DotEnv.php b/system/Config/DotEnv.php
index 05ecab900c3e..f8e757e9eab5 100644
--- a/system/Config/DotEnv.php
+++ b/system/Config/DotEnv.php
@@ -140,7 +140,7 @@ public function normaliseVariable(string $name, string $value = ''): array
*/
protected function sanitizeValue(string $value): string
{
- if (! $value) {
+ if ($value === '') {
return $value;
}
diff --git a/system/Controller.php b/system/Controller.php
index 0cc14c569651..83bc4f4b120e 100644
--- a/system/Controller.php
+++ b/system/Controller.php
@@ -187,7 +187,7 @@ private function setValidator($rules, array $messages): void
}
// If no error message is defined, use the error message in the Config\Validation file
- if (! $messages) {
+ if ($messages === []) {
$errorName = $rules . '_errors';
$messages = $validation->{$errorName} ?? [];
}
diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php
index 8a33e220d84d..65dea86da2b3 100644
--- a/system/Database/BaseBuilder.php
+++ b/system/Database/BaseBuilder.php
@@ -333,7 +333,7 @@ public function __construct($tableName, ConnectionInterface $db, ?array $options
/**
* Returns the current database connection
*
- * @return BaseConnection|ConnectionInterface
+ * @return BaseConnection
*/
public function db(): ConnectionInterface
{
diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php
index ae5c4b3805f1..93bde5ddca6d 100644
--- a/system/Database/BaseConnection.php
+++ b/system/Database/BaseConnection.php
@@ -1527,7 +1527,7 @@ public function getFieldData(string $table)
/**
* Returns an object with key data
*
- * @return array
+ * @return array
*/
public function getIndexData(string $table)
{
@@ -1547,7 +1547,9 @@ public function getForeignKeyData(string $table)
/**
* Converts array of arrays generated by _foreignKeyData() to array of objects
*
- * @return array[
+ * @return array
+ *
+ * array[
* {constraint_name} =>
* stdClass[
* 'constraint_name' => string,
@@ -1704,6 +1706,8 @@ abstract protected function _fieldData(string $table): array;
* Platform-specific index data.
*
* @see getIndexData()
+ *
+ * @return array
*/
abstract protected function _indexData(string $table): array;
@@ -1711,6 +1715,8 @@ abstract protected function _indexData(string $table): array;
* Platform-specific foreign keys data.
*
* @see getForeignKeyData()
+ *
+ * @return array
*/
abstract protected function _foreignKeyData(string $table): array;
diff --git a/system/Database/BaseResult.php b/system/Database/BaseResult.php
index 8a624029b3a2..8720b5fe111c 100644
--- a/system/Database/BaseResult.php
+++ b/system/Database/BaseResult.php
@@ -260,8 +260,8 @@ public function getResultObject(): array
* @param string $type The type of result object. 'array', 'object' or class name.
* @phpstan-param class-string|'array'|'object' $type
*
- * @return array|object|stdClass|null
- * @phpstan-return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null))
+ * @return array|float|int|object|stdClass|string|null
+ * @phpstan-return ($n is string ? float|int|string|null : ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null)))
*/
public function getRow($n = 0, string $type = 'object')
{
diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php
index 03aab408398a..b499e2ca81d6 100644
--- a/system/Database/MySQLi/Connection.php
+++ b/system/Database/MySQLi/Connection.php
@@ -443,7 +443,7 @@ protected function _fieldData(string $table): array
/**
* Returns an array of objects with index data
*
- * @return list
+ * @return array
*
* @throws DatabaseException
* @throws LogicException
@@ -489,7 +489,7 @@ protected function _indexData(string $table): array
/**
* Returns an array of objects with Foreign key data
*
- * @return list
+ * @return array
*
* @throws DatabaseException
*/
diff --git a/system/Database/OCI8/Builder.php b/system/Database/OCI8/Builder.php
index f5527ce745c6..37ba54a27392 100644
--- a/system/Database/OCI8/Builder.php
+++ b/system/Database/OCI8/Builder.php
@@ -222,7 +222,7 @@ protected function _limit(string $sql, bool $offsetIgnore = false): string
}
$this->limitUsed = true;
- $limitTemplateQuery = 'SELECT * FROM (SELECT INNER_QUERY.*, ROWNUM RNUM FROM (%s) INNER_QUERY WHERE ROWNUM < %d)' . ($offset ? ' WHERE RNUM >= %d' : '');
+ $limitTemplateQuery = 'SELECT * FROM (SELECT INNER_QUERY.*, ROWNUM RNUM FROM (%s) INNER_QUERY WHERE ROWNUM < %d)' . ($offset !== 0 ? ' WHERE RNUM >= %d' : '');
return sprintf($limitTemplateQuery, $sql, $offset + $this->QBLimit + 1, $offset);
}
diff --git a/system/Database/OCI8/Connection.php b/system/Database/OCI8/Connection.php
index fc7920e2a8ff..2feb2d36df4b 100644
--- a/system/Database/OCI8/Connection.php
+++ b/system/Database/OCI8/Connection.php
@@ -325,7 +325,7 @@ protected function _fieldData(string $table): array
/**
* Returns an array of objects with index data
*
- * @return list
+ * @return array
*
* @throws DatabaseException
*/
@@ -374,7 +374,7 @@ protected function _indexData(string $table): array
/**
* Returns an array of objects with Foreign key data
*
- * @return list
+ * @return array
*
* @throws DatabaseException
*/
diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php
index baef703b7bb3..7da3d26c9dd8 100644
--- a/system/Database/Postgre/Connection.php
+++ b/system/Database/Postgre/Connection.php
@@ -332,7 +332,7 @@ protected function _fieldData(string $table): array
/**
* Returns an array of objects with index data
*
- * @return list
+ * @return array
*
* @throws DatabaseException
*/
@@ -371,7 +371,7 @@ protected function _indexData(string $table): array
/**
* Returns an array of objects with Foreign key data
*
- * @return list
+ * @return array
*
* @throws DatabaseException
*/
diff --git a/system/Database/ResultInterface.php b/system/Database/ResultInterface.php
index ea5f0de2800f..2b1deb98c6b6 100644
--- a/system/Database/ResultInterface.php
+++ b/system/Database/ResultInterface.php
@@ -63,8 +63,8 @@ public function getResultObject(): array;
* @param string $type The type of result object. 'array', 'object' or class name.
* @phpstan-param class-string|'array'|'object' $type
*
- * @return array|object|stdClass|null
- * @phpstan-return ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null))
+ * @return array|float|int|object|stdClass|string|null
+ * @phpstan-return ($n is string ? float|int|string|null : ($type is 'object' ? stdClass|null : ($type is 'array' ? array|null : T|null)))
*/
public function getRow($n = 0, string $type = 'object');
diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php
index bc3e036078c9..77a1ab34bcf3 100755
--- a/system/Database/SQLSRV/Connection.php
+++ b/system/Database/SQLSRV/Connection.php
@@ -231,7 +231,7 @@ protected function _listColumns(string $table = ''): string
/**
* Returns an array of objects with index data
*
- * @return list
+ * @return array
*
* @throws DatabaseException
*/
@@ -269,7 +269,7 @@ protected function _indexData(string $table): array
* Returns an array of objects with Foreign key data
* referenced_object_id parent_object_id
*
- * @return list
+ * @return array
*
* @throws DatabaseException
*/
diff --git a/system/Database/SQLite3/Connection.php b/system/Database/SQLite3/Connection.php
index be4ebc25f0ca..a7ac179dadca 100644
--- a/system/Database/SQLite3/Connection.php
+++ b/system/Database/SQLite3/Connection.php
@@ -286,7 +286,7 @@ protected function _fieldData(string $table): array
/**
* Returns an array of objects with index data
*
- * @return list
+ * @return array
*
* @throws DatabaseException
*/
@@ -343,7 +343,7 @@ protected function _indexData(string $table): array
/**
* Returns an array of objects with Foreign key data
*
- * @return list
+ * @return array
*/
protected function _foreignKeyData(string $table): array
{
diff --git a/system/Database/SQLite3/Table.php b/system/Database/SQLite3/Table.php
index 47e6d1a7097e..bd2056d581d9 100644
--- a/system/Database/SQLite3/Table.php
+++ b/system/Database/SQLite3/Table.php
@@ -280,7 +280,7 @@ public function addForeignKey(array $foreignKeys)
/**
* Creates the new table based on our current fields.
*
- * @return mixed
+ * @return bool
*/
protected function createTable()
{
@@ -449,16 +449,12 @@ private function isNumericType(string $type): bool
* Converts keys retrieved from the database to
* the format needed to create later.
*
- * @param mixed $keys
+ * @param array $keys
*
- * @return mixed
+ * @return array
*/
protected function formatKeys($keys)
{
- if (! is_array($keys)) {
- return $keys;
- }
-
$return = [];
foreach ($keys as $name => $key) {
diff --git a/system/Debug/ExceptionHandler.php b/system/Debug/ExceptionHandler.php
index 63449888ffb5..09c6de0d5b7e 100644
--- a/system/Debug/ExceptionHandler.php
+++ b/system/Debug/ExceptionHandler.php
@@ -97,8 +97,8 @@ public function handle(
. DIRECTORY_SEPARATOR . 'errors' . DIRECTORY_SEPARATOR . $addPath;
// Determine the views
- $view = $this->determineView($exception, $path);
- $altView = $this->determineView($exception, $altPath);
+ $view = $this->determineView($exception, $path, $statusCode);
+ $altView = $this->determineView($exception, $altPath, $statusCode);
// Check if the view exists
$viewFile = null;
@@ -119,13 +119,16 @@ public function handle(
}
/**
- * Determines the view to display based on the exception thrown,
- * whether an HTTP or CLI request, etc.
+ * Determines the view to display based on the exception thrown, HTTP status
+ * code, whether an HTTP or CLI request, etc.
*
* @return string The filename of the view file to use
*/
- protected function determineView(Throwable $exception, string $templatePath): string
- {
+ protected function determineView(
+ Throwable $exception,
+ string $templatePath,
+ int $statusCode = 500
+ ): string {
// Production environments should have a custom exception file.
$view = 'production.php';
@@ -147,8 +150,8 @@ protected function determineView(Throwable $exception, string $templatePath): st
$templatePath = rtrim($templatePath, '\\/ ') . DIRECTORY_SEPARATOR;
// Allow for custom views based upon the status code
- if (is_file($templatePath . 'error_' . $exception->getCode() . '.php')) {
- return 'error_' . $exception->getCode() . '.php';
+ if (is_file($templatePath . 'error_' . $statusCode . '.php')) {
+ return 'error_' . $statusCode . '.php';
}
return $view;
diff --git a/system/HTTP/DownloadResponse.php b/system/HTTP/DownloadResponse.php
index 14dc3fec1421..d815a9af6e03 100644
--- a/system/HTTP/DownloadResponse.php
+++ b/system/HTTP/DownloadResponse.php
@@ -194,7 +194,7 @@ private function getContentDisposition(): string
$result = sprintf('attachment; filename="%s"', $downloadFilename);
- if ($utf8Filename) {
+ if ($utf8Filename !== '') {
$result .= '; filename*=UTF-8\'\'' . rawurlencode($utf8Filename);
}
diff --git a/system/HTTP/Files/UploadedFile.php b/system/HTTP/Files/UploadedFile.php
index 70ece748d834..e0725e7c90d5 100644
--- a/system/HTTP/Files/UploadedFile.php
+++ b/system/HTTP/Files/UploadedFile.php
@@ -15,8 +15,6 @@
use CodeIgniter\HTTP\Exceptions\HTTPException;
use Config\Mimes;
use Exception;
-use InvalidArgumentException;
-use RuntimeException;
/**
* Value object representing a single file uploaded through an
@@ -80,12 +78,12 @@ class UploadedFile extends File implements UploadedFileInterface
/**
* Accepts the file information as would be filled in from the $_FILES array.
*
- * @param string $path The temporary location of the uploaded file.
- * @param string $originalName The client-provided filename.
- * @param string $mimeType The type of file as provided by PHP
- * @param int $size The size of the file, in bytes
- * @param int $error The error constant of the upload (one of PHP's UPLOADERRXXX constants)
- * @param string $clientPath The webkit relative path of the uploaded file.
+ * @param string $path The temporary location of the uploaded file.
+ * @param string $originalName The client-provided filename.
+ * @param string|null $mimeType The type of file as provided by PHP
+ * @param int|null $size The size of the file, in bytes
+ * @param int|null $error The error constant of the upload (one of PHP's UPLOADERRXXX constants)
+ * @param string|null $clientPath The webkit relative path of the uploaded file.
*/
public function __construct(string $path, string $originalName, ?string $mimeType = null, ?int $size = null, ?int $error = null, ?string $clientPath = null)
{
@@ -122,16 +120,12 @@ public function __construct(string $path, string $originalName, ?string $mimeTyp
* @see http://php.net/is_uploaded_file
* @see http://php.net/move_uploaded_file
*
- * @param string $targetPath Path to which to move the uploaded file.
- * @param string $name the name to rename the file to.
- * @param bool $overwrite State for indicating whether to overwrite the previously generated file with the same
- * name or not.
+ * @param string $targetPath Path to which to move the uploaded file.
+ * @param string|null $name the name to rename the file to.
+ * @param bool $overwrite State for indicating whether to overwrite the previously generated file with the same
+ * name or not.
*
* @return bool
- *
- * @throws InvalidArgumentException if the $path specified is invalid.
- * @throws RuntimeException on any error during the move operation.
- * @throws RuntimeException on the second or subsequent call to the method.
*/
public function move(string $targetPath, ?string $name = null, bool $overwrite = false)
{
@@ -345,8 +339,8 @@ public function isValid(): bool
* By default, upload files are saved in writable/uploads directory. The YYYYMMDD folder
* and random file name will be created.
*
- * @param string $folderName the folder name to writable/uploads directory.
- * @param string $fileName the name to rename the file to.
+ * @param string|null $folderName the folder name to writable/uploads directory.
+ * @param string|null $fileName the name to rename the file to.
*
* @return string file full path
*/
diff --git a/system/HTTP/Files/UploadedFileInterface.php b/system/HTTP/Files/UploadedFileInterface.php
index 170f81c2de9e..ef2073f2b876 100644
--- a/system/HTTP/Files/UploadedFileInterface.php
+++ b/system/HTTP/Files/UploadedFileInterface.php
@@ -26,12 +26,12 @@ interface UploadedFileInterface
/**
* Accepts the file information as would be filled in from the $_FILES array.
*
- * @param string $path The temporary location of the uploaded file.
- * @param string $originalName The client-provided filename.
- * @param string $mimeType The type of file as provided by PHP
- * @param int $size The size of the file, in bytes
- * @param int $error The error constant of the upload (one of PHP's UPLOADERRXXX constants)
- * @param string $clientPath The webkit relative path of the uploaded file.
+ * @param string $path The temporary location of the uploaded file.
+ * @param string $originalName The client-provided filename.
+ * @param string|null $mimeType The type of file as provided by PHP
+ * @param int|null $size The size of the file, in bytes
+ * @param int|null $error The error constant of the upload (one of PHP's UPLOADERRXXX constants)
+ * @param string|null $clientPath The webkit relative path of the uploaded file.
*/
public function __construct(string $path, string $originalName, ?string $mimeType = null, ?int $size = null, ?int $error = null, ?string $clientPath = null);
@@ -57,13 +57,12 @@ public function __construct(string $path, string $originalName, ?string $mimeTyp
* @see http://php.net/is_uploaded_file
* @see http://php.net/move_uploaded_file
*
- * @param string $targetPath Path to which to move the uploaded file.
- * @param string $name the name to rename the file to.
+ * @param string $targetPath Path to which to move the uploaded file.
+ * @param string|null $name the name to rename the file to.
*
* @return bool
*
* @throws InvalidArgumentException if the $path specified is invalid.
- * @throws RuntimeException on any error during the move operation.
* @throws RuntimeException on the second or subsequent call to the method.
*/
public function move(string $targetPath, ?string $name = null);
diff --git a/system/Helpers/filesystem_helper.php b/system/Helpers/filesystem_helper.php
index 4e0e8b1532e9..46700ffc2797 100644
--- a/system/Helpers/filesystem_helper.php
+++ b/system/Helpers/filesystem_helper.php
@@ -379,19 +379,19 @@ function symbolic_permissions(int $perms): string
}
// Owner
- $symbolic .= (($perms & 0x0100) ? 'r' : '-')
- . (($perms & 0x0080) ? 'w' : '-')
- . (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x') : (($perms & 0x0800) ? 'S' : '-'));
+ $symbolic .= ((($perms & 0x0100) !== 0) ? 'r' : '-')
+ . ((($perms & 0x0080) !== 0) ? 'w' : '-')
+ . ((($perms & 0x0040) !== 0) ? ((($perms & 0x0800) !== 0) ? 's' : 'x') : ((($perms & 0x0800) !== 0) ? 'S' : '-'));
// Group
- $symbolic .= (($perms & 0x0020) ? 'r' : '-')
- . (($perms & 0x0010) ? 'w' : '-')
- . (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x') : (($perms & 0x0400) ? 'S' : '-'));
+ $symbolic .= ((($perms & 0x0020) !== 0) ? 'r' : '-')
+ . ((($perms & 0x0010) !== 0) ? 'w' : '-')
+ . ((($perms & 0x0008) !== 0) ? ((($perms & 0x0400) !== 0) ? 's' : 'x') : ((($perms & 0x0400) !== 0) ? 'S' : '-'));
// World
- $symbolic .= (($perms & 0x0004) ? 'r' : '-')
- . (($perms & 0x0002) ? 'w' : '-')
- . (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x') : (($perms & 0x0200) ? 'T' : '-'));
+ $symbolic .= ((($perms & 0x0004) !== 0) ? 'r' : '-')
+ . ((($perms & 0x0002) !== 0) ? 'w' : '-')
+ . ((($perms & 0x0001) !== 0) ? ((($perms & 0x0200) !== 0) ? 't' : 'x') : ((($perms & 0x0200) !== 0) ? 'T' : '-'));
return $symbolic;
}
diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php
index 098222e90e9f..5f62cca83d6d 100644
--- a/system/Helpers/form_helper.php
+++ b/system/Helpers/form_helper.php
@@ -29,7 +29,7 @@
function form_open(string $action = '', $attributes = [], array $hidden = []): string
{
// If no action is provided then set to the current url
- if (! $action) {
+ if ($action === '') {
$action = current_url(true);
} // If an action is not a full URL then turn it into one
elseif (strpos($action, '://') === false) {
diff --git a/system/Helpers/html_helper.php b/system/Helpers/html_helper.php
index 0f7e154a02bf..6d9a51356af6 100755
--- a/system/Helpers/html_helper.php
+++ b/system/Helpers/html_helper.php
@@ -195,7 +195,7 @@ function doctype(string $type = 'html5'): string
function script_tag($src = '', bool $indexPage = false): string
{
$cspNonce = csp_script_nonce();
- $cspNonce = $cspNonce ? ' ' . $cspNonce : $cspNonce;
+ $cspNonce = $cspNonce !== '' ? ' ' . $cspNonce : $cspNonce;
$script = '