diff --git a/.gitattributes b/.gitattributes index e2219ef90a4e..c41e331ff63c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -17,18 +17,21 @@ CONTRIBUTING.md export-ignore # contributor/development files tests/ export-ignore +tools/ export-ignore utils/ export-ignore .php-cs-fixer.dist.php export-ignore .php-cs-fixer.no-header.php export-ignore +.php-cs-fixer.tests.php export-ignore .php-cs-fixer.user-guide.php export-ignore deptrac.yaml export-ignore -phpstan-baseline.neon.dist export-ignore +phpmetrics.json export-ignore +phpstan-baseline.php 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-baseline.xml export-ignore psalm.xml export-ignore +psalm_autoload.php export-ignore rector.php export-ignore # source user guide diff --git a/.github/workflows/test-coding-standards.yml b/.github/workflows/test-coding-standards.yml index f2ecb8effbad..7e5f18820288 100644 --- a/.github/workflows/test-coding-standards.yml +++ b/.github/workflows/test-coding-standards.yml @@ -29,7 +29,7 @@ jobs: matrix: php-version: - '8.1' - - '8.2' + - '8.3' steps: - name: Checkout @@ -60,8 +60,11 @@ jobs: - name: Run lint on `app/`, `admin/`, `public/` run: vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --config=.php-cs-fixer.no-header.php --using-cache=no --diff - - name: Run lint on `system/`, `tests`, `utils/`, and root PHP files + - name: Run lint on `system/`, `utils/`, and root PHP files run: vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --using-cache=no --diff + - name: Run lint on `tests` + run: vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --config=.php-cs-fixer.tests.php --using-cache=no --diff + - name: Run lint on `user_guide_src/source/` run: vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --config=.php-cs-fixer.user-guide.php --using-cache=no --diff diff --git a/.github/workflows/test-file-permissions.yml b/.github/workflows/test-file-permissions.yml new file mode 100644 index 000000000000..e6ad5949d8b4 --- /dev/null +++ b/.github/workflows/test-file-permissions.yml @@ -0,0 +1,24 @@ +name: Check File Permissions + +on: + pull_request: + push: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + permission-check: + name: Check File Permission + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Detect unnecessary execution permissions + run: php utils/check_permission_x.php diff --git a/.github/workflows/test-phpstan.yml b/.github/workflows/test-phpstan.yml index a8e6eaefcb49..360b403ac923 100644 --- a/.github/workflows/test-phpstan.yml +++ b/.github/workflows/test-phpstan.yml @@ -10,6 +10,7 @@ on: paths: - 'app/**.php' - 'system/**.php' + - 'tests/**.php' - 'utils/**.php' - composer.json - phpstan.neon.dist @@ -23,6 +24,7 @@ on: paths: - 'app/**.php' - 'system/**.php' + - 'tests/**.php' - 'utils/**.php' - composer.json - phpstan.neon.dist diff --git a/.github/workflows/test-phpunit.yml b/.github/workflows/test-phpunit.yml index afc6d56ace2c..ba566ce5c9d1 100644 --- a/.github/workflows/test-phpunit.yml +++ b/.github/workflows/test-phpunit.yml @@ -114,7 +114,7 @@ jobs: enable-artifact-upload: ${{ matrix.php-version == needs.coverage-php-version.outputs.version }} enable-coverage: ${{ matrix.php-version == needs.coverage-php-version.outputs.version }} enable-profiling: ${{ matrix.php-version == needs.coverage-php-version.outputs.version }} - extra-extensions: mysqli, oci8, pgsql, sqlsrv-5.10.1, sqlite3 + extra-extensions: mysqli, oci8, pgsql, sqlsrv, sqlite3 extra-composer-options: ${{ matrix.composer-option }} separate-process-tests: diff --git a/.github/workflows/test-psalm.yml b/.github/workflows/test-psalm.yml index 98ca5c44c5b3..a623109fbb15 100644 --- a/.github/workflows/test-psalm.yml +++ b/.github/workflows/test-psalm.yml @@ -34,8 +34,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: '8.1' - tools: phpstan, phpunit - extensions: intl, json, mbstring, xml, oci8 + extensions: intl, json, mbstring, xml, mysqli, oci8, pgsql, sqlsrv, sqlite3 coverage: none env: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index b47b4d6480c9..4ce5e25fbc1d 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -36,27 +36,29 @@ __DIR__ . '/.php-cs-fixer.no-header.php', __DIR__ . '/.php-cs-fixer.tests.php', __DIR__ . '/.php-cs-fixer.user-guide.php', + __DIR__ . '/preload.php', __DIR__ . '/rector.php', __DIR__ . '/spark', ]); -$overrides = []; +$overrides = [ + // for updating to coding-standard + 'modernize_strpos' => true, + 'ordered_attributes' => ['order' => [], 'sort_algorithm' => 'alpha'], + 'php_unit_attributes' => true, +]; $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..e7d9647e317e 100644 --- a/.php-cs-fixer.no-header.php +++ b/.php-cs-fixer.no-header.php @@ -29,19 +29,20 @@ __DIR__ . '/admin/starter/builds', ]); -$overrides = []; - -$options = [ - 'cacheFile' => 'build/.php-cs-fixer.no-header.cache', - 'finder' => $finder, +$overrides = [ + // for updating to coding-standard + 'modernize_strpos' => true, + 'ordered_attributes' => ['order' => [], 'sort_algorithm' => 'alpha'], + 'php_unit_attributes' => true, ]; -$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(), [ +$options = [ + '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..1b4bfd71e30d 100644 --- a/.php-cs-fixer.tests.php +++ b/.php-cs-fixer.tests.php @@ -35,23 +35,23 @@ $overrides = [ 'void_return' => true, + // for updating to coding-standard + 'modernize_strpos' => true, + 'ordered_attributes' => ['order' => [], 'sort_algorithm' => 'alpha'], + 'php_unit_attributes' => true, ]; $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..3be7cd45c708 100644 --- a/.php-cs-fixer.user-guide.php +++ b/.php-cs-fixer.user-guide.php @@ -39,19 +39,19 @@ 'import_symbols' => false, 'leading_backslash_in_global_namespace' => true, ], + // for updating to coding-standard + 'modernize_strpos' => true, + 'ordered_attributes' => ['order' => [], 'sort_algorithm' => 'alpha'], + 'php_unit_attributes' => true, ]; $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(); diff --git a/CHANGELOG.md b/CHANGELOG.md index 5148b0faad05..9d71e1792fe5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # Changelog +## [v4.5.2](https://github.com/codeigniter4/CodeIgniter4/tree/v4.5.2) (2024-06-10) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.5.1...v4.5.2) + +### Fixed Bugs + +* chore: fix phpunit.xml.dist for appstarter by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8785 +* fix: update `preload.php` for 4.5 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8805 +* fix: [ErrorException] Undefined array key in `spark phpini:check` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8804 +* fix: incorrect Security exception message by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8818 +* fix: [QueryBuilder] TypeError in join() with BETWEEN by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8792 +* fix: [SQLSRV] Query Builder always sets `""."".` to the table name. by @ping-yee in https://github.com/codeigniter4/CodeIgniter4/pull/8786 +* fix: remove unused undefined param $raw in MockCache::save() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8847 +* fix: FileCollection pseudo-regex by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8868 +* fix: [Model] casting may throw InvalidArgumentException: Invalid parameter: nullable by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8870 +* fix: [Model] casting causes TypeError when finding no record by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8871 +* fix: correct property default values in Email by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8855 +* fix: CLI::promptByMultipleKeys() and prompt() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8873 +* fix: [Postgres] show missing error message by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8913 +* fix: TypeError in number_to_amount() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8932 +* fix: Model::find() returns incorrect data with casting by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/8933 + +### Refactoring + +* refactor: remove unused path parameter on PhpStreamWrapper::stream_open() by @samsonasik in https://github.com/codeigniter4/CodeIgniter4/pull/8926 + ## [v4.5.1](https://github.com/codeigniter4/CodeIgniter4/tree/v4.5.1) (2024-04-14) [Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.5.0...v4.5.1) diff --git a/README.md b/README.md index 6fbe0b4fa16c..77419c2a2348 100644 --- a/README.md +++ b/README.md @@ -93,10 +93,10 @@ PHP version 8.1 or higher is required, with the following extensions installed: - [mbstring](http://php.net/manual/en/mbstring.installation.php) > [!WARNING] -> The end of life date for PHP 7.4 was November 28, 2022. -> The end of life date for PHP 8.0 was November 26, 2023. -> If you are still using PHP 7.4 or 8.0, you should upgrade immediately. -> The end of life date for PHP 8.1 will be November 25, 2024. +> - The end of life date for PHP 7.4 was November 28, 2022. +> - The end of life date for PHP 8.0 was November 26, 2023. +> - If you are still using PHP 7.4 or 8.0, you should upgrade immediately. +> - The end of life date for PHP 8.1 will be December 31, 2025. Additionally, make sure that the following extensions are enabled in your PHP: diff --git a/admin/framework/README.md b/admin/framework/README.md index 32668f5af19e..a23783ac316a 100644 --- a/admin/framework/README.md +++ b/admin/framework/README.md @@ -48,10 +48,10 @@ PHP version 8.1 or higher is required, with the following extensions installed: - [mbstring](http://php.net/manual/en/mbstring.installation.php) > [!WARNING] -> The end of life date for PHP 7.4 was November 28, 2022. -> The end of life date for PHP 8.0 was November 26, 2023. -> If you are still using PHP 7.4 or 8.0, you should upgrade immediately. -> The end of life date for PHP 8.1 will be November 25, 2024. +> - The end of life date for PHP 7.4 was November 28, 2022. +> - The end of life date for PHP 8.0 was November 26, 2023. +> - If you are still using PHP 7.4 or 8.0, you should upgrade immediately. +> - The end of life date for PHP 8.1 will be December 31, 2025. Additionally, make sure that the following extensions are enabled in your PHP: diff --git a/admin/next-upgrading-guide.rst b/admin/next-upgrading-guide.rst index bcffc3fe3de5..e38bebe3c4a7 100644 --- a/admin/next-upgrading-guide.rst +++ b/admin/next-upgrading-guide.rst @@ -31,8 +31,9 @@ Project Files Some files in the **project space** (root, app, public, writable) received updates. Due to these files being outside of the **system** scope they will not be changed without your intervention. -There are some third-party CodeIgniter modules available to assist with merging changes to -the project space: `Explore on Packagist `_. +.. note:: There are some third-party CodeIgniter modules available to assist + with merging changes to the project space: + `Explore on Packagist `_. Content Changes =============== diff --git a/admin/starter/README.md b/admin/starter/README.md index 43eb3718978e..d14b4c9c804c 100644 --- a/admin/starter/README.md +++ b/admin/starter/README.md @@ -56,10 +56,10 @@ PHP version 8.1 or higher is required, with the following extensions installed: - [mbstring](http://php.net/manual/en/mbstring.installation.php) > [!WARNING] -> The end of life date for PHP 7.4 was November 28, 2022. -> The end of life date for PHP 8.0 was November 26, 2023. -> If you are still using PHP 7.4 or 8.0, you should upgrade immediately. -> The end of life date for PHP 8.1 will be November 25, 2024. +> - The end of life date for PHP 7.4 was November 28, 2022. +> - The end of life date for PHP 8.0 was November 26, 2023. +> - If you are still using PHP 7.4 or 8.0, you should upgrade immediately. +> - The end of life date for PHP 8.1 will be December 31, 2025. Additionally, make sure that the following extensions are enabled in your PHP: diff --git a/admin/starter/phpunit.xml.dist b/admin/starter/phpunit.xml.dist index dea940878617..b408a99d988c 100644 --- a/admin/starter/phpunit.xml.dist +++ b/admin/starter/phpunit.xml.dist @@ -2,7 +2,7 @@ [!IMPORTANT] > We expect all code changes or bug-fixes to be accompanied by one or more tests > added to our test suite to prove the code works. -If pull requests are not accompanied by relevant tests, they will likely be closed. +If pull requests do not comply with the above, they will likely be closed. Since we are a team of volunteers, we don't have any more time to work on the framework than you do. Please make it as painless for your contributions to be included as possible. -If you need help with getting tests running on your local machines, ask for help -on the [forum](https://forum.codeigniter.com/forumdisplay.php?fid=27). We would -be happy to help out. - The [Open Source Guide](https://opensource.guide/) is a good first read for those new to contributing to open source! @@ -67,13 +66,18 @@ composer cs If you are not familiar with Unit Testing, see [the forum thread](https://forum.codeigniter.com/showthread.php?tid=81830). +If you need help with getting tests running on your local machines, ask for help +on the [forum](https://forum.codeigniter.com/forumdisplay.php?fid=27). We would +be happy to help out. Unit testing is expected for all CodeIgniter components. We use PHPUnit, and run unit tests using GitHub Actions for each PR submitted or changed. -In the CodeIgniter project, there is a `tests` folder, with a structure +In the CodeIgniter project, there is a [tests][tests-folder] folder, with a structure that parallels that of `system`. +[tests-folder]: https://github.com/codeigniter4/CodeIgniter4/tree/develop/tests + The normal practice would be to have a unit test class for each of the classes in `system`, named appropriately. For instance, the `BananaTest` class would test the `Banana` class. There will be occasions when it is @@ -196,10 +200,13 @@ working on your contribution. ### Branching -All bug fixes should be sent to the __"develop"__ branch, this is where the next -bug fix version will be developed. +- All bug fix PRs should be sent to the __"develop"__ branch, this is where the + next bug fix version will be developed. +- PRs with any enhancement should be sent to next minor version branch, e.g. __"4.6"__ -PRs with any enhancement should be sent to next minor version branch, e.g. __"4.5"__ +> [!NOTE] +> If you sent your PR to the wrong branch, see +> [Contribution Workflow](./workflow.md#if-you-sent-to-the-wrong-branch). The __"master"__ branch will always contain the latest stable version and is kept clean so a "hotfix" (e.g. an emergency security patch) can be applied to the @@ -231,6 +238,10 @@ This is *not* just a "signed-off-by" commit, but instead, a digitally signed one See [Contribution signing](./signing.md) for details. +> [!NOTE] +> If you forgot GPG-signing your commits, see +> [Contribution Workflow](./workflow.md#gpg-signing-old-commits). + ### Static Analysis on PHP code We cannot, at all times, guarantee that all PHP code submitted on pull requests @@ -300,7 +311,7 @@ GitHub means "making a copy of that repo to your account" and "cloning" means - If your PR is for bug fixes: - `> git switch develop` - `> git switch -c ` - - If your PR has any enhancement, create new branch from next minor version branch, e.g. __"4.5"__: + - If your PR has any enhancement, create new branch from next minor version branch, e.g. __"4.6"__: - `> git switch ` - `> git switch -c ` 7. Fix existing bugs on the [Issue tracker](https://github.com/codeigniter4/CodeIgniter4/issues) after confirming that no one diff --git a/contributing/workflow.md b/contributing/workflow.md index d893c18f0fb0..30dfc80492af 100644 --- a/contributing/workflow.md +++ b/contributing/workflow.md @@ -18,7 +18,7 @@ values for when you try these: - All bug fix PRs should be sent to the __"develop"__ branch, this is where the next bug fix version will be developed. -- PRs with any enhancement should be sent to next minor version branch, e.g. __"4.5"__ +- PRs with any enhancement should be sent to next minor version branch, e.g. __"4.6"__ The "master" branch will always contain the latest stable version and is kept clean so a "hotfix" (e.g: an emergency security @@ -114,7 +114,7 @@ is optional, and implies a sort of namespacing if used. - All bug fix PRs should be sent to the __"develop"__ branch, this is where the next bug fix version will be developed. -- PRs with any enhancement should be sent to next minor version branch, e.g. __"4.5"__ +- PRs with any enhancement should be sent to next minor version branch, e.g. __"4.6"__ For instance, if you send a PR to __"develop"__ branch, make sure you are in the *develop* branch, and create a new bugfix branch, based on *develop*, for a new @@ -126,11 +126,11 @@ feature you are creating: ``` If you send a PR with an enhancement, make sure you are in the *next minor version* -branch, and create a new feature branch, based on, e.g., __"4.5"__, for a new +branch, and create a new feature branch, based on, e.g., __"4.6"__, for a new feature you are creating: ```console -> git switch 4.5 +> git switch 4.6 > git switch -c new/mind-reader ``` @@ -283,7 +283,7 @@ switching to the branch you wish to contribute, and then clicking on "New pull request". Make sure the pull request is for the shared __"develop"__ or next minor version -branch, e.g. __"4.5"__, or it may be rejected. +branch, e.g. __"4.6"__, or it may be rejected. Make sure that the PR title is helpful for the maintainers and other developers. Add any comments appropriate, for instance asking for @@ -324,7 +324,7 @@ And if your PRs have the breaking changes, label the following label: If you are asked for changes in the review, commit the fix in your branch and push it to GitHub again. -If the __"develop"__ or next minor version branch, e.g. __"4.5"__, progresses +If the __"develop"__ or next minor version branch, e.g. __"4.6"__, progresses and conflicts arise that prevent merging, or if you are asked to *rebase*, do the following: @@ -364,7 +364,7 @@ And finally push your local branch to your GitHub repository: If you have sent a PR to the wrong branch, you need to create a new PR branch. -When you have the PR branch `feat-abc` and you should have sent the PR to __"4.5"__, +When you have the PR branch `feat-abc` and you should have sent the PR to __"4.6"__, but you created the PR branch from `develop` and sent a PR. Copy the IDs of any commits you made that you want to keep: @@ -373,13 +373,13 @@ Copy the IDs of any commits you made that you want to keep: > git log ``` -Update your __"4.5"__ branch: +Update your __"4.6"__ branch: ```console > git fetch upstream -> git switch 4.5 -> git merge upstream/4.5 -> git push origin 4.5 +> git switch 4.6 +> git merge upstream/4.6 +> git push origin 4.6 ``` (Optional) Create a new branch as a backup, just in case: @@ -388,10 +388,10 @@ Update your __"4.5"__ branch: > git branch feat-abc.bk feat-abc ``` -Rebase your PR branch from `develop` onto __"4.5"__: +Rebase your PR branch from `develop` onto __"4.6"__: ```console -> git rebase --onto 4.5 develop feat-abc +> git rebase --onto 4.6 develop feat-abc ``` Force push. @@ -400,7 +400,7 @@ Force push. > git push --force-with-lease origin feat-abc ``` -On the GitHub PR page, change the base branch to the correct branch __"4.5"__. +On the GitHub PR page, change the base branch to the correct branch __"4.6"__. ## Cleanup diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml index 546630d3f446..141e99770713 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 cfee07815e8a..995190b9d740 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -1,11 +1,6 @@ '#^PHPDoc type array\\\\> of property Config\\\\Filters\\:\\:\\$methods is not the same as PHPDoc type array of overridden property CodeIgniter\\\\Config\\\\Filters\\:\\:\\$methods\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/app/Config/Filters.php', -]; $ignoreErrors[] = [ 'message' => '#^PHPDoc type array\\\\>\\> of property Config\\\\Filters\\:\\:\\$filters is not the same as PHPDoc type array of overridden property CodeIgniter\\\\Config\\\\Filters\\:\\:\\$filters\\.$#', 'count' => 1, @@ -383,7 +378,7 @@ ]; $ignoreErrors[] = [ 'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#', - 'count' => 5, + 'count' => 2, 'path' => __DIR__ . '/system/CLI/CLI.php', ]; $ignoreErrors[] = [ @@ -706,496 +701,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Commands/Encryption/GenerateKey.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Encryption\\\\GenerateKey\\:\\:confirmOverwrite\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Encryption/GenerateKey.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Encryption\\\\GenerateKey\\:\\:setNewEncryptionKey\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Encryption/GenerateKey.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\CellGenerator\\:\\:execute\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CellGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\CellGenerator\\:\\:generateClass\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CellGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\CellGenerator\\:\\:generateView\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CellGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\CellGenerator\\:\\:parseTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CellGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\CellGenerator\\:\\:parseTemplate\\(\\) has parameter \\$replace with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CellGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\CellGenerator\\:\\:parseTemplate\\(\\) has parameter \\$search with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CellGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\CellGenerator\\:\\:renderTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CellGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\Commands\\\\Generators\\\\CellGenerator\\:\\:\\$params type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CellGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\CommandGenerator\\:\\:execute\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CommandGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\CommandGenerator\\:\\:generateClass\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CommandGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\CommandGenerator\\:\\:generateView\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CommandGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\CommandGenerator\\:\\:parseTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CommandGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\CommandGenerator\\:\\:parseTemplate\\(\\) has parameter \\$replace with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CommandGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\CommandGenerator\\:\\:parseTemplate\\(\\) has parameter \\$search with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CommandGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\CommandGenerator\\:\\:renderTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CommandGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\Commands\\\\Generators\\\\CommandGenerator\\:\\:\\$params type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/CommandGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ConfigGenerator\\:\\:execute\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ConfigGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ConfigGenerator\\:\\:generateClass\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ConfigGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ConfigGenerator\\:\\:generateView\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ConfigGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ConfigGenerator\\:\\:parseTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ConfigGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ConfigGenerator\\:\\:parseTemplate\\(\\) has parameter \\$replace with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ConfigGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ConfigGenerator\\:\\:parseTemplate\\(\\) has parameter \\$search with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ConfigGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ConfigGenerator\\:\\:renderTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ConfigGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\Commands\\\\Generators\\\\ConfigGenerator\\:\\:\\$params type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ConfigGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ControllerGenerator\\:\\:execute\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ControllerGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ControllerGenerator\\:\\:generateClass\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ControllerGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ControllerGenerator\\:\\:generateView\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ControllerGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ControllerGenerator\\:\\:parseTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ControllerGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ControllerGenerator\\:\\:parseTemplate\\(\\) has parameter \\$replace with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ControllerGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ControllerGenerator\\:\\:parseTemplate\\(\\) has parameter \\$search with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ControllerGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ControllerGenerator\\:\\:renderTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ControllerGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\Commands\\\\Generators\\\\ControllerGenerator\\:\\:\\$params type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ControllerGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\EntityGenerator\\:\\:execute\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/EntityGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\EntityGenerator\\:\\:generateClass\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/EntityGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\EntityGenerator\\:\\:generateView\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/EntityGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\EntityGenerator\\:\\:parseTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/EntityGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\EntityGenerator\\:\\:parseTemplate\\(\\) has parameter \\$replace with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/EntityGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\EntityGenerator\\:\\:parseTemplate\\(\\) has parameter \\$search with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/EntityGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\EntityGenerator\\:\\:renderTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/EntityGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\Commands\\\\Generators\\\\EntityGenerator\\:\\:\\$params type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/EntityGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\FilterGenerator\\:\\:execute\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/FilterGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\FilterGenerator\\:\\:generateClass\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/FilterGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\FilterGenerator\\:\\:generateView\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/FilterGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\FilterGenerator\\:\\:parseTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/FilterGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\FilterGenerator\\:\\:parseTemplate\\(\\) has parameter \\$replace with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/FilterGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\FilterGenerator\\:\\:parseTemplate\\(\\) has parameter \\$search with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/FilterGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\FilterGenerator\\:\\:renderTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/FilterGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\Commands\\\\Generators\\\\FilterGenerator\\:\\:\\$params type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/FilterGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\MigrationGenerator\\:\\:execute\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/MigrationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\MigrationGenerator\\:\\:generateClass\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/MigrationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\MigrationGenerator\\:\\:generateView\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/MigrationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\MigrationGenerator\\:\\:parseTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/MigrationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\MigrationGenerator\\:\\:parseTemplate\\(\\) has parameter \\$replace with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/MigrationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\MigrationGenerator\\:\\:parseTemplate\\(\\) has parameter \\$search with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/MigrationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\MigrationGenerator\\:\\:renderTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/MigrationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\Commands\\\\Generators\\\\MigrationGenerator\\:\\:\\$params type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/MigrationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ModelGenerator\\:\\:execute\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ModelGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ModelGenerator\\:\\:generateClass\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ModelGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ModelGenerator\\:\\:generateView\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ModelGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ModelGenerator\\:\\:parseTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ModelGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ModelGenerator\\:\\:parseTemplate\\(\\) has parameter \\$replace with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ModelGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ModelGenerator\\:\\:parseTemplate\\(\\) has parameter \\$search with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ModelGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ModelGenerator\\:\\:renderTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ModelGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\Commands\\\\Generators\\\\ModelGenerator\\:\\:\\$params type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ModelGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ScaffoldGenerator\\:\\:execute\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ScaffoldGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ScaffoldGenerator\\:\\:generateClass\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ScaffoldGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ScaffoldGenerator\\:\\:generateView\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ScaffoldGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ScaffoldGenerator\\:\\:parseTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ScaffoldGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ScaffoldGenerator\\:\\:parseTemplate\\(\\) has parameter \\$replace with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ScaffoldGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ScaffoldGenerator\\:\\:parseTemplate\\(\\) has parameter \\$search with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ScaffoldGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ScaffoldGenerator\\:\\:renderTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ScaffoldGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\Commands\\\\Generators\\\\ScaffoldGenerator\\:\\:\\$params type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ScaffoldGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\SeederGenerator\\:\\:execute\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/SeederGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\SeederGenerator\\:\\:generateClass\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/SeederGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\SeederGenerator\\:\\:generateView\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/SeederGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\SeederGenerator\\:\\:parseTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/SeederGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\SeederGenerator\\:\\:parseTemplate\\(\\) has parameter \\$replace with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/SeederGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\SeederGenerator\\:\\:parseTemplate\\(\\) has parameter \\$search with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/SeederGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\SeederGenerator\\:\\:renderTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/SeederGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\Commands\\\\Generators\\\\SeederGenerator\\:\\:\\$params type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/SeederGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\TestGenerator\\:\\:execute\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/TestGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\TestGenerator\\:\\:generateClass\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/TestGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\TestGenerator\\:\\:generateView\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/TestGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\TestGenerator\\:\\:parseTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/TestGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\TestGenerator\\:\\:parseTemplate\\(\\) has parameter \\$replace with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/TestGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\TestGenerator\\:\\:parseTemplate\\(\\) has parameter \\$search with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/TestGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\TestGenerator\\:\\:renderTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/TestGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\Commands\\\\Generators\\\\TestGenerator\\:\\:\\$params type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/TestGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ValidationGenerator\\:\\:execute\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ValidationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ValidationGenerator\\:\\:generateClass\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ValidationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ValidationGenerator\\:\\:generateView\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ValidationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ValidationGenerator\\:\\:parseTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ValidationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ValidationGenerator\\:\\:parseTemplate\\(\\) has parameter \\$replace with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ValidationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ValidationGenerator\\:\\:parseTemplate\\(\\) has parameter \\$search with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ValidationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Commands\\\\Generators\\\\ValidationGenerator\\:\\:renderTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ValidationGenerator.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\Commands\\\\Generators\\\\ValidationGenerator\\:\\:\\$params type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Commands/Generators/ValidationGenerator.php', -]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\Commands\\\\ListCommands\\:\\:listFull\\(\\) has no return type specified\\.$#', 'count' => 1, @@ -1641,11 +1146,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Config/Filters.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\Config\\\\Filters\\:\\:\\$methods type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Config/Filters.php', -]; $ignoreErrors[] = [ 'message' => '#^Accessing offset \'SERVER_PROTOCOL\' directly on \\$_SERVER is discouraged\\.$#', 'count' => 1, @@ -1791,41 +1291,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseBuilder.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_deleteBatch\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_insert\\(\\) has parameter \\$keys with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_insert\\(\\) has parameter \\$unescapedKeys with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_like\\(\\) has parameter \\$field with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_replace\\(\\) has parameter \\$keys with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_replace\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_update\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_whereIn\\(\\) has parameter \\$values with no signature specified for Closure\\.$#', 'count' => 1, @@ -2206,6 +1671,11 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseBuilder.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#3 \\.\\.\\.\\$arrays of function array_map expects array, int\\|string given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/system/Database/BaseBuilder.php', +]; $ignoreErrors[] = [ 'message' => '#^Property CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:\\$QBFrom type has no value type specified in iterable type array\\.$#', 'count' => 1, @@ -3001,11 +2471,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, @@ -3127,37 +2592,22 @@ 'path' => __DIR__ . '/system/Database/OCI8/Builder.php', ]; $ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:_deleteBatch\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/OCI8/Builder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:_replace\\(\\) has parameter \\$keys with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/OCI8/Builder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:_replace\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/OCI8/Builder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:_update\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', + 'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:fieldsFromQuery\\(\\) return type has no value type specified in iterable type array\\.$#', 'count' => 1, 'path' => __DIR__ . '/system/Database/OCI8/Builder.php', ]; $ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:fieldsFromQuery\\(\\) return type has no value type specified in iterable type array\\.$#', + 'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:resetSelect\\(\\) has no return type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/system/Database/OCI8/Builder.php', ]; $ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\OCI8\\\\Builder\\:\\:resetSelect\\(\\) has no return type specified\\.$#', + '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, '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\\.$#', + 'message' => '#^Parameter \\#3 \\.\\.\\.\\$arrays of function array_map expects array, int\\|string given\\.$#', 'count' => 1, 'path' => __DIR__ . '/system/Database/OCI8/Builder.php', ]; @@ -3322,27 +2772,12 @@ 'path' => __DIR__ . '/system/Database/Postgre/Builder.php', ]; $ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Builder\\:\\:_deleteBatch\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/Postgre/Builder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Builder\\:\\:_insert\\(\\) has parameter \\$keys with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/Postgre/Builder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Builder\\:\\:_insert\\(\\) has parameter \\$unescapedKeys with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/Postgre/Builder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Builder\\:\\:_update\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', + 'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Builder\\:\\:replace\\(\\) has parameter \\$set with no value type specified in iterable type array\\.$#', 'count' => 1, 'path' => __DIR__ . '/system/Database/Postgre/Builder.php', ]; $ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\Postgre\\\\Builder\\:\\:replace\\(\\) has parameter \\$set with no value type specified in iterable type array\\.$#', + 'message' => '#^Parameter \\#3 \\.\\.\\.\\$arrays of function array_map expects array, int\\|string given\\.$#', 'count' => 1, 'path' => __DIR__ . '/system/Database/Postgre/Builder.php', ]; @@ -3391,11 +2826,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, @@ -3686,31 +3116,6 @@ 'count' => 9, 'path' => __DIR__ . '/system/Database/SQLSRV/Builder.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\SQLSRV\\\\Builder\\:\\:_insert\\(\\) has parameter \\$keys with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/SQLSRV/Builder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\SQLSRV\\\\Builder\\:\\:_insert\\(\\) has parameter \\$unescapedKeys with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/SQLSRV/Builder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\SQLSRV\\\\Builder\\:\\:_replace\\(\\) has parameter \\$keys with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/SQLSRV/Builder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\SQLSRV\\\\Builder\\:\\:_replace\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/SQLSRV/Builder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\SQLSRV\\\\Builder\\:\\:_update\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/SQLSRV/Builder.php', -]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\Database\\\\SQLSRV\\\\Builder\\:\\:fieldsFromQuery\\(\\) return type has no value type specified in iterable type array\\.$#', 'count' => 1, @@ -3752,12 +3157,7 @@ 'path' => __DIR__ . '/system/Database/SQLSRV/Connection.php', ]; $ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\SQLSRV\\\\Connection\\:\\:__construct\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - '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\\.$#', + 'message' => '#^Method CodeIgniter\\\\Database\\\\SQLSRV\\\\Connection\\:\\:__construct\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', 'count' => 1, 'path' => __DIR__ . '/system/Database/SQLSRV/Connection.php', ]; @@ -3922,17 +3322,7 @@ 'path' => __DIR__ . '/system/Database/SQLite3/Builder.php', ]; $ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\SQLite3\\\\Builder\\:\\:_deleteBatch\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/SQLite3/Builder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\SQLite3\\\\Builder\\:\\:_replace\\(\\) has parameter \\$keys with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/SQLite3/Builder.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\Database\\\\SQLite3\\\\Builder\\:\\:_replace\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', + 'message' => '#^Parameter \\#3 \\.\\.\\.\\$arrays of function array_map expects array, int\\|string given\\.$#', 'count' => 1, 'path' => __DIR__ . '/system/Database/SQLite3/Builder.php', ]; @@ -3951,11 +3341,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 +8046,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, @@ -9556,21 +8936,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/View/Cell.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Cell\\:\\:prepareParams\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Cell.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Cell\\:\\:prepareParams\\(\\) return type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Cell.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Cell\\:\\:render\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Cell.php', -]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\View\\\\Cell\\:\\:renderCell\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', 'count' => 1, @@ -9616,236 +8981,26 @@ 'count' => 1, 'path' => __DIR__ . '/system/View/Cells/Cell.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Filters\\:\\:default\\(\\) has parameter \\$value with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Filters.php', -]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:addPlugin\\(\\) has parameter \\$callback with no signature specified for callable\\.$#', 'count' => 1, 'path' => __DIR__ . '/system/View/Parser.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:applyFilters\\(\\) has parameter \\$filters with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Parser.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:objectToArray\\(\\) has parameter \\$value with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Parser.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:objectToArray\\(\\) return type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Parser.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:parse\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Parser.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:parse\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Parser.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:parsePair\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Parser.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:parsePair\\(\\) return type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Parser.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:parseSingle\\(\\) return type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Parser.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:prepareReplacement\\(\\) has parameter \\$matches with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Parser.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:render\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Parser.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:renderString\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Parser.php', -]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:replaceSingle\\(\\) has parameter \\$pattern with no value type specified in iterable type array\\.$#', 'count' => 1, 'path' => __DIR__ . '/system/View/Parser.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Parser\\:\\:setData\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Parser.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\View\\\\Parser\\:\\:\\$dataContexts type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Parser.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\View\\\\Parser\\:\\:\\$noparseBlocks type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Parser.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\RendererInterface\\:\\:render\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/RendererInterface.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\RendererInterface\\:\\:renderString\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/RendererInterface.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\RendererInterface\\:\\:setData\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/RendererInterface.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:__construct\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Table.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_defaultTemplate\\(\\) return type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Table.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_prepArgs\\(\\) has parameter \\$args with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Table.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_prepArgs\\(\\) return type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Table.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:_setFromArray\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Table.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:generate\\(\\) has parameter \\$tableData with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Table.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:makeColumns\\(\\) has parameter \\$array with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Table.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:makeColumns\\(\\) return type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Table.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\Table\\:\\:setTemplate\\(\\) has parameter \\$template with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Table.php', -]; $ignoreErrors[] = [ 'message' => '#^Only booleans are allowed in an if condition, string\\|null given\\.$#', 'count' => 1, 'path' => __DIR__ . '/system/View/Table.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$footing type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Table.php', -]; $ignoreErrors[] = [ 'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$function type has no signature specified for callable\\.$#', 'count' => 1, 'path' => __DIR__ . '/system/View/Table.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$heading type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Table.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$rows type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Table.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\View\\\\Table\\:\\:\\$template type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/Table.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:getData\\(\\) return type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/View.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:getPerformanceData\\(\\) return type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/View.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:include\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/View.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:render\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/View.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:renderString\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/View.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\View\\\\View\\:\\:setData\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/View.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\View\\\\View\\:\\:\\$data type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/View.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\View\\\\View\\:\\:\\$performanceData type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/View.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\View\\\\View\\:\\:\\$renderVars type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/View.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\View\\\\View\\:\\:\\$sections type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/View.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\View\\\\View\\:\\:\\$tempData type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/View/View.php', -]; $ignoreErrors[] = [ 'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#', 'count' => 2, @@ -9861,46 +9016,6 @@ 'count' => 1, 'path' => __DIR__ . '/tests/_support/Cells/StarterCell.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Tests\\\\Support\\\\Commands\\\\LanguageCommand\\:\\:execute\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/LanguageCommand.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Tests\\\\Support\\\\Commands\\\\LanguageCommand\\:\\:generateClass\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/LanguageCommand.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Tests\\\\Support\\\\Commands\\\\LanguageCommand\\:\\:generateView\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/LanguageCommand.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Tests\\\\Support\\\\Commands\\\\LanguageCommand\\:\\:parseTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/LanguageCommand.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Tests\\\\Support\\\\Commands\\\\LanguageCommand\\:\\:parseTemplate\\(\\) has parameter \\$replace with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/LanguageCommand.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Tests\\\\Support\\\\Commands\\\\LanguageCommand\\:\\:parseTemplate\\(\\) has parameter \\$search with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/LanguageCommand.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Tests\\\\Support\\\\Commands\\\\LanguageCommand\\:\\:renderTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/LanguageCommand.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property Tests\\\\Support\\\\Commands\\\\LanguageCommand\\:\\:\\$params type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/LanguageCommand.php', -]; $ignoreErrors[] = [ 'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#', 'count' => 1, @@ -9911,46 +9026,6 @@ 'count' => 1, 'path' => __DIR__ . '/tests/_support/Commands/ParamsReveal.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Tests\\\\Support\\\\Commands\\\\Unsuffixable\\:\\:execute\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/Unsuffixable.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Tests\\\\Support\\\\Commands\\\\Unsuffixable\\:\\:generateClass\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/Unsuffixable.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Tests\\\\Support\\\\Commands\\\\Unsuffixable\\:\\:generateView\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/Unsuffixable.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Tests\\\\Support\\\\Commands\\\\Unsuffixable\\:\\:parseTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/Unsuffixable.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Tests\\\\Support\\\\Commands\\\\Unsuffixable\\:\\:parseTemplate\\(\\) has parameter \\$replace with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/Unsuffixable.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Tests\\\\Support\\\\Commands\\\\Unsuffixable\\:\\:parseTemplate\\(\\) has parameter \\$search with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/Unsuffixable.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Tests\\\\Support\\\\Commands\\\\Unsuffixable\\:\\:renderTemplate\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/Unsuffixable.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Property Tests\\\\Support\\\\Commands\\\\Unsuffixable\\:\\:\\$params type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Commands/Unsuffixable.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Tests\\\\Support\\\\Config\\\\BadRegistrar\\:\\:RegistrarConfig\\(\\) has no return type specified\\.$#', 'count' => 1, @@ -10917,12 +9992,12 @@ 'path' => __DIR__ . '/tests/system/AutoReview/FrameworkCodeTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Method CodeIgniter\\\\AutoReview\\\\FrameworkCodeTest\\:\\:provideEachTestClassHasCorrectGroupAnnotation\\(\\) return type has no value type specified in iterable type iterable\\.$#', + 'message' => '#^Method CodeIgniter\\\\AutoReview\\\\FrameworkCodeTest\\:\\:provideEachTestClassHasCorrectGroupAttributeName\\(\\) return type has no value type specified in iterable type iterable\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/AutoReview/FrameworkCodeTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\AutoReview\\\\FrameworkCodeTest\\:\\:\\$recognizedGroupAnnotations type has no value type specified in iterable type array\\.$#', + 'message' => '#^Property CodeIgniter\\\\AutoReview\\\\FrameworkCodeTest\\:\\:\\$recognizedGroupAttributeNames type has no value type specified in iterable type array\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/AutoReview/FrameworkCodeTest.php', ]; @@ -11667,7 +10742,7 @@ 'path' => __DIR__ . '/tests/system/Config/FactoriesTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Config/FactoriesTest\\.php\\:88\\:\\:\\$widgets has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Config/FactoriesTest\\.php\\:89\\:\\:\\$widgets has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Config/FactoriesTest.php', ]; @@ -14772,122 +13847,122 @@ 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:197\\:\\:\\$_options has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:198\\:\\:\\$_options has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:197\\:\\:\\$country has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:198\\:\\:\\$country has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:197\\:\\:\\$created_at has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:198\\:\\:\\$created_at has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:197\\:\\:\\$deleted has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:198\\:\\:\\$deleted has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:197\\:\\:\\$email has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:198\\:\\:\\$email has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:197\\:\\:\\$id has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:198\\:\\:\\$id has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:197\\:\\:\\$name has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:198\\:\\:\\$name has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:197\\:\\:\\$updated_at has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:198\\:\\:\\$updated_at has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:216\\:\\:\\$_options has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:217\\:\\:\\$_options has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:216\\:\\:\\$country has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:217\\:\\:\\$country has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:216\\:\\:\\$created_at has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:217\\:\\:\\$created_at has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:216\\:\\:\\$deleted has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:217\\:\\:\\$deleted has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:216\\:\\:\\$email has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:217\\:\\:\\$email has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:216\\:\\:\\$id has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:217\\:\\:\\$id has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:216\\:\\:\\$name has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:217\\:\\:\\$name has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:216\\:\\:\\$updated_at has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:217\\:\\:\\$updated_at has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:349\\:\\:\\$_options has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:350\\:\\:\\$_options has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:349\\:\\:\\$country has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:350\\:\\:\\$country has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:349\\:\\:\\$created_at has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:350\\:\\:\\$created_at has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:349\\:\\:\\$deleted has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:350\\:\\:\\$deleted has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:349\\:\\:\\$email has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:350\\:\\:\\$email has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:349\\:\\:\\$id has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:350\\:\\:\\$id has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:349\\:\\:\\$name has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:350\\:\\:\\$name has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:349\\:\\:\\$updated_at has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/Models/UpdateModelTest\\.php\\:350\\:\\:\\$updated_at has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/Models/UpdateModelTest.php', ]; @@ -16566,11 +15641,6 @@ 'count' => 1, 'path' => __DIR__ . '/tests/system/Validation/ValidationTest.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$params of method CodeIgniter\\\\View\\\\Cell\\:\\:prepareParams\\(\\) expects array\\|string\\|null, float given\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/View/CellTest.php', -]; $ignoreErrors[] = [ 'message' => '#^Property CodeIgniter\\\\View\\\\DecoratorsTest\\:\\:\\$loader \\(CodeIgniter\\\\Autoloader\\\\FileLocator\\) does not accept CodeIgniter\\\\Autoloader\\\\FileLocatorInterface\\.$#', 'count' => 1, @@ -16602,7 +15672,7 @@ 'path' => __DIR__ . '/tests/system/View/ParserTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Method class@anonymous/tests/system/View/ParserTest\\.php\\:339\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#', + 'message' => '#^Method class@anonymous/tests/system/View/ParserTest\\.php\\:340\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/View/ParserTest.php', ]; @@ -16617,17 +15687,17 @@ 'path' => __DIR__ . '/tests/system/View/ParserTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/View/ParserTest\\.php\\:339\\:\\:\\$bar has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/View/ParserTest\\.php\\:340\\:\\:\\$bar has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/View/ParserTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/View/ParserTest\\.php\\:339\\:\\:\\$foo has no type specified\\.$#', + 'message' => '#^Property class@anonymous/tests/system/View/ParserTest\\.php\\:340\\:\\:\\$foo has no type specified\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/View/ParserTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Property class@anonymous/tests/system/View/ParserTest\\.php\\:369\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', + 'message' => '#^Property class@anonymous/tests/system/View/ParserTest\\.php\\:370\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/View/ParserTest.php', ]; @@ -16692,15 +15762,10 @@ 'path' => __DIR__ . '/tests/system/View/TableTest.php', ]; $ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$array of method CodeIgniter\\\\View\\\\Table\\:\\:makeColumns\\(\\) expects array, string given\\.$#', + 'message' => '#^Parameter \\#1 \\$array of method CodeIgniter\\\\View\\\\Table\\:\\:makeColumns\\(\\) expects array\\, string given\\.$#', 'count' => 1, 'path' => __DIR__ . '/tests/system/View/TableTest.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$template of method CodeIgniter\\\\View\\\\Table\\:\\:setTemplate\\(\\) expects array, string given\\.$#', - 'count' => 2, - 'path' => __DIR__ . '/tests/system/View/TableTest.php', -]; $ignoreErrors[] = [ 'message' => '#^Parameter \\#2 \\$columnLimit of method CodeIgniter\\\\View\\\\Table\\:\\:makeColumns\\(\\) expects int, string given\\.$#', 'count' => 1, diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 7dd53849a9a8..eccd0f88db75 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -31,7 +31,9 @@ parameters: - tests/system/View/Views/* scanDirectories: - system/Helpers - checkGenericClassInNonGenericObjectType: false + ignoreErrors: + - + identifier: missingType.generics checkMissingCallableSignature: true treatPhpDocTypesAsCertain: false strictRules: diff --git a/preload.php b/preload.php index 2fa699388270..75d86f5cf572 100644 --- a/preload.php +++ b/preload.php @@ -29,19 +29,6 @@ // Path to the front controller define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR); -/** - * See https://www.php.net/manual/en/function.str-contains.php#126277 - */ -if (! function_exists('str_contains')) { - /** - * Polyfill of str_contains() - */ - function str_contains(string $haystack, string $needle): bool - { - return empty($needle) || strpos($haystack, $needle) !== false; - } -} - class preload { /** @@ -51,6 +38,7 @@ class preload [ 'include' => __DIR__ . '/vendor/codeigniter4/framework/system', // Change this path if using manual installation 'exclude' => [ + '/system/bootstrap.php', // Not needed if you don't use them. '/system/Database/OCI8/', '/system/Database/Postgre/', @@ -77,16 +65,18 @@ public function __construct() $this->loadAutoloader(); } - private function loadAutoloader() + private function loadAutoloader(): void { $paths = new Config\Paths(); - require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php'; + require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'Boot.php'; + + CodeIgniter\Boot::preload($paths); } /** * Load PHP files. */ - public function load() + public function load(): void { foreach ($this->paths as $path) { $directory = new RecursiveDirectoryIterator($path['include']); diff --git a/rector.php b/rector.php index b9d51f872fdc..1a12e38f3223 100644 --- a/rector.php +++ b/rector.php @@ -18,7 +18,6 @@ use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector; use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector; use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector; -use Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector; use Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector; use Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector; use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector; @@ -36,7 +35,6 @@ use Rector\Config\RectorConfig; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector; -use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector; use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector; use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector; use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector; @@ -44,11 +42,9 @@ use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Php70\Rector\FuncCall\RandomFunctionRector; -use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; use Rector\Php80\Rector\FunctionLike\MixedTypeRector; -use Rector\Php81\Rector\ClassConst\FinalizePublicClassConstantRector; use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector; use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\CoversAnnotationWithValueToAttributeRector; @@ -107,14 +103,8 @@ __DIR__ . '/tests/_support/Commands/Foobar.php', __DIR__ . '/tests/_support/View', - JsonThrowOnErrorRector::class, YieldDataProviderRector::class, - RemoveUnusedPromotedPropertyRector::class => [ - // Bug in rector 1.0.0. See https://github.com/rectorphp/rector-src/pull/5573 - __DIR__ . '/tests/_support/Entity/CustomUser.php', - ], - RemoveUnusedPrivateMethodRector::class => [ // private method called via getPrivateMethodInvoker __DIR__ . '/tests/system/Test/ReflectionHelperTest.php', @@ -158,8 +148,6 @@ // use mt_rand instead of random_int on purpose on non-cryptographically random RandomFunctionRector::class, - SimplifyRegexPatternRector::class, - // PHP 8.0 features but cause breaking changes ClassPropertyAssignToConstructorPromotionRector::class => [ __DIR__ . '/system/Database/BaseResult.php', @@ -174,16 +162,6 @@ ], MixedTypeRector::class, - // PHP 8.1 features but cause breaking changes - FinalizePublicClassConstantRector::class => [ - __DIR__ . '/system/Cache/Handlers/BaseHandler.php', - __DIR__ . '/system/Cache/Handlers/FileHandler.php', - __DIR__ . '/system/CodeIgniter.php', - __DIR__ . '/system/Events/Events.php', - __DIR__ . '/system/Log/Handlers/ChromeLoggerHandler.php', - __DIR__ . '/system/Log/Handlers/ErrorlogHandler.php', - __DIR__ . '/system/Security/Security.php', - ], ReturnNeverTypeRector::class => [ __DIR__ . '/system/Cache/Handlers/BaseHandler.php', __DIR__ . '/system/Cache/Handlers/MemcachedHandler.php', @@ -234,7 +212,6 @@ $rectorConfig->rule(ChangeArrayPushToArrayAssignRector::class); $rectorConfig->rule(UnnecessaryTernaryExpressionRector::class); $rectorConfig->rule(RemoveErrorSuppressInTryCatchStmtsRector::class); - $rectorConfig->rule(SimplifyRegexPatternRector::class); $rectorConfig->rule(FuncGetArgsToVariadicParamRector::class); $rectorConfig->rule(MakeInheritedMethodVisibilitySameAsParentRector::class); $rectorConfig->rule(SimplifyEmptyArrayCheckRector::class); 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/system/Boot.php b/system/Boot.php index 8a769bbb6866..54468a5cc192 100644 --- a/system/Boot.php +++ b/system/Boot.php @@ -122,6 +122,19 @@ public static function bootTest(Paths $paths): void static::autoloadHelpers(); } + /** + * Used by `preload.php` + */ + public static function preload(Paths $paths): void + { + static::definePathConstants($paths); + static::loadConstants(); + static::defineEnvironment(); + static::loadEnvironmentBootstrap($paths, false); + + static::loadAutoloader(); + } + /** * Load environment settings from .env files into $_SERVER and $_ENV */ diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index 865241b75cbf..7badf1807dcd 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -258,7 +258,8 @@ public static function prompt(string $field, $options = null, $validation = null static::fwrite(STDOUT, $field . (trim($field) !== '' ? ' ' : '') . $extraOutput . ': '); // Read the input from keyboard. - $input = trim(static::$io->input()) ?: (string) $default; + $input = trim(static::$io->input()); + $input = ($input === '') ? (string) $default : $input; if ($validation !== []) { while (! static::validate('"' . trim($field) . '"', $input, $validation)) { @@ -330,7 +331,9 @@ public static function promptByMultipleKeys(string $text, array $options): array CLI::write($text); CLI::printKeysAndValues($options); CLI::newLine(); - $input = static::prompt($extraOutput) ?: 0; // 0 is default + + $input = static::prompt($extraOutput); + $input = ($input === '') ? '0' : $input; // 0 is default // validation while (true) { @@ -343,13 +346,15 @@ public static function promptByMultipleKeys(string $text, array $options): array // find max from input $maxInput = max($inputToArray); - // return the prompt again if $input contain(s) non-numeric charachter, except a comma. - // And if max from $options less than max from input - // it is mean user tried to access null value in $options + // return the prompt again if $input contain(s) non-numeric character, except a comma. + // And if max from $options less than max from input, + // it means user tried to access null value in $options if (! $pattern || $maxOptions < $maxInput) { static::error('Please select correctly.'); CLI::newLine(); - $input = static::prompt($extraOutput) ?: 0; + + $input = static::prompt($extraOutput); + $input = ($input === '') ? '0' : $input; } else { break; } diff --git a/system/CLI/GeneratorTrait.php b/system/CLI/GeneratorTrait.php index 5640a7ae1ac8..258f12379dd6 100644 --- a/system/CLI/GeneratorTrait.php +++ b/system/CLI/GeneratorTrait.php @@ -96,13 +96,15 @@ trait GeneratorTrait * * @internal * - * @var array + * @var array */ private $params = []; /** * Execute the command. * + * @param array $params + * * @deprecated use generateClass() instead */ protected function execute(array $params): void @@ -112,6 +114,8 @@ protected function execute(array $params): void /** * Generates a class file from an existing template. + * + * @param array $params */ protected function generateClass(array $params): void { @@ -134,7 +138,8 @@ protected function generateClass(array $params): void /** * Generate a view file from an existing template. * - * @param string $view namespaced view name that is generated + * @param string $view namespaced view name that is generated + * @param array $params */ protected function generateView(string $view, array $params): void { @@ -331,6 +336,8 @@ private function normalizeInputClassName(): string /** * Gets the generator view as defined in the `Config\Generators::$views`, * with fallback to `$template` when the defined view does not exist. + * + * @param array $data */ protected function renderTemplate(array $data = []): string { @@ -352,7 +359,10 @@ protected function renderTemplate(array $data = []): string /** * Performs pseudo-variables contained within view file. * - * @param string $class namespaced classname or namespaced view. + * @param string $class namespaced classname or namespaced view. + * @param list $search + * @param list $replace + * @param array $data * * @return string generated file content */ diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index 1758228076ab..65f5dd22b593 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -56,7 +56,7 @@ class CodeIgniter /** * The current version of CodeIgniter Framework */ - public const CI_VERSION = '4.5.1'; + public const CI_VERSION = '4.5.2'; /** * App startup time. diff --git a/system/Commands/Encryption/GenerateKey.php b/system/Commands/Encryption/GenerateKey.php index 820ec48137c9..21a582a06725 100644 --- a/system/Commands/Encryption/GenerateKey.php +++ b/system/Commands/Encryption/GenerateKey.php @@ -124,6 +124,8 @@ protected function generateRandomKey(string $prefix, int $length): string /** * Sets the new encryption key in your .env file. + * + * @param array $params */ protected function setNewEncryptionKey(string $key, array $params): bool { @@ -139,6 +141,8 @@ protected function setNewEncryptionKey(string $key, array $params): bool /** * Checks whether to overwrite existing encryption key. + * + * @param array $params */ protected function confirmOverwrite(array $params): bool { diff --git a/system/Config/Filters.php b/system/Config/Filters.php index 9096dc7ba03f..562eae8a26ef 100644 --- a/system/Config/Filters.php +++ b/system/Config/Filters.php @@ -102,6 +102,8 @@ class Filters extends BaseConfig * If you use this, you should disable auto-routing because auto-routing * permits any HTTP method to access a controller. Accessing the controller * with a method you don't expect could bypass the filter. + * + * @var array> */ public array $methods = []; diff --git a/system/DataCaster/DataCaster.php b/system/DataCaster/DataCaster.php index 854a0b50b32c..29de3987faa9 100644 --- a/system/DataCaster/DataCaster.php +++ b/system/DataCaster/DataCaster.php @@ -159,7 +159,7 @@ public function castAs(mixed $value, string $field, string $method = 'get'): mix $params = array_map('trim', explode(',', $matches[2])); } - if ($isNullable) { + if ($isNullable && ! $this->strict) { $params[] = 'nullable'; } diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 1f0807cdbbde..f9ca1efd4144 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -654,6 +654,7 @@ public function join(string $table, $cond, string $type = '', ?bool $escape = nu $cond = ' ON ' . $cond; } else { // Split multiple conditions + // @TODO This does not parse `BETWEEN a AND b` correctly. if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE)) { $conditions = []; $joints = $joints[0]; @@ -676,6 +677,13 @@ public function join(string $table, $cond, string $type = '', ?bool $escape = nu foreach ($conditions as $i => $condition) { $operator = $this->getOperator($condition); + // Workaround for BETWEEN + if ($operator === false) { + $cond .= $joints[$i] . $condition; + + continue; + } + $cond .= $joints[$i]; $cond .= preg_match('/(\(*)?([\[\]\w\.\'-]+)' . preg_quote($operator, '/') . '(.*)/i', $condition, $match) ? $match[1] . $this->db->protectIdentifiers($match[2]) . $operator . $this->db->protectIdentifiers($match[3]) : $condition; } @@ -1090,7 +1098,7 @@ public function orNotHavingLike($field, string $match = '', string $side = 'both * @used-by notHavingLike() * @used-by orNotHavingLike() * - * @param array|RawSql|string $field + * @param array|RawSql|string $field * * @return $this */ @@ -2376,7 +2384,9 @@ protected function validateInsert(): bool /** * Generates a platform-specific insert string from the supplied data * - * @param string $table Protected table name + * @param string $table Protected table name + * @param list $keys Keys of QBSet + * @param list $unescapedKeys Values of QBSet */ protected function _insert(string $table, array $keys, array $unescapedKeys): string { @@ -2416,7 +2426,9 @@ public function replace(?array $set = null) /** * Generates a platform-specific replace string from the supplied data * - * @param string $table Protected table name + * @param string $table Protected table name + * @param list $keys Keys of QBSet + * @param list $values Values of QBSet */ protected function _replace(string $table, array $keys, array $values): string { @@ -2512,7 +2524,8 @@ public function update($set = null, $where = null, ?int $limit = null): bool /** * Generates a platform-specific update string from the supplied data * - * @param string $table Protected table name + * @param string $table Protected table name + * @param array $values QBSet */ protected function _update(string $table, array $values): string { @@ -2863,9 +2876,9 @@ public function deleteBatch($set = null, $constraints = null, int $batchSize = 1 * * @used-by batchExecute() * - * @param string $table Protected table name - * @param list $keys QBKeys - * @paramst> $values QBSet + * @param string $table Protected table name + * @param list $keys QBKeys + * @param list $values QBSet */ protected function _deleteBatch(string $table, array $keys, array $values): string { diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index b597c6d6cd10..57c37d8a0a6c 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -420,7 +420,12 @@ public function initialize() // Connect to the database and set the connection ID $this->connID = $this->connect($this->pConnect); } catch (Throwable $e) { - $connectionErrors[] = sprintf('Main connection [%s]: %s', $this->DBDriver, $e->getMessage()); + $this->connID = false; + $connectionErrors[] = sprintf( + 'Main connection [%s]: %s', + $this->DBDriver, + $e->getMessage() + ); log_message('error', 'Error connecting to the database: ' . $e); } @@ -441,7 +446,12 @@ public function initialize() // Try to connect $this->connID = $this->connect($this->pConnect); } catch (Throwable $e) { - $connectionErrors[] = sprintf('Failover #%d [%s]: %s', ++$index, $this->DBDriver, $e->getMessage()); + $connectionErrors[] = sprintf( + 'Failover #%d [%s]: %s', + ++$index, + $this->DBDriver, + $e->getMessage() + ); log_message('error', 'Error connecting to the database: ' . $e); } @@ -479,7 +489,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..c22dc8605f56 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -78,9 +78,14 @@ public function connect(bool $persistent = false) $this->connID = $persistent === true ? pg_pconnect($this->DSN) : pg_connect($this->DSN); if ($this->connID !== false) { - if ($persistent === true && pg_connection_status($this->connID) === PGSQL_CONNECTION_BAD && pg_ping($this->connID) === false + if ( + $persistent === true + && pg_connection_status($this->connID) === PGSQL_CONNECTION_BAD + && pg_ping($this->connID) === false ) { - return false; + $error = pg_last_error($this->connID); + + throw new DatabaseException($error); } if (! empty($this->schema)) { @@ -88,7 +93,9 @@ public function connect(bool $persistent = false) } if ($this->setClientEncoding($this->charset) === false) { - return false; + $error = pg_last_error($this->connID); + + throw new DatabaseException($error); } } @@ -146,6 +153,8 @@ public function reconnect() /** * Close the database connection. + * + * @return void */ protected function _close() { diff --git a/system/Database/SQLSRV/Builder.php b/system/Database/SQLSRV/Builder.php old mode 100755 new mode 100644 index a624dced38d2..e2301f7ee2ab --- a/system/Database/SQLSRV/Builder.php +++ b/system/Database/SQLSRV/Builder.php @@ -145,6 +145,13 @@ public function join(string $table, $cond, string $type = '', ?bool $escape = nu foreach ($conditions as $i => $condition) { $operator = $this->getOperator($condition); + // Workaround for BETWEEN + if ($operator === false) { + $cond .= $joints[$i] . $condition; + + continue; + } + $cond .= $joints[$i]; $cond .= preg_match('/(\(*)?([\[\]\w\.\'-]+)' . preg_quote($operator, '/') . '(.*)/i', $condition, $match) ? $match[1] . $this->db->protectIdentifiers($match[2]) . $operator . $this->db->protectIdentifiers($match[3]) : $condition; } @@ -290,6 +297,23 @@ private function getFullName(string $table): string } if ($this->db->escapeChar === '"') { + if (str_contains($table, '.') && ! str_starts_with($table, '.') && ! str_ends_with($table, '.')) { + $dbInfo = explode('.', $table); + $database = $this->db->getDatabase(); + $table = $dbInfo[0]; + + if (count($dbInfo) === 3) { + $database = str_replace('"', '', $dbInfo[0]); + $schema = str_replace('"', '', $dbInfo[1]); + $tableName = str_replace('"', '', $dbInfo[2]); + } else { + $schema = str_replace('"', '', $dbInfo[0]); + $tableName = str_replace('"', '', $dbInfo[1]); + } + + return '"' . $database . '"."' . $schema . '"."' . str_replace('"', '', $tableName) . '"' . $alias; + } + return '"' . $this->db->getDatabase() . '"."' . $this->db->schema . '"."' . str_replace('"', '', $table) . '"' . $alias; } diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php old mode 100755 new mode 100644 index 411470d8e34c..0626a63c998b --- 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/SQLSRV/Forge.php b/system/Database/SQLSRV/Forge.php old mode 100755 new mode 100644 diff --git a/system/Database/SQLSRV/PreparedQuery.php b/system/Database/SQLSRV/PreparedQuery.php old mode 100755 new mode 100644 diff --git a/system/Database/SQLSRV/Result.php b/system/Database/SQLSRV/Result.php old mode 100755 new mode 100644 diff --git a/system/Database/SQLSRV/Utils.php b/system/Database/SQLSRV/Utils.php old mode 100755 new mode 100644 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/Email/Email.php b/system/Email/Email.php index a686ca0ca06e..b82779eb891d 100644 --- a/system/Email/Email.php +++ b/system/Email/Email.php @@ -151,7 +151,7 @@ class Email * * @var string */ - public $charset = 'utf-8'; + public $charset = 'UTF-8'; /** * Alternative message (for HTML messages only) @@ -182,7 +182,7 @@ class Email * * @var string "\r\n" or "\n" */ - public $newline = "\n"; + public $newline = "\r\n"; /** * CRLF character sequence @@ -197,7 +197,7 @@ class Email * * @var string */ - public $CRLF = "\n"; + public $CRLF = "\r\n"; /** * Whether to use Delivery Status Notification. diff --git a/system/Files/FileCollection.php b/system/Files/FileCollection.php index b9456dcc15ba..f1310795867d 100644 --- a/system/Files/FileCollection.php +++ b/system/Files/FileCollection.php @@ -105,7 +105,7 @@ final protected static function matchFiles(array $files, string $pattern): array ['\#', '\.', '.*', '.'], $pattern ); - $pattern = "#{$pattern}#"; + $pattern = "#\\A{$pattern}\\z#"; } return array_filter($files, static fn ($value) => (bool) preg_match($pattern, basename($value))); diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php old mode 100755 new mode 100644 diff --git a/system/HTTP/ResponseTrait.php b/system/HTTP/ResponseTrait.php index 2d4295116807..45f07d186170 100644 --- a/system/HTTP/ResponseTrait.php +++ b/system/HTTP/ResponseTrait.php @@ -670,7 +670,7 @@ private function dispatchCookies(): void foreach ($this->cookieStore->display() as $cookie) { if ($cookie->isSecure() && ! $request->isSecure()) { - throw SecurityException::forDisallowedAction(); + throw SecurityException::forInsecureCookie(); } $name = $cookie->getPrefixedName(); diff --git a/system/Helpers/cookie_helper.php b/system/Helpers/cookie_helper.php old mode 100755 new mode 100644 diff --git a/system/Helpers/html_helper.php b/system/Helpers/html_helper.php old mode 100755 new mode 100644 diff --git a/system/Helpers/inflector_helper.php b/system/Helpers/inflector_helper.php old mode 100755 new mode 100644 diff --git a/system/Helpers/number_helper.php b/system/Helpers/number_helper.php index 96468ddcdea3..0999d200f99b 100644 --- a/system/Helpers/number_helper.php +++ b/system/Helpers/number_helper.php @@ -82,8 +82,9 @@ function number_to_amount($num, int $precision = 0, ?string $locale = null) // Strip any formatting & ensure numeric input try { // @phpstan-ignore-next-line - $num = 0 + str_replace(',', '', $num); + $num = 0 + str_replace(',', '', (string) $num); } catch (ErrorException) { + // Catch "Warning: A non-numeric value encountered" return false; } diff --git a/system/Helpers/text_helper.php b/system/Helpers/text_helper.php old mode 100755 new mode 100644 diff --git a/system/Language/en/Security.php b/system/Language/en/Security.php index 145abaab71e7..fd906e378a29 100644 --- a/system/Language/en/Security.php +++ b/system/Language/en/Security.php @@ -14,6 +14,7 @@ // Security language settings return [ 'disallowedAction' => 'The action you requested is not allowed.', + 'insecureCookie' => 'Attempted to send a secure cookie over a non-secure connection.', // @deprecated 'invalidSameSite' => 'The SameSite value must be None, Lax, Strict, or a blank string. Given: "{0}"', diff --git a/system/Model.php b/system/Model.php index b3ecfc653943..d5df3f861b97 100644 --- a/system/Model.php +++ b/system/Model.php @@ -174,7 +174,7 @@ public function setTable(string $table) } /** - * Fetches the row of database from $this->table with a primary key + * Fetches the row(s) of database from $this->table with a primary key * matching $id. * This method works only with dbCalls. * @@ -198,8 +198,11 @@ protected function doFind(bool $singleton, $id = null) $builder->where($this->table . '.' . $this->deletedField, null); } + $row = null; + $rows = []; + if (is_array($id)) { - $row = $builder->whereIn($this->table . '.' . $this->primaryKey, $id) + $rows = $builder->whereIn($this->table . '.' . $this->primaryKey, $id) ->get() ->getResult($this->tempReturnType); } elseif ($singleton) { @@ -207,16 +210,32 @@ protected function doFind(bool $singleton, $id = null) ->get() ->getFirstRow($this->tempReturnType); } else { - $row = $builder->get()->getResult($this->tempReturnType); + $rows = $builder->get()->getResult($this->tempReturnType); } if ($useCast) { - $row = $this->convertToReturnType($row, $returnType); - $this->tempReturnType = $returnType; + + if ($singleton) { + if ($row === null) { + return null; + } + + return $this->convertToReturnType($row, $returnType); + } + + foreach ($rows as $i => $row) { + $rows[$i] = $this->convertToReturnType($row, $returnType); + } + + return $rows; } - return $row; + if ($singleton) { + return $row; + } + + return $rows; } /** @@ -230,15 +249,7 @@ protected function doFind(bool $singleton, $id = null) */ protected function doFindColumn(string $columnName) { - $results = $this->select($columnName)->asArray()->find(); - - if ($this->useCasts()) { - foreach ($results as $i => $row) { - $results[$i] = $this->converter->fromDataSource($row); - } - } - - return $results; + return $this->select($columnName)->asArray()->find(); } /** @@ -318,7 +329,7 @@ protected function doFirst() $row = $builder->limit(1, 0)->get()->getFirstRow($this->tempReturnType); - if ($useCast) { + if ($useCast && $row !== null) { $row = $this->convertToReturnType($row, $returnType); $this->tempReturnType = $returnType; diff --git a/system/Security/CheckPhpIni.php b/system/Security/CheckPhpIni.php index 6bbd8619c090..4cef565ad7d6 100644 --- a/system/Security/CheckPhpIni.php +++ b/system/Security/CheckPhpIni.php @@ -141,9 +141,10 @@ public static function checkIni(): array $ini = ini_get_all(); foreach ($items as $key => $values) { + $hasKeyInIni = array_key_exists($key, $ini); $output[$key] = [ - 'global' => $ini[$key]['global_value'], - 'current' => $ini[$key]['local_value'], + 'global' => $hasKeyInIni ? $ini[$key]['global_value'] : 'disabled', + 'current' => $hasKeyInIni ? $ini[$key]['local_value'] : 'disabled', 'recommended' => $values['recommended'] ?? '', 'remark' => $values['remark'] ?? '', ]; diff --git a/system/Security/Exceptions/SecurityException.php b/system/Security/Exceptions/SecurityException.php index 16383fc25bfc..ed1d76825036 100644 --- a/system/Security/Exceptions/SecurityException.php +++ b/system/Security/Exceptions/SecurityException.php @@ -20,6 +20,7 @@ class SecurityException extends FrameworkException implements HTTPExceptionInter { /** * Throws when some specific action is not allowed. + * This is used for CSRF protection. * * @return static */ @@ -28,6 +29,15 @@ public static function forDisallowedAction() return new static(lang('Security.disallowedAction'), 403); } + /** + * Throws if a secure cookie is dispatched when the current connection is not + * secure. + */ + public static function forInsecureCookie(): static + { + return new static(lang('Security.insecureCookie')); + } + /** * Throws when the source string contains invalid UTF-8 characters. * diff --git a/system/Test/Mock/MockCache.php b/system/Test/Mock/MockCache.php index df2179678de5..85b5fd9e7e14 100644 --- a/system/Test/Mock/MockCache.php +++ b/system/Test/Mock/MockCache.php @@ -92,11 +92,10 @@ public function remember(string $key, int $ttl, Closure $callback) * @param string $key Cache item name * @param mixed $value the data to save * @param int $ttl Time To Live, in seconds (default 60) - * @param bool $raw Whether to store the raw value. * * @return bool */ - public function save(string $key, $value, int $ttl = 60, bool $raw = false) + public function save(string $key, $value, int $ttl = 60) { if ($this->bypass) { return false; 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() { diff --git a/system/Test/Mock/MockResponse.php b/system/Test/Mock/MockResponse.php old mode 100755 new mode 100644 diff --git a/system/Test/PhpStreamWrapper.php b/system/Test/PhpStreamWrapper.php index 980d5424ab62..a6be8dd1329c 100644 --- a/system/Test/PhpStreamWrapper.php +++ b/system/Test/PhpStreamWrapper.php @@ -46,7 +46,7 @@ public static function restore() stream_wrapper_restore('php'); } - public function stream_open(string $path): bool + public function stream_open(): bool { return true; } diff --git a/system/ThirdParty/Kint/Parser/FsPathPlugin.php b/system/ThirdParty/Kint/Parser/FsPathPlugin.php index 7ec49de109cc..1a98c6dcd134 100644 --- a/system/ThirdParty/Kint/Parser/FsPathPlugin.php +++ b/system/ThirdParty/Kint/Parser/FsPathPlugin.php @@ -30,6 +30,7 @@ use Kint\Zval\Representation\SplFileInfoRepresentation; use Kint\Zval\Value; use SplFileInfo; +use TypeError; class FsPathPlugin extends AbstractPlugin { @@ -59,8 +60,13 @@ public function parse(&$var, Value &$o, int $trigger): void return; } - if (!@\file_exists($var)) { - return; + try { + if (!@\file_exists($var)) { + return; + } + } catch (TypeError $e) {// @codeCoverageIgnore + // Only possible in PHP 7 + return; // @codeCoverageIgnore } if (\in_array($var, self::$blacklist, true)) { diff --git a/system/ThirdParty/Kint/Parser/MysqliPlugin.php b/system/ThirdParty/Kint/Parser/MysqliPlugin.php index 90a4abd6b511..22a23a901ccb 100644 --- a/system/ThirdParty/Kint/Parser/MysqliPlugin.php +++ b/system/ThirdParty/Kint/Parser/MysqliPlugin.php @@ -105,7 +105,8 @@ public function parse(&$var, Value &$o, int $trigger): void foreach ($o->value->contents as $key => $obj) { if (isset($this->connected_readable[$obj->name])) { if (!$connected) { - continue; + // No failed connections after PHP 8.1 + continue; // @codeCoverageIgnore } } elseif (isset($this->empty_readable[$obj->name])) { // No failed connections after PHP 8.1 diff --git a/system/ThirdParty/Kint/Zval/BlobValue.php b/system/ThirdParty/Kint/Zval/BlobValue.php index 5e9f129d1181..66f60fdb9043 100644 --- a/system/ThirdParty/Kint/Zval/BlobValue.php +++ b/system/ThirdParty/Kint/Zval/BlobValue.php @@ -182,7 +182,9 @@ public static function detectEncoding(string $string) if (\function_exists('iconv')) { foreach (self::$legacy_encodings as $encoding) { // Iconv detection works by triggering - // "Detected an illegal character in input string" warnings + // "Detected an illegal character in input string" notices + // This notice does not become a TypeError with strict_types + // so we don't have to wrap this in a try catch if (@\iconv($encoding, $encoding, $string) === $string) { return $encoding; } diff --git a/system/ThirdParty/Kint/Zval/Representation/SplFileInfoRepresentation.php b/system/ThirdParty/Kint/Zval/Representation/SplFileInfoRepresentation.php index 6424ee6a9175..dad9d04cdc9e 100644 --- a/system/ThirdParty/Kint/Zval/Representation/SplFileInfoRepresentation.php +++ b/system/ThirdParty/Kint/Zval/Representation/SplFileInfoRepresentation.php @@ -76,7 +76,7 @@ public function __construct(SplFileInfo $fileInfo) } } catch (RuntimeException $e) { if (false === \strpos($e->getMessage(), ' open_basedir ')) { - throw $e; + throw $e; // @codeCoverageIgnore } } diff --git a/system/ThirdParty/Kint/init.php b/system/ThirdParty/Kint/init.php index 039489ab43ad..d682d9a9dc36 100644 --- a/system/ThirdParty/Kint/init.php +++ b/system/ThirdParty/Kint/init.php @@ -51,7 +51,7 @@ if (false !== \ini_get('xdebug.file_link_format')) { Kint::$file_link_format = \ini_get('xdebug.file_link_format'); } -if (isset($_SERVER['DOCUMENT_ROOT'])) { +if (isset($_SERVER['DOCUMENT_ROOT']) && false === \strpos($_SERVER['DOCUMENT_ROOT'], "\0")) { Kint::$app_root_dirs = [ $_SERVER['DOCUMENT_ROOT'] => '', ]; diff --git a/system/View/Cell.php b/system/View/Cell.php index cafe13d161e0..28b249a60e1c 100644 --- a/system/View/Cell.php +++ b/system/View/Cell.php @@ -68,10 +68,10 @@ public function __construct(CacheInterface $cache) /** * Render a cell, returning its body as a string. * - * @param string $library Cell class and method name. - * @param array|string|null $params Parameters to pass to the method. - * @param int $ttl Number of seconds to cache the cell. - * @param string|null $cacheName Cache item name. + * @param string $library Cell class and method name. + * @param array|string|null $params Parameters to pass to the method. + * @param int $ttl Number of seconds to cache the cell. + * @param string|null $cacheName Cache item name. * * @throws ReflectionException */ @@ -117,9 +117,10 @@ public function render(string $library, $params = null, int $ttl = 0, ?string $c * If a string, it should be in the format "key1=value key2=value". * It will be split and returned as an array. * - * @param array|string|null $params + * @param array|string|null $params + * @phpstan-param array|string|float|null $params * - * @return array + * @return array */ public function prepareParams($params) { diff --git a/system/View/Filters.php b/system/View/Filters.php index 56204c86c3d2..dde9ec6d663d 100644 --- a/system/View/Filters.php +++ b/system/View/Filters.php @@ -67,7 +67,7 @@ public static function date_modify($value, string $adjustment) /** * Returns the given default value if $value is empty or undefined. * - * @param array|bool|float|int|object|resource|string|null $value + * @param bool|float|int|list|object|resource|string|null $value */ public static function default($value, string $default): string { diff --git a/system/View/Parser.php b/system/View/Parser.php index 085252102e6e..bbeb00f757c0 100644 --- a/system/View/Parser.php +++ b/system/View/Parser.php @@ -56,7 +56,7 @@ class Parser extends View /** * Stores extracted noparse blocks. * - * @var array + * @var list */ protected $noparseBlocks = []; @@ -72,7 +72,7 @@ class Parser extends View * Stores the context for each data element * when set by `setData` so the context is respected. * - * @var array + * @var array */ protected $dataContexts = []; @@ -99,6 +99,10 @@ public function __construct( * * Parses pseudo-variables contained in the specified template view, * replacing them with any data that has already been set. + * + * @param array|null $options Reserved for 3rd-party uses since + * it might be needed to pass additional info + * to other template engines. */ public function render(string $view, ?array $options = null, ?bool $saveData = null): string { @@ -159,6 +163,10 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n * * Parses pseudo-variables contained in the specified string, * replacing them with any data that has already been set. + * + * @param array|null $options Reserved for 3rd-party uses since + * it might be needed to pass additional info + * to other template engines. */ public function renderString(string $template, ?array $options = null, ?bool $saveData = null): string { @@ -190,6 +198,7 @@ public function renderString(string $template, ?array $options = null, ?bool $sa * so that the variable is correctly handled within the * parsing itself, and contexts (including raw) are respected. * + * @param array $data * @param non-empty-string|null $context The context to escape it for. * If 'raw', no escaping will happen. * @phpstan-param null|'html'|'js'|'css'|'url'|'attr'|'raw' $context @@ -222,7 +231,8 @@ public function setData(array $data = [], ?string $context = null): RendererInte * Parses pseudo-variables contained in the specified template, * replacing them with the data in the second param * - * @param array $options Future options + * @param array $data + * @param array $options Future options */ protected function parse(string $template, array $data = [], ?array $options = null): string { @@ -266,6 +276,8 @@ protected function parse(string $template, array $data = [], ?array $options = n /** * Parse a single key/value, extracting it + * + * @return array */ protected function parseSingle(string $key, string $val): array { @@ -280,6 +292,10 @@ protected function parseSingle(string $key, string $val): array * Parse a tag pair * * Parses tag pairs: {some_tag} string... {/some_tag} + * + * @param array $data + * + * @return array */ protected function parsePair(string $variable, array $data, string $template): array { @@ -533,6 +549,8 @@ protected function replaceSingle($pattern, $content, $template, bool $escape = f /** * Callback used during parse() to apply any filters to the value. + * + * @param list $matches */ protected function prepareReplacement(array $matches, string $replace, bool $escape = true): string { @@ -586,6 +604,8 @@ public function shouldAddEscaping(string $key) /** * Given a set of filters, will apply each of the filters in turn * to $replace, and return the modified string. + * + * @param list $filters */ protected function applyFilters(string $replace, array $filters): string { @@ -708,9 +728,9 @@ public function removePlugin(string $alias) * Converts an object to an array, respecting any * toArray() methods on an object. * - * @param array|bool|float|int|object|string|null $value + * @param array|bool|float|int|object|string|null $value * - * @return array|bool|float|int|string|null + * @return array|bool|float|int|string|null */ protected function objectToArray($value) { diff --git a/system/View/RendererInterface.php b/system/View/RendererInterface.php index 62d3d7825060..5fdf8794f12d 100644 --- a/system/View/RendererInterface.php +++ b/system/View/RendererInterface.php @@ -24,10 +24,10 @@ interface RendererInterface * Builds the output based upon a file name and any * data that has already been set. * - * @param array|null $options Reserved for 3rd-party uses since - * it might be needed to pass additional info - * to other template engines. - * @param bool $saveData Whether to save data for subsequent calls + * @param array|null $options Reserved for 3rd-party uses since + * it might be needed to pass additional info + * to other template engines. + * @param bool $saveData Whether to save data for subsequent calls */ public function render(string $view, ?array $options = null, bool $saveData = false): string; @@ -35,17 +35,18 @@ public function render(string $view, ?array $options = null, bool $saveData = fa * Builds the output based upon a string and any * data that has already been set. * - * @param string $view The view contents - * @param array|null $options Reserved for 3rd-party uses since - * it might be needed to pass additional info - * to other template engines. - * @param bool $saveData Whether to save data for subsequent calls + * @param string $view The view contents + * @param array|null $options Reserved for 3rd-party uses since + * it might be needed to pass additional info + * to other template engines. + * @param bool $saveData Whether to save data for subsequent calls */ public function renderString(string $view, ?array $options = null, bool $saveData = false): string; /** * Sets several pieces of view data at once. * + * @param array $data * @param non-empty-string|null $context The context to escape it for. * If 'raw', no escaping will happen. * @phpstan-param null|'html'|'js'|'css'|'url'|'attr'|'raw' $context diff --git a/system/View/Table.php b/system/View/Table.php index 85770e31915d..60ccc509f9ae 100644 --- a/system/View/Table.php +++ b/system/View/Table.php @@ -27,21 +27,21 @@ class Table /** * Data for table rows * - * @var list|list> + * @var list>|list>> */ public $rows = []; /** * Data for table heading * - * @var array + * @var array */ public $heading = []; /** * Data for table footing * - * @var array + * @var array */ public $footing = []; @@ -62,7 +62,7 @@ class Table /** * Table layout template * - * @var array + * @var array */ public $template; @@ -95,7 +95,7 @@ class Table /** * Set the template from the table config file if it exists * - * @param array $config (default: array()) + * @param array $config (default: array()) */ public function __construct($config = []) { @@ -108,7 +108,8 @@ public function __construct($config = []) /** * Set the template * - * @param array $template + * @param array $template + * @phpstan-param array|string $template * * @return bool */ @@ -157,10 +158,10 @@ public function setFooting() * columns. This allows a single array with many elements to be * displayed in a table that has a fixed column count. * - * @param array $array - * @param int $columnLimit + * @param list $array + * @param int $columnLimit * - * @return array|false + * @return array|false */ public function makeColumns($array = [], $columnLimit = 0) { @@ -260,7 +261,9 @@ public function setSyncRowsWithHeading(bool $orderByKey) * * Ensures a standard associative array format for all cell data * - * @return array|list + * @param array $args + * + * @return array>|list> */ protected function _prepArgs(array $args) { @@ -297,7 +300,7 @@ public function setCaption($caption) /** * Generate the table * - * @param array|BaseResult|null $tableData + * @param array|BaseResult|null $tableData * * @return string */ @@ -472,7 +475,7 @@ protected function _setFromDBResult($object) /** * Set table data from an array * - * @param array $data + * @param array $data * * @return void */ @@ -510,7 +513,7 @@ protected function _compileTemplate() /** * Default Template * - * @return array + * @return array */ protected function _defaultTemplate() { diff --git a/system/View/View.php b/system/View/View.php index cda3d64f6088..7b6bfea0bba5 100644 --- a/system/View/View.php +++ b/system/View/View.php @@ -34,14 +34,14 @@ class View implements RendererInterface /** * Saved Data. * - * @var array + * @var array */ protected $data = []; /** * Data for the variables that are available in the Views. * - * @var array|null + * @var array|null */ protected $tempData; @@ -55,7 +55,7 @@ class View implements RendererInterface /** * Data for rendering including Caching and Debug Toolbar data. * - * @var array + * @var array */ protected $renderVars = []; @@ -86,7 +86,7 @@ class View implements RendererInterface * Cache stats about our performance here, * when CI_DEBUG = true * - * @var array + * @var list */ protected $performanceData = []; @@ -120,7 +120,7 @@ class View implements RendererInterface /** * Holds the sections and their data. * - * @var array + * @var array> */ protected $sections = []; @@ -165,13 +165,13 @@ public function __construct( * - cache Number of seconds to cache for * - cache_name Name to use for cache * - * @param string $view File name of the view source - * @param array|null $options Reserved for 3rd-party uses since - * it might be needed to pass additional info - * to other template engines. - * @param bool|null $saveData If true, saves data for subsequent calls, - * if false, cleans the data after displaying, - * if null, uses the config setting. + * @param string $view File name of the view source + * @param array|null $options Reserved for 3rd-party uses since + * it might be needed to pass additional info + * to other template engines. + * @param bool|null $saveData If true, saves data for subsequent calls, + * if false, cleans the data after displaying, + * if null, uses the config setting. */ public function render(string $view, ?array $options = null, ?bool $saveData = null): string { @@ -306,13 +306,13 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n * data that has already been set. * Cache does not apply, because there is no "key". * - * @param string $view The view contents - * @param array|null $options Reserved for 3rd-party uses since - * it might be needed to pass additional info - * to other template engines. - * @param bool|null $saveData If true, saves data for subsequent calls, - * if false, cleans the data after displaying, - * if null, uses the config setting. + * @param string $view The view contents + * @param array|null $options Reserved for 3rd-party uses since + * it might be needed to pass additional info + * to other template engines. + * @param bool|null $saveData If true, saves data for subsequent calls, + * if false, cleans the data after displaying, + * if null, uses the config setting. */ public function renderString(string $view, ?array $options = null, ?bool $saveData = null): string { @@ -393,6 +393,8 @@ public function resetData(): RendererInterface /** * Returns the current data that will be displayed in the view. + * + * @return array */ public function getData(): array { @@ -477,7 +479,8 @@ public function renderSection(string $sectionName, bool $saveData = false) /** * Used within layout views to include additional views. * - * @param bool $saveData + * @param array|null $options + * @param bool $saveData */ public function include(string $view, ?array $options = null, $saveData = true): string { @@ -487,6 +490,8 @@ public function include(string $view, ?array $options = null, $saveData = true): /** * Returns the performance data that might have been collected * during the execution. Used primarily in the Debug Toolbar. + * + * @return list */ public function getPerformanceData(): array { diff --git a/tests/README.md b/tests/README.md index 5de4f7f2cc8e..c0c58040917b 100644 --- a/tests/README.md +++ b/tests/README.md @@ -62,8 +62,8 @@ exclude `@DatabaseLive` group. This will make the tests run quite a bit faster. ## Groups Each test class that we are running should belong to at least one -[@group](https://phpunit.readthedocs.io/en/9.5/annotations.html#group) that is written at class-level -doc block. +[Group](https://docs.phpunit.de/en/10.5/attributes.html#group) attribute to the +test class. The available groups to use are: diff --git a/tests/_support/Entity/UserWithCasts.php b/tests/_support/Entity/UserWithCasts.php new file mode 100644 index 000000000000..cfe1981fa3fa --- /dev/null +++ b/tests/_support/Entity/UserWithCasts.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Tests\Support\Entity; + +use CodeIgniter\Entity\Entity; + +class UserWithCasts extends Entity +{ + protected $casts = [ + 'email' => 'json', + ]; +} diff --git a/tests/_support/Files/baker/fig_3.php.txt b/tests/_support/Files/baker/fig_3.php.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/_support/Models/UserCastsTimestampModel.php b/tests/_support/Models/UserCastsTimestampModel.php index c19353f01319..30f6b3e6b6f7 100644 --- a/tests/_support/Models/UserCastsTimestampModel.php +++ b/tests/_support/Models/UserCastsTimestampModel.php @@ -28,8 +28,8 @@ class UserCastsTimestampModel extends Model 'id' => 'int', 'name' => 'base64', 'email' => 'json-array', - 'created_at' => 'datetime', - 'updated_at' => 'datetime', + 'created_at' => '?datetime', + 'updated_at' => '?datetime', ]; protected array $castHandlers = [ 'base64' => CastBase64::class, diff --git a/tests/_support/Models/UserEntityWithCastsModel.php b/tests/_support/Models/UserEntityWithCastsModel.php new file mode 100644 index 000000000000..2ea32c88f842 --- /dev/null +++ b/tests/_support/Models/UserEntityWithCastsModel.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Tests\Support\Models; + +use CodeIgniter\Model; +use Tests\Support\Entity\UserWithCasts; + +class UserEntityWithCastsModel extends Model +{ + protected $table = 'user'; + protected $allowedFields = [ + 'name', + 'email', + 'country', + 'deleted_at', + ]; + protected $returnType = UserWithCasts::class; +} diff --git a/tests/system/API/ResponseTraitTest.php b/tests/system/API/ResponseTraitTest.php index b54f3037b247..0887c673d616 100644 --- a/tests/system/API/ResponseTraitTest.php +++ b/tests/system/API/ResponseTraitTest.php @@ -24,13 +24,13 @@ use CodeIgniter\Test\Mock\MockResponse; use Config\App; use Config\Cookie; +use PHPUnit\Framework\Attributes\Group; use stdClass; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ResponseTraitTest extends CIUnitTestCase { private ?MockIncomingRequest $request = null; diff --git a/tests/system/AutoReview/ComposerJsonTest.php b/tests/system/AutoReview/ComposerJsonTest.php index 8a2277ec8931..995ef99f4f2b 100644 --- a/tests/system/AutoReview/ComposerJsonTest.php +++ b/tests/system/AutoReview/ComposerJsonTest.php @@ -15,15 +15,15 @@ use InvalidArgumentException; use JsonException; +use PHPUnit\Framework\Attributes\CoversNothing; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; /** * @internal - * - * @coversNothing - * - * @group AutoReview */ +#[CoversNothing] +#[Group('AutoReview')] final class ComposerJsonTest extends TestCase { private array $devComposer; diff --git a/tests/system/AutoReview/FrameworkCodeTest.php b/tests/system/AutoReview/FrameworkCodeTest.php index bb50b8d5f185..b8b155bbbf28 100644 --- a/tests/system/AutoReview/FrameworkCodeTest.php +++ b/tests/system/AutoReview/FrameworkCodeTest.php @@ -14,17 +14,19 @@ namespace CodeIgniter\AutoReview; use FilesystemIterator; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; +use ReflectionAttribute; use ReflectionClass; use SplFileInfo; /** * @internal - * - * @group AutoReview */ +#[Group('AutoReview')] final class FrameworkCodeTest extends TestCase { /** @@ -32,7 +34,7 @@ final class FrameworkCodeTest extends TestCase */ private static array $testClasses = []; - private static array $recognizedGroupAnnotations = [ + private static array $recognizedGroupAttributeNames = [ 'AutoReview', 'CacheLive', 'DatabaseLive', @@ -41,11 +43,10 @@ final class FrameworkCodeTest extends TestCase ]; /** - * @dataProvider provideEachTestClassHasCorrectGroupAnnotation - * * @param class-string $class */ - public function testEachTestClassHasCorrectGroupAnnotation(string $class): void + #[DataProvider('provideEachTestClassHasCorrectGroupAttributeName')] + public function testEachTestClassHasCorrectGroupAttributeName(string $class): void { $reflection = new ReflectionClass($class); @@ -55,27 +56,31 @@ public function testEachTestClassHasCorrectGroupAnnotation(string $class): void return; } - $docComment = (string) $reflection->getDocComment(); - $this->assertNotEmpty($docComment, sprintf('[%s] Test class is missing a class-level PHPDoc.', $class)); + $attributes = $reflection->getAttributes(Group::class); + $this->assertNotEmpty($attributes, sprintf('[%s] Test class is missing a #[Group] attribute.', $class)); - preg_match_all('/@group (\S+)/', $docComment, $matches); - array_shift($matches); - $this->assertNotEmpty($matches[0], sprintf('[%s] Test class is missing a @group annotation.', $class)); + $unrecognizedGroups = array_diff( + array_map(static function (ReflectionAttribute $attribute): string { + $groupAttribute = $attribute->newInstance(); + assert($groupAttribute instanceof Group); - $unrecognizedGroups = array_diff($matches[0], self::$recognizedGroupAnnotations); + return $groupAttribute->name(); + }, $attributes), + self::$recognizedGroupAttributeNames + ); $this->assertEmpty($unrecognizedGroups, sprintf( - "[%s] Unexpected @group annotation%s:\n%s\nExpected annotations to be in \"%s\".", + "[%s] Unexpected #[Group] attribute%s:\n%s\nExpected group names to be in \"%s\".", $class, count($unrecognizedGroups) > 1 ? 's' : '', implode("\n", array_map( - static fn (string $group): string => sprintf(' * @group %s', $group), + static fn (string $group): string => sprintf(' * #[Group(\'%s\')]', $group), $unrecognizedGroups )), - implode(', ', self::$recognizedGroupAnnotations) + implode(', ', self::$recognizedGroupAttributeNames) )); } - public static function provideEachTestClassHasCorrectGroupAnnotation(): iterable + public static function provideEachTestClassHasCorrectGroupAttributeName(): iterable { foreach (self::getTestClasses() as $class) { yield $class => [$class]; diff --git a/tests/system/Autoloader/AutoloaderTest.php b/tests/system/Autoloader/AutoloaderTest.php index b0e7852c2910..04dfe04e991f 100644 --- a/tests/system/Autoloader/AutoloaderTest.php +++ b/tests/system/Autoloader/AutoloaderTest.php @@ -22,14 +22,16 @@ use Config\Modules; use Config\Services; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use RuntimeException; use UnnamespacedClass; /** * @internal - * - * @group Others */ +#[Group('Others')] final class AutoloaderTest extends CIUnitTestCase { use ReflectionHelper; @@ -390,10 +392,8 @@ public function testAutoloaderLoadsNonClassFiles(): void $loader->unregister(); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testLoadHelpers(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. diff --git a/tests/system/Autoloader/FileLocatorCachedTest.php b/tests/system/Autoloader/FileLocatorCachedTest.php index a10f1f30781b..0aac85a8c59c 100644 --- a/tests/system/Autoloader/FileLocatorCachedTest.php +++ b/tests/system/Autoloader/FileLocatorCachedTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Cache\FactoriesCache\FileVarExportHandler; use Config\Autoload; use Config\Modules; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FileLocatorCachedTest extends FileLocatorTest { private FileVarExportHandler $handler; diff --git a/tests/system/Autoloader/FileLocatorTest.php b/tests/system/Autoloader/FileLocatorTest.php index 869c6b36090a..e3a20286acc6 100644 --- a/tests/system/Autoloader/FileLocatorTest.php +++ b/tests/system/Autoloader/FileLocatorTest.php @@ -17,13 +17,14 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Autoload; use Config\Modules; +use PHPUnit\Framework\Attributes\Group; /** * @internal * - * @group Others * @no-final */ +#[Group('Others')] class FileLocatorTest extends CIUnitTestCase { protected FileLocatorInterface $locator; diff --git a/tests/system/CLI/CLITest.php b/tests/system/CLI/CLITest.php index f0dadef1763d..0a4e36316dbe 100644 --- a/tests/system/CLI/CLITest.php +++ b/tests/system/CLI/CLITest.php @@ -16,14 +16,15 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\PhpStreamWrapper; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use ReflectionProperty; use RuntimeException; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CLITest extends CIUnitTestCase { use StreamFilterTrait; @@ -75,9 +76,9 @@ public function testWaitZero(): void $time = time(); CLI::wait(0); - $this->assertCloseEnough(0, time() - $time); - PhpStreamWrapper::restore(); + + $this->assertCloseEnough(0, time() - $time); } public function testPrompt(): void @@ -89,9 +90,83 @@ public function testPrompt(): void $output = CLI::prompt('What is your favorite color?'); + PhpStreamWrapper::restore(); + $this->assertSame($expected, $output); + } + + public function testPromptInputNothing(): void + { + PhpStreamWrapper::register(); + + $input = ''; + PhpStreamWrapper::setContent($input); + + $output = CLI::prompt('What is your favorite color?', 'red'); + + PhpStreamWrapper::restore(); + + $this->assertSame('red', $output); + } + + public function testPromptInputZero(): void + { + PhpStreamWrapper::register(); + + $input = '0'; + PhpStreamWrapper::setContent($input); + + $output = CLI::prompt('What is your favorite number?', '7'); PhpStreamWrapper::restore(); + + $this->assertSame('0', $output); + } + + public function testPromptByKey(): void + { + PhpStreamWrapper::register(); + + $input = '1'; + PhpStreamWrapper::setContent($input); + + $options = ['Playing game', 'Sleep', 'Badminton']; + $output = CLI::promptByKey('Select your hobbies:', $options); + + PhpStreamWrapper::restore(); + + $this->assertSame($input, $output); + } + + public function testPromptByKeyInputNothing(): void + { + PhpStreamWrapper::register(); + + $input = ''; // This is when you press the Enter key. + PhpStreamWrapper::setContent($input); + + $options = ['Playing game', 'Sleep', 'Badminton']; + $output = CLI::promptByKey('Select your hobbies:', $options); + + PhpStreamWrapper::restore(); + + $expected = '0'; + $this->assertSame($expected, $output); + } + + public function testPromptByKeyInputZero(): void + { + PhpStreamWrapper::register(); + + $input = '0'; + PhpStreamWrapper::setContent($input); + + $options = ['Playing game', 'Sleep', 'Badminton']; + $output = CLI::promptByKey('Select your hobbies:', $options); + + PhpStreamWrapper::restore(); + + $this->assertSame($input, $output); } public function testPromptByMultipleKeys(): void @@ -104,14 +179,49 @@ public function testPromptByMultipleKeys(): void $options = ['Playing game', 'Sleep', 'Badminton']; $output = CLI::promptByMultipleKeys('Select your hobbies:', $options); + PhpStreamWrapper::restore(); + $expected = [ 0 => 'Playing game', 1 => 'Sleep', ]; + $this->assertSame($expected, $output); + } + public function testPromptByMultipleKeysInputNothing(): void + { + PhpStreamWrapper::register(); + + $input = ''; // This is when you press the Enter key. + PhpStreamWrapper::setContent($input); + + $options = ['Playing game', 'Sleep', 'Badminton']; + $output = CLI::promptByMultipleKeys('Select your hobbies:', $options); + + PhpStreamWrapper::restore(); + + $expected = [ + 0 => 'Playing game', + ]; $this->assertSame($expected, $output); + } + + public function testPromptByMultipleKeysInputZero(): void + { + PhpStreamWrapper::register(); + + $input = '0'; + PhpStreamWrapper::setContent($input); + + $options = ['Playing game', 'Sleep', 'Badminton']; + $output = CLI::promptByMultipleKeys('Select your hobbies:', $options); PhpStreamWrapper::restore(); + + $expected = [ + 0 => 'Playing game', + ]; + $this->assertSame($expected, $output); } public function testNewLine(): void @@ -452,12 +562,11 @@ public function testWindow(): void } /** - * @dataProvider provideTable - * * @param array $tbody * @param array $thead * @param array $expected */ + #[DataProvider('provideTable')] public function testTable($tbody, $thead, $expected): void { CLI::table($tbody, $thead); diff --git a/tests/system/CLI/ConsoleTest.php b/tests/system/CLI/ConsoleTest.php index 54f0ff4a6813..cabe2152b684 100644 --- a/tests/system/CLI/ConsoleTest.php +++ b/tests/system/CLI/ConsoleTest.php @@ -20,12 +20,12 @@ use CodeIgniter\Test\Mock\MockCLIConfig; use CodeIgniter\Test\Mock\MockCodeIgniter; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ConsoleTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Cache/CacheFactoryTest.php b/tests/system/Cache/CacheFactoryTest.php index b358a1eb1eb7..0947f31d5045 100644 --- a/tests/system/Cache/CacheFactoryTest.php +++ b/tests/system/Cache/CacheFactoryTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Cache\Handlers\DummyHandler; use CodeIgniter\Test\CIUnitTestCase; use Config\Cache; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CacheFactoryTest extends CIUnitTestCase { private static string $directory = 'CacheFactory'; diff --git a/tests/system/Cache/CacheMockTest.php b/tests/system/Cache/CacheMockTest.php index 451f7fe7c459..c867bebc4249 100644 --- a/tests/system/Cache/CacheMockTest.php +++ b/tests/system/Cache/CacheMockTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Cache\Handlers\BaseHandler; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockCache; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CacheMockTest extends CIUnitTestCase { public function testMockReturnsMockCacheClass(): void diff --git a/tests/system/Cache/FactoriesCacheFileHandlerTest.php b/tests/system/Cache/FactoriesCacheFileHandlerTest.php index eea51d1f87f9..892eb7260638 100644 --- a/tests/system/Cache/FactoriesCacheFileHandlerTest.php +++ b/tests/system/Cache/FactoriesCacheFileHandlerTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter\Cache; use Config\Cache as CacheConfig; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FactoriesCacheFileHandlerTest extends FactoriesCacheFileVarExportHandlerTest { /** diff --git a/tests/system/Cache/FactoriesCacheFileVarExportHandlerTest.php b/tests/system/Cache/FactoriesCacheFileVarExportHandlerTest.php index 1566862c2ff9..8bf5c79d9209 100644 --- a/tests/system/Cache/FactoriesCacheFileVarExportHandlerTest.php +++ b/tests/system/Cache/FactoriesCacheFileVarExportHandlerTest.php @@ -17,13 +17,13 @@ use CodeIgniter\Config\Factories; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use PHPUnit\Framework\Attributes\Group; /** * @internal * @no-final - * - * @group Others */ +#[Group('Others')] class FactoriesCacheFileVarExportHandlerTest extends CIUnitTestCase { protected FactoriesCache $cache; diff --git a/tests/system/Cache/Handlers/BaseHandlerTest.php b/tests/system/Cache/Handlers/BaseHandlerTest.php index 49462ffbe04e..06d3c4a98f8e 100644 --- a/tests/system/Cache/Handlers/BaseHandlerTest.php +++ b/tests/system/Cache/Handlers/BaseHandlerTest.php @@ -14,21 +14,21 @@ namespace CodeIgniter\Cache\Handlers; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use stdClass; use Tests\Support\Cache\RestrictiveHandler; /** * @internal - * - * @group Others */ +#[Group('Others')] final class BaseHandlerTest extends CIUnitTestCase { /** - * @dataProvider provideValidateKeyInvalidType - * * @param mixed $input */ + #[DataProvider('provideValidateKeyInvalidType')] public function testValidateKeyInvalidType($input): void { $this->expectException('InvalidArgumentException'); diff --git a/tests/system/Cache/Handlers/DummyHandlerTest.php b/tests/system/Cache/Handlers/DummyHandlerTest.php index c30c99da733e..1b6fa3aa773a 100644 --- a/tests/system/Cache/Handlers/DummyHandlerTest.php +++ b/tests/system/Cache/Handlers/DummyHandlerTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter\Cache\Handlers; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class DummyHandlerTest extends CIUnitTestCase { private DummyHandler $handler; diff --git a/tests/system/Cache/Handlers/FileHandlerTest.php b/tests/system/Cache/Handlers/FileHandlerTest.php index 67aa170c75f5..9a7213374dd2 100644 --- a/tests/system/Cache/Handlers/FileHandlerTest.php +++ b/tests/system/Cache/Handlers/FileHandlerTest.php @@ -17,12 +17,14 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\I18n\Time; use Config\Cache; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresOperatingSystem; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FileHandlerTest extends AbstractHandlerTestCase { private static string $directory = 'FileHandler'; @@ -86,9 +88,8 @@ public function testNew(): void /** * chmod('path', 0444) does not work on Windows - * - * @requires OS Linux|Darwin */ + #[RequiresOperatingSystem('Linux|Darwin')] public function testNewWithNonWritablePath(): void { $this->expectException(CacheException::class); @@ -145,9 +146,8 @@ public function testRemember(): void /** * chmod('path', 0444) does not work on Windows - * - * @requires OS Linux|Darwin */ + #[RequiresOperatingSystem('Linux|Darwin')] public function testSave(): void { $this->assertTrue($this->handler->save(self::$key1, 'value')); @@ -309,13 +309,8 @@ public function testIsSupported(): void $this->assertTrue($this->handler->isSupported()); } - /** - * @dataProvider provideSaveMode - * - * permissions given on Windows are fixed to `0666` - * - * @requires OS Linux|Darwin - */ + #[DataProvider('provideSaveMode')] + #[RequiresOperatingSystem('Linux|Darwin')] public function testSaveMode(int $int, string $string): void { // Initialize mode diff --git a/tests/system/Cache/Handlers/MemcachedHandlerTest.php b/tests/system/Cache/Handlers/MemcachedHandlerTest.php index 06ee0c567239..4aad8288401c 100644 --- a/tests/system/Cache/Handlers/MemcachedHandlerTest.php +++ b/tests/system/Cache/Handlers/MemcachedHandlerTest.php @@ -17,12 +17,12 @@ use CodeIgniter\I18n\Time; use Config\Cache; use Exception; +use PHPUnit\Framework\Attributes\Group; /** - * @group CacheLive - * * @internal */ +#[Group('CacheLive')] final class MemcachedHandlerTest extends AbstractHandlerTestCase { private Cache $config; diff --git a/tests/system/Cache/Handlers/PredisHandlerTest.php b/tests/system/Cache/Handlers/PredisHandlerTest.php index 59e68346517b..6d88d6e3f609 100644 --- a/tests/system/Cache/Handlers/PredisHandlerTest.php +++ b/tests/system/Cache/Handlers/PredisHandlerTest.php @@ -16,12 +16,12 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\I18n\Time; use Config\Cache; +use PHPUnit\Framework\Attributes\Group; /** - * @group CacheLive - * * @internal */ +#[Group('CacheLive')] final class PredisHandlerTest extends AbstractHandlerTestCase { private Cache $config; diff --git a/tests/system/Cache/Handlers/RedisHandlerTest.php b/tests/system/Cache/Handlers/RedisHandlerTest.php index c8182111971a..e5880f8ae0c2 100644 --- a/tests/system/Cache/Handlers/RedisHandlerTest.php +++ b/tests/system/Cache/Handlers/RedisHandlerTest.php @@ -16,12 +16,12 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\I18n\Time; use Config\Cache; +use PHPUnit\Framework\Attributes\Group; /** - * @group CacheLive - * * @internal */ +#[Group('CacheLive')] final class RedisHandlerTest extends AbstractHandlerTestCase { private Cache $config; diff --git a/tests/system/Cache/ResponseCacheTest.php b/tests/system/Cache/ResponseCacheTest.php index 059ad7d8f905..b0b73855231a 100644 --- a/tests/system/Cache/ResponseCacheTest.php +++ b/tests/system/Cache/ResponseCacheTest.php @@ -24,14 +24,14 @@ use Config\Cache as CacheConfig; use ErrorException; use Exception; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\Group; /** - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class ResponseCacheTest extends CIUnitTestCase { private AppConfig $appConfig; diff --git a/tests/system/CodeIgniterTest.php b/tests/system/CodeIgniterTest.php index fadfe365307a..a550e098e9b0 100644 --- a/tests/system/CodeIgniterTest.php +++ b/tests/system/CodeIgniterTest.php @@ -30,18 +30,19 @@ use Config\Filters as FiltersConfig; use Config\Modules; use Config\Routing; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; use Tests\Support\Filters\Customfilter; use Tests\Support\Filters\RedirectFilter; /** - * @runTestsInSeparateProcesses - * - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] +#[RunTestsInSeparateProcesses] final class CodeIgniterTest extends CIUnitTestCase { private CodeIgniter $codeigniter; @@ -839,10 +840,9 @@ public function testPageCacheSendSecureHeaders(): void /** * @param array|bool $cacheQueryStringValue * - * @dataProvider providePageCacheWithCacheQueryString - * * @see https://github.com/codeigniter4/CodeIgniter4/pull/6410 */ + #[DataProvider('providePageCacheWithCacheQueryString')] public function testPageCacheWithCacheQueryString( $cacheQueryStringValue, int $expectedPagesInCache, diff --git a/tests/system/Commands/BaseCommandTest.php b/tests/system/Commands/BaseCommandTest.php index 7c5aba288db5..9e9a2d3408a0 100644 --- a/tests/system/Commands/BaseCommandTest.php +++ b/tests/system/Commands/BaseCommandTest.php @@ -16,13 +16,13 @@ use CodeIgniter\Log\Logger; use CodeIgniter\Test\CIUnitTestCase; use Config\Services; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Commands\AppInfo; /** * @internal - * - * @group Others */ +#[Group('Others')] final class BaseCommandTest extends CIUnitTestCase { private Logger $logger; diff --git a/tests/system/Commands/CellGeneratorTest.php b/tests/system/Commands/CellGeneratorTest.php index 84c7a0243be7..31ec6dc3921e 100644 --- a/tests/system/Commands/CellGeneratorTest.php +++ b/tests/system/Commands/CellGeneratorTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CellGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/ClearCacheTest.php b/tests/system/Commands/ClearCacheTest.php index 7e669cc9c851..e27978e40919 100644 --- a/tests/system/Commands/ClearCacheTest.php +++ b/tests/system/Commands/ClearCacheTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; use Config\Services; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ClearCacheTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/ClearDebugbarTest.php b/tests/system/Commands/ClearDebugbarTest.php index 1e86406f7054..b3c2de18c394 100644 --- a/tests/system/Commands/ClearDebugbarTest.php +++ b/tests/system/Commands/ClearDebugbarTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ClearDebugbarTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/ClearLogsTest.php b/tests/system/Commands/ClearLogsTest.php index afdd7a56541c..28019d5d51f6 100644 --- a/tests/system/Commands/ClearLogsTest.php +++ b/tests/system/Commands/ClearLogsTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ClearLogsTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/CommandGeneratorTest.php b/tests/system/Commands/CommandGeneratorTest.php index a661f4a7783b..d485d6e4f063 100644 --- a/tests/system/Commands/CommandGeneratorTest.php +++ b/tests/system/Commands/CommandGeneratorTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CommandGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/CommandTest.php b/tests/system/Commands/CommandTest.php index 3a0c0adfbd7d..aa8c4959ac75 100644 --- a/tests/system/Commands/CommandTest.php +++ b/tests/system/Commands/CommandTest.php @@ -18,13 +18,14 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; use Config\Services; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Commands\ParamsReveal; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CommandTest extends CIUnitTestCase { use StreamFilterTrait; @@ -129,9 +130,7 @@ public function testInexistentCommandsButWithManyAlternatives(): void $this->assertStringContainsString(':clear', $this->getBuffer()); } - /** - * @dataProvider provideCommandParsesArgsCorrectly - */ + #[DataProvider('provideCommandParsesArgsCorrectly')] public function testCommandParsesArgsCorrectly(string $input, array $expected): void { ParamsReveal::$args = null; diff --git a/tests/system/Commands/ConfigGeneratorTest.php b/tests/system/Commands/ConfigGeneratorTest.php index c4e9f644a71f..ab4914914719 100644 --- a/tests/system/Commands/ConfigGeneratorTest.php +++ b/tests/system/Commands/ConfigGeneratorTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ConfigGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/ConfigurableSortImportsTest.php b/tests/system/Commands/ConfigurableSortImportsTest.php index 3fbec68b0c89..4f54390d7ffe 100644 --- a/tests/system/Commands/ConfigurableSortImportsTest.php +++ b/tests/system/Commands/ConfigurableSortImportsTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ConfigurableSortImportsTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/ControllerGeneratorTest.php b/tests/system/Commands/ControllerGeneratorTest.php index e13c8aec839e..dc8293bb3997 100644 --- a/tests/system/Commands/ControllerGeneratorTest.php +++ b/tests/system/Commands/ControllerGeneratorTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ControllerGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/CreateDatabaseTest.php b/tests/system/Commands/CreateDatabaseTest.php index 790b0c6c57b0..6bf93f4a2eb3 100644 --- a/tests/system/Commands/CreateDatabaseTest.php +++ b/tests/system/Commands/CreateDatabaseTest.php @@ -20,12 +20,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; use Config\Database; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class CreateDatabaseTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/Database/MigrateStatusTest.php b/tests/system/Commands/Database/MigrateStatusTest.php index 33b7edde379d..5e54b380fdee 100644 --- a/tests/system/Commands/Database/MigrateStatusTest.php +++ b/tests/system/Commands/Database/MigrateStatusTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; use Config\Database; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class MigrateStatusTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/Database/ShowTableInfoMockIOTest.php b/tests/system/Commands/Database/ShowTableInfoMockIOTest.php index f6f66bc223b4..0842c28ae12a 100644 --- a/tests/system/Commands/Database/ShowTableInfoMockIOTest.php +++ b/tests/system/Commands/Database/ShowTableInfoMockIOTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use CodeIgniter\Test\Mock\MockInputOutput; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class ShowTableInfoMockIOTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Commands/Database/ShowTableInfoTest.php b/tests/system/Commands/Database/ShowTableInfoTest.php index 79972377f1e6..a707f519a858 100644 --- a/tests/system/Commands/Database/ShowTableInfoTest.php +++ b/tests/system/Commands/Database/ShowTableInfoTest.php @@ -18,13 +18,13 @@ use CodeIgniter\Test\DatabaseTestTrait; use CodeIgniter\Test\StreamFilterTrait; use Config\Database; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class ShowTableInfoTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Commands/DatabaseCommandsTest.php b/tests/system/Commands/DatabaseCommandsTest.php index 8a28ebf5fe86..1ccdea9251ee 100644 --- a/tests/system/Commands/DatabaseCommandsTest.php +++ b/tests/system/Commands/DatabaseCommandsTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class DatabaseCommandsTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/EntityGeneratorTest.php b/tests/system/Commands/EntityGeneratorTest.php index fd84207f8f14..1e764add9cec 100644 --- a/tests/system/Commands/EntityGeneratorTest.php +++ b/tests/system/Commands/EntityGeneratorTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class EntityGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/EnvironmentCommandTest.php b/tests/system/Commands/EnvironmentCommandTest.php index d087fdda64f1..177becf34f9f 100644 --- a/tests/system/Commands/EnvironmentCommandTest.php +++ b/tests/system/Commands/EnvironmentCommandTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class EnvironmentCommandTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/FilterCheckTest.php b/tests/system/Commands/FilterCheckTest.php index de543936293b..0c26dd9bf349 100644 --- a/tests/system/Commands/FilterCheckTest.php +++ b/tests/system/Commands/FilterCheckTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FilterCheckTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/FilterGeneratorTest.php b/tests/system/Commands/FilterGeneratorTest.php index fbb911ab2624..b336387d3ab4 100644 --- a/tests/system/Commands/FilterGeneratorTest.php +++ b/tests/system/Commands/FilterGeneratorTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FilterGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/GenerateKeyTest.php b/tests/system/Commands/GenerateKeyTest.php index 80d0879bc958..289a294f5d0c 100644 --- a/tests/system/Commands/GenerateKeyTest.php +++ b/tests/system/Commands/GenerateKeyTest.php @@ -16,12 +16,14 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Filters\CITestStreamFilter; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; /** * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] final class GenerateKeyTest extends CIUnitTestCase { use StreamFilterTrait; @@ -86,10 +88,8 @@ public function testGenerateKeyShowsEncodedKey(): void $this->assertStringContainsString('hex2bin:', $this->getBuffer()); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testGenerateKeyCreatesNewKey(): void { command('key:generate'); diff --git a/tests/system/Commands/GeneratorsTest.php b/tests/system/Commands/GeneratorsTest.php index 3f4bffb95a77..f72ceabc710c 100644 --- a/tests/system/Commands/GeneratorsTest.php +++ b/tests/system/Commands/GeneratorsTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class GeneratorsTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/HelpCommandTest.php b/tests/system/Commands/HelpCommandTest.php index 91832e44e7b2..7ce07d8129fb 100644 --- a/tests/system/Commands/HelpCommandTest.php +++ b/tests/system/Commands/HelpCommandTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class HelpCommandTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/InfoCacheTest.php b/tests/system/Commands/InfoCacheTest.php index f587f63ffeb1..1c3ad93db5f0 100644 --- a/tests/system/Commands/InfoCacheTest.php +++ b/tests/system/Commands/InfoCacheTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; use Config\Services; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class InfoCacheTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/MigrationGeneratorTest.php b/tests/system/Commands/MigrationGeneratorTest.php index 148faed28d1e..0f999d638789 100644 --- a/tests/system/Commands/MigrationGeneratorTest.php +++ b/tests/system/Commands/MigrationGeneratorTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class MigrationGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/MigrationIntegrationTest.php b/tests/system/Commands/MigrationIntegrationTest.php index ba9c3c93d923..14b66ccb920a 100644 --- a/tests/system/Commands/MigrationIntegrationTest.php +++ b/tests/system/Commands/MigrationIntegrationTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class MigrationIntegrationTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/ModelGeneratorTest.php b/tests/system/Commands/ModelGeneratorTest.php index 4f780740a7cc..65596958606c 100644 --- a/tests/system/Commands/ModelGeneratorTest.php +++ b/tests/system/Commands/ModelGeneratorTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ModelGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/PublishCommandTest.php b/tests/system/Commands/PublishCommandTest.php index 67ad141735d4..0cd2605aaa1e 100644 --- a/tests/system/Commands/PublishCommandTest.php +++ b/tests/system/Commands/PublishCommandTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Publishers\TestPublisher; /** * @internal - * - * @group Others */ +#[Group('Others')] final class PublishCommandTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/RoutesTest.php b/tests/system/Commands/RoutesTest.php index 634078e98409..4c0ffd174550 100644 --- a/tests/system/Commands/RoutesTest.php +++ b/tests/system/Commands/RoutesTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; use Config\Services; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class RoutesTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/ScaffoldGeneratorTest.php b/tests/system/Commands/ScaffoldGeneratorTest.php index 92cba333448f..aca2bf2a2469 100644 --- a/tests/system/Commands/ScaffoldGeneratorTest.php +++ b/tests/system/Commands/ScaffoldGeneratorTest.php @@ -18,12 +18,12 @@ use Config\Autoload; use Config\Modules; use Config\Services; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ScaffoldGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/SeederGeneratorTest.php b/tests/system/Commands/SeederGeneratorTest.php index 2ac08d508c71..b8f504489c5b 100644 --- a/tests/system/Commands/SeederGeneratorTest.php +++ b/tests/system/Commands/SeederGeneratorTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class SeederGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/TestGeneratorTest.php b/tests/system/Commands/TestGeneratorTest.php index 8ffe89c3de55..b449afd76f05 100644 --- a/tests/system/Commands/TestGeneratorTest.php +++ b/tests/system/Commands/TestGeneratorTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class TestGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/Translation/LocalizationFinderTest.php b/tests/system/Commands/Translation/LocalizationFinderTest.php index 722a812785ac..85bb59c7c09b 100644 --- a/tests/system/Commands/Translation/LocalizationFinderTest.php +++ b/tests/system/Commands/Translation/LocalizationFinderTest.php @@ -18,12 +18,12 @@ use Config\App; use Config\Services; use Locale; +use PHPUnit\Framework\Attributes\Group; /** - * @group Others - * * @internal */ +#[Group('Others')] final class LocalizationFinderTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/Utilities/ConfigCheckTest.php b/tests/system/Commands/Utilities/ConfigCheckTest.php index b7e3890a5e61..535cb0dd0489 100644 --- a/tests/system/Commands/Utilities/ConfigCheckTest.php +++ b/tests/system/Commands/Utilities/ConfigCheckTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Test\StreamFilterTrait; use Config\App; use Config\Services; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ConfigCheckTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/Utilities/NamespacesTest.php b/tests/system/Commands/Utilities/NamespacesTest.php index fae294afb2ff..c32d9280aef4 100644 --- a/tests/system/Commands/Utilities/NamespacesTest.php +++ b/tests/system/Commands/Utilities/NamespacesTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class NamespacesTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Commands/Utilities/Routes/AutoRouteCollectorTest.php b/tests/system/Commands/Utilities/Routes/AutoRouteCollectorTest.php index c1e8f81f3d4f..ef8e43282b92 100644 --- a/tests/system/Commands/Utilities/Routes/AutoRouteCollectorTest.php +++ b/tests/system/Commands/Utilities/Routes/AutoRouteCollectorTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter\Commands\Utilities\Routes; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class AutoRouteCollectorTest extends CIUnitTestCase { public function testGet(): void diff --git a/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php b/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php index f906a9298505..a669385568dd 100644 --- a/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php +++ b/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Filters; use Config\Services; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class AutoRouteCollectorTest extends CIUnitTestCase { protected function setUp(): void diff --git a/tests/system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReaderTest.php b/tests/system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReaderTest.php index dd60518b57d9..936b2b8fe184 100644 --- a/tests/system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReaderTest.php +++ b/tests/system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReaderTest.php @@ -19,14 +19,14 @@ use CodeIgniter\Config\Factories; use CodeIgniter\Test\CIUnitTestCase; use Config\Routing; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Controllers\Newautorouting; use Tests\Support\Controllers\Remap; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ControllerMethodReaderTest extends CIUnitTestCase { private function createControllerMethodReader( diff --git a/tests/system/Commands/Utilities/Routes/ControllerFinderTest.php b/tests/system/Commands/Utilities/Routes/ControllerFinderTest.php index 90160f39a194..1f6ecce2ec3e 100644 --- a/tests/system/Commands/Utilities/Routes/ControllerFinderTest.php +++ b/tests/system/Commands/Utilities/Routes/ControllerFinderTest.php @@ -14,13 +14,13 @@ namespace CodeIgniter\Commands\Utilities\Routes; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Controllers\Hello; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ControllerFinderTest extends CIUnitTestCase { public function testFind(): void diff --git a/tests/system/Commands/Utilities/Routes/ControllerMethodReaderTest.php b/tests/system/Commands/Utilities/Routes/ControllerMethodReaderTest.php index 6e01ba162331..04563a481d7b 100644 --- a/tests/system/Commands/Utilities/Routes/ControllerMethodReaderTest.php +++ b/tests/system/Commands/Utilities/Routes/ControllerMethodReaderTest.php @@ -14,14 +14,14 @@ namespace CodeIgniter\Commands\Utilities\Routes; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Controllers\Popcorn; use Tests\Support\Controllers\Remap; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ControllerMethodReaderTest extends CIUnitTestCase { public function testRead(): void diff --git a/tests/system/Commands/Utilities/Routes/FilterCollectorTest.php b/tests/system/Commands/Utilities/Routes/FilterCollectorTest.php index b4925efa936a..e3b86fcf9a56 100644 --- a/tests/system/Commands/Utilities/Routes/FilterCollectorTest.php +++ b/tests/system/Commands/Utilities/Routes/FilterCollectorTest.php @@ -16,12 +16,12 @@ use CodeIgniter\HTTP\Method; use CodeIgniter\Test\CIUnitTestCase; use Config\Services; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FilterCollectorTest extends CIUnitTestCase { public function testGet(): void diff --git a/tests/system/Commands/Utilities/Routes/FilterFinderTest.php b/tests/system/Commands/Utilities/Routes/FilterFinderTest.php index 495fbb46f31b..d96571c6b2f2 100644 --- a/tests/system/Commands/Utilities/Routes/FilterFinderTest.php +++ b/tests/system/Commands/Utilities/Routes/FilterFinderTest.php @@ -29,12 +29,12 @@ use Config\Filters as FiltersConfig; use Config\Modules; use Config\Routing; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FilterFinderTest extends CIUnitTestCase { use ConfigFromArrayTrait; diff --git a/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php b/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php index e075f984aa6b..d5f3d4a542c8 100644 --- a/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php +++ b/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php @@ -15,17 +15,16 @@ use CodeIgniter\Config\Services; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class SampleURIGeneratorTest extends CIUnitTestCase { - /** - * @dataProvider provideGet - */ + #[DataProvider('provideGet')] public function testGet(string $routeKey, string $expected): void { $generator = new SampleURIGenerator(); diff --git a/tests/system/Commands/ValidationGeneratorTest.php b/tests/system/Commands/ValidationGeneratorTest.php index 4a853fb61c54..0bcbcdec12e7 100644 --- a/tests/system/Commands/ValidationGeneratorTest.php +++ b/tests/system/Commands/ValidationGeneratorTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ValidationGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/CommonFunctionsSendTest.php b/tests/system/CommonFunctionsSendTest.php index ee4090264da2..46871c6284df 100644 --- a/tests/system/CommonFunctionsSendTest.php +++ b/tests/system/CommonFunctionsSendTest.php @@ -14,12 +14,14 @@ namespace CodeIgniter; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; /** * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] final class CommonFunctionsSendTest extends CIUnitTestCase { protected function setUp(): void @@ -36,10 +38,9 @@ protected function setUp(): void /** * Make sure cookies are set by RedirectResponse this way * See https://github.com/codeigniter4/CodeIgniter4/issues/1393 - * - * @runInSeparateProcess - * @preserveGlobalState disabled */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testRedirectResponseCookiesSent(): void { $loginTime = time(); diff --git a/tests/system/CommonFunctionsTest.php b/tests/system/CommonFunctionsTest.php index 7e1e9d27c349..fbbece86ddd1 100644 --- a/tests/system/CommonFunctionsTest.php +++ b/tests/system/CommonFunctionsTest.php @@ -41,17 +41,20 @@ use Config\Session as SessionConfig; use Exception; use Kint; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use RuntimeException; use stdClass; use Tests\Support\Models\JobModel; /** - * @backupGlobals enabled - * * @internal - * - * @group SeparateProcess */ +#[BackupGlobals(true)] +#[Group('SeparateProcess')] final class CommonFunctionsTest extends CIUnitTestCase { private ?App $config = null; @@ -269,10 +272,8 @@ public function testEscapeRecursiveArrayRaw(): void $this->assertSame($data, esc($data, 'raw')); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testSessionInstance(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. @@ -284,10 +285,8 @@ public function testSessionInstance(): void $this->assertInstanceOf(Session::class, session()); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testSessionVariable(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. @@ -301,10 +300,8 @@ public function testSessionVariable(): void $this->assertSame('Hi there', session('notbogus')); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testSessionVariableNotThere(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. @@ -429,10 +426,8 @@ public function testModelExistsAbsoluteClassname(): void $this->assertInstanceOf(JobModel::class, model(JobModel::class)); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testOldInput(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. @@ -468,10 +463,8 @@ public function testOldInput(): void $this->assertSame('fritz', old('zibble')); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testOldInputSerializeData(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. @@ -507,10 +500,9 @@ public function testOldInputSerializeData(): void /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/1492 - * - * @runInSeparateProcess - * @preserveGlobalState disabled */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testOldInputArray(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. @@ -628,10 +620,8 @@ public function testRedirectResponseCookies1(): void $this->assertTrue($answer1->hasCookie('login_time')); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testTrace(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. @@ -655,10 +645,8 @@ public function testViewNotSaveData(): void $this->assertStringContainsString('

is_not

', view('\Tests\Support\View\Views\simples')); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testForceHttpsNullRequestAndResponse(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. @@ -709,11 +697,10 @@ public function testForceHttpsWithBaseUrlSubFolder(): void } /** - * @dataProvider provideCleanPathActuallyCleaningThePaths - * * @param mixed $input * @param mixed $expected */ + #[DataProvider('provideCleanPathActuallyCleaningThePaths')] public function testCleanPathActuallyCleaningThePaths($input, $expected): void { $this->assertSame($expected, clean_path($input)); @@ -774,10 +761,8 @@ public function testDWithCSP(): void Kint::$cli_detection = $cliDetection; } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testTraceWithCSP(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. diff --git a/tests/system/CommonHelperTest.php b/tests/system/CommonHelperTest.php index 5195412db940..90b417d41639 100644 --- a/tests/system/CommonHelperTest.php +++ b/tests/system/CommonHelperTest.php @@ -16,17 +16,17 @@ use CodeIgniter\Autoloader\FileLocator; use CodeIgniter\Test\CIUnitTestCase; use Config\Services; +use PHPUnit\Framework\Attributes\CoversFunction; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; use RuntimeException; use Tests\Support\Autoloader\FatalLocator; /** * @internal - * - * @group Others - * - * @covers ::helper */ +#[CoversFunction('helper')] +#[Group('Others')] final class CommonHelperTest extends CIUnitTestCase { private array $dummyHelpers = [ diff --git a/tests/system/CommonSingleServiceTest.php b/tests/system/CommonSingleServiceTest.php index 13344db12142..a8b4c6dabc32 100644 --- a/tests/system/CommonSingleServiceTest.php +++ b/tests/system/CommonSingleServiceTest.php @@ -18,19 +18,18 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockSecurity; use Config\Security as SecurityConfig; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use ReflectionClass; use ReflectionMethod; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CommonSingleServiceTest extends CIUnitTestCase { - /** - * @dataProvider provideServiceNames - */ + #[DataProvider('provideServiceNames')] public function testSingleServiceWithNoParamsSupplied(string $service): void { Services::injectMock('security', new MockSecurity(new SecurityConfig())); @@ -44,9 +43,7 @@ public function testSingleServiceWithNoParamsSupplied(string $service): void $this->assertNotSame($service1, $service2); } - /** - * @dataProvider provideServiceNames - */ + #[DataProvider('provideServiceNames')] public function testSingleServiceWithAtLeastOneParamSupplied(string $service): void { if ($service === 'commands') { diff --git a/tests/system/Config/BaseConfigTest.php b/tests/system/Config/BaseConfigTest.php index 1b59fc623e52..c8e27dce75ef 100644 --- a/tests/system/Config/BaseConfigTest.php +++ b/tests/system/Config/BaseConfigTest.php @@ -17,6 +17,9 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Modules; use Encryption; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use PHPUnit\Framework\MockObject\MockObject; use RegistrarConfig; use RuntimeException; @@ -26,9 +29,8 @@ /** * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] final class BaseConfigTest extends CIUnitTestCase { private string $fixturesFolder; @@ -99,10 +101,8 @@ public function testUseDefaultValueTypeStringValue(): void $this->assertSame('123456', $config->password); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testServerValues(): void { $_SERVER = [ @@ -195,10 +195,8 @@ public function testSetsDefaultValues(): void $this->assertSame('bar', $config->second); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testSetsDefaultValuesEncryptionUsingHex2Bin(): void { $dotenv = new DotEnv($this->fixturesFolder, 'encryption.env'); @@ -210,10 +208,8 @@ public function testSetsDefaultValuesEncryptionUsingHex2Bin(): void $this->assertSame('OpenSSL', $config->driver); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testSetDefaultValuesEncryptionUsingBase64(): void { $dotenv = new DotEnv($this->fixturesFolder, 'base64encryption.env'); diff --git a/tests/system/Config/DotEnvTest.php b/tests/system/Config/DotEnvTest.php index d5ad1448a036..db54d2663820 100644 --- a/tests/system/Config/DotEnvTest.php +++ b/tests/system/Config/DotEnvTest.php @@ -16,15 +16,18 @@ use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use TypeError; /** - * @backupGlobals enabled - * * @internal - * - * @group SeparateProcess */ +#[BackupGlobals(true)] +#[Group('SeparateProcess')] final class DotEnvTest extends CIUnitTestCase { private ?vfsStreamDirectory $root; @@ -62,9 +65,7 @@ public function testReturnsFalseIfCannotFindFile(): void $this->assertFalse($dotenv->load()); } - /** - * @dataProvider provideLoadsVars - */ + #[DataProvider('provideLoadsVars')] public function testLoadsVars(string $expected, string $varname): void { $dotenv = new DotEnv($this->fixturesFolder); @@ -88,10 +89,8 @@ public static function provideLoadsVars(): iterable ]; } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testLoadsHex2Bin(): void { $dotenv = new DotEnv($this->fixturesFolder, 'encryption.env'); @@ -102,10 +101,8 @@ public function testLoadsHex2Bin(): void $this->assertSame('OpenSSL', getenv('encryption.driver')); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testLoadsBase64(): void { $dotenv = new DotEnv($this->fixturesFolder, 'base64encryption.env'); diff --git a/tests/system/Config/FactoriesTest.php b/tests/system/Config/FactoriesTest.php index dfca8511ada5..11a5e77a433e 100644 --- a/tests/system/Config/FactoriesTest.php +++ b/tests/system/Config/FactoriesTest.php @@ -17,6 +17,8 @@ use Config\App; use Config\Database; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; use ReflectionClass; use stdClass; use Tests\Support\Config\TestRegistrar; @@ -28,9 +30,8 @@ /** * @internal - * - * @group Others */ +#[Group('Others')] final class FactoriesTest extends CIUnitTestCase { protected function setUp(): void @@ -438,9 +439,7 @@ public function testGetComponentInstances() return $data; } - /** - * @depends testGetComponentInstances - */ + #[Depends('testGetComponentInstances')] public function testSetComponentInstances(array $data) { $before = Factories::getComponentInstances('config'); @@ -457,9 +456,7 @@ public function testSetComponentInstances(array $data) return $data; } - /** - * @depends testSetComponentInstances - */ + #[Depends('testSetComponentInstances')] public function testIsUpdated(array $data): void { Factories::reset(); diff --git a/tests/system/Config/MimesTest.php b/tests/system/Config/MimesTest.php index bc500caaa2fa..bcf5923f5b9d 100644 --- a/tests/system/Config/MimesTest.php +++ b/tests/system/Config/MimesTest.php @@ -15,12 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Mimes; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class MimesTest extends CIUnitTestCase { public static function provideGuessExtensionFromType(): iterable @@ -49,9 +50,7 @@ public static function provideGuessExtensionFromType(): iterable ]; } - /** - * @dataProvider provideGuessExtensionFromType - */ + #[DataProvider('provideGuessExtensionFromType')] public function testGuessExtensionFromType(?string $expected, string $mime): void { $this->assertSame($expected, Mimes::guessExtensionFromType($mime)); @@ -83,9 +82,7 @@ public static function provideGuessTypeFromExtension(): iterable ]; } - /** - * @dataProvider provideGuessTypeFromExtension - */ + #[DataProvider('provideGuessTypeFromExtension')] public function testGuessTypeFromExtension(?string $expected, string $ext): void { $this->assertSame($expected, Mimes::guessTypeFromExtension($ext)); diff --git a/tests/system/Config/ServicesTest.php b/tests/system/Config/ServicesTest.php index 24d2afb7302e..7825687841c7 100644 --- a/tests/system/Config/ServicesTest.php +++ b/tests/system/Config/ServicesTest.php @@ -46,14 +46,16 @@ use Config\App; use Config\Exceptions; use Config\Security as SecurityConfig; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use RuntimeException; use Tests\Support\Config\Services; /** * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] final class ServicesTest extends CIUnitTestCase { private array $original; @@ -241,30 +243,24 @@ public function testNewViewcell(): void $this->assertInstanceOf(Cell::class, $actual); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testNewSession(): void { $actual = Services::session(); $this->assertInstanceOf(Session::class, $actual); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testNewSessionWithNullConfig(): void { $actual = Services::session(null, false); $this->assertInstanceOf(Session::class, $actual); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testCallStatic(): void { // __callStatic should kick in for this but fail @@ -275,10 +271,8 @@ public function testCallStatic(): void $this->assertInstanceOf(Session::class, $actual); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testCallStaticDirectly(): void { // $actual = \CodeIgniter\Config\Services::SeSsIoN(null, false); // original @@ -286,10 +280,8 @@ public function testCallStaticDirectly(): void $this->assertInstanceOf(Session::class, $actual); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testMockInjection(): void { Services::injectMock('response', new MockResponse(new App())); @@ -308,10 +300,8 @@ public function testMockInjection(): void $this->assertSame($response, $response3); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testReset(): void { Services::injectMock('response', new MockResponse(new App())); @@ -327,10 +317,8 @@ public function testReset(): void $this->assertNotSame($response2, $response); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testResetSingle(): void { Services::injectMock('response', new MockResponse(new App())); diff --git a/tests/system/ControllerTest.php b/tests/system/ControllerTest.php index 00a144e1b01c..7cbe664aabc0 100644 --- a/tests/system/ControllerTest.php +++ b/tests/system/ControllerTest.php @@ -25,6 +25,8 @@ use Config\App; use Config\Services; use Config\Validation as ValidationConfig; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\Group; use Psr\Log\LoggerInterface; /** @@ -32,12 +34,10 @@ * Not a lot of business logic, so concentrate on making sure * we can exercise everything without blowing up :-/ * - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class ControllerTest extends CIUnitTestCase { private App $config; diff --git a/tests/system/Cookie/CookieStoreTest.php b/tests/system/Cookie/CookieStoreTest.php index a7014b9a0997..7e752fde5da5 100644 --- a/tests/system/Cookie/CookieStoreTest.php +++ b/tests/system/Cookie/CookieStoreTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Cookie\Exceptions\CookieException; use CodeIgniter\Test\CIUnitTestCase; use DateTimeImmutable; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CookieStoreTest extends CIUnitTestCase { private array $defaults; diff --git a/tests/system/Cookie/CookieTest.php b/tests/system/Cookie/CookieTest.php index bdb9b7498f94..51016ca0061e 100644 --- a/tests/system/Cookie/CookieTest.php +++ b/tests/system/Cookie/CookieTest.php @@ -19,12 +19,13 @@ use DateTimeImmutable; use DateTimeZone; use LogicException; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CookieTest extends CIUnitTestCase { private array $defaults; @@ -80,9 +81,7 @@ public function testConfigInjectionForDefaults(): void Cookie::setDefaults($old); } - /** - * @dataProvider provideConfigPrefix - */ + #[DataProvider('provideConfigPrefix')] public function testConfigPrefix(string $configPrefix, string $optionPrefix, string $expected): void { $config = new CookieConfig(); @@ -167,10 +166,9 @@ public function testExpirationTime(): void } /** - * @dataProvider provideInvalidExpires - * * @param bool|float|string $expires */ + #[DataProvider('provideInvalidExpires')] public function testInvalidExpires($expires): void { $this->expectException(CookieException::class); @@ -190,9 +188,7 @@ public static function provideInvalidExpires(): iterable } } - /** - * @dataProvider provideSetCookieHeaderCreation - */ + #[DataProvider('provideSetCookieHeaderCreation')] public function testSetCookieHeaderCreation(string $header, array $changed): void { $cookie = Cookie::fromHeaderString($header); diff --git a/tests/system/DataConverter/DataConverterTest.php b/tests/system/DataConverter/DataConverterTest.php index e5ae5e7abe90..6592f4d801c6 100644 --- a/tests/system/DataConverter/DataConverterTest.php +++ b/tests/system/DataConverter/DataConverterTest.php @@ -18,14 +18,15 @@ use CodeIgniter\I18n\Time; use CodeIgniter\Test\CIUnitTestCase; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Entity\CustomUser; use Tests\Support\Entity\User; /** * @internal - * - * @group Others */ +#[Group('Others')] final class DataConverterTest extends CIUnitTestCase { public function testInstantiate(): void @@ -39,9 +40,7 @@ public function testInstantiate(): void $this->assertInstanceOf(DataConverter::class, $converter); } - /** - * @dataProvider provideConvertDataFromDB - */ + #[DataProvider('provideConvertDataFromDB')] public function testConvertDataFromDB(array $types, array $dbData, array $expected): void { $converter = $this->createDataConverter($types); @@ -51,9 +50,7 @@ public function testConvertDataFromDB(array $types, array $dbData, array $expect $this->assertSame($expected, $data); } - /** - * @dataProvider provideConvertDataToDB - */ + #[DataProvider('provideConvertDataToDB')] public function testConvertDataToDB(array $types, array $phpData, array $expected): void { $converter = $this->createDataConverter($types); diff --git a/tests/system/Database/BaseConnectionTest.php b/tests/system/Database/BaseConnectionTest.php index 6c7624ce795a..b36ec7ea022a 100644 --- a/tests/system/Database/BaseConnectionTest.php +++ b/tests/system/Database/BaseConnectionTest.php @@ -16,13 +16,14 @@ use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Throwable; /** * @internal - * - * @group Others */ +#[Group('Others')] final class BaseConnectionTest extends CIUnitTestCase { private array $options = [ @@ -180,9 +181,8 @@ public function testMagicGetMissing(): void /** * These tests are intended to confirm the current behavior. * We do not know if all of these are the correct behavior. - * - * @dataProvider provideProtectIdentifiers */ + #[DataProvider('provideProtectIdentifiers')] public function testProtectIdentifiers( bool $prefixSingle, bool $protectIdentifiers, @@ -286,9 +286,8 @@ public static function provideProtectIdentifiers(): iterable /** * These tests are intended to confirm the current behavior. - * - * @dataProvider provideEscapeIdentifiers */ + #[DataProvider('provideEscapeIdentifiers')] public function testEscapeIdentifiers(string $item, string $expected): void { $db = new MockConnection($this->options); @@ -310,9 +309,7 @@ public static function provideEscapeIdentifiers(): iterable ]; } - /** - * @dataProvider provideEscapeIdentifier - */ + #[DataProvider('provideEscapeIdentifier')] public function testEscapeIdentifier(string $item, string $expected): void { $db = new MockConnection($this->options); diff --git a/tests/system/Database/BaseQueryTest.php b/tests/system/Database/BaseQueryTest.php index d4685ae2e989..a87bc64e727a 100644 --- a/tests/system/Database/BaseQueryTest.php +++ b/tests/system/Database/BaseQueryTest.php @@ -15,12 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class BaseQueryTest extends CIUnitTestCase { protected $db; @@ -185,11 +186,10 @@ public static function provideIsWriteType(): iterable } /** - * @dataProvider provideIsWriteType - * * @param mixed $expected * @param mixed $sql */ + #[DataProvider('provideIsWriteType')] public function testIsWriteType($expected, $sql): void { $query = new Query($this->db); @@ -598,11 +598,10 @@ public static function provideHighlightQueryKeywords(): iterable } /** - * @dataProvider provideHighlightQueryKeywords - * * @param mixed $expected * @param mixed $sql */ + #[DataProvider('provideHighlightQueryKeywords')] public function testHighlightQueryKeywords($expected, $sql): void { $query = new Query($this->db); diff --git a/tests/system/Database/Builder/AliasTest.php b/tests/system/Database/Builder/AliasTest.php index 3e4c88ec9af5..9528ba6aabb2 100644 --- a/tests/system/Database/Builder/AliasTest.php +++ b/tests/system/Database/Builder/AliasTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class AliasTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Builder/BaseTest.php b/tests/system/Database/Builder/BaseTest.php index bcb4bcfb8822..49f74da2762d 100644 --- a/tests/system/Database/Builder/BaseTest.php +++ b/tests/system/Database/Builder/BaseTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class BaseTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Builder/CountTest.php b/tests/system/Database/Builder/CountTest.php index 0ba9ac7832e2..8d129efb5c31 100644 --- a/tests/system/Database/Builder/CountTest.php +++ b/tests/system/Database/Builder/CountTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CountTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Builder/DeleteTest.php b/tests/system/Database/Builder/DeleteTest.php index 87cbdf0366fe..53b66eed805b 100644 --- a/tests/system/Database/Builder/DeleteTest.php +++ b/tests/system/Database/Builder/DeleteTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class DeleteTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Builder/DistinctTest.php b/tests/system/Database/Builder/DistinctTest.php index 7000a001cde0..5a5712db2c0e 100644 --- a/tests/system/Database/Builder/DistinctTest.php +++ b/tests/system/Database/Builder/DistinctTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class DistinctTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Builder/EmptyTest.php b/tests/system/Database/Builder/EmptyTest.php index 176fc8738251..959bfbc81c56 100644 --- a/tests/system/Database/Builder/EmptyTest.php +++ b/tests/system/Database/Builder/EmptyTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class EmptyTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Builder/FromTest.php b/tests/system/Database/Builder/FromTest.php index 36edaa1dcf0c..99bacd97fe18 100644 --- a/tests/system/Database/Builder/FromTest.php +++ b/tests/system/Database/Builder/FromTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Database\SQLSRV\Builder as SQLSRVBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FromTest extends CIUnitTestCase { protected $db; @@ -153,4 +153,32 @@ public function testFromSubqueryWithSQLSRV(): void $this->assertSame($expectedSQL, str_replace("\n", ' ', $builder->getCompiledSelect())); } + + /** + * @see https://github.com/codeigniter4/CodeIgniter4/issues/8697 + */ + public function testConstructorWithMultipleSegmentTableWithSQLSRV(): void + { + $this->db = new MockConnection(['DBDriver' => 'SQLSRV', 'database' => 'test', 'schema' => 'dbo']); + + $builder = new SQLSRVBuilder('database.dbo.table', $this->db); + + $expectedSQL = 'SELECT * FROM "database"."dbo"."table"'; + + $this->assertSame($expectedSQL, str_replace("\n", ' ', $builder->getCompiledSelect())); + } + + /** + * @see https://github.com/codeigniter4/CodeIgniter4/issues/8697 + */ + public function testConstructorWithMultipleSegmentTableWithoutDatabaseWithSQLSRV(): void + { + $this->db = new MockConnection(['DBDriver' => 'SQLSRV', 'database' => 'test', 'schema' => 'dbo']); + + $builder = new SQLSRVBuilder('dbo.table', $this->db); + + $expectedSQL = 'SELECT * FROM "test"."dbo"."table"'; + + $this->assertSame($expectedSQL, str_replace("\n", ' ', $builder->getCompiledSelect())); + } } diff --git a/tests/system/Database/Builder/GetTest.php b/tests/system/Database/Builder/GetTest.php index 3daf4a6831d6..2447511c89ca 100644 --- a/tests/system/Database/Builder/GetTest.php +++ b/tests/system/Database/Builder/GetTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; use Config\Feature; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class GetTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Builder/GroupTest.php b/tests/system/Database/Builder/GroupTest.php index c6f2b24667b0..d03937ca6b3f 100644 --- a/tests/system/Database/Builder/GroupTest.php +++ b/tests/system/Database/Builder/GroupTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class GroupTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Builder/InsertTest.php b/tests/system/Database/Builder/InsertTest.php index 55faceaa5657..e021472b72fc 100644 --- a/tests/system/Database/Builder/InsertTest.php +++ b/tests/system/Database/Builder/InsertTest.php @@ -19,12 +19,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class InsertTest extends CIUnitTestCase { /** diff --git a/tests/system/Database/Builder/JoinTest.php b/tests/system/Database/Builder/JoinTest.php index 0ab74729ed7a..377df4816e57 100644 --- a/tests/system/Database/Builder/JoinTest.php +++ b/tests/system/Database/Builder/JoinTest.php @@ -19,12 +19,12 @@ use CodeIgniter\Database\SQLSRV\Builder as SQLSRVBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class JoinTest extends CIUnitTestCase { protected $db; @@ -80,6 +80,25 @@ public function testJoinMultipleConditions(): void $this->assertSame($expectedSQL, str_replace("\n", ' ', $builder->getCompiledSelect())); } + /** + * @see https://github.com/codeigniter4/CodeIgniter4/issues/8791 + */ + public function testJoinMultipleConditionsBetween(): void + { + $builder = new BaseBuilder('table1', $this->db); + + $builder->join( + 'leases', + 'units.unit_id = leases.unit_id AND CURDATE() BETWEEN lease_start_date AND lease_exp_date', + 'LEFT' + ); + + // @TODO Should be `... CURDATE() BETWEEN "lease_start_date" AND "lease_exp_date"` + $expectedSQL = 'SELECT * FROM "table1" LEFT JOIN "leases" ON "units"."unit_id" = "leases"."unit_id" AND CURDATE() BETWEEN lease_start_date AND lease_exp_date'; + + $this->assertSame($expectedSQL, str_replace("\n", ' ', $builder->getCompiledSelect())); + } + /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/3832 */ diff --git a/tests/system/Database/Builder/LikeTest.php b/tests/system/Database/Builder/LikeTest.php index 5cdae0729d70..d2a534b5bf27 100644 --- a/tests/system/Database/Builder/LikeTest.php +++ b/tests/system/Database/Builder/LikeTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Database\RawSql; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class LikeTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Builder/LimitTest.php b/tests/system/Database/Builder/LimitTest.php index 04d4668ec356..4e7bbfd40203 100644 --- a/tests/system/Database/Builder/LimitTest.php +++ b/tests/system/Database/Builder/LimitTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class LimitTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Builder/OrderTest.php b/tests/system/Database/Builder/OrderTest.php index 1dc4ba4052ae..b1b2a684d9df 100644 --- a/tests/system/Database/Builder/OrderTest.php +++ b/tests/system/Database/Builder/OrderTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class OrderTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Builder/PrefixTest.php b/tests/system/Database/Builder/PrefixTest.php index 5ff7ccb720a1..03b8cd99e4d3 100644 --- a/tests/system/Database/Builder/PrefixTest.php +++ b/tests/system/Database/Builder/PrefixTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class PrefixTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Builder/ReplaceTest.php b/tests/system/Database/Builder/ReplaceTest.php index 24a68cffff8e..c0aa754ac9e5 100644 --- a/tests/system/Database/Builder/ReplaceTest.php +++ b/tests/system/Database/Builder/ReplaceTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ReplaceTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Builder/SelectTest.php b/tests/system/Database/Builder/SelectTest.php index 6a9c32183afc..cd3f39029f6b 100644 --- a/tests/system/Database/Builder/SelectTest.php +++ b/tests/system/Database/Builder/SelectTest.php @@ -19,12 +19,12 @@ use CodeIgniter\Database\SQLSRV\Builder as SQLSRVBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class SelectTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Builder/TruncateTest.php b/tests/system/Database/Builder/TruncateTest.php index 4cf6d05d1ed9..1b9d4199ade0 100644 --- a/tests/system/Database/Builder/TruncateTest.php +++ b/tests/system/Database/Builder/TruncateTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class TruncateTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Builder/UnionTest.php b/tests/system/Database/Builder/UnionTest.php index d0487259445c..bd498e2e2cab 100644 --- a/tests/system/Database/Builder/UnionTest.php +++ b/tests/system/Database/Builder/UnionTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Database\SQLSRV\Connection as SQLSRVConnection; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class UnionTest extends CIUnitTestCase { /** diff --git a/tests/system/Database/Builder/UpdateTest.php b/tests/system/Database/Builder/UpdateTest.php index de338111c4a9..b13739dfbd58 100644 --- a/tests/system/Database/Builder/UpdateTest.php +++ b/tests/system/Database/Builder/UpdateTest.php @@ -18,12 +18,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; use CodeIgniter\Test\Mock\MockQuery; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class UpdateTest extends CIUnitTestCase { /** diff --git a/tests/system/Database/Builder/WhenTest.php b/tests/system/Database/Builder/WhenTest.php index b70a8e82e7b9..a7fede7879d3 100644 --- a/tests/system/Database/Builder/WhenTest.php +++ b/tests/system/Database/Builder/WhenTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class WhenTest extends CIUnitTestCase { /** diff --git a/tests/system/Database/Builder/WhereTest.php b/tests/system/Database/Builder/WhereTest.php index e48f0c6711a9..57980f28ee8c 100644 --- a/tests/system/Database/Builder/WhereTest.php +++ b/tests/system/Database/Builder/WhereTest.php @@ -20,13 +20,14 @@ use DateTime; use Error; use ErrorException; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use stdClass; /** * @internal - * - * @group Others */ +#[Group('Others')] final class WhereTest extends CIUnitTestCase { /** @@ -403,10 +404,9 @@ public static function provideWhereInvalidKeyThrowInvalidArgumentException(): it } /** - * @dataProvider provideWhereInvalidKeyThrowInvalidArgumentException - * * @param mixed $key */ + #[DataProvider('provideWhereInvalidKeyThrowInvalidArgumentException')] public function testWhereInvalidKeyThrowInvalidArgumentException($key): void { $this->expectException('InvalidArgumentException'); @@ -425,10 +425,9 @@ public static function provideWhereInEmptyValuesThrowInvalidArgumentException(): } /** - * @dataProvider provideWhereInEmptyValuesThrowInvalidArgumentException - * * @param mixed $values */ + #[DataProvider('provideWhereInEmptyValuesThrowInvalidArgumentException')] public function testWhereInEmptyValuesThrowInvalidArgumentException($values): void { $this->expectException('InvalidArgumentException'); diff --git a/tests/system/Database/ConfigTest.php b/tests/system/Database/ConfigTest.php index c35b0f60f202..882301692352 100644 --- a/tests/system/Database/ConfigTest.php +++ b/tests/system/Database/ConfigTest.php @@ -15,12 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\ReflectionHelper; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ConfigTest extends CIUnitTestCase { use ReflectionHelper; @@ -194,10 +195,9 @@ public function testConnectionGroupWithDSNPostgreNative(): void } /** - * @dataProvider provideConvertDSN - * * @see https://github.com/codeigniter4/CodeIgniter4/issues/7550 */ + #[DataProvider('provideConvertDSN')] public function testConvertDSN(string $input, string $expected): void { // @TODO This format is for PDO_PGSQL. diff --git a/tests/system/Database/DatabaseSeederTest.php b/tests/system/Database/DatabaseSeederTest.php index 5d0258c57dc2..398052636246 100644 --- a/tests/system/Database/DatabaseSeederTest.php +++ b/tests/system/Database/DatabaseSeederTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Database; use Faker\Generator; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class DatabaseSeederTest extends CIUnitTestCase { public function testInstantiateNoSeedPath(): void diff --git a/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce1Test.php b/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce1Test.php index 597e66aaf967..8a0980f853a9 100644 --- a/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce1Test.php +++ b/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce1Test.php @@ -17,15 +17,15 @@ use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; use Config\Services; +use PHPUnit\Framework\Attributes\Group; /** * DatabaseTestCaseMigrationOnce1Test and DatabaseTestCaseMigrationOnce2Test * show $migrateOnce applies per test case file. * - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class DatabaseTestCaseMigrationOnce1Test extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce2Test.php b/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce2Test.php index 17def3edec19..5c4013e055e1 100644 --- a/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce2Test.php +++ b/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce2Test.php @@ -17,15 +17,15 @@ use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; use Config\Services; +use PHPUnit\Framework\Attributes\Group; /** * DatabaseTestCaseMigrationOnce1Test and DatabaseTestCaseMigrationOnce2Test * show $migrateOnce applies per test case file. * - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class DatabaseTestCaseMigrationOnce2Test extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/DatabaseTestCaseTest.php b/tests/system/Database/DatabaseTestCaseTest.php index 3224efe054ce..c6a03022df72 100644 --- a/tests/system/Database/DatabaseTestCaseTest.php +++ b/tests/system/Database/DatabaseTestCaseTest.php @@ -17,14 +17,14 @@ use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; use Config\Services; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\AnotherSeeder; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class DatabaseTestCaseTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Forge/CreateTableTest.php b/tests/system/Database/Forge/CreateTableTest.php index 1e52d348a04b..115c5506d379 100644 --- a/tests/system/Database/Forge/CreateTableTest.php +++ b/tests/system/Database/Forge/CreateTableTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Database\RawSql; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CreateTableTest extends CIUnitTestCase { public function testCreateTableWithDefaultRawSql(): void diff --git a/tests/system/Database/Forge/DropForeignKeyTest.php b/tests/system/Database/Forge/DropForeignKeyTest.php index 98acf337b7fb..8c2b37e10b2b 100644 --- a/tests/system/Database/Forge/DropForeignKeyTest.php +++ b/tests/system/Database/Forge/DropForeignKeyTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Database\Forge; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class DropForeignKeyTest extends CIUnitTestCase { protected $db; diff --git a/tests/system/Database/Live/AliasTest.php b/tests/system/Database/Live/AliasTest.php index c55e08a0345e..ccd83ee361b8 100644 --- a/tests/system/Database/Live/AliasTest.php +++ b/tests/system/Database/Live/AliasTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class AliasTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/BadQueryTest.php b/tests/system/Database/Live/BadQueryTest.php index c07963cf2b61..8b842b21b930 100644 --- a/tests/system/Database/Live/BadQueryTest.php +++ b/tests/system/Database/Live/BadQueryTest.php @@ -16,13 +16,13 @@ use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class BadQueryTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/ConnectTest.php b/tests/system/Database/Live/ConnectTest.php index 777c074ad136..3f7941a201ec 100644 --- a/tests/system/Database/Live/ConnectTest.php +++ b/tests/system/Database/Live/ConnectTest.php @@ -18,12 +18,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class ConnectTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/CountTest.php b/tests/system/Database/Live/CountTest.php index 0df9132e808a..c5aa64d4c700 100644 --- a/tests/system/Database/Live/CountTest.php +++ b/tests/system/Database/Live/CountTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class CountTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/DatabaseTestTraitCaseTest.php b/tests/system/Database/Live/DatabaseTestTraitCaseTest.php index 8c4c2d4ab4bc..dc43976de9f1 100644 --- a/tests/system/Database/Live/DatabaseTestTraitCaseTest.php +++ b/tests/system/Database/Live/DatabaseTestTraitCaseTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class DatabaseTestTraitCaseTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/DbDebugTest.php b/tests/system/Database/Live/DbDebugTest.php index 5939ff0df127..8155e9e42db2 100644 --- a/tests/system/Database/Live/DbDebugTest.php +++ b/tests/system/Database/Live/DbDebugTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class DbDebugTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/DbUtilsTest.php b/tests/system/Database/Live/DbUtilsTest.php index ac1aa660cbf4..b7fd56923334 100644 --- a/tests/system/Database/Live/DbUtilsTest.php +++ b/tests/system/Database/Live/DbUtilsTest.php @@ -17,13 +17,13 @@ use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class DbUtilsTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/DeleteTest.php b/tests/system/Database/Live/DeleteTest.php index 3a8d10b03020..421f5c0f430f 100644 --- a/tests/system/Database/Live/DeleteTest.php +++ b/tests/system/Database/Live/DeleteTest.php @@ -18,13 +18,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class DeleteTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/EmptyTest.php b/tests/system/Database/Live/EmptyTest.php index 4790addd9650..42f21af10f39 100644 --- a/tests/system/Database/Live/EmptyTest.php +++ b/tests/system/Database/Live/EmptyTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class EmptyTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/EscapeTest.php b/tests/system/Database/Live/EscapeTest.php index 0f931cdbe85c..adc5d414e34e 100644 --- a/tests/system/Database/Live/EscapeTest.php +++ b/tests/system/Database/Live/EscapeTest.php @@ -17,12 +17,12 @@ use CodeIgniter\I18n\Time; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class EscapeTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/FabricatorLiveTest.php b/tests/system/Database/Live/FabricatorLiveTest.php index 9b161778b0e0..a865d2fef4c8 100644 --- a/tests/system/Database/Live/FabricatorLiveTest.php +++ b/tests/system/Database/Live/FabricatorLiveTest.php @@ -17,14 +17,14 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use CodeIgniter\Test\Fabricator; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Models\UserModel; use Tests\Support\Models\ValidModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class FabricatorLiveTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/ForgeTest.php b/tests/system/Database/Live/ForgeTest.php index 8061e80d7241..7fccd6b1d298 100644 --- a/tests/system/Database/Live/ForgeTest.php +++ b/tests/system/Database/Live/ForgeTest.php @@ -19,15 +19,15 @@ use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; use LogicException; +use PHPUnit\Framework\Attributes\Group; use RuntimeException; use stdClass; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class ForgeTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/FromTest.php b/tests/system/Database/Live/FromTest.php index ee7a429c1f22..8e26ef0cad78 100644 --- a/tests/system/Database/Live/FromTest.php +++ b/tests/system/Database/Live/FromTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class FromTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/GetNumRowsTest.php b/tests/system/Database/Live/GetNumRowsTest.php index cea8ef4b0e49..c7575462d598 100644 --- a/tests/system/Database/Live/GetNumRowsTest.php +++ b/tests/system/Database/Live/GetNumRowsTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class GetNumRowsTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/GetTest.php b/tests/system/Database/Live/GetTest.php index f666d3aa629d..681af7344183 100644 --- a/tests/system/Database/Live/GetTest.php +++ b/tests/system/Database/Live/GetTest.php @@ -17,13 +17,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Feature; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class GetTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/GetVersionTest.php b/tests/system/Database/Live/GetVersionTest.php index 65cca3e21df9..73da7c07071d 100644 --- a/tests/system/Database/Live/GetVersionTest.php +++ b/tests/system/Database/Live/GetVersionTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class GetVersionTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/GroupTest.php b/tests/system/Database/Live/GroupTest.php index a242546ebcd0..7dee9b1e5a67 100644 --- a/tests/system/Database/Live/GroupTest.php +++ b/tests/system/Database/Live/GroupTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class GroupTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/IncrementTest.php b/tests/system/Database/Live/IncrementTest.php index e6bd52a3b96d..0051e1a9039d 100644 --- a/tests/system/Database/Live/IncrementTest.php +++ b/tests/system/Database/Live/IncrementTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class IncrementTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/InsertTest.php b/tests/system/Database/Live/InsertTest.php index 265c0b407246..217632551b29 100644 --- a/tests/system/Database/Live/InsertTest.php +++ b/tests/system/Database/Live/InsertTest.php @@ -18,13 +18,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class InsertTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/JoinTest.php b/tests/system/Database/Live/JoinTest.php index 046270c5fd5b..77324cea6403 100644 --- a/tests/system/Database/Live/JoinTest.php +++ b/tests/system/Database/Live/JoinTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class JoinTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/LikeTest.php b/tests/system/Database/Live/LikeTest.php index 3b79598e3613..5884f9d01220 100644 --- a/tests/system/Database/Live/LikeTest.php +++ b/tests/system/Database/Live/LikeTest.php @@ -16,13 +16,13 @@ use CodeIgniter\Database\RawSql; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class LikeTest extends CIUnitTestCase { use DatabaseTestTrait; @@ -132,11 +132,7 @@ public function testLikeRawSqlAndCountAllResultsAndGet(): void { $builder = $this->db->table('job'); - if ($this->db->DBDriver === 'OCI8') { - $key = new RawSql('"name"'); - } else { - $key = new RawSql('name'); - } + $key = $this->db->DBDriver === 'OCI8' ? new RawSql('"name"') : new RawSql('name'); $builder->like($key, 'Developer'); $count = $builder->countAllResults(false); @@ -153,11 +149,7 @@ public function testLikeRawSqlAndGetAndCountAllResults(): void { $builder = $this->db->table('job'); - if ($this->db->DBDriver === 'OCI8') { - $key = new RawSql('"name"'); - } else { - $key = new RawSql('name'); - } + $key = $this->db->DBDriver === 'OCI8' ? new RawSql('"name"') : new RawSql('name'); $builder->like($key, 'Developer'); $results = $builder->get(null, 0, false)->getResult(); diff --git a/tests/system/Database/Live/LimitTest.php b/tests/system/Database/Live/LimitTest.php index 546096eb9be5..a35bf1d8056c 100644 --- a/tests/system/Database/Live/LimitTest.php +++ b/tests/system/Database/Live/LimitTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class LimitTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/MetadataTest.php b/tests/system/Database/Live/MetadataTest.php index 4d6927f2d800..56e5d70a60e8 100644 --- a/tests/system/Database/Live/MetadataTest.php +++ b/tests/system/Database/Live/MetadataTest.php @@ -16,13 +16,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class MetadataTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php b/tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php index 5b9bc3b16701..98403c46e8a8 100644 --- a/tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php +++ b/tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php @@ -15,12 +15,12 @@ use CodeIgniter\Database\Live\AbstractGetFieldDataTestCase; use Config\Database; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase { protected function createForge(): void diff --git a/tests/system/Database/Live/MySQLi/NumberNativeTest.php b/tests/system/Database/Live/MySQLi/NumberNativeTest.php index 5ba37eaf804e..4469e4c3659a 100644 --- a/tests/system/Database/Live/MySQLi/NumberNativeTest.php +++ b/tests/system/Database/Live/MySQLi/NumberNativeTest.php @@ -16,13 +16,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class NumberNativeTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/MySQLi/RawSqlTest.php b/tests/system/Database/Live/MySQLi/RawSqlTest.php index 84949848b5f3..e136d526e2de 100644 --- a/tests/system/Database/Live/MySQLi/RawSqlTest.php +++ b/tests/system/Database/Live/MySQLi/RawSqlTest.php @@ -16,14 +16,14 @@ use CodeIgniter\Database\RawSql; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use stdclass; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class RawSqlTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/OCI8/CallStoredProcedureTest.php b/tests/system/Database/Live/OCI8/CallStoredProcedureTest.php index c2f2b377387e..2baffb669957 100644 --- a/tests/system/Database/Live/OCI8/CallStoredProcedureTest.php +++ b/tests/system/Database/Live/OCI8/CallStoredProcedureTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class CallStoredProcedureTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/OCI8/GetFieldDataTestCase.php b/tests/system/Database/Live/OCI8/GetFieldDataTestCase.php index 809a58e30264..a45c893dc3f9 100644 --- a/tests/system/Database/Live/OCI8/GetFieldDataTestCase.php +++ b/tests/system/Database/Live/OCI8/GetFieldDataTestCase.php @@ -16,13 +16,13 @@ use CodeIgniter\Database\Live\AbstractGetFieldDataTestCase; use Config\Database; use LogicException; +use PHPUnit\Framework\Attributes\Group; use stdClass; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase { protected function createForge(): void diff --git a/tests/system/Database/Live/OCI8/LastInsertIDTest.php b/tests/system/Database/Live/OCI8/LastInsertIDTest.php index eef3be40bc85..5cc88e39510b 100644 --- a/tests/system/Database/Live/OCI8/LastInsertIDTest.php +++ b/tests/system/Database/Live/OCI8/LastInsertIDTest.php @@ -16,13 +16,13 @@ use CodeIgniter\Database\Query; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class LastInsertIDTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/OrderTest.php b/tests/system/Database/Live/OrderTest.php index 9109c88f066a..1451222b5ceb 100644 --- a/tests/system/Database/Live/OrderTest.php +++ b/tests/system/Database/Live/OrderTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class OrderTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/Postgre/ConnectTest.php b/tests/system/Database/Live/Postgre/ConnectTest.php new file mode 100644 index 000000000000..29de0976eb21 --- /dev/null +++ b/tests/system/Database/Live/Postgre/ConnectTest.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace CodeIgniter\Database\Live\Postgre; + +use CodeIgniter\Database\Exceptions\DatabaseException; +use CodeIgniter\Test\CIUnitTestCase; +use Config\Database; +use PHPUnit\Framework\Attributes\Group; + +/** + * @internal + */ +#[Group('DatabaseLive')] +final class ConnectTest extends CIUnitTestCase +{ + protected function setUp(): void + { + parent::setUp(); + + $this->db = Database::connect($this->DBGroup); + + if ($this->db->DBDriver !== 'Postgre') { + $this->markTestSkipped('This test is only for Postgre.'); + } + } + + public function testShowErrorMessageWhenSettingInvalidCharset(): void + { + $this->expectException(DatabaseException::class); + $this->expectExceptionMessage( + 'Unable to connect to the database. +Main connection [Postgre]: ERROR: invalid value for parameter "client_encoding": "utf8mb4"' + ); + + $config = config('Database'); + $group = $config->tests; + // Sets invalid charset. + $group['charset'] = 'utf8mb4'; + $db = Database::connect($group); + + // Actually connect to DB. + $db->initialize(); + } +} diff --git a/tests/system/Database/Live/Postgre/GetFieldDataTestCase.php b/tests/system/Database/Live/Postgre/GetFieldDataTestCase.php index 04adeb0bda53..42e823397926 100644 --- a/tests/system/Database/Live/Postgre/GetFieldDataTestCase.php +++ b/tests/system/Database/Live/Postgre/GetFieldDataTestCase.php @@ -15,12 +15,12 @@ use CodeIgniter\Database\Live\AbstractGetFieldDataTestCase; use Config\Database; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase { protected function createForge(): void diff --git a/tests/system/Database/Live/PreparedQueryTest.php b/tests/system/Database/Live/PreparedQueryTest.php index cf9bf4d24d67..fd3b6cedb403 100644 --- a/tests/system/Database/Live/PreparedQueryTest.php +++ b/tests/system/Database/Live/PreparedQueryTest.php @@ -20,13 +20,13 @@ use CodeIgniter\Database\ResultInterface; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class PreparedQueryTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/PretendTest.php b/tests/system/Database/Live/PretendTest.php index e915cd7ff567..b3e6506c1be6 100644 --- a/tests/system/Database/Live/PretendTest.php +++ b/tests/system/Database/Live/PretendTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Database\Query; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class PretendTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/SQLSRV/GetFieldDataTestCase.php b/tests/system/Database/Live/SQLSRV/GetFieldDataTestCase.php index 05f77981cff0..bf00175c4fab 100644 --- a/tests/system/Database/Live/SQLSRV/GetFieldDataTestCase.php +++ b/tests/system/Database/Live/SQLSRV/GetFieldDataTestCase.php @@ -15,12 +15,12 @@ use CodeIgniter\Database\Live\AbstractGetFieldDataTestCase; use Config\Database; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase { protected function createForge(): void diff --git a/tests/system/Database/Live/SQLite3/AlterTableTest.php b/tests/system/Database/Live/SQLite3/AlterTableTest.php index 1c47fb607c4a..46806b9618fb 100644 --- a/tests/system/Database/Live/SQLite3/AlterTableTest.php +++ b/tests/system/Database/Live/SQLite3/AlterTableTest.php @@ -19,14 +19,14 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; /** - * @group DatabaseLive - * - * @requires extension sqlite3 - * * @internal */ +#[Group('DatabaseLive')] +#[RequiresPhpExtension('sqlite3')] final class AlterTableTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/SQLite3/ForgeModifyColumnTest.php b/tests/system/Database/Live/SQLite3/ForgeModifyColumnTest.php index cf14c0070119..c628b01aea21 100644 --- a/tests/system/Database/Live/SQLite3/ForgeModifyColumnTest.php +++ b/tests/system/Database/Live/SQLite3/ForgeModifyColumnTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Database\Forge; use CodeIgniter\Test\CIUnitTestCase; use Config\Database; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class ForgeModifyColumnTest extends CIUnitTestCase { private Forge $forge; diff --git a/tests/system/Database/Live/SQLite3/GetFieldDataTestCase.php b/tests/system/Database/Live/SQLite3/GetFieldDataTestCase.php index 164845a8f9d8..9fb6d881f019 100644 --- a/tests/system/Database/Live/SQLite3/GetFieldDataTestCase.php +++ b/tests/system/Database/Live/SQLite3/GetFieldDataTestCase.php @@ -15,12 +15,12 @@ use CodeIgniter\Database\Live\AbstractGetFieldDataTestCase; use Config\Database; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase { protected function createForge(): void diff --git a/tests/system/Database/Live/SQLite3/GetIndexDataTest.php b/tests/system/Database/Live/SQLite3/GetIndexDataTest.php index 72662be16d1d..5ef439644417 100644 --- a/tests/system/Database/Live/SQLite3/GetIndexDataTest.php +++ b/tests/system/Database/Live/SQLite3/GetIndexDataTest.php @@ -17,13 +17,13 @@ use CodeIgniter\Database\SQLite3\Forge; use CodeIgniter\Test\CIUnitTestCase; use Config\Database; +use PHPUnit\Framework\Attributes\Group; use stdClass; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class GetIndexDataTest extends CIUnitTestCase { /** diff --git a/tests/system/Database/Live/SelectTest.php b/tests/system/Database/Live/SelectTest.php index b66b26fbe960..8fbd416da8ee 100644 --- a/tests/system/Database/Live/SelectTest.php +++ b/tests/system/Database/Live/SelectTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class SelectTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/TransactionDBDebugFalseTest.php b/tests/system/Database/Live/TransactionDBDebugFalseTest.php index 5bf0f288e2f9..8be00575abed 100644 --- a/tests/system/Database/Live/TransactionDBDebugFalseTest.php +++ b/tests/system/Database/Live/TransactionDBDebugFalseTest.php @@ -13,11 +13,12 @@ namespace CodeIgniter\Database\Live; +use PHPUnit\Framework\Attributes\Group; + /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class TransactionDBDebugFalseTest extends TransactionDBDebugTrueTest { protected function setUp(): void diff --git a/tests/system/Database/Live/TransactionDBDebugTrueTest.php b/tests/system/Database/Live/TransactionDBDebugTrueTest.php index e9a39847b939..da77edb9b975 100644 --- a/tests/system/Database/Live/TransactionDBDebugTrueTest.php +++ b/tests/system/Database/Live/TransactionDBDebugTrueTest.php @@ -17,15 +17,15 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal * * @no-final */ +#[Group('DatabaseLive')] class TransactionDBDebugTrueTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/TransactionTest.php b/tests/system/Database/Live/TransactionTest.php index 06a0abf886c2..3414d2dfffdf 100644 --- a/tests/system/Database/Live/TransactionTest.php +++ b/tests/system/Database/Live/TransactionTest.php @@ -17,13 +17,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class TransactionTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/UnionTest.php b/tests/system/Database/Live/UnionTest.php index f30625ee3187..c3ddee84c5b1 100644 --- a/tests/system/Database/Live/UnionTest.php +++ b/tests/system/Database/Live/UnionTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class UnionTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/UpdateTest.php b/tests/system/Database/Live/UpdateTest.php index 12f94503d793..8af549fc638e 100644 --- a/tests/system/Database/Live/UpdateTest.php +++ b/tests/system/Database/Live/UpdateTest.php @@ -19,13 +19,14 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class UpdateTest extends CIUnitTestCase { use DatabaseTestTrait; @@ -113,9 +114,7 @@ public function testUpdateWithWhereAndLimit(): void } } - /** - * @dataProvider provideUpdateBatch - */ + #[DataProvider('provideUpdateBatch')] public function testUpdateBatch(string $constraints, array $data, array $expected): void { $table = 'type_test'; diff --git a/tests/system/Database/Live/UpsertTest.php b/tests/system/Database/Live/UpsertTest.php index 76329a432843..94732e694d50 100644 --- a/tests/system/Database/Live/UpsertTest.php +++ b/tests/system/Database/Live/UpsertTest.php @@ -19,14 +19,14 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use PHPUnit\Framework\Attributes\Group; use stdclass; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class UpsertTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/WhereTest.php b/tests/system/Database/Live/WhereTest.php index 8742cfee6bf9..8513144356cf 100644 --- a/tests/system/Database/Live/WhereTest.php +++ b/tests/system/Database/Live/WhereTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class WhereTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Live/WriteTypeQueryTest.php b/tests/system/Database/Live/WriteTypeQueryTest.php index 56b700e76fbc..faaa7bfabddb 100644 --- a/tests/system/Database/Live/WriteTypeQueryTest.php +++ b/tests/system/Database/Live/WriteTypeQueryTest.php @@ -16,13 +16,13 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class WriteTypeQueryTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Migrations/MigrationRunnerTest.php b/tests/system/Database/Migrations/MigrationRunnerTest.php index be40e676c529..547eec670ce4 100644 --- a/tests/system/Database/Migrations/MigrationRunnerTest.php +++ b/tests/system/Database/Migrations/MigrationRunnerTest.php @@ -24,14 +24,14 @@ use Config\Services; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\MigrationTestMigrations\Database\Migrations\Migration_another_migration; use Tests\Support\MigrationTestMigrations\Database\Migrations\Migration_some_migration; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class MigrationRunnerTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/Migrations/MigrationTest.php b/tests/system/Database/Migrations/MigrationTest.php index 21c08fd303cc..7e4049a113ce 100644 --- a/tests/system/Database/Migrations/MigrationTest.php +++ b/tests/system/Database/Migrations/MigrationTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Database\Migration; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class MigrationTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Database/RawSqlTest.php b/tests/system/Database/RawSqlTest.php index 4915752ed389..340e85c0ffba 100644 --- a/tests/system/Database/RawSqlTest.php +++ b/tests/system/Database/RawSqlTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter\Database; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class RawSqlTest extends CIUnitTestCase { public function testCanConvertToString(): void diff --git a/tests/system/Debug/ExceptionHandlerTest.php b/tests/system/Debug/ExceptionHandlerTest.php index 6516eff34c4e..85eaed74621b 100644 --- a/tests/system/Debug/ExceptionHandlerTest.php +++ b/tests/system/Debug/ExceptionHandlerTest.php @@ -20,13 +20,13 @@ use CodeIgniter\Test\StreamFilterTrait; use Config\Exceptions as ExceptionsConfig; use Config\Services; +use PHPUnit\Framework\Attributes\Group; use RuntimeException; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ExceptionHandlerTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Debug/ExceptionsTest.php b/tests/system/Debug/ExceptionsTest.php index c71cb0be936f..aa3c2d8b49a6 100644 --- a/tests/system/Debug/ExceptionsTest.php +++ b/tests/system/Debug/ExceptionsTest.php @@ -20,13 +20,14 @@ use CodeIgniter\Test\ReflectionHelper; use Config\Exceptions as ExceptionsConfig; use ErrorException; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhp; use RuntimeException; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ExceptionsTest extends CIUnitTestCase { use ReflectionHelper; @@ -54,9 +55,7 @@ protected function setUp(): void $this->exception = new Exceptions(new ExceptionsConfig()); } - /** - * @requires PHP >= 8.1 - */ + #[RequiresPhp('>= 8.1')] public function testDeprecationsOnPhp81DoNotThrow(): void { $config = new ExceptionsConfig(); diff --git a/tests/system/Debug/TimerTest.php b/tests/system/Debug/TimerTest.php index f93374a32246..eb3cb243b398 100644 --- a/tests/system/Debug/TimerTest.php +++ b/tests/system/Debug/TimerTest.php @@ -15,13 +15,13 @@ use ArgumentCountError; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; use RuntimeException; /** * @internal - * - * @group Others */ +#[Group('Others')] final class TimerTest extends CIUnitTestCase { /** diff --git a/tests/system/Debug/Toolbar/Collectors/DatabaseTest.php b/tests/system/Debug/Toolbar/Collectors/DatabaseTest.php index 8da3c5e6115d..9c091ee4e530 100644 --- a/tests/system/Debug/Toolbar/Collectors/DatabaseTest.php +++ b/tests/system/Debug/Toolbar/Collectors/DatabaseTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Database\Query; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; /** * @internal - * - * @group Others */ +#[Group('Others')] final class DatabaseTest extends CIUnitTestCase { public function testDisplay(): void diff --git a/tests/system/Debug/Toolbar/Collectors/HistoryTest.php b/tests/system/Debug/Toolbar/Collectors/HistoryTest.php index 94297c6d1c63..3a5411a96a0f 100644 --- a/tests/system/Debug/Toolbar/Collectors/HistoryTest.php +++ b/tests/system/Debug/Toolbar/Collectors/HistoryTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; use DateTime; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class HistoryTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/DebugTraceableTraitTest.php b/tests/system/DebugTraceableTraitTest.php index 776bad36c9b5..26161d8de683 100644 --- a/tests/system/DebugTraceableTraitTest.php +++ b/tests/system/DebugTraceableTraitTest.php @@ -16,14 +16,14 @@ use CodeIgniter\Exceptions\DebugTraceableTrait; use CodeIgniter\Exceptions\FrameworkException; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others - * - * @covers \CodeIgniter\Exceptions\DebugTraceableTrait */ +#[CoversClass(DebugTraceableTrait::class)] +#[Group('Others')] final class DebugTraceableTraitTest extends CIUnitTestCase { public function testFactoryInstanceReturnsWhereItIsRaised(): void diff --git a/tests/system/Email/EmailTest.php b/tests/system/Email/EmailTest.php index 1950fbbf6328..99918122d8cf 100644 --- a/tests/system/Email/EmailTest.php +++ b/tests/system/Email/EmailTest.php @@ -17,12 +17,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockEmail; use ErrorException; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class EmailTest extends CIUnitTestCase { public function testEmailValidation(): void @@ -43,10 +44,9 @@ public static function provideEmailSendWithClearance(): iterable } /** - * @dataProvider provideEmailSendWithClearance - * * @param mixed $autoClear */ + #[DataProvider('provideEmailSendWithClearance')] public function testEmailSendWithClearance($autoClear): void { $email = $this->createMockEmail(); diff --git a/tests/system/Encryption/EncryptionTest.php b/tests/system/Encryption/EncryptionTest.php index c92af195657d..de372e232411 100644 --- a/tests/system/Encryption/EncryptionTest.php +++ b/tests/system/Encryption/EncryptionTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Encryption as EncryptionConfig; use Config\Services; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class EncryptionTest extends CIUnitTestCase { private Encryption $encryption; diff --git a/tests/system/Encryption/Handlers/OpenSSLHandlerTest.php b/tests/system/Encryption/Handlers/OpenSSLHandlerTest.php index bec040d45ba0..f82e9151cd3c 100644 --- a/tests/system/Encryption/Handlers/OpenSSLHandlerTest.php +++ b/tests/system/Encryption/Handlers/OpenSSLHandlerTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Encryption\Exceptions\EncryptionException; use CodeIgniter\Test\CIUnitTestCase; use Config\Encryption as EncryptionConfig; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class OpenSSLHandlerTest extends CIUnitTestCase { private Encryption $encryption; diff --git a/tests/system/Encryption/Handlers/SodiumHandlerTest.php b/tests/system/Encryption/Handlers/SodiumHandlerTest.php index 8c6c9299fbf3..bf30036eb2a4 100644 --- a/tests/system/Encryption/Handlers/SodiumHandlerTest.php +++ b/tests/system/Encryption/Handlers/SodiumHandlerTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Encryption\Exceptions\EncryptionException; use CodeIgniter\Test\CIUnitTestCase; use Config\Encryption as EncryptionConfig; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class SodiumHandlerTest extends CIUnitTestCase { private Encryption $encryption; diff --git a/tests/system/Entity/EntityTest.php b/tests/system/Entity/EntityTest.php index 37e65c497e57..10947277926a 100644 --- a/tests/system/Entity/EntityTest.php +++ b/tests/system/Entity/EntityTest.php @@ -21,6 +21,7 @@ use CodeIgniter\Test\ReflectionHelper; use DateTime; use DateTimeInterface; +use PHPUnit\Framework\Attributes\Group; use ReflectionException; use Tests\Support\Entity\Cast\CastBase64; use Tests\Support\Entity\Cast\CastPassParameters; @@ -29,9 +30,8 @@ /** * @internal - * - * @group Others */ +#[Group('Others')] final class EntityTest extends CIUnitTestCase { use ReflectionHelper; diff --git a/tests/system/Events/EventsTest.php b/tests/system/Events/EventsTest.php index 289f4f2c0676..a2de4fb2f432 100644 --- a/tests/system/Events/EventsTest.php +++ b/tests/system/Events/EventsTest.php @@ -16,12 +16,14 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockEvents; use Config\Modules; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; /** * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] final class EventsTest extends CIUnitTestCase { /** @@ -47,10 +49,8 @@ protected function tearDown(): void Events::simulate(false); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testInitialize(): void { /** diff --git a/tests/system/Files/FileCollectionTest.php b/tests/system/Files/FileCollectionTest.php index 8aa2e8098c2b..81005356fee3 100644 --- a/tests/system/Files/FileCollectionTest.php +++ b/tests/system/Files/FileCollectionTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Files\Exceptions\FileException; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FileCollectionTest extends CIUnitTestCase { /** @@ -175,6 +175,7 @@ public function testAddStringDirectoryRecursive(): void $this->directory . 'fig_3.php', $this->directory . 'prune_ripe.php', SUPPORTPATH . 'Files/baker/banana.php', + SUPPORTPATH . 'Files/baker/fig_3.php.txt', ]; $files->add(SUPPORTPATH . 'Files'); @@ -227,6 +228,7 @@ public function testAddArrayRecursive(): void $this->directory . 'fig_3.php', $this->directory . 'prune_ripe.php', SUPPORTPATH . 'Files/baker/banana.php', + SUPPORTPATH . 'Files/baker/fig_3.php.txt', SUPPORTPATH . 'Log/Handlers/TestHandler.php', ]; @@ -392,6 +394,7 @@ public function testAddDirectoryRecursive(): void $this->directory . 'fig_3.php', $this->directory . 'prune_ripe.php', SUPPORTPATH . 'Files/baker/banana.php', + SUPPORTPATH . 'Files/baker/fig_3.php.txt', ]; $collection->addDirectory(SUPPORTPATH . 'Files', true); @@ -407,6 +410,7 @@ public function testAddDirectories(): void $this->directory . 'fig_3.php', $this->directory . 'prune_ripe.php', SUPPORTPATH . 'Files/baker/banana.php', + SUPPORTPATH . 'Files/baker/fig_3.php.txt', ]; $collection->addDirectories([ @@ -425,6 +429,7 @@ public function testAddDirectoriesRecursive(): void $this->directory . 'fig_3.php', $this->directory . 'prune_ripe.php', SUPPORTPATH . 'Files/baker/banana.php', + SUPPORTPATH . 'Files/baker/fig_3.php.txt', SUPPORTPATH . 'Log/Handlers/TestHandler.php', ]; @@ -471,6 +476,7 @@ public function testRemovePatternPseudo(): void $expected = [ $this->directory . 'apple.php', SUPPORTPATH . 'Files/baker/banana.php', + SUPPORTPATH . 'Files/baker/fig_3.php.txt', ]; $collection->removePattern('*_*.php'); @@ -485,6 +491,7 @@ public function testRemovePatternScope(): void $expected = [ SUPPORTPATH . 'Files/baker/banana.php', + SUPPORTPATH . 'Files/baker/fig_3.php.txt', ]; $collection->removePattern('*.php', $this->directory); @@ -512,6 +519,7 @@ public function testRetainPatternRegex(): void $expected = [ $this->directory . 'fig_3.php', $this->directory . 'prune_ripe.php', + SUPPORTPATH . 'Files/baker/fig_3.php.txt', ]; $collection->retainPattern('#[a-z]+_.*#'); @@ -541,6 +549,7 @@ public function testRetainPatternScope(): void $expected = [ $this->directory . 'fig_3.php', SUPPORTPATH . 'Files/baker/banana.php', + SUPPORTPATH . 'Files/baker/fig_3.php.txt', ]; $collection->retainPattern('*_?.php', $this->directory); @@ -553,7 +562,7 @@ public function testCount(): void $collection = new FileCollection(); $collection->addDirectory(SUPPORTPATH . 'Files', true); - $this->assertCount(4, $collection); + $this->assertCount(5, $collection); } public function testIterable(): void @@ -568,6 +577,6 @@ public function testIterable(): void $count++; } - $this->assertSame($count, 4); + $this->assertSame($count, 5); } } diff --git a/tests/system/Files/FileTest.php b/tests/system/Files/FileTest.php index 384f94073857..800a1ac278f1 100644 --- a/tests/system/Files/FileTest.php +++ b/tests/system/Files/FileTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Files\Exceptions\FileNotFoundException; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; use ZipArchive; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FileTest extends CIUnitTestCase { public function testNewGoodChecked(): void diff --git a/tests/system/Files/FileWithVfsTest.php b/tests/system/Files/FileWithVfsTest.php index eb23d51b5831..9a1075ad9a1c 100644 --- a/tests/system/Files/FileWithVfsTest.php +++ b/tests/system/Files/FileWithVfsTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FileWithVfsTest extends CIUnitTestCase { // For VFS stuff diff --git a/tests/system/Filters/CSRFTest.php b/tests/system/Filters/CSRFTest.php index 873ff05b8740..c0d85b02150d 100644 --- a/tests/system/Filters/CSRFTest.php +++ b/tests/system/Filters/CSRFTest.php @@ -18,14 +18,14 @@ use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\Response; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\Group; /** - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class CSRFTest extends CIUnitTestCase { private \Config\Filters $config; diff --git a/tests/system/Filters/CorsTest.php b/tests/system/Filters/CorsTest.php index a628bccfd162..78023ddfdadc 100644 --- a/tests/system/Filters/CorsTest.php +++ b/tests/system/Filters/CorsTest.php @@ -23,6 +23,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockAppConfig; use Config\Services; +use PHPUnit\Framework\Attributes\Group; /** * This test case is based on: @@ -30,9 +31,8 @@ * https://github.com/asm89/stack-cors/blob/b6920bd8996449400ac976e083b55fb45f035467/tests/CorsTest.php * * @internal - * - * @group Others */ +#[Group('Others')] final class CorsTest extends CIUnitTestCase { private Cors $cors; diff --git a/tests/system/Filters/DebugToolbarTest.php b/tests/system/Filters/DebugToolbarTest.php index f293eb1def25..6cb716ee9556 100644 --- a/tests/system/Filters/DebugToolbarTest.php +++ b/tests/system/Filters/DebugToolbarTest.php @@ -19,14 +19,14 @@ use CodeIgniter\HTTP\Response; use CodeIgniter\Test\CIUnitTestCase; use Config\Filters as FilterConfig; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\Group; /** - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class DebugToolbarTest extends CIUnitTestCase { /** diff --git a/tests/system/Filters/FiltersTest.php b/tests/system/Filters/FiltersTest.php index 9ce2c1b28985..3a35920989e5 100644 --- a/tests/system/Filters/FiltersTest.php +++ b/tests/system/Filters/FiltersTest.php @@ -31,6 +31,9 @@ use CodeIgniter\Test\ConfigFromArrayTrait; use CodeIgniter\Test\Mock\MockAppConfig; use Config\Filters as FiltersConfig; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; require_once __DIR__ . '/fixtures/GoogleMe.php'; require_once __DIR__ . '/fixtures/GoogleYou.php'; @@ -42,12 +45,10 @@ require_once __DIR__ . '/fixtures/Role.php'; /** - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class FiltersTest extends CIUnitTestCase { use ConfigFromArrayTrait; @@ -230,10 +231,9 @@ public static function provideProcessMethodProcessGlobalsWithExcept(): iterable } /** - * @dataProvider provideProcessMethodProcessGlobalsWithExcept - * * @param array|string $except */ + #[DataProvider('provideProcessMethodProcessGlobalsWithExcept')] public function testProcessMethodProcessGlobalsWithExcept($except): void { $_SERVER['REQUEST_METHOD'] = 'GET'; @@ -584,10 +584,9 @@ public function testOtherResult(): void } /** - * @dataProvider provideBeforeExcept - * * @param array|string $except */ + #[DataProvider('provideBeforeExcept')] public function testBeforeExcept(string $uri, $except, array $expected): void { $_SERVER['REQUEST_METHOD'] = 'GET'; diff --git a/tests/system/Filters/HoneypotTest.php b/tests/system/Filters/HoneypotTest.php index cb2d804d4cbc..50909abe5a3e 100644 --- a/tests/system/Filters/HoneypotTest.php +++ b/tests/system/Filters/HoneypotTest.php @@ -20,14 +20,16 @@ use CodeIgniter\HTTP\Response; use CodeIgniter\Test\CIUnitTestCase; use Config\Honeypot; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; /** - * @backupGlobals enabled - * * @internal - * - * @group SeparateProcess */ +#[BackupGlobals(true)] +#[Group('SeparateProcess')] final class HoneypotTest extends CIUnitTestCase { private \Config\Filters $config; @@ -92,10 +94,8 @@ public function testBeforeClean(): void $this->assertSame($expected, $request); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testAfter(): void { $this->config->globals = [ @@ -114,10 +114,8 @@ public function testAfter(): void $this->assertStringContainsString($this->honey->name, $this->response->getBody()); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testAfterNotApplicable(): void { $this->config->globals = [ diff --git a/tests/system/Filters/InvalidCharsTest.php b/tests/system/Filters/InvalidCharsTest.php index db2eb6a5b0fa..a0546ef586bc 100644 --- a/tests/system/Filters/InvalidCharsTest.php +++ b/tests/system/Filters/InvalidCharsTest.php @@ -20,12 +20,14 @@ use CodeIgniter\Security\Exceptions\SecurityException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockAppConfig; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class InvalidCharsTest extends CIUnitTestCase { private InvalidChars $invalidChars; @@ -66,9 +68,7 @@ private function createRequest(): IncomingRequest return $request; } - /** - * @doesNotPerformAssertions - */ + #[DoesNotPerformAssertions] public function testBeforeDoNothingWhenCLIRequest(): void { $cliRequest = new CLIRequest(new MockAppConfig()); @@ -76,9 +76,7 @@ public function testBeforeDoNothingWhenCLIRequest(): void $this->invalidChars->before($cliRequest); } - /** - * @doesNotPerformAssertions - */ + #[DoesNotPerformAssertions] public function testBeforeValidString(): void { $_POST['val'] = [ @@ -114,11 +112,8 @@ public function testBeforeInvalidControlCharCausesException(): void $this->invalidChars->before($this->request); } - /** - * @doesNotPerformAssertions - * - * @dataProvider provideCheckControlStringWithLineBreakAndTabReturnsTheString - */ + #[DataProvider('provideCheckControlStringWithLineBreakAndTabReturnsTheString')] + #[DoesNotPerformAssertions] public function testCheckControlStringWithLineBreakAndTabReturnsTheString(string $input): void { $_GET['val'] = $input; @@ -137,9 +132,7 @@ public static function provideCheckControlStringWithLineBreakAndTabReturnsTheStr ]; } - /** - * @dataProvider provideCheckControlStringWithControlCharsCausesException - */ + #[DataProvider('provideCheckControlStringWithControlCharsCausesException')] public function testCheckControlStringWithControlCharsCausesException(string $input): void { $this->expectException(SecurityException::class); diff --git a/tests/system/Filters/SecureHeadersTest.php b/tests/system/Filters/SecureHeadersTest.php index 89dbf126e2a8..48ff8bb7d04f 100644 --- a/tests/system/Filters/SecureHeadersTest.php +++ b/tests/system/Filters/SecureHeadersTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Config\Services; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class SecureHeadersTest extends CIUnitTestCase { public function testAfter(): void diff --git a/tests/system/Format/FormatTest.php b/tests/system/Format/FormatTest.php index 6abda45fbb6f..89fab7512368 100644 --- a/tests/system/Format/FormatTest.php +++ b/tests/system/Format/FormatTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Format\Exceptions\FormatException; use CodeIgniter\HTTP\URI; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FormatTest extends CIUnitTestCase { private Format $format; diff --git a/tests/system/Format/JSONFormatterTest.php b/tests/system/Format/JSONFormatterTest.php index 18f7ef7d3daa..a479be9e8f63 100644 --- a/tests/system/Format/JSONFormatterTest.php +++ b/tests/system/Format/JSONFormatterTest.php @@ -14,13 +14,13 @@ namespace CodeIgniter\Format; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; use RuntimeException; /** * @internal - * - * @group Others */ +#[Group('Others')] final class JSONFormatterTest extends CIUnitTestCase { private JSONFormatter $jsonFormatter; diff --git a/tests/system/Format/XMLFormatterTest.php b/tests/system/Format/XMLFormatterTest.php index c9601020eaa8..0615a1eafd91 100644 --- a/tests/system/Format/XMLFormatterTest.php +++ b/tests/system/Format/XMLFormatterTest.php @@ -15,12 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use DOMDocument; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class XMLFormatterTest extends CIUnitTestCase { private XMLFormatter $xmlFormatter; @@ -103,9 +104,7 @@ public function testValidatingXmlTags(): void $this->assertSame($expected, $this->xmlFormatter->format($data)); } - /** - * @dataProvider provideValidatingInvalidTags - */ + #[DataProvider('provideValidatingInvalidTags')] public function testValidatingInvalidTags(string $expected, array $input): void { $expectedXML = <<assertSame('apple', $request->header('fruit')->getValue()); } - /** - * @backupGlobals enabled - */ + #[BackupGlobals(true)] public function testOptionsHeadersNotUsingPopulate(): void { $_SERVER['HTTP_HOST'] = 'site1.com'; @@ -248,9 +247,7 @@ public function testHeaderContentLengthNotSharedBetweenRequests(): void $this->assertNull($request->header('Content-Length')); } - /** - * @backupGlobals enabled - */ + #[BackupGlobals(true)] public function testHeaderContentLengthNotSharedBetweenClients(): void { $_SERVER['HTTP_CONTENT_LENGTH'] = '10'; diff --git a/tests/system/HTTP/ContentSecurityPolicyTest.php b/tests/system/HTTP/ContentSecurityPolicyTest.php index 6502579eadf4..31c915b09b1b 100644 --- a/tests/system/HTTP/ContentSecurityPolicyTest.php +++ b/tests/system/HTTP/ContentSecurityPolicyTest.php @@ -17,6 +17,9 @@ use CodeIgniter\Test\TestResponse; use Config\App; use Config\ContentSecurityPolicy as CSPConfig; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; /** * Test the CSP policy directive creation. @@ -25,9 +28,8 @@ * See https://cspvalidator.org/ * * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] final class ContentSecurityPolicyTest extends CIUnitTestCase { private ?Response $response = null; @@ -70,10 +72,8 @@ protected function work(string $parm = 'Hello') return $buffer; } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testExistence(): void { $this->prepare(); @@ -82,10 +82,8 @@ public function testExistence(): void $this->assertHeaderEmitted('Content-Security-Policy:'); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testReportOnly(): void { $this->prepare(); @@ -95,10 +93,8 @@ public function testReportOnly(): void $this->assertHeaderEmitted('Content-Security-Policy:'); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testDefaults(): void { $this->prepare(); @@ -114,10 +110,8 @@ public function testDefaults(): void $this->assertStringContainsString("style-src 'self';", $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testChildSrc(): void { $this->prepare(); @@ -131,10 +125,8 @@ public function testChildSrc(): void $this->assertStringContainsString("child-src 'self' good.com;", $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testConnectSrc(): void { $this->prepare(); @@ -147,10 +139,8 @@ public function testConnectSrc(): void $this->assertStringContainsString("connect-src 'self' iffy.com maybe.com;", $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testFontSrc(): void { $this->prepare(); @@ -165,10 +155,8 @@ public function testFontSrc(): void $this->assertStringContainsString('font-src fontsrus.com;', $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testFormAction(): void { $this->prepare(); @@ -183,10 +171,8 @@ public function testFormAction(): void $this->assertStringNotContainsString("form-action 'self';", $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testFrameAncestor(): void { $this->prepare(); @@ -200,10 +186,8 @@ public function testFrameAncestor(): void $this->assertStringContainsString("frame-ancestors 'self';", $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testFrameSrc(): void { $this->prepare(); @@ -217,10 +201,8 @@ public function testFrameSrc(): void $this->assertStringContainsString("frame-src 'self';", $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testImageSrc(): void { $this->prepare(); @@ -234,10 +216,8 @@ public function testImageSrc(): void $this->assertStringContainsString("img-src 'self' cdn.cloudy.com;", $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testMediaSrc(): void { $this->prepare(); @@ -251,10 +231,8 @@ public function testMediaSrc(): void $this->assertStringContainsString("media-src 'self';", $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testManifestSrc(): void { $this->prepare(); @@ -268,10 +246,8 @@ public function testManifestSrc(): void $this->assertStringContainsString('manifest-src cdn.cloudy.com;', $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testPluginType(): void { $this->prepare(); @@ -285,10 +261,8 @@ public function testPluginType(): void $this->assertStringContainsString("plugin-types 'self';", $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testPluginArray(): void { $this->prepare(); @@ -300,10 +274,8 @@ public function testPluginArray(): void $this->assertStringContainsString('plugin-types application/x-shockwave-flash application/wacky-hacky;', $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testObjectSrc(): void { $this->prepare(); @@ -317,10 +289,8 @@ public function testObjectSrc(): void $this->assertStringContainsString("object-src 'self' cdn.cloudy.com;", $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testScriptSrc(): void { $this->prepare(); @@ -334,10 +304,8 @@ public function testScriptSrc(): void $this->assertStringContainsString("script-src 'self' cdn.cloudy.com;", $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testStyleSrc(): void { $this->prepare(); @@ -351,10 +319,8 @@ public function testStyleSrc(): void $this->assertStringContainsString("style-src 'self' cdn.cloudy.com;", $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testBaseURIDefault(): void { $this->prepare(); @@ -364,10 +330,8 @@ public function testBaseURIDefault(): void $this->assertStringContainsString("base-uri 'self';", $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testBaseURI(): void { $this->prepare(); @@ -378,10 +342,8 @@ public function testBaseURI(): void $this->assertStringContainsString('base-uri example.com;', $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testBaseURIRich(): void { $this->prepare(); @@ -392,10 +354,8 @@ public function testBaseURIRich(): void $this->assertStringContainsString("base-uri 'self' example.com;", $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testDefaultSrc(): void { $this->prepare(); @@ -408,10 +368,8 @@ public function testDefaultSrc(): void $this->assertStringContainsString('default-src iffy.com;', $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testReportURI(): void { $this->prepare(); @@ -423,10 +381,8 @@ public function testReportURI(): void $this->assertStringContainsString('report-uri http://example.com/csptracker;', $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testSandboxFlags(): void { $this->prepare(); @@ -439,10 +395,8 @@ public function testSandboxFlags(): void $this->assertStringContainsString('sandbox allow-popups allow-top-navigation;', $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testUpgradeInsecureRequests(): void { $this->prepare(); @@ -453,10 +407,8 @@ public function testUpgradeInsecureRequests(): void $this->assertStringContainsString('upgrade-insecure-requests;', $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testBodyEmpty(): void { $this->prepare(); @@ -466,10 +418,8 @@ public function testBodyEmpty(): void $this->assertSame($body, $this->response->getBody()); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testBodyScriptNonce(): void { $this->prepare(); @@ -543,10 +493,8 @@ public function testBodyStyleNonceDisableAutoNonce(): void $result->assertHeader('Content-Security-Policy'); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testBodyStyleNonce(): void { $this->prepare(); @@ -582,10 +530,8 @@ public function testBodyStyleNonceCustomStyleTag(): void $this->assertStringContainsString('nonce=', $response->getBody()); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testHeaderWrongCaseNotFound(): void { $this->prepare(); @@ -595,10 +541,8 @@ public function testHeaderWrongCaseNotFound(): void $this->assertNull($result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testHeaderIgnoreCase(): void { $this->prepare(); @@ -608,10 +552,8 @@ public function testHeaderIgnoreCase(): void $this->assertStringContainsString("base-uri 'self';", $result); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testCSPDisabled(): void { $this->prepare(false); @@ -639,10 +581,8 @@ public function testGetStyleNonce(): void $this->assertMatchesRegularExpression('/\A[0-9a-z]{24}\z/', $nonce); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testHeaderScriptNonceEmittedOnceGetScriptNonceCalled(): void { $this->prepare(); diff --git a/tests/system/HTTP/CorsTest.php b/tests/system/HTTP/CorsTest.php index 8b15fb8d4c83..9f2a7280bee4 100644 --- a/tests/system/HTTP/CorsTest.php +++ b/tests/system/HTTP/CorsTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Services; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CorsTest extends CIUnitTestCase { /** diff --git a/tests/system/HTTP/DownloadResponseTest.php b/tests/system/HTTP/DownloadResponseTest.php index b1071e39dc01..2f27bc4651ea 100644 --- a/tests/system/HTTP/DownloadResponseTest.php +++ b/tests/system/HTTP/DownloadResponseTest.php @@ -18,12 +18,14 @@ use CodeIgniter\Test\CIUnitTestCase; use DateTime; use DateTimeZone; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; /** * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] final class DownloadResponseTest extends CIUnitTestCase { protected function setUp(): void @@ -317,10 +319,8 @@ public function testPretendOutput(): void $this->assertSame(file_get_contents(__FILE__), $actual); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testRealOutput(): void { $response = new DownloadResponse('unit-test.php', false); diff --git a/tests/system/HTTP/Files/FileCollectionTest.php b/tests/system/HTTP/Files/FileCollectionTest.php index 3b565156aa6b..a0d7bb1de771 100644 --- a/tests/system/HTTP/Files/FileCollectionTest.php +++ b/tests/system/HTTP/Files/FileCollectionTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Mimes; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FileCollectionTest extends CIUnitTestCase { protected function setUp(): void diff --git a/tests/system/HTTP/Files/FileMovingTest.php b/tests/system/HTTP/Files/FileMovingTest.php index df79faa1a15f..c07116970b5a 100644 --- a/tests/system/HTTP/Files/FileMovingTest.php +++ b/tests/system/HTTP/Files/FileMovingTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FileMovingTest extends CIUnitTestCase { private ?vfsStreamDirectory $root; diff --git a/tests/system/HTTP/HeaderTest.php b/tests/system/HTTP/HeaderTest.php index 910c04923566..6ca5180ff838 100644 --- a/tests/system/HTTP/HeaderTest.php +++ b/tests/system/HTTP/HeaderTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Test\CIUnitTestCase; use Error; +use PHPUnit\Framework\Attributes\Group; use stdClass; /** * @internal - * - * @group Others */ +#[Group('Others')] final class HeaderTest extends CIUnitTestCase { public function testHeaderStoresBasics(): void diff --git a/tests/system/HTTP/IncomingRequestDetectingTest.php b/tests/system/HTTP/IncomingRequestDetectingTest.php index 6f52bcc1baf4..fa53060b6a83 100644 --- a/tests/system/HTTP/IncomingRequestDetectingTest.php +++ b/tests/system/HTTP/IncomingRequestDetectingTest.php @@ -15,14 +15,14 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\Group; /** - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class IncomingRequestDetectingTest extends CIUnitTestCase { private IncomingRequest $request; diff --git a/tests/system/HTTP/IncomingRequestTest.php b/tests/system/HTTP/IncomingRequestTest.php index e0d827523405..f76ea4a0c7cf 100644 --- a/tests/system/HTTP/IncomingRequestTest.php +++ b/tests/system/HTTP/IncomingRequestTest.php @@ -21,15 +21,18 @@ use Config\App; use InvalidArgumentException; use JsonException; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use TypeError; /** - * @backupGlobals enabled - * * @internal - * - * @group SeparateProcess */ +#[BackupGlobals(true)] +#[Group('SeparateProcess')] final class IncomingRequestTest extends CIUnitTestCase { private Request $request; @@ -144,10 +147,9 @@ public function testCanGetOldInputArrayWithSESSION(): void /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/1492 - * - * @runInSeparateProcess - * @preserveGlobalState disabled */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testCanGetOldInputArrayWithSessionService(): void { $locations = [ @@ -659,14 +661,13 @@ public static function provideCanGrabGetRawInputVar(): iterable } /** - * @dataProvider provideCanGrabGetRawInputVar - * * @param string $rawstring * @param mixed $var * @param mixed $expected * @param mixed $filter * @param mixed $flag */ + #[DataProvider('provideCanGrabGetRawInputVar')] public function testCanGrabGetRawInputVar($rawstring, $var, $expected, $filter, $flag): void { $config = new App(); @@ -677,9 +678,7 @@ public function testCanGrabGetRawInputVar($rawstring, $var, $expected, $filter, $this->assertSame($expected, $request->getRawInputVar($var, $filter, $flag)); } - /** - * @dataProvider provideIsHTTPMethods - */ + #[DataProvider('provideIsHTTPMethods')] public function testIsHTTPMethodLowerCase(string $value): void { $request = $this->request->withMethod($value); @@ -700,9 +699,7 @@ public static function provideIsHTTPMethods(): iterable ]; } - /** - * @dataProvider provideIsHTTPMethods - */ + #[DataProvider('provideIsHTTPMethods')] public function testIsHTTPMethodUpperCase(string $value): void { $request = $this->request->withMethod($value); @@ -922,11 +919,10 @@ public static function provideExtensionPHP(): iterable } /** - * @dataProvider provideExtensionPHP - * * @param mixed $path * @param mixed $detectPath */ + #[DataProvider('provideExtensionPHP')] public function testExtensionPHP($path, $detectPath): void { $config = new App(); diff --git a/tests/system/HTTP/MessageTest.php b/tests/system/HTTP/MessageTest.php index c91b8ab9255f..d16224367a6f 100644 --- a/tests/system/HTTP/MessageTest.php +++ b/tests/system/HTTP/MessageTest.php @@ -16,12 +16,13 @@ use CodeIgniter\HTTP\Exceptions\HTTPException; use CodeIgniter\Test\CIUnitTestCase; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class MessageTest extends CIUnitTestCase { private ?Message $message; @@ -208,10 +209,9 @@ public static function provideArrayHeaderValue(): iterable } /** - * @dataProvider provideArrayHeaderValue - * * @param array $arrayHeaderValue */ + #[DataProvider('provideArrayHeaderValue')] public function testSetHeaderWithExistingArrayValuesAppendStringValue($arrayHeaderValue): void { $this->message->setHeader('Accept', $arrayHeaderValue); @@ -221,10 +221,9 @@ public function testSetHeaderWithExistingArrayValuesAppendStringValue($arrayHead } /** - * @dataProvider provideArrayHeaderValue - * * @param array $arrayHeaderValue */ + #[DataProvider('provideArrayHeaderValue')] public function testSetHeaderWithExistingArrayValuesAppendArrayValue($arrayHeaderValue): void { $this->message->setHeader('Accept', $arrayHeaderValue); diff --git a/tests/system/HTTP/NegotiateTest.php b/tests/system/HTTP/NegotiateTest.php index 8ace30f86aaa..18d546c0a9c6 100644 --- a/tests/system/HTTP/NegotiateTest.php +++ b/tests/system/HTTP/NegotiateTest.php @@ -16,12 +16,12 @@ use CodeIgniter\HTTP\Exceptions\HTTPException; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class NegotiateTest extends CIUnitTestCase { private ?IncomingRequest $request; diff --git a/tests/system/HTTP/OutgoingRequestTest.php b/tests/system/HTTP/OutgoingRequestTest.php index 123f4acc706b..37b22a6cf8c6 100644 --- a/tests/system/HTTP/OutgoingRequestTest.php +++ b/tests/system/HTTP/OutgoingRequestTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter\HTTP; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class OutgoingRequestTest extends CIUnitTestCase { public function testCreateWithHeader(): void diff --git a/tests/system/HTTP/RedirectExceptionTest.php b/tests/system/HTTP/RedirectExceptionTest.php index e7e01f539650..e77c0ea060d3 100644 --- a/tests/system/HTTP/RedirectExceptionTest.php +++ b/tests/system/HTTP/RedirectExceptionTest.php @@ -19,14 +19,14 @@ use CodeIgniter\Test\Mock\MockLogger as LoggerConfig; use Config\Services; use LogicException; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Tests\Support\Log\Handlers\TestHandler; /** * @internal - * - * @group Others */ +#[Group('Others')] final class RedirectExceptionTest extends TestCase { protected function setUp(): void diff --git a/tests/system/HTTP/RedirectResponseTest.php b/tests/system/HTTP/RedirectResponseTest.php index 4abc965d59da..a800ce0afb2b 100644 --- a/tests/system/HTTP/RedirectResponseTest.php +++ b/tests/system/HTTP/RedirectResponseTest.php @@ -23,12 +23,14 @@ use Config\Modules; use Config\Routing; use Config\Services; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; /** * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] final class RedirectResponseTest extends CIUnitTestCase { /** @@ -129,10 +131,8 @@ public function testRedirectRelativeConvertsToFullURI(): void $this->assertSame('http://example.com/index.php/foo', $response->getHeaderLine('Location')); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testWithInput(): void { $_SESSION = []; @@ -149,10 +149,8 @@ public function testWithInput(): void $this->assertSame('baz', $_SESSION['_ci_old_input']['post']['bar']); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testWithValidationErrors(): void { $_SESSION = []; @@ -169,10 +167,8 @@ public function testWithValidationErrors(): void $this->assertArrayHasKey('_ci_validation_errors', $_SESSION); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testWith(): void { $_SESSION = []; @@ -185,10 +181,8 @@ public function testWith(): void $this->assertArrayHasKey('foo', $_SESSION); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testRedirectBack(): void { $_SERVER['HTTP_REFERER'] = 'http://somewhere.com'; @@ -202,10 +196,8 @@ public function testRedirectBack(): void $this->assertSame('http://somewhere.com', $returned->header('location')->getValue()); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testRedirectBackMissing(): void { $_SESSION = []; @@ -218,11 +210,10 @@ public function testRedirectBackMissing(): void } /** - * @runInSeparateProcess - * @preserveGlobalState disabled - * * @see https://github.com/codeigniter4/CodeIgniter4/issues/2119 */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testRedirectRouteBaseUrl(): void { $config = new App(); @@ -258,10 +249,8 @@ public function testWithCookies(): void $this->assertTrue($response->hasCookie('foo', 'bar')); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testWithCookiesWithEmptyCookies(): void { $_SESSION = []; diff --git a/tests/system/HTTP/RequestTest.php b/tests/system/HTTP/RequestTest.php index aea3f56b140f..e2073268d794 100644 --- a/tests/system/HTTP/RequestTest.php +++ b/tests/system/HTTP/RequestTest.php @@ -16,14 +16,14 @@ use CodeIgniter\Config\Factories; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\Group; /** - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class RequestTest extends CIUnitTestCase { private Request $request; diff --git a/tests/system/HTTP/ResponseCookieTest.php b/tests/system/HTTP/ResponseCookieTest.php index 6f5f039a1983..9782287fd70a 100644 --- a/tests/system/HTTP/ResponseCookieTest.php +++ b/tests/system/HTTP/ResponseCookieTest.php @@ -20,12 +20,12 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\App; use Config\Cookie as CookieConfig; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ResponseCookieTest extends CIUnitTestCase { private array $defaults; diff --git a/tests/system/HTTP/ResponseSendTest.php b/tests/system/HTTP/ResponseSendTest.php index a4cc67765d3d..d910b2de5c29 100644 --- a/tests/system/HTTP/ResponseSendTest.php +++ b/tests/system/HTTP/ResponseSendTest.php @@ -17,6 +17,9 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\App; use Config\Services; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; /** * This test suite has been created separately from @@ -25,9 +28,8 @@ * test cases need to be run as separate processes. * * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] final class ResponseSendTest extends CIUnitTestCase { /** @@ -43,11 +45,8 @@ final class ResponseSendTest extends CIUnitTestCase * The tests includes a basic sanity check, to make sure that * the body we thought would be sent actually was. */ - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testHeadersMissingDate(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. @@ -81,10 +80,9 @@ public function testHeadersMissingDate(): void /** * This test does not test that CSP is handled properly - * it makes sure that sending gives CSP a chance to do its thing. - * - * @runInSeparateProcess - * @preserveGlobalState disabled */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testHeadersWithCSP(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. @@ -121,10 +119,9 @@ public function testHeadersWithCSP(): void * Make sure cookies are set by RedirectResponse this way * * @see https://github.com/codeigniter4/CodeIgniter4/issues/1393 - * - * @runInSeparateProcess - * @preserveGlobalState disabled */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testRedirectResponseCookies(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. @@ -162,14 +159,11 @@ public function testRedirectResponseCookies(): void /** * Make sure secure cookies are not sent with HTTP request - * - * @ runInSeparateProcess - * @ preserveGlobalState disabled */ public function testDoNotSendUnSecureCookie(): void { $this->expectException(SecurityException::class); - $this->expectExceptionMessage('The action you requested is not allowed'); + $this->expectExceptionMessage('Attempted to send a secure cookie over a non-secure connection.'); $request = $this->createMock(IncomingRequest::class); $request->method('isSecure')->willReturn(false); diff --git a/tests/system/HTTP/ResponseTest.php b/tests/system/HTTP/ResponseTest.php index f8de63d1f1b0..bb939741dda1 100644 --- a/tests/system/HTTP/ResponseTest.php +++ b/tests/system/HTTP/ResponseTest.php @@ -21,12 +21,13 @@ use Config\Services; use DateTime; use DateTimeZone; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ResponseTest extends CIUnitTestCase { private array $server; @@ -270,9 +271,7 @@ public function testRedirectSetsDefaultCodeAndLocationHeader(): void $this->assertSame(302, $response->getStatusCode()); } - /** - * @dataProvider provideRedirect - */ + #[DataProvider('provideRedirect')] public function testRedirect( string $server, string $protocol, @@ -316,9 +315,7 @@ public static function provideRedirect(): iterable ]; } - /** - * @dataProvider provideRedirectWithIIS - */ + #[DataProvider('provideRedirectWithIIS')] public function testRedirectWithIIS( string $protocol, string $method, diff --git a/tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php b/tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php index f6386b858165..d14a6e5e4151 100644 --- a/tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php +++ b/tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php @@ -16,14 +16,15 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class SiteURIFactoryDetectRoutePathTest extends CIUnitTestCase { protected function setUp(): void @@ -280,11 +281,10 @@ public function testPathInfoSubfolder(): void } /** - * @dataProvider provideExtensionPHP - * * @param string $path * @param string $detectPath */ + #[DataProvider('provideExtensionPHP')] public function testExtensionPHP($path, $detectPath): void { $config = new App(); diff --git a/tests/system/HTTP/SiteURIFactoryTest.php b/tests/system/HTTP/SiteURIFactoryTest.php index 9b0a55d20b5f..62e20639b5e0 100644 --- a/tests/system/HTTP/SiteURIFactoryTest.php +++ b/tests/system/HTTP/SiteURIFactoryTest.php @@ -16,14 +16,15 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class SiteURIFactoryTest extends CIUnitTestCase { protected function setUp(): void @@ -87,9 +88,7 @@ public function testCreateFromGlobalsAllowedHost(): void $this->assertSame('woot', $uri->getRoutePath()); } - /** - * @dataProvider provideCreateFromStringWithIndexPage - */ + #[DataProvider('provideCreateFromStringWithIndexPage')] public function testCreateFromStringWithIndexPage( string $uriString, string $expectUriString, @@ -130,9 +129,7 @@ public static function provideCreateFromStringWithIndexPage(): iterable ]; } - /** - * @dataProvider provideCreateFromStringWithoutIndexPage - */ + #[DataProvider('provideCreateFromStringWithoutIndexPage')] public function testCreateFromStringWithoutIndexPage( string $uriString, string $expectUriString, diff --git a/tests/system/HTTP/SiteURITest.php b/tests/system/HTTP/SiteURITest.php index 80deeddc2879..644aaa795b6d 100644 --- a/tests/system/HTTP/SiteURITest.php +++ b/tests/system/HTTP/SiteURITest.php @@ -18,19 +18,18 @@ use CodeIgniter\HTTP\Exceptions\HTTPException; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class SiteURITest extends CIUnitTestCase { - /** - * @dataProvider provideConstructor - */ + #[DataProvider('provideConstructor')] public function testConstructor( string $baseURL, string $indexPage, @@ -327,9 +326,7 @@ public function testConstructorInvalidBaseURL(): void new SiteURI($config); } - /** - * @dataProvider provideSetPath - */ + #[DataProvider('provideSetPath')] public function testSetPath( string $baseURL, string $indexPage, diff --git a/tests/system/HTTP/URITest.php b/tests/system/HTTP/URITest.php index 0211d6d2e1f9..8a953ee3cab1 100644 --- a/tests/system/HTTP/URITest.php +++ b/tests/system/HTTP/URITest.php @@ -18,14 +18,15 @@ use CodeIgniter\HTTP\Exceptions\HTTPException; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class URITest extends CIUnitTestCase { public function testConstructorSetsAllParts(): void @@ -127,9 +128,7 @@ public function testCanCastAsString(): void $this->assertSame($expected, (string) $uri); } - /** - * @dataProvider provideSimpleUri - */ + #[DataProvider('provideSimpleUri')] public function testSimpleUri(string $url, string $expectedURL, string $expectedPath): void { $uri = new URI($url); @@ -401,9 +400,7 @@ public function testSetPathSetsValue(): void $this->assertSame($expected, (string) $uri); } - /** - * @dataProvider provideSetPath - */ + #[DataProvider('provideSetPath')] public function testSetPath(string $path, string $expectedURL, string $expectedPath): void { $url = 'http://example.com/'; @@ -514,11 +511,10 @@ public static function providePathGetsFiltered(): iterable } /** - * @dataProvider providePathGetsFiltered - * * @param string $path * @param string $expected */ + #[DataProvider('providePathGetsFiltered')] public function testPathGetsFiltered($path, $expected): void { $uri = new URI(); @@ -630,11 +626,10 @@ public static function provideAuthorityReturnsExceptedValues(): iterable } /** - * @dataProvider provideAuthorityReturnsExceptedValues - * * @param string $url * @param string $expected */ + #[DataProvider('provideAuthorityReturnsExceptedValues')] public function testAuthorityReturnsExceptedValues($url, $expected): void { $uri = new URI($url); @@ -657,11 +652,10 @@ public static function provideAuthorityRemovesDefaultPorts(): iterable } /** - * @dataProvider provideAuthorityRemovesDefaultPorts - * * @param string $scheme * @param int $port */ + #[DataProvider('provideAuthorityRemovesDefaultPorts')] public function testAuthorityRemovesDefaultPorts($scheme, $port): void { $url = "{$scheme}://example.com:{$port}/path"; @@ -780,11 +774,10 @@ public static function provideRemoveDotSegments(): iterable } /** - * @dataProvider provideRemoveDotSegments - * * @param string $path * @param string $expected */ + #[DataProvider('provideRemoveDotSegments')] public function testRemoveDotSegments($path, $expected): void { $this->assertSame($expected, URI::removeDotSegments($path)); @@ -821,11 +814,10 @@ public static function defaultResolutions(): iterable } /** - * @dataProvider defaultResolutions - * * @param string $rel * @param string $expected */ + #[DataProvider('defaultResolutions')] public function testResolveRelativeURI($rel, $expected): void { $base = 'http://a/b/c/d'; @@ -837,11 +829,10 @@ public function testResolveRelativeURI($rel, $expected): void } /** - * @dataProvider defaultResolutions - * * @param string $rel * @param string $expected */ + #[DataProvider('defaultResolutions')] public function testResolveRelativeURIHTTPS($rel, $expected): void { $base = 'https://a/b/c/d'; diff --git a/tests/system/HTTP/UserAgentTest.php b/tests/system/HTTP/UserAgentTest.php index 30d175b7ff55..9799a79c2851 100644 --- a/tests/system/HTTP/UserAgentTest.php +++ b/tests/system/HTTP/UserAgentTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter\HTTP; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class UserAgentTest extends CIUnitTestCase { private string $_user_agent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27'; diff --git a/tests/system/Helpers/Array/ArrayHelperDotKeyExistsTest.php b/tests/system/Helpers/Array/ArrayHelperDotKeyExistsTest.php index 602c4d0209d8..ea7b379d0b44 100644 --- a/tests/system/Helpers/Array/ArrayHelperDotKeyExistsTest.php +++ b/tests/system/Helpers/Array/ArrayHelperDotKeyExistsTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Group; /** - * @group Others - * * @internal */ +#[Group('Others')] final class ArrayHelperDotKeyExistsTest extends CIUnitTestCase { private array $array = [ diff --git a/tests/system/Helpers/Array/ArrayHelperRecursiveDiffTest.php b/tests/system/Helpers/Array/ArrayHelperRecursiveDiffTest.php index 7fed620641df..2bb1c594def1 100644 --- a/tests/system/Helpers/Array/ArrayHelperRecursiveDiffTest.php +++ b/tests/system/Helpers/Array/ArrayHelperRecursiveDiffTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter\Helpers\Array; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** - * @group Others - * * @internal */ +#[Group('Others')] final class ArrayHelperRecursiveDiffTest extends CIUnitTestCase { private array $compareWith; diff --git a/tests/system/Helpers/Array/ArrayHelperSortValuesByNaturalTest.php b/tests/system/Helpers/Array/ArrayHelperSortValuesByNaturalTest.php index 861d6ede713f..4529b4da6918 100644 --- a/tests/system/Helpers/Array/ArrayHelperSortValuesByNaturalTest.php +++ b/tests/system/Helpers/Array/ArrayHelperSortValuesByNaturalTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter\Helpers\Array; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** - * @group Others - * * @internal */ +#[Group('Others')] final class ArrayHelperSortValuesByNaturalTest extends CIUnitTestCase { private array $arrayWithStringValues = [ diff --git a/tests/system/Helpers/ArrayHelperTest.php b/tests/system/Helpers/ArrayHelperTest.php index c7beb0e405b4..a7ed8ae8ec8a 100644 --- a/tests/system/Helpers/ArrayHelperTest.php +++ b/tests/system/Helpers/ArrayHelperTest.php @@ -14,13 +14,14 @@ namespace CodeIgniter\Helpers; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use ValueError; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ArrayHelperTest extends CIUnitTestCase { protected function setUp(): void @@ -210,11 +211,10 @@ public function testArrayDotIgnoresLastWildcard(): void } /** - * @dataProvider provideArrayDeepSearch - * * @param int|string $key * @param array|string|null $expected */ + #[DataProvider('provideArrayDeepSearch')] public function testArrayDeepSearch($key, $expected): void { $data = [ @@ -248,9 +248,7 @@ public function testArrayDeepSearchReturnNullEmptyArray(): void $this->assertNull(array_deep_search('key644', $data)); } - /** - * @dataProvider provideSortByMultipleKeys - */ + #[DataProvider('provideSortByMultipleKeys')] public function testArraySortByMultipleKeysWithArray(array $data, array $sortColumns, array $expected): void { $success = array_sort_by_multiple_keys($data, $sortColumns); @@ -259,9 +257,7 @@ public function testArraySortByMultipleKeysWithArray(array $data, array $sortCol $this->assertSame($expected, array_column($data, 'name')); } - /** - * @dataProvider provideSortByMultipleKeys - */ + #[DataProvider('provideSortByMultipleKeys')] public function testArraySortByMultipleKeysWithObjects(array $data, array $sortColumns, array $expected): void { // Morph to objects @@ -275,9 +271,7 @@ public function testArraySortByMultipleKeysWithObjects(array $data, array $sortC $this->assertSame($expected, array_column((array) $data, 'name')); } - /** - * @dataProvider provideSortByMultipleKeys - */ + #[DataProvider('provideSortByMultipleKeys')] public function testArraySortByMultipleKeysFailsEmptyParameter(array $data, array $sortColumns, array $expected): void { // Both filled @@ -298,10 +292,9 @@ public function testArraySortByMultipleKeysFailsEmptyParameter(array $data, arra } /** - * @dataProvider provideSortByMultipleKeys - * * @param mixed $data */ + #[DataProvider('provideSortByMultipleKeys')] public function testArraySortByMultipleKeysFailsInconsistentArraySizes($data): void { $this->expectException(ValueError::class); @@ -394,9 +387,7 @@ public static function provideSortByMultipleKeys(): iterable ]; } - /** - * @dataProvider provideArrayFlattening - */ + #[DataProvider('provideArrayFlattening')] public function testArrayFlattening(array $input, array $expected): void { $this->assertSame($expected, array_flatten_with_dots($input)); @@ -494,9 +485,7 @@ public static function provideArrayFlattening(): iterable ]; } - /** - * @dataProvider provideArrayGroupByIncludeEmpty - */ + #[DataProvider('provideArrayGroupByIncludeEmpty')] public function testArrayGroupByIncludeEmpty(array $indexes, array $data, array $expected): void { $actual = array_group_by($data, $indexes, true); @@ -504,9 +493,7 @@ public function testArrayGroupByIncludeEmpty(array $indexes, array $data, array $this->assertSame($expected, $actual, 'array including empty not the same'); } - /** - * @dataProvider provideArrayGroupByExcludeEmpty - */ + #[DataProvider('provideArrayGroupByExcludeEmpty')] public function testArrayGroupByExcludeEmpty(array $indexes, array $data, array $expected): void { $actual = array_group_by($data, $indexes, false); diff --git a/tests/system/Helpers/CookieHelperTest.php b/tests/system/Helpers/CookieHelperTest.php old mode 100755 new mode 100644 index 8325104ca73a..619a21717f86 --- a/tests/system/Helpers/CookieHelperTest.php +++ b/tests/system/Helpers/CookieHelperTest.php @@ -25,12 +25,12 @@ use Config\Cookie; use Config\Cookie as CookieConfig; use Config\Services; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CookieHelperTest extends CIUnitTestCase { private IncomingRequest $request; diff --git a/tests/system/Helpers/DateHelperTest.php b/tests/system/Helpers/DateHelperTest.php index ef0d2afa939e..173a979e29e3 100644 --- a/tests/system/Helpers/DateHelperTest.php +++ b/tests/system/Helpers/DateHelperTest.php @@ -16,12 +16,12 @@ use CodeIgniter\I18n\Time; use CodeIgniter\Test\CIUnitTestCase; use DateTimeZone; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class DateHelperTest extends CIUnitTestCase { protected function setUp(): void diff --git a/tests/system/Helpers/FilesystemHelperTest.php b/tests/system/Helpers/FilesystemHelperTest.php index 619f22f08938..ad169cf3b58b 100644 --- a/tests/system/Helpers/FilesystemHelperTest.php +++ b/tests/system/Helpers/FilesystemHelperTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\visitor\vfsStreamStructureVisitor; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FilesystemHelperTest extends CIUnitTestCase { /** @@ -429,20 +429,32 @@ public function testGetFilenamesWithSymlinks(): void public function testGetDirFileInfo(): void { - $file = SUPPORTPATH . 'Files/baker/banana.php'; - $info = get_file_info($file); + $file1 = SUPPORTPATH . 'Files/baker/banana.php'; + $info1 = get_file_info($file1); + $file2 = SUPPORTPATH . 'Files/baker/fig_3.php.txt'; + $info2 = get_file_info($file2); $expected = [ 'banana.php' => [ 'name' => 'banana.php', - 'server_path' => $file, - 'size' => $info['size'], - 'date' => $info['date'], + 'server_path' => $file1, + 'size' => $info1['size'], + 'date' => $info1['date'], + 'relative_path' => realpath(__DIR__ . '/../../_support/Files/baker'), + ], + 'fig_3.php.txt' => [ + 'name' => 'fig_3.php.txt', + 'server_path' => $file2, + 'size' => $info2['size'], + 'date' => $info2['date'], 'relative_path' => realpath(__DIR__ . '/../../_support/Files/baker'), ], ]; - $this->assertSame($expected, get_dir_file_info(SUPPORTPATH . 'Files/baker')); + $result = get_dir_file_info(SUPPORTPATH . 'Files/baker'); + ksort($result); + + $this->assertSame($expected, $result); } public function testGetDirFileInfoNested(): void diff --git a/tests/system/Helpers/FormHelperTest.php b/tests/system/Helpers/FormHelperTest.php index b623068943fe..35ed834a174c 100644 --- a/tests/system/Helpers/FormHelperTest.php +++ b/tests/system/Helpers/FormHelperTest.php @@ -19,12 +19,14 @@ use Config\DocTypes; use Config\Filters; use Config\Services; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; /** * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] final class FormHelperTest extends CIUnitTestCase { protected function setUp(): void @@ -953,10 +955,8 @@ public function testSetCheckboxWithUnchecked(): void ); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testSetRadioFromSessionOldInput(): void { $_SESSION = [ @@ -973,10 +973,8 @@ public function testSetRadioFromSessionOldInput(): void unset($_SESSION['_ci_old_input']); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testSetRadioFromPost(): void { $_POST['bar'] = 'baz'; @@ -986,10 +984,8 @@ public function testSetRadioFromPost(): void $this->assertSame('', set_radio('bar', 'boop', true)); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testSetRadioFromPostWithValueZero(): void { $_POST['bar'] = '0'; diff --git a/tests/system/Helpers/HTMLHelperTest.php b/tests/system/Helpers/HTMLHelperTest.php old mode 100755 new mode 100644 index ecce00af6783..b7159253706e --- a/tests/system/Helpers/HTMLHelperTest.php +++ b/tests/system/Helpers/HTMLHelperTest.php @@ -18,12 +18,12 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\App; use Config\DocTypes; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class HTMLHelperTest extends CIUnitTestCase { private array $tracks; diff --git a/tests/system/Helpers/InflectorHelperTest.php b/tests/system/Helpers/InflectorHelperTest.php old mode 100755 new mode 100644 index d6f07f59c4f0..f0df11977126 --- a/tests/system/Helpers/InflectorHelperTest.php +++ b/tests/system/Helpers/InflectorHelperTest.php @@ -14,12 +14,13 @@ namespace CodeIgniter\Helpers; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class InflectorHelperTest extends CIUnitTestCase { protected function setUp(): void @@ -261,9 +262,7 @@ public static function provideOrdinal(): iterable ]; } - /** - * @dataProvider provideOrdinal - */ + #[DataProvider('provideOrdinal')] public function testOrdinal(string $suffix, int $number): void { $this->assertSame($suffix, ordinal($number)); diff --git a/tests/system/Helpers/NumberHelperTest.php b/tests/system/Helpers/NumberHelperTest.php old mode 100755 new mode 100644 index 8e410e121679..7e5fe2a358c4 --- a/tests/system/Helpers/NumberHelperTest.php +++ b/tests/system/Helpers/NumberHelperTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter\Helpers; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class NumberHelperTest extends CIUnitTestCase { protected function setUp(): void @@ -38,6 +38,11 @@ public function testRomanNumber(): void $this->assertSame('X', number_to_roman(10)); } + public function testRomanNumberString(): void + { + $this->assertSame('XCVI', number_to_roman('96')); + } + public function testRomanNumberRange(): void { $this->assertNull(number_to_roman(-1)); @@ -70,6 +75,11 @@ public function testNumberToSize(): void $this->assertSame('456 Bytes', number_to_size(456, 1, 'en_US')); } + public function testNumberToSizeString(): void + { + $this->assertSame('456 Bytes', number_to_size('456', 1, 'en_US')); + } + public function testKbFormat(): void { $this->assertSame('4.5 KB', number_to_size(4567, 1, 'en_US')); @@ -109,6 +119,11 @@ public function testThousands(): void $this->assertSame('1,000 thousand', number_to_amount('999999', 0, 'en_US')); } + public function testThousandsInt(): void + { + $this->assertSame('123 thousand', number_to_amount(123000, 0, 'en_US')); + } + public function testMillions(): void { $this->assertSame('123.4 million', number_to_amount('123,400,000', 1, 'en_US')); diff --git a/tests/system/Helpers/SecurityHelperTest.php b/tests/system/Helpers/SecurityHelperTest.php index 7a237b34fe1a..ba0c01849458 100644 --- a/tests/system/Helpers/SecurityHelperTest.php +++ b/tests/system/Helpers/SecurityHelperTest.php @@ -16,13 +16,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockSecurity; use Config\Security as SecurityConfig; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Config\Services; /** * @internal - * - * @group Others */ +#[Group('Others')] final class SecurityHelperTest extends CIUnitTestCase { protected function setUp(): void diff --git a/tests/system/Helpers/TextHelperTest.php b/tests/system/Helpers/TextHelperTest.php old mode 100755 new mode 100644 index 1cc4def05869..e3acd7bb9c50 --- a/tests/system/Helpers/TextHelperTest.php +++ b/tests/system/Helpers/TextHelperTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class TextHelperTest extends CIUnitTestCase { private string $_long_string = 'Once upon a time, a framework had no tests. It sad. So some nice people began to write tests. The more time that went on, the happier it became. Everyone was happy.'; diff --git a/tests/system/Helpers/URLHelper/CurrentUrlTest.php b/tests/system/Helpers/URLHelper/CurrentUrlTest.php index ab5c5c381f49..1c7de84586e2 100644 --- a/tests/system/Helpers/URLHelper/CurrentUrlTest.php +++ b/tests/system/Helpers/URLHelper/CurrentUrlTest.php @@ -22,18 +22,19 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * Test cases for all URL Helper functions * that rely on the "current" URL. * Includes: current_url, uri_string, uri_is * - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class CurrentUrlTest extends CIUnitTestCase { private App $config; @@ -282,9 +283,7 @@ public static function provideUrlIs(): iterable ]; } - /** - * @dataProvider provideUrlIs - */ + #[DataProvider('provideUrlIs')] public function testUrlIs(string $currentPath, string $testPath, bool $expected): void { $_SERVER['HTTP_HOST'] = 'example.com'; @@ -295,9 +294,7 @@ public function testUrlIs(string $currentPath, string $testPath, bool $expected) $this->assertSame($expected, url_is($testPath)); } - /** - * @dataProvider provideUrlIs - */ + #[DataProvider('provideUrlIs')] public function testUrlIsNoIndex(string $currentPath, string $testPath, bool $expected): void { $_SERVER['HTTP_HOST'] = 'example.com'; @@ -310,9 +307,7 @@ public function testUrlIsNoIndex(string $currentPath, string $testPath, bool $ex $this->assertSame($expected, url_is($testPath)); } - /** - * @dataProvider provideUrlIs - */ + #[DataProvider('provideUrlIs')] public function testUrlIsWithSubfolder(string $currentPath, string $testPath, bool $expected): void { $_SERVER['HTTP_HOST'] = 'example.com'; diff --git a/tests/system/Helpers/URLHelper/MiscUrlTest.php b/tests/system/Helpers/URLHelper/MiscUrlTest.php index 1a15bb4c1fac..d38db01c56bf 100644 --- a/tests/system/Helpers/URLHelper/MiscUrlTest.php +++ b/tests/system/Helpers/URLHelper/MiscUrlTest.php @@ -23,14 +23,17 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\App; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; /** - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class MiscUrlTest extends CIUnitTestCase { private App $config; @@ -55,12 +58,9 @@ protected function tearDown(): void $_SERVER = []; } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - * - * @group SeparateProcess - */ + #[Group('SeparateProcess')] + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testPreviousURLUsesSessionFirst(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. @@ -93,12 +93,9 @@ private function createRequest(string $uri): void Factories::injectMock('config', 'App', $this->config); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - * - * @group SeparateProcess - */ + #[Group('SeparateProcess')] + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testPreviousURLUsesRefererIfNeeded(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. @@ -183,13 +180,12 @@ public static function provideAnchor(): iterable } /** - * @dataProvider provideAnchor - * * @param mixed $expected * @param mixed $uri * @param mixed $title * @param mixed $attributes */ + #[DataProvider('provideAnchor')] public function testAnchor($expected = '', $uri = '', $title = '', $attributes = ''): void { $uriString = 'http://example.com/'; @@ -248,13 +244,12 @@ public static function provideAnchorNoindex(): iterable } /** - * @dataProvider provideAnchorNoindex - * * @param mixed $expected * @param mixed $uri * @param mixed $title * @param mixed $attributes */ + #[DataProvider('provideAnchorNoindex')] public function testAnchorNoindex($expected = '', $uri = '', $title = '', $attributes = ''): void { $this->config->indexPage = ''; @@ -305,13 +300,12 @@ public static function provideAnchorTargetted(): iterable } /** - * @dataProvider provideAnchorTargetted - * * @param mixed $expected * @param mixed $uri * @param mixed $title * @param mixed $attributes */ + #[DataProvider('provideAnchorTargetted')] public function testAnchorTargetted($expected = '', $uri = '', $title = '', $attributes = ''): void { $this->config->indexPage = ''; @@ -351,13 +345,12 @@ public static function provideAnchorExamples(): iterable } /** - * @dataProvider provideAnchorExamples - * * @param mixed $expected * @param mixed $uri * @param mixed $title * @param mixed $attributes */ + #[DataProvider('provideAnchorExamples')] public function testAnchorExamples($expected = '', $uri = '', $title = '', $attributes = ''): void { $uriString = 'http://example.com/'; @@ -409,13 +402,12 @@ public static function provideAnchorPopup(): iterable } /** - * @dataProvider provideAnchorPopup - * * @param mixed $expected * @param mixed $uri * @param mixed $title * @param mixed $attributes */ + #[DataProvider('provideAnchorPopup')] public function testAnchorPopup($expected = '', $uri = '', $title = '', $attributes = false): void { $uriString = 'http://example.com/'; @@ -448,13 +440,12 @@ public static function provideMailto(): iterable } /** - * @dataProvider provideMailto - * * @param mixed $expected * @param mixed $email * @param mixed $title * @param mixed $attributes */ + #[DataProvider('provideMailto')] public function testMailto($expected = '', $email = '', $title = '', $attributes = ''): void { $uriString = 'http://example.com/'; @@ -487,13 +478,12 @@ public static function provideSafeMailto(): iterable } /** - * @dataProvider provideSafeMailto - * * @param mixed $expected * @param mixed $email * @param mixed $title * @param mixed $attributes */ + #[DataProvider('provideSafeMailto')] public function testSafeMailto($expected = '', $email = '', $title = '', $attributes = ''): void { $uriString = 'http://example.com/'; @@ -553,11 +543,10 @@ public static function provideAutoLinkUrl(): iterable } /** - * @dataProvider provideAutoLinkUrl - * * @param mixed $in * @param mixed $out */ + #[DataProvider('provideAutoLinkUrl')] public function testAutoLinkUrl($in, $out): void { $this->assertSame($out, auto_link($in, 'url')); @@ -602,11 +591,10 @@ public static function provideAutoLinkEmail(): iterable } /** - * @dataProvider provideAutoLinkEmail - * * @param mixed $in * @param mixed $out */ + #[DataProvider('provideAutoLinkEmail')] public function testAutoLinkEmail($in, $out): void { $this->assertSame($out, auto_link($in, 'email')); @@ -651,11 +639,10 @@ public static function provideAutolinkBoth(): iterable } /** - * @dataProvider provideAutolinkBoth - * * @param mixed $in * @param mixed $out */ + #[DataProvider('provideAutolinkBoth')] public function testAutolinkBoth($in, $out): void { $this->assertSame($out, auto_link($in)); @@ -700,11 +687,10 @@ public static function provideAutoLinkPopup(): iterable } /** - * @dataProvider provideAutoLinkPopup - * * @param mixed $in * @param mixed $out */ + #[DataProvider('provideAutoLinkPopup')] public function testAutoLinkPopup($in, $out): void { $this->assertSame($out, auto_link($in, 'url', true)); @@ -789,9 +775,7 @@ public static function providePrepUrl(): iterable ]; } - /** - * @dataProvider providePrepUrl - */ + #[DataProvider('providePrepUrl')] public function testPrepUrl(string $input, string $expected, bool $secure): void { $this->assertSame($expected, prep_url($input, $secure)); @@ -855,9 +839,7 @@ public function testMbUrlTitleExtraDashes(): void } } - /** - * @dataProvider provideUrlTo - */ + #[DataProvider('provideUrlTo')] public function testUrlTo(string $expected, string $input, ...$args): void { $_SERVER['HTTP_HOST'] = 'example.com'; @@ -871,9 +853,7 @@ public function testUrlTo(string $expected, string $input, ...$args): void $this->assertSame($expected, url_to($input, ...$args)); } - /** - * @dataProvider provideUrlToThrowsOnEmptyOrMissingRoute - */ + #[DataProvider('provideUrlToThrowsOnEmptyOrMissingRoute')] public function testUrlToThrowsOnEmptyOrMissingRoute(string $route): void { $this->expectException(RouterException::class); diff --git a/tests/system/Helpers/URLHelper/SiteUrlCliTest.php b/tests/system/Helpers/URLHelper/SiteUrlCliTest.php index 526d2250f2c7..2ae86cb883eb 100644 --- a/tests/system/Helpers/URLHelper/SiteUrlCliTest.php +++ b/tests/system/Helpers/URLHelper/SiteUrlCliTest.php @@ -18,18 +18,19 @@ use CodeIgniter\HTTP\CLIRequest; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * Since base_url() only slightly modifies * site_url() these functions are tested * simultaneously. * - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class SiteUrlCliTest extends CIUnitTestCase { private App $config; @@ -71,9 +72,8 @@ private function createRequest(?App $config = null): void * @param string $path * @param string $expectedSiteUrl * @param string $expectedBaseUrl - * - * @dataProvider provideUrls */ + #[DataProvider('provideUrls')] public function testUrls( $baseURL, $indexPage, diff --git a/tests/system/Helpers/URLHelper/SiteUrlTest.php b/tests/system/Helpers/URLHelper/SiteUrlTest.php index 41c1cfc7974b..cd9d1da66cde 100644 --- a/tests/system/Helpers/URLHelper/SiteUrlTest.php +++ b/tests/system/Helpers/URLHelper/SiteUrlTest.php @@ -21,18 +21,19 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * Since base_url() only slightly modifies * site_url() these functions are tested * simultaneously. * - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class SiteUrlTest extends CIUnitTestCase { private App $config; @@ -81,9 +82,8 @@ private function createRequest(?App $config = null, $body = null, ?string $path * @param string $path * @param string $expectedSiteUrl * @param string $expectedBaseUrl - * - * @dataProvider provideUrls */ + #[DataProvider('provideUrls')] public function testUrls( $baseURL, $indexPage, diff --git a/tests/system/Helpers/XMLHelperTest.php b/tests/system/Helpers/XMLHelperTest.php index c508c9f95905..f0a52d104d64 100644 --- a/tests/system/Helpers/XMLHelperTest.php +++ b/tests/system/Helpers/XMLHelperTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter\Helpers; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class XMLHelperTest extends CIUnitTestCase { protected function setUp(): void diff --git a/tests/system/HomeTest.php b/tests/system/HomeTest.php index b620335f2cca..67efb3961b58 100644 --- a/tests/system/HomeTest.php +++ b/tests/system/HomeTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\FeatureTestTrait; use CodeIgniter\Test\TestResponse; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class HomeTest extends CIUnitTestCase { use FeatureTestTrait; diff --git a/tests/system/Honeypot/HoneypotTest.php b/tests/system/Honeypot/HoneypotTest.php index c243645d905b..ee048a1a785c 100644 --- a/tests/system/Honeypot/HoneypotTest.php +++ b/tests/system/Honeypot/HoneypotTest.php @@ -23,14 +23,14 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\App; use Config\Honeypot as HoneypotConfig; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\Group; /** - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class HoneypotTest extends CIUnitTestCase { private HoneypotConfig $config; diff --git a/tests/system/HotReloader/DirectoryHasherTest.php b/tests/system/HotReloader/DirectoryHasherTest.php index 4df7e69fd924..3ef02c1217a4 100644 --- a/tests/system/HotReloader/DirectoryHasherTest.php +++ b/tests/system/HotReloader/DirectoryHasherTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Exceptions\FrameworkException; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class DirectoryHasherTest extends CIUnitTestCase { private DirectoryHasher $hasher; diff --git a/tests/system/I18n/TimeDifferenceTest.php b/tests/system/I18n/TimeDifferenceTest.php index e1b242fc72c5..4342d53f92ee 100644 --- a/tests/system/I18n/TimeDifferenceTest.php +++ b/tests/system/I18n/TimeDifferenceTest.php @@ -15,12 +15,12 @@ use CodeIgniter\Test\CIUnitTestCase; use Locale; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class TimeDifferenceTest extends CIUnitTestCase { private string $currentLocale; diff --git a/tests/system/I18n/TimeLegacyTest.php b/tests/system/I18n/TimeLegacyTest.php index f966e3750ce9..771890699ece 100644 --- a/tests/system/I18n/TimeLegacyTest.php +++ b/tests/system/I18n/TimeLegacyTest.php @@ -21,12 +21,13 @@ use DateTimeZone; use IntlDateFormatter; use Locale; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class TimeLegacyTest extends CIUnitTestCase { private string $currentLocale; @@ -1152,9 +1153,7 @@ public function testSetTestNowWithFaLocale(): void $this->assertSame('2017-03-10T12:00:00+09:00', $now); } - /** - * @dataProvider provideToStringDoesNotDependOnLocale - */ + #[DataProvider('provideToStringDoesNotDependOnLocale')] public function testToStringDoesNotDependOnLocale(string $locale): void { Locale::setDefault($locale); diff --git a/tests/system/I18n/TimeTest.php b/tests/system/I18n/TimeTest.php index 8e85e8cff3e3..34516948ef65 100644 --- a/tests/system/I18n/TimeTest.php +++ b/tests/system/I18n/TimeTest.php @@ -21,12 +21,13 @@ use DateTimeZone; use IntlDateFormatter; use Locale; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class TimeTest extends CIUnitTestCase { private string $currentLocale; @@ -1168,9 +1169,7 @@ public function testSetTestNowWithFaLocale(): void $this->assertSame('2017-03-10T12:00:00+09:00', $now); } - /** - * @dataProvider provideToStringDoesNotDependOnLocale - */ + #[DataProvider('provideToStringDoesNotDependOnLocale')] public function testToStringDoesNotDependOnLocale(string $locale): void { Locale::setDefault($locale); diff --git a/tests/system/Images/BaseHandlerTest.php b/tests/system/Images/BaseHandlerTest.php index bcaf035ed30e..7332eba9031f 100644 --- a/tests/system/Images/BaseHandlerTest.php +++ b/tests/system/Images/BaseHandlerTest.php @@ -20,6 +20,7 @@ use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use PHPUnit\Framework\Attributes\Group; /** * Test the common image processing functionality. @@ -30,9 +31,8 @@ * testing saving only. * * @internal - * - * @group Others */ +#[Group('Others')] final class BaseHandlerTest extends CIUnitTestCase { private vfsStreamDirectory $root; diff --git a/tests/system/Images/GDHandlerTest.php b/tests/system/Images/GDHandlerTest.php index 5d39a3c93fd2..db8297ae212f 100644 --- a/tests/system/Images/GDHandlerTest.php +++ b/tests/system/Images/GDHandlerTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use PHPUnit\Framework\Attributes\Group; /** * Unit testing for the GD image handler. @@ -30,9 +31,8 @@ * Was unable to test fontPath & related logic. * * @internal - * - * @group Others */ +#[Group('Others')] final class GDHandlerTest extends CIUnitTestCase { private vfsStreamDirectory $root; diff --git a/tests/system/Images/ImageMagickHandlerTest.php b/tests/system/Images/ImageMagickHandlerTest.php index 2edc1c60e714..8ca59fd8dbbc 100644 --- a/tests/system/Images/ImageMagickHandlerTest.php +++ b/tests/system/Images/ImageMagickHandlerTest.php @@ -20,6 +20,9 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Images; use Imagick; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; /** * Unit testing for the ImageMagick image handler. @@ -31,11 +34,9 @@ * Was unable to test fontPath & related logic. * * @internal - * - * @group Others - * - * @requires extension imagick */ +#[Group('Others')] +#[RequiresPhpExtension('imagick')] final class ImageMagickHandlerTest extends CIUnitTestCase { private string $root; @@ -80,9 +81,7 @@ protected function setUp(): void $this->handler = Services::image('imagick', $config, false); } - /** - * @dataProvider provideNonexistentLibraryPathTerminatesProcessing - */ + #[DataProvider('provideNonexistentLibraryPathTerminatesProcessing')] public function testNonexistentLibraryPathTerminatesProcessing(string $path, string $invalidPath): void { $this->expectException(ImageException::class); diff --git a/tests/system/Images/ImageTest.php b/tests/system/Images/ImageTest.php index c3c4b119a6fb..c4411dd7dedb 100644 --- a/tests/system/Images/ImageTest.php +++ b/tests/system/Images/ImageTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ImageTest extends CIUnitTestCase { private vfsStreamDirectory $root; diff --git a/tests/system/Language/LanguageTest.php b/tests/system/Language/LanguageTest.php index b318d28fc19a..2651413060c8 100644 --- a/tests/system/Language/LanguageTest.php +++ b/tests/system/Language/LanguageTest.php @@ -17,13 +17,14 @@ use CodeIgniter\Test\Mock\MockLanguage; use Config\Services; use MessageFormatter; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Language\SecondMockLanguage; /** * @internal - * - * @group Others */ +#[Group('Others')] final class LanguageTest extends CIUnitTestCase { private Language $lang; @@ -266,10 +267,9 @@ public static function provideBundleUniqueKeys(): iterable * There's not a whole lot that can be done with message bundles, * but we can at least try loading them ... more accurate code coverage? * - * @dataProvider provideBundleUniqueKeys - * * @param mixed $bundle */ + #[DataProvider('provideBundleUniqueKeys')] public function testBundleUniqueKeys($bundle): void { $messages = require SYSTEMPATH . 'Language/en/' . $bundle . '.php'; diff --git a/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php b/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php index 228e358e3ba1..3dc0b1ccee80 100644 --- a/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php +++ b/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php @@ -18,13 +18,13 @@ use CodeIgniter\Test\Mock\MockResponse; use Config\App; use Config\Services; +use PHPUnit\Framework\Attributes\Group; use stdClass; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ChromeLoggerHandlerTest extends CIUnitTestCase { public function testCanHandleLogLevel(): void diff --git a/tests/system/Log/Handlers/ErrorlogHandlerTest.php b/tests/system/Log/Handlers/ErrorlogHandlerTest.php index cde1c2e983c8..609cea39af7d 100644 --- a/tests/system/Log/Handlers/ErrorlogHandlerTest.php +++ b/tests/system/Log/Handlers/ErrorlogHandlerTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Log\Exceptions\LogException; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ErrorlogHandlerTest extends CIUnitTestCase { public function testHandlerThrowsOnInvalidMessageType(): void diff --git a/tests/system/Log/Handlers/FileHandlerTest.php b/tests/system/Log/Handlers/FileHandlerTest.php index 3b3ee9c53b56..7cf11c1f3cf9 100644 --- a/tests/system/Log/Handlers/FileHandlerTest.php +++ b/tests/system/Log/Handlers/FileHandlerTest.php @@ -18,13 +18,13 @@ use CodeIgniter\Test\Mock\MockLogger as LoggerConfig; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Log\Handlers\TestHandler; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FileHandlerTest extends CIUnitTestCase { private vfsStreamDirectory $root; diff --git a/tests/system/Log/LoggerTest.php b/tests/system/Log/LoggerTest.php index e76e60cbd4c3..9464d4d286fd 100644 --- a/tests/system/Log/LoggerTest.php +++ b/tests/system/Log/LoggerTest.php @@ -19,14 +19,14 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockLogger as LoggerConfig; use Exception; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Log\Handlers\TestHandler; use TypeError; /** * @internal - * - * @group Others */ +#[Group('Others')] final class LoggerTest extends CIUnitTestCase { protected function tearDown(): void diff --git a/tests/system/Models/AffectedRowsTest.php b/tests/system/Models/AffectedRowsTest.php index 9c7d60267ebc..bbf749d23233 100644 --- a/tests/system/Models/AffectedRowsTest.php +++ b/tests/system/Models/AffectedRowsTest.php @@ -13,13 +13,13 @@ namespace CodeIgniter\Models; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Models\UserModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class AffectedRowsTest extends LiveModelTestCase { /** diff --git a/tests/system/Models/CountAllModelTest.php b/tests/system/Models/CountAllModelTest.php index 836a6e08a13f..f91a97c1b309 100644 --- a/tests/system/Models/CountAllModelTest.php +++ b/tests/system/Models/CountAllModelTest.php @@ -13,13 +13,13 @@ namespace CodeIgniter\Models; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Models\UserModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class CountAllModelTest extends LiveModelTestCase { /** diff --git a/tests/system/Models/DataConverterModelTest.php b/tests/system/Models/DataConverterModelTest.php index c22fa39b5050..f243871526f3 100644 --- a/tests/system/Models/DataConverterModelTest.php +++ b/tests/system/Models/DataConverterModelTest.php @@ -14,15 +14,15 @@ namespace CodeIgniter\Models; use CodeIgniter\I18n\Time; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Entity\CustomUser; use Tests\Support\Entity\User; use Tests\Support\Models\UserCastsTimestampModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class DataConverterModelTest extends LiveModelTestCase { protected $migrate = true; @@ -43,6 +43,16 @@ public function testFindAsArray(): void $this->seeInDatabase('user', ['name' => 'Sm9obiBTbWl0aA==']); } + public function testFindAsArrayReturnsNull(): void + { + $this->createModel(UserCastsTimestampModel::class); + $this->db->table('user')->truncate(); + + $user = $this->model->find(1); + + $this->assertNull($user); + } + /** * @return int|string Insert ID */ @@ -90,6 +100,28 @@ public function testFindAsEntity(): void $this->assertInstanceOf(Time::class, $user->created_at); } + public function testFindArrayAsEntity(): void + { + $id = $this->prepareOneRecord(); + + $users = $this->model->asObject(User::class)->find([$id, 999]); + + $this->assertCount(1, $users); + $this->assertIsInt($users[0]->id); + $this->assertInstanceOf(Time::class, $users[0]->created_at); + } + + public function testFindNullAsEntity(): void + { + $this->prepareOneRecord(); + + $users = $this->model->asObject(User::class)->find(); + + $this->assertCount(1, $users); + $this->assertIsInt($users[0]->id); + $this->assertInstanceOf(Time::class, $users[0]->created_at); + } + public function testFindAllAsArray(): void { $this->prepareTwoRecords(); @@ -102,6 +134,16 @@ public function testFindAllAsArray(): void $this->assertInstanceOf(Time::class, $users[1]['created_at']); } + public function testFindAllAsArrayReturnsNull(): void + { + $this->createModel(UserCastsTimestampModel::class); + $this->db->table('user')->truncate(); + + $users = $this->model->findAll(); + + $this->assertSame([], $users); + } + private function prepareTwoRecords(): void { $this->prepareOneRecord(); @@ -170,6 +212,16 @@ public function testFirstAsArray(): void $this->assertInstanceOf(Time::class, $user['created_at']); } + public function testFirstAsArrayReturnsNull(): void + { + $this->createModel(UserCastsTimestampModel::class); + $this->db->table('user')->truncate(); + + $user = $this->model->first(); + + $this->assertNull($user); + } + public function testFirstAsObject(): void { $this->prepareTwoRecords(); diff --git a/tests/system/Models/DeleteModelTest.php b/tests/system/Models/DeleteModelTest.php index bd2af1f4ad0d..bb78ec46f00a 100644 --- a/tests/system/Models/DeleteModelTest.php +++ b/tests/system/Models/DeleteModelTest.php @@ -15,15 +15,16 @@ use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Exceptions\ModelException; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Models\JobModel; use Tests\Support\Models\StringifyPkeyModel; use Tests\Support\Models\UserModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class DeleteModelTest extends LiveModelTestCase { public function testDeleteBasics(): void @@ -154,10 +155,9 @@ public function testOnlyDeleted(): void * When executing a soft delete * Then an exception should not be thrown * - * @dataProvider emptyPkValues - * * @param int|string|null $emptyValue */ + #[DataProvider('emptyPkValues')] public function testDontThrowExceptionWhenSoftDeleteConditionIsSetWithEmptyValue($emptyValue): void { $this->createModel(UserModel::class); @@ -168,10 +168,9 @@ public function testDontThrowExceptionWhenSoftDeleteConditionIsSetWithEmptyValue } /** - * @dataProvider emptyPkValues - * * @param int|string|null $emptyValue */ + #[DataProvider('emptyPkValues')] public function testThrowExceptionWhenSoftDeleteParamIsEmptyValue($emptyValue): void { $this->expectException(DatabaseException::class); @@ -183,10 +182,9 @@ public function testThrowExceptionWhenSoftDeleteParamIsEmptyValue($emptyValue): } /** - * @dataProvider emptyPkValues - * * @param int|string|null $emptyValue */ + #[DataProvider('emptyPkValues')] public function testDontDeleteRowsWhenSoftDeleteParamIsEmpty($emptyValue): void { $this->seeInDatabase('user', ['name' => 'Derek Jones', 'deleted_at IS NULL' => null]); @@ -243,10 +241,9 @@ public function testPurgeDeletedWithSoftDeleteFalse(): void } /** - * @dataProvider emptyPkValues - * * @param int|string|null $id */ + #[DataProvider('emptyPkValues')] public function testDeleteThrowDatabaseExceptionWithoutWhereClause($id): void { // BaseBuilder throws Exception. @@ -262,10 +259,9 @@ public function testDeleteThrowDatabaseExceptionWithoutWhereClause($id): void } /** - * @dataProvider emptyPkValues - * * @param int|string|null $id */ + #[DataProvider('emptyPkValues')] public function testDeleteWithSoftDeleteThrowDatabaseExceptionWithoutWhereClause($id): void { // Model throws Exception. diff --git a/tests/system/Models/EventsModelTest.php b/tests/system/Models/EventsModelTest.php index 52130f73f9f8..d697437d3534 100644 --- a/tests/system/Models/EventsModelTest.php +++ b/tests/system/Models/EventsModelTest.php @@ -14,13 +14,13 @@ namespace CodeIgniter\Models; use CodeIgniter\Database\Exceptions\DataException; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Models\EventModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class EventsModelTest extends LiveModelTestCase { /** diff --git a/tests/system/Models/FindModelTest.php b/tests/system/Models/FindModelTest.php index d27fcb791bb3..b15857d4aaaf 100644 --- a/tests/system/Models/FindModelTest.php +++ b/tests/system/Models/FindModelTest.php @@ -15,15 +15,18 @@ use CodeIgniter\Database\Exceptions\DataException; use CodeIgniter\Exceptions\ModelException; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use Tests\Support\Entity\UserWithCasts; use Tests\Support\Models\JobModel; use Tests\Support\Models\SecondaryModel; +use Tests\Support\Models\UserEntityWithCastsModel; use Tests\Support\Models\UserModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class FindModelTest extends LiveModelTestCase { public function testFindReturnsRow(): void @@ -32,6 +35,24 @@ public function testFindReturnsRow(): void $this->assertSame('Musician', $this->model->find(4)->name); } + public function testFindReturnsEntityWithCasts(): void + { + $this->createModel(UserEntityWithCastsModel::class); + $this->model->builder()->truncate(); + $user = new UserWithCasts([ + 'name' => 'John Smith', + 'email' => ['foo@example.jp', 'bar@example.com'], + 'country' => 'US', + ]); + $id = $this->model->insert($user, true); + + /** @var UserWithCasts $user */ + $user = $this->model->find($id); + + $this->assertSame('John Smith', $user->name); + $this->assertSame(['foo@example.jp', 'bar@example.com'], $user->email); + } + public function testFindReturnsMultipleRows(): void { $this->createModel(JobModel::class); @@ -159,11 +180,10 @@ public function testFirst(): void } /** - * @dataProvider provideFirstAggregate - * * @param mixed $groupBy * @param mixed $total */ + #[DataProvider('provideFirstAggregate')] public function testFirstAggregate($groupBy, $total): void { $this->createModel(UserModel::class); @@ -195,11 +215,10 @@ public static function provideFirstAggregate(): iterable } /** - * @dataProvider provideAggregateAndGroupBy - * * @param mixed $aggregate * @param mixed $groupBy */ + #[DataProvider('provideAggregateAndGroupBy')] public function testFirstRespectsSoftDeletes($aggregate, $groupBy): void { $this->db->table('user') @@ -241,11 +260,10 @@ public function testFirstRespectsSoftDeletes($aggregate, $groupBy): void } /** - * @dataProvider provideAggregateAndGroupBy - * * @param mixed $aggregate * @param mixed $groupBy */ + #[DataProvider('provideAggregateAndGroupBy')] public function testFirstRecoverTempUseSoftDeletes($aggregate, $groupBy): void { $this->createModel(UserModel::class); diff --git a/tests/system/Models/GeneralModelTest.php b/tests/system/Models/GeneralModelTest.php index b119e6f1550b..d0e50768457a 100644 --- a/tests/system/Models/GeneralModelTest.php +++ b/tests/system/Models/GeneralModelTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Database\BaseConnection; use CodeIgniter\Model; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Models\JobModel; use Tests\Support\Models\UserModel; @@ -25,9 +26,8 @@ * features without requiring a database connection. * * @internal - * - * @group Others */ +#[Group('Others')] final class GeneralModelTest extends CIUnitTestCase { /** diff --git a/tests/system/Models/GetCompiledModelTest.php b/tests/system/Models/GetCompiledModelTest.php index fd12cc880065..77663bd49700 100644 --- a/tests/system/Models/GetCompiledModelTest.php +++ b/tests/system/Models/GetCompiledModelTest.php @@ -17,13 +17,13 @@ use CodeIgniter\Model; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Models\UserObjModel; /** * @internal - * - * @group Others */ +#[Group('Others')] final class GetCompiledModelTest extends CIUnitTestCase { private ?object $model = null; diff --git a/tests/system/Models/InsertModelTest.php b/tests/system/Models/InsertModelTest.php index 25e844dd5cb0..d4a680d7696b 100644 --- a/tests/system/Models/InsertModelTest.php +++ b/tests/system/Models/InsertModelTest.php @@ -18,6 +18,7 @@ use CodeIgniter\I18n\Time; use CodeIgniter\Model; use Config\Database; +use PHPUnit\Framework\Attributes\Group; use stdClass; use Tests\Support\Entity\User; use Tests\Support\Models\JobModel; @@ -26,10 +27,9 @@ use Tests\Support\Models\WithoutAutoIncrementModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class InsertModelTest extends LiveModelTestCase { public function testSetWorksWithInsert(): void diff --git a/tests/system/Models/MiscellaneousModelTest.php b/tests/system/Models/MiscellaneousModelTest.php index 83b72cd13d78..f595973ca13e 100644 --- a/tests/system/Models/MiscellaneousModelTest.php +++ b/tests/system/Models/MiscellaneousModelTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Database\Exceptions\DataException; use CodeIgniter\I18n\Time; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Models\EntityModel; use Tests\Support\Models\JobModel; use Tests\Support\Models\SimpleEntity; @@ -22,10 +23,9 @@ use Tests\Support\Models\ValidModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class MiscellaneousModelTest extends LiveModelTestCase { public function testChunk(): void diff --git a/tests/system/Models/PaginateModelTest.php b/tests/system/Models/PaginateModelTest.php index 570a53b5792a..b7e4661f83ec 100644 --- a/tests/system/Models/PaginateModelTest.php +++ b/tests/system/Models/PaginateModelTest.php @@ -13,14 +13,14 @@ namespace CodeIgniter\Models; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Models\UserModel; use Tests\Support\Models\ValidModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class PaginateModelTest extends LiveModelTestCase { public function testPaginate(): void diff --git a/tests/system/Models/ReplaceModelTest.php b/tests/system/Models/ReplaceModelTest.php index 59780cce3eef..1fa71323334e 100644 --- a/tests/system/Models/ReplaceModelTest.php +++ b/tests/system/Models/ReplaceModelTest.php @@ -13,13 +13,13 @@ namespace CodeIgniter\Models; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Models\UserModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class ReplaceModelTest extends LiveModelTestCase { public function testReplaceRespectsUseTimestamps(): void diff --git a/tests/system/Models/SaveModelTest.php b/tests/system/Models/SaveModelTest.php index e4a012803067..29f2959878e4 100644 --- a/tests/system/Models/SaveModelTest.php +++ b/tests/system/Models/SaveModelTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Entity\Entity; use CodeIgniter\I18n\Time; use CodeIgniter\Model; +use PHPUnit\Framework\Attributes\Group; use stdClass; use Tests\Support\Models\EntityModel; use Tests\Support\Models\JobModel; @@ -26,10 +27,9 @@ use Tests\Support\Models\WithoutAutoIncrementModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class SaveModelTest extends LiveModelTestCase { public function testSaveNewRecordObject(): void diff --git a/tests/system/Models/TimestampModelTest.php b/tests/system/Models/TimestampModelTest.php index 7d27d18800d5..8736691b2d4a 100644 --- a/tests/system/Models/TimestampModelTest.php +++ b/tests/system/Models/TimestampModelTest.php @@ -14,14 +14,14 @@ namespace CodeIgniter\Models; use CodeIgniter\I18n\Time; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Entity\User; use Tests\Support\Models\UserTimestampModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class TimestampModelTest extends LiveModelTestCase { protected $migrate = true; diff --git a/tests/system/Models/UpdateModelTest.php b/tests/system/Models/UpdateModelTest.php index 866fc4b8661e..c7c8b9ad51d4 100644 --- a/tests/system/Models/UpdateModelTest.php +++ b/tests/system/Models/UpdateModelTest.php @@ -18,6 +18,8 @@ use CodeIgniter\Entity\Entity; use Config\Database; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use stdClass; use Tests\Support\Entity\User; use Tests\Support\Entity\UUID; @@ -31,10 +33,9 @@ use Tests\Support\Models\WithoutAutoIncrementModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class UpdateModelTest extends LiveModelTestCase { public function testSetWorksWithUpdate(): void @@ -552,10 +553,9 @@ public function testUpdateWithSetAndEscape(): void } /** - * @dataProvider provideUpdateThrowDatabaseExceptionWithoutWhereClause - * * @param false|null $id */ + #[DataProvider('provideUpdateThrowDatabaseExceptionWithoutWhereClause')] public function testUpdateThrowDatabaseExceptionWithoutWhereClause($id, string $exception, string $exceptionMessage): void { $this->expectException($exception); diff --git a/tests/system/Models/ValidationModelRuleGroupTest.php b/tests/system/Models/ValidationModelRuleGroupTest.php index e1de82841832..4274d5d1578f 100644 --- a/tests/system/Models/ValidationModelRuleGroupTest.php +++ b/tests/system/Models/ValidationModelRuleGroupTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BaseConnection; use CodeIgniter\Model; use Config\Services; +use PHPUnit\Framework\Attributes\Group; use stdClass; use Tests\Support\Config\Validation; use Tests\Support\Models\JobModel; @@ -24,10 +25,9 @@ use Tests\Support\Models\ValidModelRuleGroup; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class ValidationModelRuleGroupTest extends LiveModelTestCase { protected function setUp(): void diff --git a/tests/system/Models/ValidationModelTest.php b/tests/system/Models/ValidationModelTest.php index 99780faeba73..d2c9c7d0dab8 100644 --- a/tests/system/Models/ValidationModelTest.php +++ b/tests/system/Models/ValidationModelTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Config\Factories; use CodeIgniter\Model; use Config\Validation; +use PHPUnit\Framework\Attributes\Group; use stdClass; use Tests\Support\Models\JobModel; use Tests\Support\Models\SimpleEntity; @@ -23,10 +24,9 @@ use Tests\Support\Models\ValidModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class ValidationModelTest extends LiveModelTestCase { protected function setUp(): void diff --git a/tests/system/Models/WhenWhenNotModelTest.php b/tests/system/Models/WhenWhenNotModelTest.php index 3039fc0b57b5..31015aa88bb1 100644 --- a/tests/system/Models/WhenWhenNotModelTest.php +++ b/tests/system/Models/WhenWhenNotModelTest.php @@ -13,13 +13,13 @@ namespace CodeIgniter\Models; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Models\SecondaryModel; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class WhenWhenNotModelTest extends LiveModelTestCase { public function testWhenWithTrueCondition(): void diff --git a/tests/system/Pager/PagerRendererTest.php b/tests/system/Pager/PagerRendererTest.php index f35f30a361d2..8ac8683a4327 100644 --- a/tests/system/Pager/PagerRendererTest.php +++ b/tests/system/Pager/PagerRendererTest.php @@ -15,12 +15,12 @@ use CodeIgniter\HTTP\URI; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class PagerRendererTest extends CIUnitTestCase { private string $expect; diff --git a/tests/system/Pager/PagerTest.php b/tests/system/Pager/PagerTest.php index b7f9866579ab..047637a2025f 100644 --- a/tests/system/Pager/PagerTest.php +++ b/tests/system/Pager/PagerTest.php @@ -23,14 +23,14 @@ use Config\App; use Config\Pager as PagerConfig; use Config\Services; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\Group; /** - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class PagerTest extends CIUnitTestCase { private ?Pager $pager = null; diff --git a/tests/system/Publisher/ContentReplacerTest.php b/tests/system/Publisher/ContentReplacerTest.php index 758075f1fc7f..b5d0c1b4604d 100644 --- a/tests/system/Publisher/ContentReplacerTest.php +++ b/tests/system/Publisher/ContentReplacerTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter\Publisher; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ContentReplacerTest extends CIUnitTestCase { public function testReplace(): void diff --git a/tests/system/Publisher/PublisherContentReplaceTest.php b/tests/system/Publisher/PublisherContentReplaceTest.php index ca3cc8fbef1e..3b612a93baee 100644 --- a/tests/system/Publisher/PublisherContentReplaceTest.php +++ b/tests/system/Publisher/PublisherContentReplaceTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter\Publisher; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class PublisherContentReplaceTest extends CIUnitTestCase { private string $file; diff --git a/tests/system/Publisher/PublisherInputTest.php b/tests/system/Publisher/PublisherInputTest.php index af6f3323969d..1336137defd4 100644 --- a/tests/system/Publisher/PublisherInputTest.php +++ b/tests/system/Publisher/PublisherInputTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter\Publisher; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class PublisherInputTest extends CIUnitTestCase { /** @@ -86,6 +86,7 @@ public function testAddPathDirectoryRecursive(): void $this->directory . 'fig_3.php', $this->directory . 'prune_ripe.php', SUPPORTPATH . 'Files/baker/banana.php', + SUPPORTPATH . 'Files/baker/fig_3.php.txt', ]; $publisher->addPath('Files'); @@ -121,6 +122,7 @@ public function testAddPathsRecursive(): void $this->directory . 'fig_3.php', $this->directory . 'prune_ripe.php', SUPPORTPATH . 'Files/baker/banana.php', + SUPPORTPATH . 'Files/baker/fig_3.php.txt', SUPPORTPATH . 'Log/Handlers/TestHandler.php', ]; diff --git a/tests/system/Publisher/PublisherOutputTest.php b/tests/system/Publisher/PublisherOutputTest.php index 816f045d2b21..e03335e86fe6 100644 --- a/tests/system/Publisher/PublisherOutputTest.php +++ b/tests/system/Publisher/PublisherOutputTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class PublisherOutputTest extends CIUnitTestCase { /** @@ -161,6 +161,7 @@ public function testMerge(): void $this->root->url() . '/able/fig_3.php', $this->root->url() . '/able/prune_ripe.php', $this->root->url() . '/baker/banana.php', + $this->root->url() . '/baker/fig_3.php.txt', ]; $this->assertFileDoesNotExist($this->root->url() . '/able/fig_3.php'); @@ -183,6 +184,7 @@ public function testMergeReplace(): void $this->root->url() . '/able/fig_3.php', $this->root->url() . '/able/prune_ripe.php', $this->root->url() . '/baker/banana.php', + $this->root->url() . '/baker/fig_3.php.txt', ]; $result = $publisher->addPath('/')->merge(true); @@ -200,6 +202,7 @@ public function testMergeCollides(): void $this->root->url() . '/able/apple.php', $this->root->url() . '/able/prune_ripe.php', $this->root->url() . '/baker/banana.php', + $this->root->url() . '/baker/fig_3.php.txt', ]; mkdir($this->root->url() . '/able/fig_3.php'); diff --git a/tests/system/Publisher/PublisherRestrictionsTest.php b/tests/system/Publisher/PublisherRestrictionsTest.php index ac4dce6b52fa..eaa326ee82eb 100644 --- a/tests/system/Publisher/PublisherRestrictionsTest.php +++ b/tests/system/Publisher/PublisherRestrictionsTest.php @@ -15,6 +15,8 @@ use CodeIgniter\Publisher\Exceptions\PublisherException; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * Publisher Restrictions Test @@ -23,9 +25,8 @@ * file properly prevent disallowed actions. * * @internal - * - * @group Others */ +#[Group('Others')] final class PublisherRestrictionsTest extends CIUnitTestCase { /** @@ -48,9 +49,7 @@ public function testImmutableRestrictions(): void $this->assertArrayNotHasKey(SUPPORTPATH, $restrictions); } - /** - * @dataProvider provideDefaultPublicRestrictions - */ + #[DataProvider('provideDefaultPublicRestrictions')] public function testDefaultPublicRestrictions(string $path): void { $publisher = new Publisher(ROOTPATH, FCPATH); @@ -80,9 +79,7 @@ public static function provideDefaultPublicRestrictions(): iterable ]; } - /** - * @dataProvider provideDestinations - */ + #[DataProvider('provideDestinations')] public function testDestinations(string $destination, bool $allowed): void { config('Publisher')->restrictions = [ diff --git a/tests/system/Publisher/PublisherSupportTest.php b/tests/system/Publisher/PublisherSupportTest.php index e62ed76a48dd..5854e1c516d9 100644 --- a/tests/system/Publisher/PublisherSupportTest.php +++ b/tests/system/Publisher/PublisherSupportTest.php @@ -15,13 +15,13 @@ use CodeIgniter\Publisher\Exceptions\PublisherException; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Publishers\TestPublisher; /** * @internal - * - * @group Others */ +#[Group('Others')] final class PublisherSupportTest extends CIUnitTestCase { /** diff --git a/tests/system/RESTful/ResourceControllerTest.php b/tests/system/RESTful/ResourceControllerTest.php index 471ae58157c5..000abee6e317 100644 --- a/tests/system/RESTful/ResourceControllerTest.php +++ b/tests/system/RESTful/ResourceControllerTest.php @@ -27,6 +27,9 @@ use CodeIgniter\Test\Mock\MockCodeIgniter; use CodeIgniter\Test\Mock\MockResourceController; use Config\App; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; use Psr\Log\NullLogger; use Tests\Support\Models\UserModel; use Tests\Support\RESTful\Worker; @@ -37,14 +40,11 @@ * so we need to make sure that the methods routed to * return correct responses. * - * @runTestsInSeparateProcesses - * - * @preserveGlobalState disabled - * * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] +#[PreserveGlobalState(false)] +#[RunTestsInSeparateProcesses] final class ResourceControllerTest extends CIUnitTestCase { private CodeIgniter $codeigniter; diff --git a/tests/system/RESTful/ResourcePresenterTest.php b/tests/system/RESTful/ResourcePresenterTest.php index 975f0d2b9e0c..5d98dee4e583 100644 --- a/tests/system/RESTful/ResourcePresenterTest.php +++ b/tests/system/RESTful/ResourcePresenterTest.php @@ -21,6 +21,9 @@ use CodeIgniter\Test\Mock\MockCodeIgniter; use CodeIgniter\Test\Mock\MockResourcePresenter; use Config\App; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; use Tests\Support\Models\EntityModel; use Tests\Support\Models\UserModel; use Tests\Support\RESTful\Worker2; @@ -31,14 +34,11 @@ * so we need to make sure that the methods routed to * return correct responses. * - * @runTestsInSeparateProcesses - * - * @preserveGlobalState disabled - * * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] +#[PreserveGlobalState(false)] +#[RunTestsInSeparateProcesses] final class ResourcePresenterTest extends CIUnitTestCase { private CodeIgniter $codeigniter; diff --git a/tests/system/Router/AutoRouterImprovedTest.php b/tests/system/Router/AutoRouterImprovedTest.php index 6c531db06a8b..c60c978e4a3c 100644 --- a/tests/system/Router/AutoRouterImprovedTest.php +++ b/tests/system/Router/AutoRouterImprovedTest.php @@ -25,12 +25,13 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Modules; use Config\Routing; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class AutoRouterImprovedTest extends CIUnitTestCase { private RouteCollection $collection; @@ -458,9 +459,7 @@ public function testDoesNotTranslateDashInParam(): void $this->assertSame(['a-b'], $params); } - /** - * @dataProvider provideTranslateUriToCamelCase - */ + #[DataProvider('provideTranslateUriToCamelCase')] public function testTranslateUriToCamelCase( string $uri, ?string $expDirectory, @@ -532,9 +531,7 @@ public static function provideTranslateUriToCamelCase(): iterable ]; } - /** - * @dataProvider provideRejectTranslateUriToCamelCase - */ + #[DataProvider('provideRejectTranslateUriToCamelCase')] public function testRejectTranslateUriToCamelCase(string $uri, string $expMsg): void { $this->expectException(PageNotFoundException::class); diff --git a/tests/system/Router/DefinedRouteCollectorTest.php b/tests/system/Router/DefinedRouteCollectorTest.php index 779639204ded..ca10a2fd7b51 100644 --- a/tests/system/Router/DefinedRouteCollectorTest.php +++ b/tests/system/Router/DefinedRouteCollectorTest.php @@ -18,12 +18,12 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Modules; use Config\Routing; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class DefinedRouteCollectorTest extends CIUnitTestCase { private function createRouteCollection(array $config = [], $moduleConfig = null): RouteCollection diff --git a/tests/system/Router/RouteCollectionReverseRouteTest.php b/tests/system/Router/RouteCollectionReverseRouteTest.php index cbde8a16a118..ebe344293f46 100644 --- a/tests/system/Router/RouteCollectionReverseRouteTest.php +++ b/tests/system/Router/RouteCollectionReverseRouteTest.php @@ -19,12 +19,13 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Modules; use Config\Routing; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class RouteCollectionReverseRouteTest extends CIUnitTestCase { protected function setUp(): void @@ -143,9 +144,7 @@ public static function provideReverseRoutingDefaultNamespaceAppController(): ite ]; } - /** - * @dataProvider provideReverseRoutingDefaultNamespaceAppController - */ + #[DataProvider('provideReverseRoutingDefaultNamespaceAppController')] public function testReverseRoutingDefaultNamespaceAppController(string $controller): void { $routes = $this->getCollector(); diff --git a/tests/system/Router/RouteCollectionTest.php b/tests/system/Router/RouteCollectionTest.php index 400f9a99ca29..89959cd5f33e 100644 --- a/tests/system/Router/RouteCollectionTest.php +++ b/tests/system/Router/RouteCollectionTest.php @@ -21,13 +21,14 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Modules; use Config\Routing; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Controllers\Hello; /** * @internal - * - * @group Others */ +#[Group('Others')] final class RouteCollectionTest extends CIUnitTestCase { protected function setUp(): void @@ -485,9 +486,7 @@ static function ($routes): void { $this->assertSame($expected, $routes->getRoutes()); } - /** - * @dataProvider provideNestedGroupingWorksWithRootPrefix - */ + #[DataProvider('provideNestedGroupingWorksWithRootPrefix')] public function testNestedGroupingWorksWithRootPrefix( string $group, string $subgroup, @@ -1323,9 +1322,7 @@ static function (): void {}, $this->assertSame($options, ['as' => 'admin', 'foo' => 'baz']); } - /** - * @dataProvider provideRoutesOptionsWithSameFromTwoRoutes - */ + #[DataProvider('provideRoutesOptionsWithSameFromTwoRoutes')] public function testRoutesOptionsWithSameFromTwoRoutes(array $options1, array $options2): void { $routes = $this->getCollector(); @@ -1772,10 +1769,9 @@ public static function provideRouteDefaultNamespace(): iterable } /** - * @dataProvider provideRouteDefaultNamespace - * * @param mixed $namespace */ + #[DataProvider('provideRouteDefaultNamespace')] public function testAutoRoutesControllerNameReturnsFQCN($namespace): void { $routes = $this->getCollector(); @@ -1793,10 +1789,9 @@ public function testAutoRoutesControllerNameReturnsFQCN($namespace): void } /** - * @dataProvider provideRouteDefaultNamespace - * * @param mixed $namespace */ + #[DataProvider('provideRouteDefaultNamespace')] public function testRoutesControllerNameReturnsFQCN($namespace): void { Services::request()->setMethod(Method::GET); diff --git a/tests/system/Router/RouterTest.php b/tests/system/Router/RouterTest.php index fb71568e8af3..bb5302e721dc 100644 --- a/tests/system/Router/RouterTest.php +++ b/tests/system/Router/RouterTest.php @@ -25,13 +25,14 @@ use Config\App; use Config\Modules; use Config\Routing; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Filters\Customfilter; /** * @internal - * - * @group Others */ +#[Group('Others')] final class RouterTest extends CIUnitTestCase { private RouteCollection $collection; @@ -913,9 +914,7 @@ public function testSetDirectoryInvalid(): void $this->assertSame('', $router->directory()); } - /** - * @dataProvider provideRedirectRoute - */ + #[DataProvider('provideRedirectRoute')] public function testRedirectRoute( string $route, string $redirectFrom, diff --git a/tests/system/Security/CheckPhpIniTest.php b/tests/system/Security/CheckPhpIniTest.php index 9028a676ca90..8636337f2893 100644 --- a/tests/system/Security/CheckPhpIniTest.php +++ b/tests/system/Security/CheckPhpIniTest.php @@ -16,12 +16,12 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockInputOutput; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CheckPhpIniTest extends CIUnitTestCase { public function testCheckIni(): void diff --git a/tests/system/Security/SecurityCSRFCookieRandomizeTokenTest.php b/tests/system/Security/SecurityCSRFCookieRandomizeTokenTest.php index 6ea63b694ddc..459de0a47fa7 100644 --- a/tests/system/Security/SecurityCSRFCookieRandomizeTokenTest.php +++ b/tests/system/Security/SecurityCSRFCookieRandomizeTokenTest.php @@ -22,12 +22,12 @@ use CodeIgniter\Test\Mock\MockAppConfig; use CodeIgniter\Test\Mock\MockSecurity; use Config\Security as SecurityConfig; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class SecurityCSRFCookieRandomizeTokenTest extends CIUnitTestCase { /** diff --git a/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php b/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php index c2d11db26a05..7e8f753d08e0 100644 --- a/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php +++ b/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php @@ -32,17 +32,17 @@ use Config\Logger as LoggerConfig; use Config\Security as SecurityConfig; use Config\Session as SessionConfig; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; use PHPUnit\Framework\Attributes\WithoutErrorHandler; /** - * @runTestsInSeparateProcesses - * - * @preserveGlobalState disabled - * * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] +#[PreserveGlobalState(false)] +#[RunTestsInSeparateProcesses] final class SecurityCSRFSessionRandomizeTokenTest extends CIUnitTestCase { /** diff --git a/tests/system/Security/SecurityCSRFSessionTest.php b/tests/system/Security/SecurityCSRFSessionTest.php index 397932889182..771193bc3171 100644 --- a/tests/system/Security/SecurityCSRFSessionTest.php +++ b/tests/system/Security/SecurityCSRFSessionTest.php @@ -31,16 +31,16 @@ use Config\Logger as LoggerConfig; use Config\Security as SecurityConfig; use Config\Session as SessionConfig; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; /** - * @runTestsInSeparateProcesses - * - * @preserveGlobalState disabled - * * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] +#[PreserveGlobalState(false)] +#[RunTestsInSeparateProcesses] final class SecurityCSRFSessionTest extends CIUnitTestCase { /** diff --git a/tests/system/Security/SecurityTest.php b/tests/system/Security/SecurityTest.php index e8b93cf7ab05..0ccc092e7e29 100644 --- a/tests/system/Security/SecurityTest.php +++ b/tests/system/Security/SecurityTest.php @@ -24,14 +24,14 @@ use CodeIgniter\Test\Mock\MockSecurity; use Config\Security as SecurityConfig; use Config\Services; +use PHPUnit\Framework\Attributes\BackupGlobals; +use PHPUnit\Framework\Attributes\Group; /** - * @backupGlobals enabled - * * @internal - * - * @group Others */ +#[BackupGlobals(true)] +#[Group('Others')] final class SecurityTest extends CIUnitTestCase { protected function setUp(): void diff --git a/tests/system/Session/Handlers/Database/MySQLiHandlerTest.php b/tests/system/Session/Handlers/Database/MySQLiHandlerTest.php index f7f9f855895a..0b364c7f6559 100644 --- a/tests/system/Session/Handlers/Database/MySQLiHandlerTest.php +++ b/tests/system/Session/Handlers/Database/MySQLiHandlerTest.php @@ -15,12 +15,12 @@ use Config\Database as DatabaseConfig; use Config\Session as SessionConfig; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class MySQLiHandlerTest extends AbstractHandlerTestCase { protected function setUp(): void diff --git a/tests/system/Session/Handlers/Database/PostgreHandlerTest.php b/tests/system/Session/Handlers/Database/PostgreHandlerTest.php index deae7988c04c..21fb96b96244 100644 --- a/tests/system/Session/Handlers/Database/PostgreHandlerTest.php +++ b/tests/system/Session/Handlers/Database/PostgreHandlerTest.php @@ -15,12 +15,12 @@ use Config\Database as DatabaseConfig; use Config\Session as SessionConfig; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class PostgreHandlerTest extends AbstractHandlerTestCase { protected function setUp(): void diff --git a/tests/system/Session/Handlers/Database/RedisHandlerTest.php b/tests/system/Session/Handlers/Database/RedisHandlerTest.php index 8d5a76c9be14..f7e3a5558a13 100644 --- a/tests/system/Session/Handlers/Database/RedisHandlerTest.php +++ b/tests/system/Session/Handlers/Database/RedisHandlerTest.php @@ -16,14 +16,15 @@ use CodeIgniter\Session\Handlers\RedisHandler; use CodeIgniter\Test\CIUnitTestCase; use Config\Session as SessionConfig; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; /** - * @group DatabaseLive - * - * @requires extension redis - * * @internal */ +#[Group('DatabaseLive')] +#[RequiresPhpExtension('redis')] final class RedisHandlerTest extends CIUnitTestCase { private string $sessionDriver = RedisHandler::class; @@ -136,9 +137,7 @@ public function testSecondaryReadAfterClose(): void $handler->close(); } - /** - * @dataProvider provideSetSavePath - */ + #[DataProvider('provideSetSavePath')] public function testSetSavePath(string $savePath, array $expected): void { $option = ['savePath' => $savePath]; diff --git a/tests/system/Session/SessionTest.php b/tests/system/Session/SessionTest.php index 63009e5230a0..9faadb66b219 100644 --- a/tests/system/Session/SessionTest.php +++ b/tests/system/Session/SessionTest.php @@ -22,16 +22,16 @@ use Config\Cookie as CookieConfig; use Config\Logger as LoggerConfig; use Config\Session as SessionConfig; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; /** - * @runTestsInSeparateProcesses - * - * @preserveGlobalState disabled - * * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] +#[PreserveGlobalState(false)] +#[RunTestsInSeparateProcesses] final class SessionTest extends CIUnitTestCase { protected function setUp(): void diff --git a/tests/system/SparkTest.php b/tests/system/SparkTest.php index 17a6be99c891..19f5b9934db9 100644 --- a/tests/system/SparkTest.php +++ b/tests/system/SparkTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class SparkTest extends CIUnitTestCase { public function testCanUseOption(): void diff --git a/tests/system/SuperglobalsTest.php b/tests/system/SuperglobalsTest.php index 54ab69958ec4..904e3e913d21 100644 --- a/tests/system/SuperglobalsTest.php +++ b/tests/system/SuperglobalsTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class SuperglobalsTest extends CIUnitTestCase { public function testSetGet(): void diff --git a/tests/system/Test/BootstrapFCPATHTest.php b/tests/system/Test/BootstrapFCPATHTest.php index 9a6976a8b516..61d2e1ca1695 100644 --- a/tests/system/Test/BootstrapFCPATHTest.php +++ b/tests/system/Test/BootstrapFCPATHTest.php @@ -13,6 +13,8 @@ namespace CodeIgniter\Test; +use PHPUnit\Framework\Attributes\Group; + /** * Class BootstrapFCPATHTest * @@ -24,9 +26,8 @@ * from correctFCPATH(); * * @internal - * - * @group Others */ +#[Group('Others')] final class BootstrapFCPATHTest extends CIUnitTestCase { private string $currentDir = __DIR__; diff --git a/tests/system/Test/ControllerTestTraitTest.php b/tests/system/Test/ControllerTestTraitTest.php index 94146215bc13..8708bcce2008 100644 --- a/tests/system/Test/ControllerTestTraitTest.php +++ b/tests/system/Test/ControllerTestTraitTest.php @@ -21,20 +21,20 @@ use Config\App; use Config\Services; use Exception; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; use Tests\Support\Controllers\Newautorouting; use Tests\Support\Controllers\Popcorn; /** * Exercise our Controller class. * - * @runTestsInSeparateProcesses - * - * @preserveGlobalState disabled - * * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] +#[PreserveGlobalState(false)] +#[RunTestsInSeparateProcesses] final class ControllerTestTraitTest extends CIUnitTestCase { use ControllerTestTrait; diff --git a/tests/system/Test/DOMParserTest.php b/tests/system/Test/DOMParserTest.php index 73d38a0e809d..31d9b65342a4 100644 --- a/tests/system/Test/DOMParserTest.php +++ b/tests/system/Test/DOMParserTest.php @@ -13,11 +13,13 @@ namespace CodeIgniter\Test; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; + /** * @internal - * - * @group Others */ +#[Group('Others')] final class DOMParserTest extends CIUnitTestCase { protected function setUp(): void @@ -91,10 +93,9 @@ public static function provideText(): iterable } /** - * @dataProvider provideText - * * @param string $text */ + #[DataProvider('provideText')] public function testSeeText($text): void { $dom = new DOMParser(); @@ -139,10 +140,9 @@ public function testSeeFail(): void } /** - * @dataProvider provideText - * * @param string $text */ + #[DataProvider('provideText')] public function testSeeElement($text): void { $dom = new DOMParser(); diff --git a/tests/system/Test/FabricatorTest.php b/tests/system/Test/FabricatorTest.php index f00cf6f5f81a..46e7f7d95cfe 100644 --- a/tests/system/Test/FabricatorTest.php +++ b/tests/system/Test/FabricatorTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Config\Factories; use CodeIgniter\Model; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Models\EntityModel; use Tests\Support\Models\EventModel; use Tests\Support\Models\FabricatorModel; @@ -23,9 +24,8 @@ /** * @internal - * - * @group Others */ +#[Group('Others')] final class FabricatorTest extends CIUnitTestCase { /** diff --git a/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php b/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php index 568bbb25d05f..3b8703f08ea8 100644 --- a/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php +++ b/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php @@ -16,12 +16,12 @@ use CodeIgniter\Events\Events; use Config\Feature; use Config\Services; +use PHPUnit\Framework\Attributes\Group; /** - * @group Others - * * @internal */ +#[Group('Others')] final class FeatureTestAutoRoutingImprovedTest extends CIUnitTestCase { use FeatureTestTrait; diff --git a/tests/system/Test/FeatureTestTraitTest.php b/tests/system/Test/FeatureTestTraitTest.php index bd746c7a9c57..4fd921d6e9a6 100644 --- a/tests/system/Test/FeatureTestTraitTest.php +++ b/tests/system/Test/FeatureTestTraitTest.php @@ -22,12 +22,13 @@ use Config\App; use Config\Routing; use Config\Services; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** - * @group DatabaseLive - * * @internal */ +#[Group('DatabaseLive')] final class FeatureTestTraitTest extends CIUnitTestCase { use FeatureTestTrait; @@ -359,12 +360,11 @@ public static function provideOpenCliRoutesFromHttpGot404(): iterable } /** - * @dataProvider provideOpenCliRoutesFromHttpGot404 - * * @param mixed $from * @param mixed $to * @param mixed $httpGet */ + #[DataProvider('provideOpenCliRoutesFromHttpGot404')] public function testOpenCliRoutesFromHttpGot404($from, $to, $httpGet): void { $this->expectException(PageNotFoundException::class); diff --git a/tests/system/Test/FilterTestTraitTest.php b/tests/system/Test/FilterTestTraitTest.php index 911a03740f18..233e5c13cd22 100644 --- a/tests/system/Test/FilterTestTraitTest.php +++ b/tests/system/Test/FilterTestTraitTest.php @@ -15,6 +15,7 @@ use CodeIgniter\HTTP\RequestInterface; use Config\Services; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Filters\Customfilter; /** @@ -27,9 +28,8 @@ * - class: \Tests\Support\Filters\Customfilter::class * * @internal - * - * @group Others */ +#[Group('Others')] final class FilterTestTraitTest extends CIUnitTestCase { use FilterTestTrait; diff --git a/tests/system/Test/IniTestTraitTest.php b/tests/system/Test/IniTestTraitTest.php index d577a23deb56..1e958493937f 100644 --- a/tests/system/Test/IniTestTraitTest.php +++ b/tests/system/Test/IniTestTraitTest.php @@ -13,13 +13,13 @@ namespace CodeIgniter\Test; +use PHPUnit\Framework\Attributes\Group; use ReflectionException; /** * @internal - * - * @group Others */ +#[Group('Others')] final class IniTestTraitTest extends CIUnitTestCase { use IniTestTrait; diff --git a/tests/system/Test/ReflectionHelperTest.php b/tests/system/Test/ReflectionHelperTest.php index 324a56c7f285..59afc3411f61 100644 --- a/tests/system/Test/ReflectionHelperTest.php +++ b/tests/system/Test/ReflectionHelperTest.php @@ -13,13 +13,13 @@ namespace CodeIgniter\Test; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Test\TestForReflectionHelper; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ReflectionHelperTest extends CIUnitTestCase { public function testGetPrivatePropertyWithObject(): void diff --git a/tests/system/Test/TestCaseEmissionsTest.php b/tests/system/Test/TestCaseEmissionsTest.php index 26d7ee7898d3..e46a4bf5581d 100644 --- a/tests/system/Test/TestCaseEmissionsTest.php +++ b/tests/system/Test/TestCaseEmissionsTest.php @@ -15,6 +15,9 @@ use CodeIgniter\HTTP\Response; use Config\App; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; /** * This test suite has been created separately from @@ -23,9 +26,8 @@ * test cases need to be run as separate processes. * * @internal - * - * @group SeparateProcess */ +#[Group('SeparateProcess')] final class TestCaseEmissionsTest extends CIUnitTestCase { /** @@ -41,11 +43,8 @@ final class TestCaseEmissionsTest extends CIUnitTestCase * The tests includes a basic sanity check, to make sure that * the body we thought would be sent actually was. */ - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testHeadersEmitted(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. @@ -74,10 +73,8 @@ public function testHeadersEmitted(): void $this->assertHeaderEmitted('set-cookie: FOO=bar', true); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testHeadersNotEmitted(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. diff --git a/tests/system/Test/TestCaseTest.php b/tests/system/Test/TestCaseTest.php index 6521029636d3..6905d825533a 100644 --- a/tests/system/Test/TestCaseTest.php +++ b/tests/system/Test/TestCaseTest.php @@ -15,13 +15,13 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\Events\Events; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Test\TestForReflectionHelper; /** * @internal - * - * @group Others */ +#[Group('Others')] final class TestCaseTest extends CIUnitTestCase { use StreamFilterTrait; diff --git a/tests/system/Test/TestLoggerTest.php b/tests/system/Test/TestLoggerTest.php index facf492c83b6..4c9f38df0dad 100644 --- a/tests/system/Test/TestLoggerTest.php +++ b/tests/system/Test/TestLoggerTest.php @@ -14,17 +14,16 @@ namespace CodeIgniter\Test; use Config\Logger; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class TestLoggerTest extends CIUnitTestCase { - /** - * @dataProvider provideDidLogMethod - */ + #[DataProvider('provideDidLogMethod')] public function testDidLogMethod(bool $expected, string $level, string $message, bool $exact): void { (new TestLogger(new Logger()))->log('error', 'Some variable did not contain a value.'); diff --git a/tests/system/Test/TestResponseTest.php b/tests/system/Test/TestResponseTest.php index 3157a31b18d5..7fedf05bab65 100644 --- a/tests/system/Test/TestResponseTest.php +++ b/tests/system/Test/TestResponseTest.php @@ -18,12 +18,13 @@ use Config\App; use Config\Services; use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class TestResponseTest extends CIUnitTestCase { private ?TestResponse $testResponse = null; @@ -34,9 +35,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @dataProvider provideHttpStatusCodes - */ + #[DataProvider('provideHttpStatusCodes')] public function testIsOK(int $code, bool $isOk): void { $this->getTestResponse('Hello World'); @@ -224,9 +223,7 @@ public function testAssertStatus(): void $this->testResponse->assertStatus(201); } - /** - * @dataProvider provideHttpStatusCodes - */ + #[DataProvider('provideHttpStatusCodes')] public function testAssertIsOK(int $code, bool $isOk): void { $this->getTestResponse('

Hello World

', ['statusCode' => $code]); diff --git a/tests/system/Throttle/ThrottleTest.php b/tests/system/Throttle/ThrottleTest.php index 683d1ad50145..655cc21dfcfa 100644 --- a/tests/system/Throttle/ThrottleTest.php +++ b/tests/system/Throttle/ThrottleTest.php @@ -16,12 +16,13 @@ use CodeIgniter\Cache\CacheInterface; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockCache; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ThrottleTest extends CIUnitTestCase { private CacheInterface $cache; @@ -190,9 +191,7 @@ public function testFlooding(): void $this->assertEqualsWithDelta(10.0, round($this->cache->get('throttler_127.0.0.1')), PHP_FLOAT_EPSILON); } - /** - * @dataProvider provideTokenTimeCalculationUCs - */ + #[DataProvider('provideTokenTimeCalculationUCs')] public function testTokenTimeCalculationUCs(int $capacity, int $seconds, array $checkInputs): void { $key = 'testkey'; diff --git a/tests/system/Typography/TypographyTest.php b/tests/system/Typography/TypographyTest.php index 23547a6e0a0e..aa46e639e180 100644 --- a/tests/system/Typography/TypographyTest.php +++ b/tests/system/Typography/TypographyTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter\Typography; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class TypographyTest extends CIUnitTestCase { private Typography $typography; diff --git a/tests/system/Validation/CreditCardRulesTest.php b/tests/system/Validation/CreditCardRulesTest.php index 911365538e57..9e6b58cdc192 100644 --- a/tests/system/Validation/CreditCardRulesTest.php +++ b/tests/system/Validation/CreditCardRulesTest.php @@ -15,13 +15,14 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Services; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CreditCardRulesTest extends CIUnitTestCase { private Validation $validation; @@ -50,9 +51,7 @@ protected function setUp(): void $this->validation->reset(); } - /** - * @dataProvider provideValidCCNumber - */ + #[DataProvider('provideValidCCNumber')] public function testValidCCNumber(string $type, ?string $number, bool $expected): void { $data = ['cc' => $number]; diff --git a/tests/system/Validation/DatabaseRelatedRulesTest.php b/tests/system/Validation/DatabaseRelatedRulesTest.php index d8795fac46c4..d683320e968b 100644 --- a/tests/system/Validation/DatabaseRelatedRulesTest.php +++ b/tests/system/Validation/DatabaseRelatedRulesTest.php @@ -14,13 +14,13 @@ namespace CodeIgniter\Validation; use CodeIgniter\Validation\StrictRules\DatabaseRelatedRulesTest as StrictDatabaseRelatedRulesTest; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; /** * @internal - * - * @group DatabaseLive */ +#[Group('DatabaseLive')] final class DatabaseRelatedRulesTest extends StrictDatabaseRelatedRulesTest { protected array $config = [ diff --git a/tests/system/Validation/DotArrayFilterTest.php b/tests/system/Validation/DotArrayFilterTest.php index 67274860ed35..e83b4fe9e566 100644 --- a/tests/system/Validation/DotArrayFilterTest.php +++ b/tests/system/Validation/DotArrayFilterTest.php @@ -14,12 +14,12 @@ namespace CodeIgniter\Validation; use CodeIgniter\Test\CIUnitTestCase; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class DotArrayFilterTest extends CIUnitTestCase { public function testRunReturnEmptyArray(): void diff --git a/tests/system/Validation/FileRulesTest.php b/tests/system/Validation/FileRulesTest.php index a29c95c18add..6d59af537a06 100644 --- a/tests/system/Validation/FileRulesTest.php +++ b/tests/system/Validation/FileRulesTest.php @@ -16,13 +16,13 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Services; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FileRulesTest extends CIUnitTestCase { private Validation $validation; diff --git a/tests/system/Validation/FormatRulesTest.php b/tests/system/Validation/FormatRulesTest.php index 75d0cc968135..a952e25f8e7b 100644 --- a/tests/system/Validation/FormatRulesTest.php +++ b/tests/system/Validation/FormatRulesTest.php @@ -16,15 +16,16 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Services; use Generator; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; /** * @internal * - * @group Others - * * @no-final */ +#[Group('Others')] class FormatRulesTest extends CIUnitTestCase { public const ALPHABET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHLIJKLMNOPQRSTUVWXYZ'; @@ -86,9 +87,7 @@ public function testRegexMatchFalse(): void $this->assertFalse($this->validation->run($data)); } - /** - * @dataProvider provideValidUrl - */ + #[DataProvider('provideValidUrl')] public function testValidURL(?string $url, bool $isLoose, bool $isStrict): void { $data = [ @@ -102,9 +101,7 @@ public function testValidURL(?string $url, bool $isLoose, bool $isStrict): void $this->assertSame($isLoose, $this->validation->run($data)); } - /** - * @dataProvider provideValidUrl - */ + #[DataProvider('provideValidUrl')] public function testValidURLStrict(?string $url, bool $isLoose, bool $isStrict): void { $data = [ @@ -230,9 +227,7 @@ public static function provideValidUrl(): iterable ]; } - /** - * @dataProvider provideValidEmail - */ + #[DataProvider('provideValidEmail')] public function testValidEmail(?string $email, bool $expected): void { $data = [ @@ -246,9 +241,7 @@ public function testValidEmail(?string $email, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } - /** - * @dataProvider provideValidEmails - */ + #[DataProvider('provideValidEmails')] public function testValidEmails(?string $email, bool $expected): void { $data = [ @@ -310,9 +303,7 @@ public static function provideValidEmails(): iterable ]; } - /** - * @dataProvider provideValidIP - */ + #[DataProvider('provideValidIP')] public function testValidIP(?string $ip, ?string $which, bool $expected): void { $data = [ @@ -378,10 +369,9 @@ public static function provideValidIP(): iterable } /** - * @dataProvider provideString - * * @param int|string $str */ + #[DataProvider('provideString')] public function testString($str, bool $expected): void { $data = [ @@ -413,9 +403,7 @@ public static function provideString(): iterable ]; } - /** - * @dataProvider provideAlpha - */ + #[DataProvider('provideAlpha')] public function testAlpha(?string $str, bool $expected): void { $data = [ @@ -455,9 +443,7 @@ public static function provideAlpha(): iterable ]; } - /** - * @dataProvider provideAlphaSpace - */ + #[DataProvider('provideAlphaSpace')] public function testAlphaSpace(?string $value, bool $expected): void { $data = [ @@ -501,9 +487,7 @@ public static function provideAlphaSpace(): iterable ]; } - /** - * @dataProvider alphaNumericProvider - */ + #[DataProvider('alphaNumericProvider')] public function testAlphaNumeric(?string $str, bool $expected): void { $data = [ @@ -539,9 +523,7 @@ public static function alphaNumericProvider(): iterable ]; } - /** - * @dataProvider provideAlphaNumericPunct - */ + #[DataProvider('provideAlphaNumericPunct')] public function testAlphaNumericPunct(?string $str, bool $expected): void { $data = [ @@ -633,9 +615,7 @@ public static function provideAlphaNumericPunct(): iterable ]; } - /** - * @dataProvider alphaNumericProvider - */ + #[DataProvider('alphaNumericProvider')] public function testAlphaNumericSpace(?string $str, bool $expected): void { $data = [ @@ -671,9 +651,7 @@ public function alphaNumericSpaceProvider(): Generator ]; } - /** - * @dataProvider provideAlphaDash - */ + #[DataProvider('provideAlphaDash')] public function testAlphaDash(?string $str, bool $expected): void { $data = [ @@ -709,9 +687,7 @@ public static function provideAlphaDash(): iterable ]; } - /** - * @dataProvider provideHex - */ + #[DataProvider('provideHex')] public function testHex(?string $str, bool $expected): void { $data = [ @@ -747,9 +723,7 @@ public static function provideHex(): iterable ]; } - /** - * @dataProvider provideNumeric - */ + #[DataProvider('provideNumeric')] public function testNumeric(?string $str, bool $expected): void { $data = [ @@ -804,10 +778,9 @@ public static function provideNumeric(): iterable /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/5374 * - * @dataProvider provideInvalidIntegerType - * * @param mixed $value */ + #[DataProvider('provideInvalidIntegerType')] public function testIntegerWithInvalidTypeData($value, bool $expected): void { $this->validation->setRules([ @@ -823,10 +796,9 @@ public function testIntegerWithInvalidTypeData($value, bool $expected): void /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/5374 * - * @dataProvider provideInvalidIntegerType - * * @param mixed $value */ + #[DataProvider('provideInvalidIntegerType')] public function testNumericWithInvalidTypeData($value, bool $expected): void { $this->validation->setRules([ @@ -869,9 +841,7 @@ public static function provideInvalidIntegerType(): iterable ]; } - /** - * @dataProvider provideInteger - */ + #[DataProvider('provideInteger')] public function testInteger(?string $str, bool $expected): void { $data = [ @@ -923,9 +893,7 @@ public static function provideInteger(): iterable ]; } - /** - * @dataProvider provideDecimal - */ + #[DataProvider('provideDecimal')] public function testDecimal(?string $str, bool $expected): void { $data = [ @@ -981,9 +949,7 @@ public static function provideDecimal(): iterable ]; } - /** - * @dataProvider provideNatural - */ + #[DataProvider('provideNatural')] public function testNatural(?string $str, bool $expected): void { $data = [ @@ -1023,9 +989,7 @@ public static function provideNatural(): iterable ]; } - /** - * @dataProvider provideNaturalNoZero - */ + #[DataProvider('provideNaturalNoZero')] public function testNaturalNoZero(?string $str, bool $expected): void { $data = [ @@ -1065,9 +1029,7 @@ public static function provideNaturalNoZero(): iterable ]; } - /** - * @dataProvider provideBase64 - */ + #[DataProvider('provideBase64')] public function testBase64(?string $str, bool $expected): void { $data = [ @@ -1099,9 +1061,7 @@ public static function provideBase64(): iterable ]; } - /** - * @dataProvider provideJson - */ + #[DataProvider('provideJson')] public function testJson(?string $str, bool $expected): void { $data = [ @@ -1157,9 +1117,7 @@ public static function provideJson(): iterable ]; } - /** - * @dataProvider provideTimeZone - */ + #[DataProvider('provideTimeZone')] public function testTimeZone(?string $str, bool $expected): void { $data = [ @@ -1195,9 +1153,7 @@ public static function provideTimeZone(): iterable ]; } - /** - * @dataProvider provideValidDate - */ + #[DataProvider('provideValidDate')] public function testValidDate(?string $str, ?string $format, bool $expected): void { $data = [ diff --git a/tests/system/Validation/RulesTest.php b/tests/system/Validation/RulesTest.php index 54b0756c094c..25b3510323bb 100644 --- a/tests/system/Validation/RulesTest.php +++ b/tests/system/Validation/RulesTest.php @@ -15,16 +15,17 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Services; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use stdClass; use Tests\Support\Validation\TestRules; /** * @internal * - * @group Others - * * @no-final */ +#[Group('Others')] class RulesTest extends CIUnitTestCase { protected Validation $validation; @@ -54,9 +55,7 @@ protected function setUp(): void $this->validation->reset(); } - /** - * @dataProvider provideRequired - */ + #[DataProvider('provideRequired')] public function testRequired(array $data, bool $expected): void { $this->validation->setRules(['foo' => 'required']); @@ -76,9 +75,7 @@ public static function provideRequired(): iterable ]; } - /** - * @dataProvider provideIfExist - */ + #[DataProvider('provideIfExist')] public function testIfExist(array $rules, array $data, bool $expected): void { $this->validation->setRules($rules); @@ -129,9 +126,7 @@ public static function provideIfExist(): iterable ]; } - /** - * @dataProvider providePermitEmpty - */ + #[DataProvider('providePermitEmpty')] public function testPermitEmpty(array $rules, array $data, bool $expected): void { $this->validation->setRules($rules); @@ -298,9 +293,7 @@ public static function providePermitEmpty(): iterable ]; } - /** - * @dataProvider provideMatches - */ + #[DataProvider('provideMatches')] public function testMatches(array $data, bool $expected): void { $this->validation->setRules(['foo' => 'matches[bar]']); @@ -322,9 +315,7 @@ public static function provideMatches(): iterable ]; } - /** - * @dataProvider provideMatchesNestedCases - */ + #[DataProvider('provideMatchesNestedCases')] public function testMatchesNested(array $data, bool $expected): void { $this->validation->setRules(['nested.foo' => 'matches[nested.bar]']); @@ -339,9 +330,7 @@ public static function provideMatchesNestedCases(): iterable ]; } - /** - * @dataProvider provideDiffers - */ + #[DataProvider('provideDiffers')] public function testDiffers(array $data, bool $expected): void { $this->validation->setRules(['foo' => 'differs[bar]']); @@ -363,18 +352,14 @@ public static function provideDiffers(): iterable ]; } - /** - * @dataProvider provideMatchesNestedCases - */ + #[DataProvider('provideMatchesNestedCases')] public function testDiffersNested(array $data, bool $expected): void { $this->validation->setRules(['nested.foo' => 'differs[nested.bar]']); $this->assertSame(! $expected, $this->validation->run($data)); } - /** - * @dataProvider provideEquals - */ + #[DataProvider('provideEquals')] public function testEquals(array $data, string $param, bool $expected): void { $this->validation->setRules(['foo' => "equals[{$param}]"]); @@ -392,9 +377,7 @@ public static function provideEquals(): iterable ]; } - /** - * @dataProvider provideMinLengthCases - */ + #[DataProvider('provideMinLengthCases')] public function testMinLength(?string $data, string $length, bool $expected): void { $this->validation->setRules(['foo' => "min_length[{$length}]"]); @@ -411,9 +394,7 @@ public static function provideMinLengthCases(): iterable ]; } - /** - * @dataProvider provideMinLengthCases - */ + #[DataProvider('provideMinLengthCases')] public function testMaxLength(?string $data, string $length, bool $expected): void { $this->validation->setRules(['foo' => "max_length[{$length}]"]); @@ -427,10 +408,9 @@ public function testMaxLengthReturnsFalseWithNonNumericVal(): void } /** - * @dataProvider provideExactLength - * * @param int|string|null $data */ + #[DataProvider('provideExactLength')] public function testExactLength($data, bool $expected): void { $this->validation->setRules(['foo' => 'exact_length[3]']); @@ -457,9 +437,7 @@ public function testExactLengthDetectsBadLength(): void $this->assertFalse($this->validation->run($data)); } - /** - * @dataProvider provideGreaterThan - */ + #[DataProvider('provideGreaterThan')] public function testGreaterThan(?string $first, ?string $second, bool $expected): void { $data = ['foo' => $first]; @@ -482,9 +460,7 @@ public static function provideGreaterThan(): iterable ]; } - /** - * @dataProvider provideGreaterThanEqual - */ + #[DataProvider('provideGreaterThanEqual')] public function testGreaterThanEqual(?string $first, ?string $second, bool $expected): void { $data = ['foo' => $first]; @@ -508,9 +484,7 @@ public static function provideGreaterThanEqual(): iterable ]; } - /** - * @dataProvider provideLessThan - */ + #[DataProvider('provideLessThan')] public function testLessThan(?string $first, ?string $second, bool $expected): void { $data = ['foo' => $first]; @@ -534,9 +508,7 @@ public static function provideLessThan(): iterable ]; } - /** - * @dataProvider provideLessThanEqual - */ + #[DataProvider('provideLessThanEqual')] public function testLessThanEqual(?string $first, ?string $second, bool $expected): void { $data = ['foo' => $first]; @@ -560,9 +532,7 @@ public static function provideLessThanEqual(): iterable ]; } - /** - * @dataProvider provideInList - */ + #[DataProvider('provideInList')] public function testInList(?string $first, ?string $second, bool $expected): void { $data = ['foo' => $first]; @@ -570,9 +540,7 @@ public function testInList(?string $first, ?string $second, bool $expected): voi $this->assertSame($expected, $this->validation->run($data)); } - /** - * @dataProvider provideInList - */ + #[DataProvider('provideInList')] public function testNotInList(?string $first, ?string $second, bool $expected): void { $data = ['foo' => $first]; @@ -595,9 +563,7 @@ public static function provideInList(): iterable ]; } - /** - * @dataProvider provideRequiredWith - */ + #[DataProvider('provideRequiredWith')] public function testRequiredWith(?string $field, ?string $check, bool $expected): void { $data = [ @@ -650,9 +616,8 @@ public static function provideRequiredWith(): iterable /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/7557 - * - * @dataProvider provideRequiredWithAndOtherRules */ + #[DataProvider('provideRequiredWithAndOtherRules')] public function testRequiredWithAndOtherRules(bool $expected, array $data): void { $this->validation->setRules([ @@ -686,9 +651,7 @@ public static function provideRequiredWithAndOtherRules(): iterable ]; } - /** - * @dataProvider provideRequiredWithAndOtherRuleWithValueZero - */ + #[DataProvider('provideRequiredWithAndOtherRuleWithValueZero')] public function testRequiredWithAndOtherRuleWithValueZero(bool $expected, array $data): void { $this->validation->setRules([ @@ -710,9 +673,7 @@ public static function provideRequiredWithAndOtherRuleWithValueZero(): iterable ]; } - /** - * @dataProvider provideRequiredWithout - */ + #[DataProvider('provideRequiredWithout')] public function testRequiredWithout(?string $field, ?string $check, bool $expected): void { $data = [ @@ -762,9 +723,7 @@ public static function provideRequiredWithout(): iterable ]; } - /** - * @dataProvider provideRequiredWithoutMultiple - */ + #[DataProvider('provideRequiredWithoutMultiple')] public function testRequiredWithoutMultiple(string $foo, string $bar, string $baz, bool $result): void { $this->validation->setRules(['foo' => 'required_without[bar,baz]']); @@ -813,9 +772,7 @@ public static function provideRequiredWithoutMultiple(): iterable ]; } - /** - * @dataProvider provideRequiredWithoutMultipleWithoutFields - */ + #[DataProvider('provideRequiredWithoutMultipleWithoutFields')] public function testRequiredWithoutMultipleWithoutFields(array $data, bool $result): void { $this->validation->setRules(['foo' => 'required_without[bar,baz]']); @@ -855,9 +812,7 @@ public static function provideRequiredWithoutMultipleWithoutFields(): iterable ]; } - /** - * @dataProvider provideFieldExists - */ + #[DataProvider('provideFieldExists')] public function testFieldExists(array $rules, array $data, bool $expected): void { $this->validation->setRules($rules); diff --git a/tests/system/Validation/StrictRules/CreditCardRulesTest.php b/tests/system/Validation/StrictRules/CreditCardRulesTest.php index 754de75a67e6..4705cdcb9c90 100644 --- a/tests/system/Validation/StrictRules/CreditCardRulesTest.php +++ b/tests/system/Validation/StrictRules/CreditCardRulesTest.php @@ -16,13 +16,14 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Validation\Validation; use Config\Services; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CreditCardRulesTest extends CIUnitTestCase { private Validation $validation; @@ -51,9 +52,7 @@ protected function setUp(): void $this->validation->reset(); } - /** - * @dataProvider provideValidCCNumber - */ + #[DataProvider('provideValidCCNumber')] public function testValidCCNumber(string $type, ?string $number, bool $expected): void { $data = ['cc' => $number]; diff --git a/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php b/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php index c584b572266d..1535d265f729 100644 --- a/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php +++ b/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php @@ -20,15 +20,15 @@ use Config\Services; use InvalidArgumentException; use LogicException; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; /** * @internal * * @no-final - * - * @group DatabaseLive */ +#[Group('DatabaseLive')] class DatabaseRelatedRulesTest extends CIUnitTestCase { use DatabaseTestTrait; diff --git a/tests/system/Validation/StrictRules/FileRulesTest.php b/tests/system/Validation/StrictRules/FileRulesTest.php index d6c20dfaef6c..07dfc44ad8ce 100644 --- a/tests/system/Validation/StrictRules/FileRulesTest.php +++ b/tests/system/Validation/StrictRules/FileRulesTest.php @@ -17,13 +17,13 @@ use CodeIgniter\Validation\Validation; use Config\Services; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FileRulesTest extends CIUnitTestCase { private Validation $validation; diff --git a/tests/system/Validation/StrictRules/FormatRulesTest.php b/tests/system/Validation/StrictRules/FormatRulesTest.php index b6bc2d55bed4..998f8f324a16 100644 --- a/tests/system/Validation/StrictRules/FormatRulesTest.php +++ b/tests/system/Validation/StrictRules/FormatRulesTest.php @@ -14,13 +14,13 @@ namespace CodeIgniter\Validation\StrictRules; use CodeIgniter\Validation\FormatRulesTest as TraditionalFormatRulesTest; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; /** * @internal - * - * @group Others */ +#[Group('Others')] final class FormatRulesTest extends TraditionalFormatRulesTest { protected array $config = [ diff --git a/tests/system/Validation/StrictRules/RulesTest.php b/tests/system/Validation/StrictRules/RulesTest.php index e4a767421054..e211ed38e888 100644 --- a/tests/system/Validation/StrictRules/RulesTest.php +++ b/tests/system/Validation/StrictRules/RulesTest.php @@ -15,13 +15,14 @@ use CodeIgniter\Validation\RulesTest as TraditionalRulesTest; use CodeIgniter\Validation\Validation; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; /** * @internal - * - * @group Others */ +#[Group('Others')] final class RulesTest extends TraditionalRulesTest { protected Validation $validation; @@ -43,9 +44,7 @@ final class RulesTest extends TraditionalRulesTest ], ]; - /** - * @dataProvider providePermitEmptyStrict - */ + #[DataProvider('providePermitEmptyStrict')] public function testPermitEmptyStrict(array $rules, array $data, bool $expected): void { $this->validation->setRules($rules); @@ -100,10 +99,9 @@ public static function providePermitEmptyStrict(): iterable } /** - * @dataProvider provideGreaterThanEqualStrict - * * @param int $value */ + #[DataProvider('provideGreaterThanEqualStrict')] public function testGreaterThanEqualStrict($value, string $param, bool $expected): void { $this->validation->setRules(['foo' => "greater_than_equal_to[{$param}]"]); @@ -126,10 +124,9 @@ public static function provideGreaterThanEqualStrict(): iterable } /** - * @dataProvider provideGreaterThanStrict - * * @param int $value */ + #[DataProvider('provideGreaterThanStrict')] public function testGreaterThanStrict($value, string $param, bool $expected): void { $this->validation->setRules(['foo' => "greater_than[{$param}]"]); @@ -153,10 +150,9 @@ public static function provideGreaterThanStrict(): iterable } /** - * @dataProvider provideLessThanStrict - * * @param int $value */ + #[DataProvider('provideLessThanStrict')] public function testLessThanStrict($value, string $param, bool $expected): void { $this->validation->setRules(['foo' => "less_than[{$param}]"]); @@ -181,10 +177,9 @@ public static function provideLessThanStrict(): iterable } /** - * @dataProvider provideLessEqualThanStrict - * * @param int $value */ + #[DataProvider('provideLessEqualThanStrict')] public function testLessEqualThanStrict($value, ?string $param, bool $expected): void { $this->validation->setRules(['foo' => "less_than_equal_to[{$param}]"]); @@ -206,9 +201,7 @@ public static function provideLessEqualThanStrict(): iterable ]; } - /** - * @dataProvider provideMatches - */ + #[DataProvider('provideMatches')] public function testMatches(array $data, bool $expected): void { $this->validation->setRules(['foo' => 'matches[bar]']); @@ -230,9 +223,7 @@ public static function provideMatches(): iterable ]; } - /** - * @dataProvider provideDiffers - */ + #[DataProvider('provideDiffers')] public function testDiffers(array $data, bool $expected): void { $this->validation->setRules(['foo' => 'differs[bar]']); diff --git a/tests/system/Validation/StrictRules/ValidationTest.php b/tests/system/Validation/StrictRules/ValidationTest.php index 3e6a1d0b5a1e..ca0160ee44e2 100644 --- a/tests/system/Validation/StrictRules/ValidationTest.php +++ b/tests/system/Validation/StrictRules/ValidationTest.php @@ -14,13 +14,13 @@ namespace CodeIgniter\Validation\StrictRules; use CodeIgniter\Validation\ValidationTest as TraditionalValidationTest; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ValidationTest extends TraditionalValidationTest { protected static array $config = [ diff --git a/tests/system/Validation/ValidationTest.php b/tests/system/Validation/ValidationTest.php index f47e62b0f319..b5493a682c8e 100644 --- a/tests/system/Validation/ValidationTest.php +++ b/tests/system/Validation/ValidationTest.php @@ -21,6 +21,8 @@ use CodeIgniter\Validation\Exceptions\ValidationException; use Config\App; use Config\Services; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\ExpectationFailedException; use Tests\Support\Validation\TestRules; use Throwable; @@ -29,10 +31,9 @@ /** * @internal * - * @group Others - * * @no-final */ +#[Group('Others')] class ValidationTest extends CIUnitTestCase { protected Validation $validation; @@ -190,10 +191,9 @@ public function testSetRuleOverwritesRuleReverse(): void } /** - * @dataProvider provideSetRuleRulesFormat - * * @param mixed $rules */ + #[DataProvider('provideSetRuleRulesFormat')] public function testSetRuleRulesFormat(bool $expected, $rules): void { if (! $expected) { @@ -445,10 +445,9 @@ public function testCallableRuleWithLabel(): void /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/5368 * - * @dataProvider provideCanValidatetArrayData - * * @param mixed $value */ + #[DataProvider('provideCanValidatetArrayData')] public function testCanValidatetArrayData($value, bool $expected): void { $data = []; @@ -498,10 +497,9 @@ public static function provideCanValidatetArrayData(): iterable /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/5374 * - * @dataProvider provideIsIntWithInvalidTypeData - * * @param mixed $value */ + #[DataProvider('provideIsIntWithInvalidTypeData')] public function testIsIntWithInvalidTypeData($value, bool $expected): void { $this->validation->setRules(['foo' => 'is_int']); @@ -735,11 +733,10 @@ public function testRunWithCustomErrorsAndAsteriskField(): void } /** - * @dataProvider provideRulesSetup - * * @param list|string $rules * @param string $expected */ + #[DataProvider('provideRulesSetup')] public function testRulesSetup($rules, $expected, array $errors = []): void { $data = ['foo' => '']; @@ -1132,9 +1129,7 @@ public function testRulesForObjectField(): void ], $this->validation->getErrors()); } - /** - * @dataProvider provideRulesForArrayField - */ + #[DataProvider('provideRulesForArrayField')] public function testRulesForArrayField(array $body, array $rules, array $results): void { $config = new App(); @@ -1373,10 +1368,9 @@ public function testTranslatedLabelTagReplacement(): void } /** - * @dataProvider provideIfExistRuleWithAsterisk - * * @see https://github.com/codeigniter4/CodeIgniter4/issues/4521 */ + #[DataProvider('provideIfExistRuleWithAsterisk')] public function testIfExistRuleWithAsterisk(bool $expected, array $rules, array $data): void { $actual = $this->validation->setRules($rules)->run($data); @@ -1443,10 +1437,9 @@ public static function provideIfExistRuleWithAsterisk(): iterable } /** - * @dataProvider provideValidationOfArrayData - * * @see https://github.com/codeigniter4/CodeIgniter4/issues/4510 */ + #[DataProvider('provideValidationOfArrayData')] public function testValidationOfArrayData(bool $expected, array $rules, array $data): void { $actual = $this->validation->setRules($rules)->run($data); @@ -1499,10 +1492,9 @@ public static function provideValidationOfArrayData(): iterable } /** - * @dataProvider provideSplittingOfComplexStringRules - * * @see https://github.com/codeigniter4/CodeIgniter4/issues/4929 */ + #[DataProvider('provideSplittingOfComplexStringRules')] public function testSplittingOfComplexStringRules(string $input, array $expected): void { $splitter = $this->getPrivateMethodInvoker($this->validation, 'splitRules'); diff --git a/tests/system/View/CellTest.php b/tests/system/View/CellTest.php index dd400e4ef7e8..27dd6512d174 100644 --- a/tests/system/View/CellTest.php +++ b/tests/system/View/CellTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockCache; use CodeIgniter\View\Exceptions\ViewException; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class CellTest extends CIUnitTestCase { private MockCache $cache; diff --git a/tests/system/View/ControlledCellTest.php b/tests/system/View/ControlledCellTest.php index 9da6d1162b85..8448aed22ced 100644 --- a/tests/system/View/ControlledCellTest.php +++ b/tests/system/View/ControlledCellTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\View\Exceptions\ViewException; use LogicException; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\View\Cells\AdditionCell; use Tests\Support\View\Cells\AwesomeCell; use Tests\Support\View\Cells\BadCell; @@ -29,9 +30,8 @@ /** * @internal - * - * @group Others */ +#[Group('Others')] final class ControlledCellTest extends CIUnitTestCase { public function testCellRendersDefaultValues(): void diff --git a/tests/system/View/DecoratorsTest.php b/tests/system/View/DecoratorsTest.php index 225b10d18462..6964575dd5c3 100644 --- a/tests/system/View/DecoratorsTest.php +++ b/tests/system/View/DecoratorsTest.php @@ -18,14 +18,14 @@ use CodeIgniter\Config\Services; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\View\Exceptions\ViewException; +use PHPUnit\Framework\Attributes\Group; use Tests\Support\View\BadDecorator; use Tests\Support\View\WorldDecorator; /** * @internal - * - * @group Others */ +#[Group('Others')] final class DecoratorsTest extends CIUnitTestCase { private FileLocator $loader; diff --git a/tests/system/View/ParserFilterTest.php b/tests/system/View/ParserFilterTest.php index 497dab64455e..c11310299cc0 100644 --- a/tests/system/View/ParserFilterTest.php +++ b/tests/system/View/ParserFilterTest.php @@ -17,12 +17,12 @@ use CodeIgniter\Config\Services; use CodeIgniter\Test\CIUnitTestCase; use Config\View; +use PHPUnit\Framework\Attributes\Group; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ParserFilterTest extends CIUnitTestCase { private FileLocator $loader; diff --git a/tests/system/View/ParserPluginTest.php b/tests/system/View/ParserPluginTest.php index 9d6b97dec716..e37aab0e2309 100644 --- a/tests/system/View/ParserPluginTest.php +++ b/tests/system/View/ParserPluginTest.php @@ -16,12 +16,14 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Validation\Validation; use Config\Services; +use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ParserPluginTest extends CIUnitTestCase { private Parser $parser; @@ -44,12 +46,9 @@ public function testCurrentURL(): void $this->assertSame(current_url(), $this->parser->renderString($template)); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - * - * @group SeparateProcess - */ + #[Group('SeparateProcess')] + #[PreserveGlobalState(false)] + #[RunInSeparateProcess] public function testPreviousURL(): void { // Workaround for errors on PHPUnit 10 and PHP 8.3. diff --git a/tests/system/View/ParserTest.php b/tests/system/View/ParserTest.php index e724edc1d4eb..0cce9f722ebf 100644 --- a/tests/system/View/ParserTest.php +++ b/tests/system/View/ParserTest.php @@ -19,13 +19,14 @@ use CodeIgniter\View\Exceptions\ViewException; use Config\Services; use Config\View as ViewConfig; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use stdClass; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ParserTest extends CIUnitTestCase { private FileLocator $loader; @@ -477,11 +478,10 @@ public static function provideEscHandling(): iterable } /** - * @dataProvider provideEscHandling - * * @param mixed $value * @param mixed|null $expected */ + #[DataProvider('provideEscHandling')] public function testEscHandling($value, $expected = null): void { if ($expected === null) { diff --git a/tests/system/View/TableTest.php b/tests/system/View/TableTest.php index 2dfe08cae3a5..97fb1e2ed1a9 100644 --- a/tests/system/View/TableTest.php +++ b/tests/system/View/TableTest.php @@ -16,13 +16,15 @@ use CodeIgniter\Database\MySQLi\Result; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockTable; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\Attributes\Group; use stdClass; /** * @internal - * - * @group Others */ +#[Group('Others')] final class TableTest extends CIUnitTestCase { private Table $table; @@ -58,9 +60,7 @@ public function testSetCaption(): void $this->assertSame('awesome cap', $this->table->caption); } - /** - * @depends testPrepArgs - */ + #[Depends('testPrepArgs')] public function testSetHeading(): void { // uses _prep_args internally, so we'll just do a quick @@ -150,9 +150,7 @@ public function testSetFootingWithStyle(): void ); } - /** - * @depends testPrepArgs - */ + #[Depends('testPrepArgs')] public function testAddRow(): void { // uses _prep_args internally, so we'll just do a quick @@ -783,9 +781,7 @@ public function testInvalidCallback(): void $this->assertStringContainsString('FredBlueSmall', $generated); } - /** - * @dataProvider orderedColumnUsecases - */ + #[DataProvider('orderedColumnUsecases')] public function testAddRowAndGenerateOrderedColumns(array $heading, array $row, string $expectContainsString): void { $this->table->setHeading($heading); @@ -797,9 +793,7 @@ public function testAddRowAndGenerateOrderedColumns(array $heading, array $row, $this->assertStringContainsString($expectContainsString, $generated); } - /** - * @dataProvider orderedColumnUsecases - */ + #[DataProvider('orderedColumnUsecases')] public function testGenerateOrderedColumns(array $heading, array $row, string $expectContainsString): void { $this->table->setHeading($heading); diff --git a/tests/system/View/ViewTest.php b/tests/system/View/ViewTest.php index 996db86be92a..d1455a604f1b 100644 --- a/tests/system/View/ViewTest.php +++ b/tests/system/View/ViewTest.php @@ -18,13 +18,13 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\View\Exceptions\ViewException; use Config; +use PHPUnit\Framework\Attributes\Group; use RuntimeException; /** * @internal - * - * @group Others */ +#[Group('Others')] final class ViewTest extends CIUnitTestCase { private FileLocator $loader; diff --git a/user_guide_src/source/_static/css/citheme.css b/user_guide_src/source/_static/css/citheme.css index 3410fbc5cbb2..fae4909dd62c 100644 --- a/user_guide_src/source/_static/css/citheme.css +++ b/user_guide_src/source/_static/css/citheme.css @@ -245,6 +245,11 @@ html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not( background-color: #fffff0; } +span.std, +span.pre { + text-wrap: nowrap; +} + /* Messages ----------------------------------------------------------------- */ .rst-content .success { diff --git a/user_guide_src/source/changelogs/index.rst b/user_guide_src/source/changelogs/index.rst index 8f5c5df8d290..299644d7f060 100644 --- a/user_guide_src/source/changelogs/index.rst +++ b/user_guide_src/source/changelogs/index.rst @@ -12,6 +12,7 @@ See all the changes. .. toctree:: :titlesonly: + v4.5.2 v4.5.1 v4.5.0 v4.4.8 diff --git a/user_guide_src/source/changelogs/v4.5.2.rst b/user_guide_src/source/changelogs/v4.5.2.rst new file mode 100644 index 000000000000..cb25e2fc74a8 --- /dev/null +++ b/user_guide_src/source/changelogs/v4.5.2.rst @@ -0,0 +1,25 @@ +############# +Version 4.5.2 +############# + +Release Date: June 10, 2024 + +**4.5.2 release of CodeIgniter4** + +.. contents:: + :local: + :depth: 3 + +*************** +Message Changes +*************** + +- Added ``Security.insecureCookie`` message. + +********** +Bugs Fixed +********** + +See the repo's +`CHANGELOG.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/concepts/autoloader.rst b/user_guide_src/source/concepts/autoloader.rst index c7590bde3a2a..2829e1240929 100644 --- a/user_guide_src/source/concepts/autoloader.rst +++ b/user_guide_src/source/concepts/autoloader.rst @@ -62,7 +62,7 @@ The key of each row is the namespace itself. This does not need a trailing back The value is the location to the directory the classes can be found in. By default, the namespace ``App`` is located in the **app** directory, and the -namespace ``Config`` is located in the ``app/Config`` directory. +namespace ``Config`` is located in the **app/Config** directory. If you create class files in the locations and according to `PSR-4`_, the autoloader will autoload them. diff --git a/user_guide_src/source/concepts/factories.rst b/user_guide_src/source/concepts/factories.rst index 6f6848bdb52b..f98fd1726e38 100644 --- a/user_guide_src/source/concepts/factories.rst +++ b/user_guide_src/source/concepts/factories.rst @@ -86,6 +86,8 @@ The following code loads **app/Libraries/Sub/SubLib.php** if it exists: .. literalinclude:: factories/013.php :lines: 2- +.. _factories-passing-fully-qualified-classname: + Passing Fully Qualified Classname --------------------------------- @@ -270,6 +272,10 @@ Config Caching .. versionadded:: 4.4.0 +.. important:: Do not use this feature unless you have carefully read this section + and understand how this feature works. Otherwise, your application will not + function properly. + To improve performance, Config Caching has been implemented. Prerequisite @@ -287,6 +293,9 @@ Prerequisite How It Works ============ +.. important:: Once cached, configuration values are never changed until the cache + is deleted, even if the configuration file or **.env** is changed. + - Save the all Config instances in Factories into a cache file before shutdown, if the state of the Config instances in Factories changes. - Restore cached Config instances before CodeIgniter initialization if a cache diff --git a/user_guide_src/source/concepts/services.rst b/user_guide_src/source/concepts/services.rst index a3dc9fabb74d..92eec136e1c8 100644 --- a/user_guide_src/source/concepts/services.rst +++ b/user_guide_src/source/concepts/services.rst @@ -37,7 +37,7 @@ come in handy. Instead of creating the instance ourself, we let a central class create an instance of the class for us. This class is kept very simple. It only contains a method for each class that we want to use as a service. The method typically returns a **shared instance** of that class, passing any dependencies -it might have into it. Then, we would replace our timer creation code with code that calls this new class: +it might have into it. Then, we would replace our timer creation code with code that calls this global function or Services class: .. literalinclude:: services/002.php @@ -55,7 +55,7 @@ As many CodeIgniter classes are provided as services, you can get them like the .. literalinclude:: services/013.php -The ``$typography`` is an instance of the Typography class, and if you call ``\Config\Services::typography()`` again, you will get the exactly same instance. +The ``$timer`` is an instance of the Timer class, and if you call ``service('timer')`` again, you will get the exactly same instance. The Services typically return a **shared instance** of the class. The following code creates a ``CURLRequest`` instance at the first call. And the second call returns the exactly same instance. @@ -66,7 +66,7 @@ Therefore, the parameter ``$options2`` for the ``$client2`` does not work. It is Getting a New Instance ====================== -If you want to get a new instance of the Typography class, you need to pass ``false`` to the argument ``$getShared``: +If you want to get a new instance of the Timer class, you need to pass ``false`` to the argument ``$getShared``: .. literalinclude:: services/014.php @@ -85,6 +85,8 @@ always return the same instance: .. literalinclude:: services/003.php +.. note:: Since v4.5.0, when you don't pass parameters to the service, the global function ``service()`` is recommended due to performance improvements. + If the creation method requires additional parameters, they can be passed after the service name: .. literalinclude:: services/004.php diff --git a/user_guide_src/source/concepts/services/002.php b/user_guide_src/source/concepts/services/002.php index cb292ecaeb42..cedf5d19ed65 100644 --- a/user_guide_src/source/concepts/services/002.php +++ b/user_guide_src/source/concepts/services/002.php @@ -1,3 +1,6 @@ 'http://example.com/api/v1/', 'timeout' => 3, ]; -$client1 = \Config\Services::curlrequest($options1); +$client1 = service('curlrequest', $options1); $options2 = [ 'baseURI' => 'http://another.example.com/api/v2/', 'timeout' => 10, ]; -$client2 = \Config\Services::curlrequest($options2); +$client2 = service('curlrequest', $options2); // $options2 does not work. // $client2 is the exactly same instance as $client1. diff --git a/user_guide_src/source/concepts/structure.rst b/user_guide_src/source/concepts/structure.rst index 5e2084556380..9b00fc57e2d5 100644 --- a/user_guide_src/source/concepts/structure.rst +++ b/user_guide_src/source/concepts/structure.rst @@ -2,8 +2,9 @@ Application Structure ##################### -To get the most out of CodeIgniter, you need to understand how the application is structured, by default, and what you -can change to meet the needs of your application. +To get the most out of CodeIgniter, you need to understand how the application +is structured, by default, and what you can change to meet the needs of your +application. .. contents:: :local: @@ -12,15 +13,23 @@ can change to meet the needs of your application. Default Directories ******************* -A fresh install has five directories: ``app/``, ``public/``, -``writable/``, ``tests/`` and ``vendor/`` or ``system/``. +A fresh install has five directories: + +- **app** +- **public** +- **writable** +- **tests** +- **vendor** or **system** + Each of these directories has a very specific part to play. app === -The ``app`` directory is where all of your application code lives. This comes with a default directory -structure that works well for many applications. The following folders make up the basic contents: +The **app** directory is where all of your application code lives. This comes +with a default directory structure that works well for many applications. + +The following folders make up the basic contents: .. code-block:: none @@ -36,25 +45,26 @@ structure that works well for many applications. The following folders make up t ThirdParty/ ThirdParty libraries that can be used in application Views/ Views make up the HTML that is displayed to the client -Because the ``app`` directory is already namespaced, you should feel free to modify the structure -of this directory to suit your application's needs. For example, you might decide to start using the Repository -pattern and Entity Models to work with your data. In this case, you could rename the ``Models`` directory to -``Repositories``, and add a new ``Entities`` directory. +Because the **app** directory is already namespaced, you should feel free to +modify the structure of this directory to suit your application's needs. -.. note:: If you rename the ``Controllers`` directory, though, you will not be able to use the automatic method of - routing to controllers, and will need to define all of your routes in the routes file. +For example, you might decide to start using the Repository +pattern and Entities to work with your data. In this case, you could rename the +**Models** directory to **Repositories**, and add a new **Entities** directory. -All files in this directory live under the ``App`` namespace, though you are free to change that in -**app/Config/Constants.php**. +All files in this directory live under the ``App`` namespace, though you are free +to change that in **app/Config/Constants.php**. system ====== -.. note:: If you install CodeIgniter with Composer, the ``system`` is located in ``vendor/codeigniter4/framework/system``. +.. note:: If you install CodeIgniter with Composer, the **system** is located in + **vendor/codeigniter4/framework/system**. -This directory stores the files that make up the framework, itself. While you have a lot of flexibility in how you -use the application directory, the files in the system directory should never be modified. Instead, you should -extend the classes, or create new classes, to provide the desired functionality. +This directory stores the files that make up the framework, itself. While you +have a lot of flexibility in how you use the application directory, the files in +the system directory should never be modified. Instead, you should extend the +classes, or create new classes, to provide the desired functionality. All files in this directory live under the ``CodeIgniter`` namespace. @@ -65,9 +75,9 @@ public The **public** folder holds the browser-accessible portion of your web application, preventing direct access to your source code. + It contains the main **.htaccess** file, **index.php**, and any application -assets that you add, like CSS, javascript, or -images. +assets that you add, like CSS, javascript, or images. This folder is meant to be the "web root" of your site, and your web server would be configured to point to it. @@ -75,17 +85,22 @@ would be configured to point to it. writable ======== -This directory holds any directories that might need to be written to in the course of an application's life. -This includes directories for storing cache files, logs, and any uploads a user might send. You should add any other -directories that your application will need to write to here. This allows you to keep your other primary directories -non-writable as an added security measure. +This directory holds any directories that might need to be written to in the +course of an application's life. This includes directories for storing cache +files, logs, and any uploads a user might send. + +You should add any other directories that your application will need to write to +here. This allows you to keep your other primary directories non-writable as an +added security measure. tests ===== -This directory is set up to hold your test files. The ``_support`` directory holds various mock classes and other -utilities that you can use while writing your tests. This directory does not need to be transferred to your -production servers. +This directory is set up to hold your test files. The **_support** directory +holds various mock classes and other utilities that you can use while writing +your tests. + +This directory does not need to be transferred to your production servers. Modifying Directory Locations ***************************** diff --git a/user_guide_src/source/conf.py b/user_guide_src/source/conf.py index 1bc7efd9d0ab..e5f3b2a71ccd 100644 --- a/user_guide_src/source/conf.py +++ b/user_guide_src/source/conf.py @@ -26,7 +26,7 @@ version = '4.5' # The full version, including alpha/beta/rc tags. -release = '4.5.1' +release = '4.5.2' # -- General configuration --------------------------------------------------- diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index 26b7515bab12..86155dea0803 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -29,13 +29,13 @@ prototype: The name of the class property is the connection name, and can be used while connecting to specify a group name. -.. note:: The default location of the SQLite3 database is in the **writable** folder. - If you want to change the location, you must set the full path to the new folder. +.. note:: The default location of the SQLite3 database is the **writable** folder. + If you want to change the location, you must set the full path to the new folder (e.g., 'database' => WRITEPATH . 'db/database_name.db'). DSN --- -Some database drivers (such as Postgre, OCI8) requires a full DSN string to connect. +Some database drivers (such as Postgre, OCI8) requires a full DSN (Data Source Name) string to connect. But if you do not specify a DSN string for a driver that requires it, CodeIgniter will try to build it with the rest of the provided settings. @@ -48,7 +48,7 @@ you're using the driver's underlying native PHP extension, like this: DSN in Universal Manner ^^^^^^^^^^^^^^^^^^^^^^^ -You can also set a Data Source Name in universal manner (URL like). In that case DSNs must have this prototype: +You can also set a DSN in universal manner (URL like). In that case DSNs must have this prototype: .. literalinclude:: configuration/003.php :lines: 11-14 @@ -113,7 +113,7 @@ Configuring with .env File You can also save your configuration values within a **.env** file with the current server's database settings. You only need to enter the values that change from what is in the -default group's configuration settings. The values should be name following this format, where +default group's configuration settings. The values should follow this format, where ``default`` is the group name:: database.default.username = 'root'; @@ -137,11 +137,11 @@ and decode it in the constructor in the Config class: .. _database-config-explanation-of-values: ********************* -Explanation of Values +Description of Values ********************* ================ =========================================================================================================== - Name Config Description + Config Name Description ================ =========================================================================================================== **DSN** The DSN connect string (an all-in-one configuration sequence). **hostname** The hostname of your database server. Often this is 'localhost'. @@ -154,31 +154,31 @@ Explanation of Values **DBDriver** The database driver name. The case must match the driver name. You can set a fully qualified classname to use your custom driver. Supported drivers: ``MySQLi``, ``Postgre``, ``SQLite3``, ``SQLSRV``, and ``OCI8``. -**DBPrefix** An optional table prefix which will added to the table name when running +**DBPrefix** An optional table prefix which will be added to the table name when running :doc:`Query Builder ` queries. This permits multiple CodeIgniter installations to share one database. **pConnect** true/false (boolean) - Whether to use a persistent connection. -**DBDebug** true/false (boolean) - Whether to throw exceptions or not when database errors occur. +**DBDebug** true/false (boolean) - Whether to throw exceptions when database errors occur. **charset** The character set used in communicating with the database. **DBCollat** (``MySQLi`` only) The character collation used in communicating with the database. **swapPre** A default table prefix that should be swapped with ``DBPrefix``. This is useful for distributed applications where you might run manually written queries, and need the prefix to still be customizable by the end user. **schema** (``Postgre`` and ``SQLSRV`` only) The database schema, default value varies by driver. -**encrypt** (``MySQLi`` and ``SQLSRV`` only) Whether or not to use an encrypted connection. +**encrypt** (``MySQLi`` and ``SQLSRV`` only) Whether to use an encrypted connection. See :ref:`MySQLi encrypt ` for ``MySQLi`` settings. ``SQLSRV`` driver accepts true/false. -**compress** (``MySQLi`` only) Whether or not to use client compression. +**compress** (``MySQLi`` only) Whether to use client compression. **strictOn** (``MySQLi`` only) true/false (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL while developing an application. **port** The database port number - Empty string ``''`` for default port (or dynamic port with ``SQLSRV``). -**foreignKeys** (``SQLite3`` only) true/false (boolean) - Whether or not to enable Foreign Key constraint. +**foreignKeys** (``SQLite3`` only) true/false (boolean) - Whether to enable Foreign Key constraint. .. important:: SQLite3 Foreign Key constraint is disabled by default. See `SQLite documentation `_. To enforce Foreign Key constraint, set this config item to true. **busyTimeout** (``SQLite3`` only) milliseconds (int) - Sleeps for a specified amount of time when a table is locked. -**numberNative** (``MySQLi`` only) true/false (boolean) - Whether or not to enable MYSQLI_OPT_INT_AND_FLOAT_NATIVE. +**numberNative** (``MySQLi`` only) true/false (boolean) - Whether to enable MYSQLI_OPT_INT_AND_FLOAT_NATIVE. **dateFormat** The default date/time formats as PHP's `DateTime format`_. * ``date`` - date format * ``datetime`` - date and time format @@ -225,4 +225,4 @@ MySQLi driver accepts an array with the following options: * ``ssl_ca`` - Path to the certificate authority file * ``ssl_capath`` - Path to a directory containing trusted CA certificates in PEM format * ``ssl_cipher`` - List of *allowed* ciphers to be used for the encryption, separated by colons (``:``) -* ``ssl_verify`` - true/false; Whether to verify the server certificate or not +* ``ssl_verify`` - true/false (boolean) - Whether to verify the server certificate or not diff --git a/user_guide_src/source/database/examples.rst b/user_guide_src/source/database/examples.rst index a88608e85651..43a2bdceac62 100644 --- a/user_guide_src/source/database/examples.rst +++ b/user_guide_src/source/database/examples.rst @@ -1,6 +1,6 @@ -################################## -Database Quick Start: Example Code -################################## +########################### +Quick Start: Usage Examples +########################### The following page contains example code showing how the database class is used. For complete details please read the individual pages @@ -24,7 +24,7 @@ your :doc:`configuration ` settings: Once loaded the class is ready to be used as described below. .. note:: If all your pages require database access you can connect - automatically. See the :doc:`connecting ` page for details. + automatically. See the :doc:`Connecting to a Database ` page for details. Standard Query With Multiple Results (Object Version) ===================================================== @@ -66,7 +66,7 @@ Standard Insert Query Builder Query =================== -The :doc:`Query Builder Pattern ` gives you a simplified +The :doc:`Query Builder ` gives you a simplified means of retrieving data: .. literalinclude:: examples/007.php diff --git a/user_guide_src/source/database/helpers.rst b/user_guide_src/source/database/helpers.rst index 0d640f6422e1..0542057379b1 100644 --- a/user_guide_src/source/database/helpers.rst +++ b/user_guide_src/source/database/helpers.rst @@ -42,7 +42,6 @@ $db->countAll() Permits you to determine the number of rows in a particular table. Submit the table name in the first parameter. This is part of Query Builder. -Example: .. literalinclude:: helpers/001.php @@ -51,7 +50,6 @@ $db->countAllResults() Permits you to determine the number of rows in a particular result set. Submit the table name in the first parameter. This is part of Query Builder. -Example: .. literalinclude:: helpers/002.php diff --git a/user_guide_src/source/database/index.rst b/user_guide_src/source/database/index.rst index 0862ec0f4125..e9ab69ad17cb 100644 --- a/user_guide_src/source/database/index.rst +++ b/user_guide_src/source/database/index.rst @@ -14,10 +14,10 @@ patterns. The database functions offer clear, simple syntax. Connecting to a Database Running Queries Generating Query Results - Query Helper Functions + Query Helper Methods Query Builder Class Transactions - Getting MetaData + Getting Metadata Custom Function Calls Database Events Database Utilities diff --git a/user_guide_src/source/database/metadata.rst b/user_guide_src/source/database/metadata.rst index 85dcdc0b1d33..7674c401b793 100644 --- a/user_guide_src/source/database/metadata.rst +++ b/user_guide_src/source/database/metadata.rst @@ -1,13 +1,13 @@ -################# -Database Metadata -################# +################ +Getting Metadata +################ .. contents:: :local: :depth: 2 ************** -Table MetaData +Table Metadata ************** These functions let you fetch table information. @@ -39,7 +39,7 @@ running an operation on it. Returns a boolean true/false. Usage example: .. note:: Replace *table_name* with the name of the table you are looking for. ************** -Field MetaData +Field Metadata ************** List the Fields in a Table @@ -71,9 +71,7 @@ performing an action. Returns a boolean true/false. Usage example: .. literalinclude:: metadata/005.php -.. note:: Replace *field_name* with the name of the column you are looking - for, and replace *table_name* with the name of the table you are - looking for. +.. note:: Replace *field_name* and *table_name* with the column name and the table name you are looking for. Retrieve Field Metadata ======================= @@ -88,7 +86,7 @@ Returns an array of objects containing field information. Sometimes it's helpful to gather the field names or other metadata, like the column type, max length, etc. -.. note:: Not all databases provide meta-data. +.. note:: Not all databases provide metadata. Usage example: diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst old mode 100755 new mode 100644 index 5dac7926f7a8..171c354d1120 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -88,7 +88,7 @@ $query, which can be used to show the results: .. literalinclude:: query_builder/004.php -Please visit the :doc:`getResult*() method ` page for a full +Please visit the :ref:`getResult() ` method for a full discussion regarding result generation. $builder->getCompiledSelect() @@ -101,14 +101,14 @@ Example: .. literalinclude:: query_builder/005.php -The first parameter enables you to set whether or not the query builder query -will be reset (by default it will be reset, just like when using ``$builder->get()``): +The parameter (false) in the first query below enables you to set whether or not the query builder +will be reset (because the default value of the parameter is true, ``getCompiledSelect(bool $reset = true)``, by default it will be reset just like when using ``$builder->get()``): .. literalinclude:: query_builder/006.php The key thing to notice in the above example is that the second query did not utilize ``limit(10, 20)`` but the generated SQL query has ``LIMIT 20, 10``. -The reason for this outcome is because the first parameter is set to ``false``. +The reason for this outcome is because the parameter in the first query is set to ``false``, ``limit(10, 20)`` remained in the second query. $builder->getWhere() -------------------- @@ -169,7 +169,7 @@ $builder->selectMin() --------------------- Writes a **SELECT MIN(field)** portion for your query. As with -``selectMax()``, You can optionally include a second parameter to rename +``selectMax()``, you can optionally include a second parameter to rename the resulting field. .. literalinclude:: query_builder/011.php @@ -178,7 +178,7 @@ $builder->selectAvg() --------------------- Writes a **SELECT AVG(field)** portion for your query. As with -``selectMax()``, You can optionally include a second parameter to rename +``selectMax()``, you can optionally include a second parameter to rename the resulting field. .. literalinclude:: query_builder/012.php @@ -187,7 +187,7 @@ $builder->selectSum() --------------------- Writes a **SELECT SUM(field)** portion for your query. As with -``selectMax()``, You can optionally include a second parameter to rename +``selectMax()``, you can optionally include a second parameter to rename the resulting field. .. literalinclude:: query_builder/013.php @@ -196,7 +196,7 @@ $builder->selectCount() ----------------------- Writes a **SELECT COUNT(field)** portion for your query. As with -``selectMax()``, You can optionally include a second parameter to rename +``selectMax()``, you can optionally include a second parameter to rename the resulting field. .. note:: This method is particularly helpful when used with ``groupBy()``. For diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst index a5d490a81a20..85e57c3be70e 100644 --- a/user_guide_src/source/database/results.rst +++ b/user_guide_src/source/database/results.rst @@ -12,6 +12,8 @@ There are several ways to generate query results: Result Arrays ************* +.. _getresult: + getResult() =========== @@ -93,7 +95,7 @@ digit in the first parameter: .. literalinclude:: results/009.php -In addition, you can walk forward/backwards/first/last through your +In addition, you can walk forward/backward/first/last through your results using these variations: | ``$row = $query->getFirstRow()`` diff --git a/user_guide_src/source/database/utilities.rst b/user_guide_src/source/database/utilities.rst index c8c11e51d864..00c04ebaddc9 100644 --- a/user_guide_src/source/database/utilities.rst +++ b/user_guide_src/source/database/utilities.rst @@ -1,6 +1,6 @@ -###################### -Database Utility Class -###################### +################## +Database Utilities +################## The Database Utility Class contains methods that help you manage your database. diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index 241743fb487e..00915a5dae81 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -41,7 +41,7 @@ Returns true/false based on success or failure: .. literalinclude:: forge/003.php An optional second parameter set to true will add ``IF EXISTS`` statement -or will check if a database exists before create it (depending on DBMS). +or will check if a database exists before creating it (depending on DBMS). .. literalinclude:: forge/004.php diff --git a/user_guide_src/source/dbmgmt/index.rst b/user_guide_src/source/dbmgmt/index.rst index 68bfea3e6098..38701c2e1ac8 100644 --- a/user_guide_src/source/dbmgmt/index.rst +++ b/user_guide_src/source/dbmgmt/index.rst @@ -7,7 +7,7 @@ CodeIgniter comes with tools to restructure or seed your database. .. toctree:: :titlesonly: - Database Manipulation with Database Forge + Database Forge Database Migrations Database Seeding db_commands diff --git a/user_guide_src/source/dbmgmt/migration.rst b/user_guide_src/source/dbmgmt/migration.rst index 5b6b09dc4414..dec16c5037ff 100644 --- a/user_guide_src/source/dbmgmt/migration.rst +++ b/user_guide_src/source/dbmgmt/migration.rst @@ -121,7 +121,7 @@ Migrates a database group with all available migrations: php spark migrate -You can use (migrate) with the following options: +You can use ``migrate`` with the following options: - ``-g`` - to specify database group. If specified, only migrations for the specified database group will be run. If not specified, all migrations will be run. - ``-n`` - to choose namespace, otherwise ``App`` namespace will be used. @@ -145,8 +145,8 @@ When using the ``--all`` option, it will scan through all namespaces attempting not been run. These will all be collected and then sorted as a group by date created. This should help to minimize any potential conflicts between the main application and any modules. -rollback -======== +migrate:rollback +================ Rolls back all migrations to a blank slate, effectively migration 0: @@ -154,13 +154,13 @@ Rolls back all migrations to a blank slate, effectively migration 0: php spark migrate:rollback -You can use (rollback) with the following options: +You can use ``migrate:rollback`` with the following options: - ``-b`` - to choose a batch: natural numbers specify the batch. - ``-f`` - to force a bypass confirmation question, it is only asked in a production environment. -refresh -======= +migrate:refresh +=============== Refreshes the database state by first rolling back all migrations, and then migrating all: @@ -168,15 +168,15 @@ Refreshes the database state by first rolling back all migrations, and then migr php spark migrate:refresh -You can use (refresh) with the following options: +You can use ``migrate:refresh`` with the following options: - ``-g`` - to specify database group. If specified, only migrations for the specified database group will be run. If not specified, all migrations will be run. - ``-n`` - to choose namespace, otherwise ``App`` namespace will be used. - ``--all`` - to refresh all namespaces. - ``-f`` - to force a bypass confirmation question, it is only asked in a production environment. -status -====== +migrate:status +============== Displays a list of all migrations and the date and time they ran, or '--' if they have not been run: @@ -194,7 +194,7 @@ Displays a list of all migrations and the date and time they ran, or '--' if the | CodeIgniter\Settings | 2021-11-14-143905 | AddContextColumn | default | 2022-04-06 01:23:08 | 1 | +----------------------+-------------------+-----------------------+---------+---------------------+-------+ -You can use (status) with the following options: +You can use ``migrate:status`` with the following options: - ``-g`` - to specify database group. If specified, only migrations for the specified database group will be checked. If not specified, all migrations will be checked. @@ -209,7 +209,7 @@ creates is the Pascal case version of the filename. php spark make:migration [options] -You can use (``make:migration``) with the following options: +You can use ``make:migration`` with the following options: - ``--namespace`` - Set root namespace. Default: ``APP_NAMESPACE``. - ``--suffix`` - Append the component title to the class name. diff --git a/user_guide_src/source/extending/basecontroller/003.php b/user_guide_src/source/extending/basecontroller/003.php index 2f6fcb9d08cb..b7bcab22545d 100644 --- a/user_guide_src/source/extending/basecontroller/003.php +++ b/user_guide_src/source/extending/basecontroller/003.php @@ -18,6 +18,6 @@ public function initController(/* ... */) // Do Not Edit This Line parent::initController($request, $response, $logger); - $this->session = \Config\Services::session(); + $this->session = service('session'); } } diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst old mode 100755 new mode 100644 index b16b5576ee45..d0a23758e348 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -106,13 +106,15 @@ Service Accessors .. php:function:: lang($line[, $args[, $locale]]) - :param string $line: The line of text to retrieve + :param string $line: The language filename and the key of the text to retrieve. :param array $args: An array of data to substitute for placeholders. - :param string $locale: Specify a different locale to be used instead of default one. + :param string $locale: Specify a different locale to be used instead of the current locale. + :returns: The text in the language file + :rtype: list|string - Retrieves a locale-specific file based on an alias string. + Retrieves text from the language files. - For more information, see the :doc:`Localization ` page. + For more information, see the :ref:`language-localization`. .. php:function:: model($name[, $getShared = true[, &$conn = null]]) @@ -180,6 +182,7 @@ Service Accessors :rtype: string Grabs the current RendererInterface-compatible class + (:doc:`View <../outgoing/view_renderer>` class by default) and tells it to render the specified view. Simply provides a convenience method that can be used in Controllers, libraries, and routed closures. @@ -369,7 +372,7 @@ Miscellaneous Functions :returns: The shared Request object. :rtype: IncomingRequest|CLIRequest - This function is a wrapper for ``Services::request()``. + This function is a wrapper for ``Services::request()`` and ``service('request')``. .. php:function:: response() @@ -378,7 +381,7 @@ Miscellaneous Functions :returns: The shared Response object. :rtype: Response - This function is a wrapper for ``Services::response()``. + This function is a wrapper for ``Services::response()`` and ``service('response')``. .. php:function:: route_to($method[, ...$params]) diff --git a/user_guide_src/source/general/errors.rst b/user_guide_src/source/general/errors.rst index 2b6eafce8c33..8d307de0bd5a 100644 --- a/user_guide_src/source/general/errors.rst +++ b/user_guide_src/source/general/errors.rst @@ -19,8 +19,8 @@ Using Exceptions This section is a quick overview for newer programmers, or for developers who are not experienced with using exceptions. -What is Exceptions ------------------- +What are Exceptions +------------------- Exceptions are simply events that happen when the exception is "thrown". This halts the current flow of the script, and execution is then sent to the error handler which displays the appropriate error page: @@ -94,12 +94,26 @@ Logging Deprecation Warnings .. versionadded:: 4.3.0 -By default, all errors reported by ``error_reporting()`` will be thrown as an ``ErrorException`` object. These -include both ``E_DEPRECATED`` and ``E_USER_DEPRECATED`` errors. With the surge in use of PHP 8.1+, many users -may see exceptions thrown for `passing null to non-nullable arguments of internal functions `_. -To ease the migration to PHP 8.1, you can instruct CodeIgniter to log the deprecations instead of throwing them. +Prior to v4.3.0, all errors reported by ``error_reporting()`` will be thrown as +an ``ErrorException`` object. + +But with the surge in use of PHP 8.1+, many users may see exceptions thrown for +`passing null to non-nullable arguments of internal functions `_. + +To ease the migration to PHP 8.1, starting with v4.3.0, CodeIgniter has the feature +that only logs the deprecation errors (``E_DEPRECATED`` and ``E_USER_DEPRECATED``) +without throwing them as exceptions. + +By default, CodeIgniter will only log deprecations without throwing exceptions in +development environment. In production environment, no logging is done and no +exceptions are thrown. + +Configuration +^^^^^^^^^^^^^ -First, make sure your copy of ``Config\Exceptions`` is updated with the two new properties and set as follows: +The settings for this feature are as follows. +First, make sure your copy of ``Config\Exceptions`` is updated with the two new +properties and set as follows: .. literalinclude:: errors/012.php @@ -109,7 +123,8 @@ it accordingly. .. literalinclude:: errors/013.php -After that, subsequent deprecations will be logged instead of thrown. +After that, subsequent deprecations will be logged as configured without throwing +as exceptions. This feature also works with user deprecations: diff --git a/user_guide_src/source/general/errors/012.php b/user_guide_src/source/general/errors/012.php index 1b773613143c..2c81e8784757 100644 --- a/user_guide_src/source/general/errors/012.php +++ b/user_guide_src/source/general/errors/012.php @@ -7,8 +7,9 @@ class Exceptions extends BaseConfig { - // ... other properties - - public bool $logDeprecations = true; - public string $deprecationLogLevel = LogLevel::WARNING; // this should be one of the log levels supported by PSR-3 + // ... + public bool $logDeprecations = true; // If set to false, an exception will be thrown. + // ... + public string $deprecationLogLevel = LogLevel::WARNING; // This should be one of the log levels supported by PSR-3. + // ... } diff --git a/user_guide_src/source/general/errors/013.php b/user_guide_src/source/general/errors/013.php index 23352f0ef54e..b099c6d19b3c 100644 --- a/user_guide_src/source/general/errors/013.php +++ b/user_guide_src/source/general/errors/013.php @@ -6,7 +6,8 @@ class Logger extends BaseConfig { - // .. other properties - - public $threshold = 5; // originally 4 but changed to 5 to log the warnings from the deprecations + // ... + // This must contain the log level (5 for LogLevel::WARNING) corresponding to $deprecationLogLevel. + public $threshold = (ENVIRONMENT === 'production') ? 4 : 9; + // ... } diff --git a/user_guide_src/source/general/errors/018.php b/user_guide_src/source/general/errors/018.php index 3cba09951d8b..9546e4a606ae 100644 --- a/user_guide_src/source/general/errors/018.php +++ b/user_guide_src/source/general/errors/018.php @@ -1,6 +1,6 @@ redirect('https://example.com/path') ->setHeader('Some', 'header') ->setCookie('and', 'cookie'); diff --git a/user_guide_src/source/general/managing_apps.rst b/user_guide_src/source/general/managing_apps.rst index ff664668bf8b..35a30153d034 100644 --- a/user_guide_src/source/general/managing_apps.rst +++ b/user_guide_src/source/general/managing_apps.rst @@ -8,21 +8,6 @@ directory. It is possible, however, to have multiple sets of applications that share a single CodeIgniter installation, or even to rename or relocate your application directory. -.. important:: When you installed CodeIgniter v4.1.9 or before, and if there are ``App\\`` and ``Config\\`` namespaces in your ``/composer.json``'s ``autoload.psr-4`` like the following, you need to remove these lines, and run ``composer dump-autoload``. - - .. code-block:: text - - { - ... - "autoload": { - "psr-4": { - "App\\": "app", <-- Remove this line - "Config\\": "app/Config" <-- Remove this line - } - }, - ... - } - .. contents:: :local: :depth: 2 @@ -42,13 +27,15 @@ your main **app/Config/Paths.php** and set a *full server path* in the You will need to modify two additional files in your project root, so that they can find the **Paths** configuration file: -- **/spark** runs command line apps. +- **spark** runs command line apps. .. literalinclude:: managing_apps/002.php + :lines: 2- -- **/public/index.php** is the front controller for your webapp. +- **public/index.php** is the front controller for your webapp. .. literalinclude:: managing_apps/003.php + :lines: 2- .. _running-multiple-app: diff --git a/user_guide_src/source/general/modules.rst b/user_guide_src/source/general/modules.rst index 4e5c72a9fa9b..a077b8f5523d 100644 --- a/user_guide_src/source/general/modules.rst +++ b/user_guide_src/source/general/modules.rst @@ -251,7 +251,8 @@ You can specify namespaces. See :ref:`helpers-loading-from-specified-namespace` Language Files ============== -Language files are located automatically from defined namespaces when using the ``lang()`` method, as long as the +Language files are located automatically from defined namespaces when using the +:php:func:`lang()` function, as long as the file follows the same directory structures as the main application directory. Libraries @@ -272,13 +273,15 @@ Model files are automatically discovered whenever using the :php:func:`model()` .. note:: We don't recommend you use the same short classname in modules. -.. note:: ``model()`` finds the file in **app/Models/** when there is a class with the same shortname, - even if you specify a fully qualified class name like ``model(\Acme\Blog\Model\PostModel::class)``. - This is because ``model()`` is a wrapper for the ``Factories`` class which uses ``preferApp`` by default. See :ref:`factories-loading-class` for more information. +.. note:: Prior to v4.4.0, ``model()`` finds the file in **app/Models/** when + there is a class with the same shortname, even if you specify a fully qualified + class name like ``model(\Acme\Blog\Model\PostModel::class)``. + See the Note in :ref:`factories-passing-fully-qualified-classname` for more + information. Views ===== -Views can be loaded using the class namespace as described in the :doc:`views ` documentation: +Views can be loaded using the class namespace as described in the :ref:`views ` documentation: .. literalinclude:: modules/012.php diff --git a/user_guide_src/source/helpers/cookie_helper.rst b/user_guide_src/source/helpers/cookie_helper.rst old mode 100755 new mode 100644 diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst index 68c7090408df..9a2d9f026abb 100644 --- a/user_guide_src/source/helpers/form_helper.rst +++ b/user_guide_src/source/helpers/form_helper.rst @@ -28,7 +28,7 @@ Escaping Field Values ********************* You may need to use HTML and characters such as quotes within your form -elements. In order to do that safely, you'll need to use +elements. In order to do that safely, you'll need to use the :doc:`common function <../general/common_functions>` :php:func:`esc()`. @@ -64,8 +64,8 @@ The following functions are available: Creates an opening form tag with a site URL **built from your** ``Config\App::$baseURL``. It will optionally let you add form attributes and hidden input fields, and - will always add the `accept-charset` attribute based on the charset value in your - config file. + will always add the `accept-charset` attribute based on the ``$charset`` property in your + **app/Config/App.php** config file. The main benefit of using this tag rather than hard coding your own HTML is that it permits your site to be more portable in the event your URLs ever change. @@ -103,16 +103,21 @@ The following functions are available: