diff --git a/admin/starter/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php b/admin/starter/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php index a73356d3479a..96b1330131b6 100644 --- a/admin/starter/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php +++ b/admin/starter/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php @@ -3,11 +3,13 @@ namespace Tests\Support\Database\Migrations; use CodeIgniter\Database\Migration; +use Override; class ExampleMigration extends Migration { protected $DBGroup = 'tests'; + #[Override] public function up(): void { $this->forge->addField('id'); @@ -30,6 +32,7 @@ public function up(): void $this->forge->createTable('factories'); } + #[Override] public function down(): void { $this->forge->dropTable('factories'); diff --git a/admin/starter/tests/_support/Database/Seeds/ExampleSeeder.php b/admin/starter/tests/_support/Database/Seeds/ExampleSeeder.php index 619fc27a7292..7c0dafa6002e 100644 --- a/admin/starter/tests/_support/Database/Seeds/ExampleSeeder.php +++ b/admin/starter/tests/_support/Database/Seeds/ExampleSeeder.php @@ -3,9 +3,11 @@ namespace Tests\Support\Database\Seeds; use CodeIgniter\Database\Seeder; +use Override; class ExampleSeeder extends Seeder { + #[Override] public function run(): void { $factories = [ diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 6f86f9254ed1..5afcd5bd3688 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -7,6 +7,7 @@ use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; use Psr\Log\LoggerInterface; /** @@ -34,6 +35,7 @@ abstract class BaseController extends Controller * * @return void */ + #[Override] public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { // Load here all helpers you want to be available in your controllers that extend BaseController. diff --git a/docs/cli/cli_commands.md b/docs/cli/cli_commands.md index 353828421495..49d2599bcaaf 100644 --- a/docs/cli/cli_commands.md +++ b/docs/cli/cli_commands.md @@ -38,6 +38,7 @@ namespace App\Commands; use CodeIgniter\CLI\BaseCommand; use CodeIgniter\CLI\CLI; +use Override; class AppInfo extends BaseCommand { @@ -45,6 +46,7 @@ class AppInfo extends BaseCommand protected $name = 'app:info'; protected $description = 'Displays basic application information.'; + #[Override] public function run(array $params) { // ... @@ -85,11 +87,13 @@ namespace App\Commands; use CodeIgniter\CLI\BaseCommand; use CodeIgniter\CLI\CLI; +use Override; class AppInfo extends BaseCommand { // ... + #[Override] public function run(array $params) { CLI::write('PHP Version: ' . CLI::color(PHP_VERSION, 'yellow')); diff --git a/docs/cli/cli_library.md b/docs/cli/cli_library.md index 821643274d74..8c610204524f 100644 --- a/docs/cli/cli_library.md +++ b/docs/cli/cli_library.md @@ -19,11 +19,13 @@ namespace App\Commands; use CodeIgniter\CLI\BaseCommand; use CodeIgniter\CLI\CLI; +use Override; class MyCommand extends BaseCommand { // ... + #[Override] public function run(array $params) { // ... diff --git a/docs/cli/cli_modern_commands.md b/docs/cli/cli_modern_commands.md index f8b098e4f4b5..4d6002f30406 100644 --- a/docs/cli/cli_modern_commands.md +++ b/docs/cli/cli_modern_commands.md @@ -23,10 +23,12 @@ namespace App\Commands; use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; +use Override; #[Command(name: 'app:greet', description: 'Prints a greeting.', group: 'App')] class AppGreet extends AbstractCommand { + #[Override] protected function execute(array $arguments, array $options): int { $this->getOutput()->write('Hello!', 'green'); @@ -60,6 +62,7 @@ namespace App\Commands; use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; +use Override; #[Command( name: 'app:deploy', @@ -69,6 +72,7 @@ use CodeIgniter\CLI\Attributes\Command; )] class AppDeploy extends AbstractCommand { + #[Override] protected function execute(array $arguments, array $options): int { // Reachable as `php spark app:deploy`, `php spark app:ship`, or `php spark deploy`. @@ -89,6 +93,7 @@ namespace App\Commands; use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; +use Override; #[Command( name: 'app:reindex', @@ -98,6 +103,7 @@ use CodeIgniter\CLI\Attributes\Command; )] class AppReindex extends AbstractCommand { + #[Override] protected function execute(array $arguments, array $options): int { // Not shown by `php spark list`, but `php spark app:reindex` still runs it. @@ -134,6 +140,7 @@ namespace App\Commands; use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; +use Override; #[Command( name: 'app:status', @@ -143,6 +150,7 @@ use CodeIgniter\CLI\Attributes\Command; )] class AppStatus extends AbstractCommand { + #[Override] protected function execute(array $arguments, array $options): int { $this->getOutput()->write(json_encode(['status' => 'ok'], JSON_THROW_ON_ERROR)); @@ -181,10 +189,12 @@ namespace App\Commands; use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Argument; +use Override; #[Command(name: 'app:greet', description: 'Greets people.', group: 'App')] class AppGreet extends AbstractCommand { + #[Override] protected function configure(): void { $this @@ -208,6 +218,7 @@ class AppGreet extends AbstractCommand )); } + #[Override] protected function execute(array $arguments, array $options): int { // ... @@ -238,10 +249,12 @@ namespace App\Commands; use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Option; +use Override; #[Command(name: 'app:publish', description: 'Publishes assets.', group: 'App')] class AppPublish extends AbstractCommand { + #[Override] protected function configure(): void { $this @@ -282,6 +295,7 @@ class AppPublish extends AbstractCommand )); } + #[Override] protected function execute(array $arguments, array $options): int { // ... @@ -346,10 +360,12 @@ namespace App\Commands; use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Option; +use Override; #[Command(name: 'logs:clear', description: 'Clears logs.', group: 'Housekeeping')] class ClearLogs extends AbstractCommand { + #[Override] protected function configure(): void { $this->addOption(new Option( @@ -359,6 +375,7 @@ class ClearLogs extends AbstractCommand )); } + #[Override] protected function interact(array &$arguments, array &$options): void { // hasUnboundOption() resolves --force, -f, and --no-force in one call, @@ -376,6 +393,7 @@ class ClearLogs extends AbstractCommand $options['force'] = null; } + #[Override] protected function execute(array $arguments, array $options): int { if ($this->getValidatedOption('force') === false) { @@ -406,10 +424,12 @@ use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Argument; use CodeIgniter\CLI\PromptsForMissingInputInterface; +use Override; #[Command(name: 'app:greet', description: 'Greets people.', group: 'App')] class AppGreet extends AbstractCommand implements PromptsForMissingInputInterface { + #[Override] protected function configure(): void { $this->addArgument(new Argument( @@ -419,11 +439,13 @@ class AppGreet extends AbstractCommand implements PromptsForMissingInputInterfac )); } + #[Override] protected function getArgumentPromptLabels(): array { return ['name' => 'Who should be greeted?']; } + #[Override] protected function execute(array $arguments, array $options): int { $this->getOutput()->write(sprintf('Hello, %s!', $arguments['name']), 'green'); @@ -477,16 +499,19 @@ namespace App\Commands; use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; +use Override; #[Command(name: 'dev:only', description: 'A dev only command', group: 'Dev')] class DevOnly extends AbstractCommand { + #[Override] protected function isAvailable(): bool { // Only allow this command in the development environment return ENVIRONMENT === 'development'; } + #[Override] protected function execute(array $arguments, array $options): int { // ... @@ -526,10 +551,12 @@ use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Argument; use CodeIgniter\CLI\Input\Option; +use Override; #[Command(name: 'app:demo', description: 'Demonstrates accessors.', group: 'App')] class AppDemo extends AbstractCommand { + #[Override] protected function configure(): void { $this @@ -537,6 +564,7 @@ class AppDemo extends AbstractCommand ->addOption(new Option(name: 'loud', negatable: true, default: false)); } + #[Override] protected function execute(array $arguments, array $options): int { // Directly from the parameters: @@ -572,10 +600,12 @@ namespace App\Commands; use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Table; +use Override; #[Command(name: 'app:report', description: 'Prints a report.', group: 'App')] class AppReport extends AbstractCommand { + #[Override] protected function execute(array $arguments, array $options): int { $output = $this->getOutput(); @@ -621,10 +651,12 @@ use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Table; use CodeIgniter\CLI\Verbosity; +use Override; #[Command(name: 'app:sync', description: 'Synchronizes the records.', group: 'App')] class AppSync extends AbstractCommand { + #[Override] protected function execute(array $arguments, array $options): int { $output = $this->getOutput(); @@ -708,10 +740,12 @@ namespace App\Commands; use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Argument; +use Override; #[Command(name: 'app:greet', description: 'Greets people.', group: 'App')] class AppGreet extends AbstractCommand { + #[Override] protected function configure(): void { $this @@ -722,6 +756,7 @@ class AppGreet extends AbstractCommand ->addUsage('app:greet "Bob the Builder"'); } + #[Override] protected function execute(array $arguments, array $options): int { // ... @@ -797,6 +832,7 @@ namespace App\Commands; use CodeIgniter\CLI\BaseCommand; use CodeIgniter\CLI\CLI; +use Override; use Throwable; class Publish extends BaseCommand @@ -811,6 +847,7 @@ class Publish extends BaseCommand '--dry-run' => 'Print the plan without writing anything.', ]; + #[Override] public function run(array $params) { try { @@ -853,11 +890,13 @@ use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Argument; use CodeIgniter\CLI\Input\Option; +use Override; use Throwable; #[Command(name: 'app:publish', description: 'Publishes something.', group: 'App')] class Publish extends AbstractCommand { + #[Override] protected function configure(): void { $this @@ -866,6 +905,7 @@ class Publish extends AbstractCommand ->addOption(new Option(name: 'dry-run', description: 'Print the plan without writing anything.')); } + #[Override] protected function interact(array &$arguments, array &$options): void { if ($arguments === []) { @@ -873,6 +913,7 @@ class Publish extends AbstractCommand } } + #[Override] protected function execute(array $arguments, array $options): int { try { diff --git a/docs/cli/cli_modern_generators.md b/docs/cli/cli_modern_generators.md index 69f4c1da0bba..6db47f452eea 100644 --- a/docs/cli/cli_modern_generators.md +++ b/docs/cli/cli_modern_generators.md @@ -121,11 +121,13 @@ use CodeIgniter\CLI\AbstractGeneratorCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Attributes\GeneratorCommand; use CodeIgniter\CLI\Input\Option; +use Override; #[Command(name: 'make:widget', description: 'Generates a new widget class.', group: 'Generators')] #[GeneratorCommand(component: 'Widget', template: 'widget.tpl.php', directory: 'Widgets')] class WidgetGenerator extends AbstractGeneratorCommand { + #[Override] protected function configure(): void { // Registers the required "name" argument. @@ -139,12 +141,14 @@ class WidgetGenerator extends AbstractGeneratorCommand )); } + #[Override] protected function getReplacements(string $class): array { // Replaces the {table} placeholder in the template. return ['{table}' => (string) $this->getValidatedOption('table')]; } + #[Override] protected function getTemplateData(string $class): array { // Available as a plain $sortable variable inside the template. @@ -167,17 +171,20 @@ namespace App\Commands; use CodeIgniter\CLI\AbstractGeneratorCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Attributes\GeneratorCommand; +use Override; #[Command(name: 'make:widget', description: 'Generates a new widget class.', group: 'Generators')] #[GeneratorCommand(component: 'Widget', template: 'widget.tpl.php', directory: 'Widgets')] class WidgetGenerator extends AbstractGeneratorCommand { + #[Override] protected function provideGeneratorOptions(): void { // No --suffix: suffixing is not optional for this generator. $this->addNamespaceOption()->addForceOption(); } + #[Override] protected function shouldAppendSuffix(): bool { // The "Widget" suffix is always appended. @@ -257,6 +264,7 @@ namespace App\Commands; use CodeIgniter\CLI\BaseCommand; use CodeIgniter\CLI\GeneratorTrait; +use Override; class WidgetGenerator extends BaseCommand { @@ -273,6 +281,7 @@ class WidgetGenerator extends BaseCommand '--force' => 'Force overwrite existing file.', ]; + #[Override] public function run(array $params) { $this->component = 'Widget'; diff --git a/docs/cli/cli_signals.md b/docs/cli/cli_signals.md index d0a8d382f70b..c42efb4e2377 100644 --- a/docs/cli/cli_signals.md +++ b/docs/cli/cli_signals.md @@ -75,6 +75,7 @@ class SampleCommand extends AbstractCommand { use SignalTrait; + #[\Override] protected function execute(array $arguments, array $options): int { // Register basic termination signals @@ -116,6 +117,7 @@ class SampleCommand extends AbstractCommand { use SignalTrait; + #[\Override] protected function execute(array $arguments, array $options): int { // Register signals with custom handlers @@ -179,6 +181,7 @@ class SampleCommand extends AbstractCommand { use SignalTrait; + #[\Override] protected function execute(array $arguments, array $options): int { // Register signals without explicit mappings @@ -301,6 +304,7 @@ class SampleCommand extends AbstractCommand { use SignalTrait; + #[\Override] protected function execute(array $arguments, array $options): int { // Register pause/resume signals with custom handlers @@ -659,6 +663,7 @@ class SampleCommand extends AbstractCommand { use SignalTrait; + #[\Override] protected function execute(array $arguments, array $options): int { // Register signals first @@ -707,6 +712,7 @@ class SampleCommand extends AbstractCommand { use SignalTrait; + #[\Override] protected function execute(array $arguments, array $options): int { // ... @@ -754,6 +760,7 @@ class SampleCommand extends AbstractCommand { use SignalTrait; + #[\Override] protected function execute(array $arguments, array $options): int { // ... diff --git a/docs/dbmgmt/migration.md b/docs/dbmgmt/migration.md index 4f1e544c4ba7..3e2f05384fcf 100644 --- a/docs/dbmgmt/migration.md +++ b/docs/dbmgmt/migration.md @@ -32,9 +32,11 @@ This will be the first migration for a new site which has a blog. All migrations namespace App\Database\Migrations; use CodeIgniter\Database\Migration; +use Override; class AddBlog extends Migration { + #[Override] public function up() { $this->forge->addField([ @@ -57,6 +59,7 @@ class AddBlog extends Migration $this->forge->createTable('blog'); } + #[Override] public function down() { $this->forge->dropTable('blog'); @@ -81,9 +84,11 @@ When your tables include Foreign Keys, migrations can often cause problems as yo namespace App\Database\Migrations; use CodeIgniter\Database\Migration; +use Override; class AddBlog extends Migration { + #[Override] public function up() { $this->db->disableForeignKeyChecks(); @@ -109,16 +114,19 @@ You can ensure that migrations are run only against the proper group by setting namespace App\Database\Migrations; use CodeIgniter\Database\Migration; +use Override; class AddBlog extends Migration { protected $DBGroup = 'alternate_db_group'; + #[Override] public function up() { // ... } + #[Override] public function down() { // ... diff --git a/docs/dbmgmt/seeds.md b/docs/dbmgmt/seeds.md index b3bc7d08dc80..a46e2ef55ecd 100644 --- a/docs/dbmgmt/seeds.md +++ b/docs/dbmgmt/seeds.md @@ -12,9 +12,11 @@ Database seeders are simple classes that must have a `run()` method, and extend namespace App\Database\Seeds; use CodeIgniter\Database\Seeder; +use Override; class SimpleSeeder extends Seeder { + #[Override] public function run() { $data = [ @@ -41,9 +43,11 @@ Seeders can call other seeders with the `call()` method. This allows you to easi namespace App\Database\Seeds; use CodeIgniter\Database\Seeder; +use Override; class TestSeeder extends Seeder { + #[Override] public function run() { $this->call('UserSeeder'); @@ -61,9 +65,11 @@ You can also use a fully-qualified class name in the `call()` method, allowing y namespace App\Database\Seeds; use CodeIgniter\Database\Seeder; +use Override; class SimpleSeeder extends Seeder { + #[Override] public function run() { $this->call('UserSeeder'); @@ -104,11 +110,13 @@ If a seeder needs to always use a specific database group regardless of the pare namespace App\Database\Seeds; use CodeIgniter\Database\Seeder; +use Override; class UserSeeder extends Seeder { protected $DBGroup = 'group_name'; + #[Override] public function run() { // ... diff --git a/docs/extending/basecontroller.md b/docs/extending/basecontroller.md index c476471d23fb..95250e816fdd 100644 --- a/docs/extending/basecontroller.md +++ b/docs/extending/basecontroller.md @@ -44,6 +44,7 @@ namespace App\Controllers; use CodeIgniter\Controller; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; use Psr\Log\LoggerInterface; abstract class BaseController extends Controller @@ -55,6 +56,7 @@ abstract class BaseController extends Controller */ protected $session; + #[Override] public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { // Do Not Edit This Line diff --git a/docs/general/errors.md b/docs/general/errors.md index 674728675023..0c73020b722b 100644 --- a/docs/general/errors.md +++ b/docs/general/errors.md @@ -365,6 +365,7 @@ use CodeIgniter\Debug\BaseExceptionHandler; use CodeIgniter\Debug\ExceptionHandlerInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; use Throwable; class MyExceptionHandler extends BaseExceptionHandler implements ExceptionHandlerInterface @@ -372,6 +373,7 @@ class MyExceptionHandler extends BaseExceptionHandler implements ExceptionHandle // You can override the view path. protected ?string $viewPath = APPPATH . 'Views/exception/'; + #[Override] public function handle( Throwable $exception, RequestInterface $request, diff --git a/docs/guides/api/controller.md b/docs/guides/api/controller.md index b4e8e027a6e6..1558f38fd68d 100644 --- a/docs/guides/api/controller.md +++ b/docs/guides/api/controller.md @@ -94,9 +94,11 @@ Edit the Book transformer at **app/Transformers/BookTransformer.php**. This one namespace App\Transformers; use CodeIgniter\API\BaseTransformer; +use Override; class BookTransformer extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return [ diff --git a/docs/guides/api/database-setup.md b/docs/guides/api/database-setup.md index 86e0adf05660..bafb058a5d14 100644 --- a/docs/guides/api/database-setup.md +++ b/docs/guides/api/database-setup.md @@ -23,9 +23,11 @@ Edit the generated **app/Database/Migrations/<timestamp>\_CreateAuthorsTable. namespace App\Database\Migrations; use CodeIgniter\Database\Migration; +use Override; class CreateAuthorsTable extends Migration { + #[Override] public function up() { $this->forge->addField([ @@ -54,6 +56,7 @@ class CreateAuthorsTable extends Migration $this->forge->createTable('authors'); } + #[Override] public function down() { $this->forge->dropTable('authors'); @@ -71,9 +74,11 @@ Now, edit the generated **app/Database/Migrations/<timestamp>\_CreateBooksTab namespace App\Database\Migrations; use CodeIgniter\Database\Migration; +use Override; class CreateBooksTable extends Migration { + #[Override] public function up() { $this->forge->addField([ @@ -111,6 +116,7 @@ class CreateBooksTable extends Migration $this->forge->createTable('books'); } + #[Override] public function down() { $this->forge->dropTable('books'); @@ -146,9 +152,11 @@ Edit the file at **app/Database/Seeds/BookSeeder.php**: namespace App\Database\Seeds; use CodeIgniter\Database\Seeder; +use Override; class BookSeeder extends Seeder { + #[Override] public function run() { // Define author data and insert diff --git a/docs/incoming/controller_attributes.md b/docs/incoming/controller_attributes.md index aecc5ed8ce9f..6e6f31184415 100644 --- a/docs/incoming/controller_attributes.md +++ b/docs/incoming/controller_attributes.md @@ -171,6 +171,7 @@ use Attribute; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\Router\Attributes\RouteAttributeInterface; +use Override; /** * Custom Header Attribute @@ -197,6 +198,7 @@ class AddHeader implements RouteAttributeInterface * Called before the controller method executes. * Return null to continue to the controller. */ + #[Override] public function before(RequestInterface $request): RequestInterface|ResponseInterface|null { // We don't need to do anything before the controller runs @@ -207,6 +209,7 @@ class AddHeader implements RouteAttributeInterface * Called after the controller method executes. * Add the custom header to the response. */ + #[Override] public function after(RequestInterface $request, ResponseInterface $response): ?ResponseInterface { $response->setHeader($this->name, $this->value); diff --git a/docs/incoming/controllers.md b/docs/incoming/controllers.md index 213a7d650fd6..2884cb89c473 100644 --- a/docs/incoming/controllers.md +++ b/docs/incoming/controllers.md @@ -21,10 +21,12 @@ namespace App\Controllers; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; use Psr\Log\LoggerInterface; class Product extends BaseController { + #[Override] public function initController( RequestInterface $request, ResponseInterface $response, diff --git a/docs/incoming/filters.md b/docs/incoming/filters.md index 76921f6803d9..38aedb25752a 100644 --- a/docs/incoming/filters.md +++ b/docs/incoming/filters.md @@ -23,14 +23,17 @@ namespace App\Filters; use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; class MyFilter implements FilterInterface { + #[Override] public function before(RequestInterface $request, $arguments = null) { // Do something here } + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { // Do something here @@ -64,9 +67,11 @@ namespace App\Filters; use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; class MyFilter implements FilterInterface { + #[Override] public function before(RequestInterface $request, $arguments = null) { $auth = service('auth'); diff --git a/docs/incoming/form_requests.md b/docs/incoming/form_requests.md index 4236535e8824..5bc9bf0ed06d 100644 --- a/docs/incoming/form_requests.md +++ b/docs/incoming/form_requests.md @@ -18,9 +18,11 @@ This creates **app/Requests/StorePostRequest.php**. Fill in the `rules()` method namespace App\Requests; use CodeIgniter\HTTP\FormRequest; +use Override; class StorePostRequest extends FormRequest { + #[Override] public function rules(): array { return [ @@ -221,9 +223,11 @@ Override `messages()` to return field-specific error messages. The format is ide namespace App\Requests; use CodeIgniter\HTTP\FormRequest; +use Override; class StorePostRequest extends FormRequest { + #[Override] public function rules(): array { return [ @@ -232,6 +236,7 @@ class StorePostRequest extends FormRequest ]; } + #[Override] public function messages(): array { return [ @@ -255,9 +260,11 @@ Override `isAuthorized()` to control whether the current user is allowed to make namespace App\Requests; use CodeIgniter\HTTP\FormRequest; +use Override; class StorePostRequest extends FormRequest { + #[Override] public function rules(): array { return [ @@ -266,6 +273,7 @@ class StorePostRequest extends FormRequest ]; } + #[Override] public function isAuthorized(): bool { // Only authenticated users may submit posts. @@ -285,9 +293,11 @@ Override `prepareForValidation(array $data): array` to normalize or derive input namespace App\Requests; use CodeIgniter\HTTP\FormRequest; +use Override; class StorePostRequest extends FormRequest { + #[Override] public function rules(): array { return [ @@ -296,6 +306,7 @@ class StorePostRequest extends FormRequest ]; } + #[Override] protected function prepareForValidation(array $data): array { // Derive the slug from the title so it is available for the @@ -327,15 +338,18 @@ Override `validationData()` when you need a different data source - for example, namespace App\Requests; use CodeIgniter\HTTP\FormRequest; +use Override; class SearchRequest extends FormRequest { + #[Override] public function rules(): array { return ['q' => 'required|min_length[2]']; } // Merge query-string parameters and POST body for this endpoint. + #[Override] protected function validationData(): array { return array_merge( @@ -355,9 +369,11 @@ namespace App\Requests; use CodeIgniter\HTTP\FormRequest; use CodeIgniter\HTTP\ResponseInterface; +use Override; class StorePostRequest extends FormRequest { + #[Override] public function rules(): array { return [ @@ -367,12 +383,14 @@ class StorePostRequest extends FormRequest } // Always respond with JSON, regardless of the request type. + #[Override] protected function failedValidation(array $errors, array $preparedData): ResponseInterface { return service('response')->setStatusCode(422)->setJSON(['errors' => $errors]); } // Always respond with 403, regardless of the request type. + #[Override] protected function failedAuthorization(): ResponseInterface { return service('response')->setStatusCode(403); @@ -396,9 +414,11 @@ namespace App\Requests; use CodeIgniter\HTTP\FormRequest; use CodeIgniter\HTTP\ResponseInterface; +use Override; class StorePostRequest extends FormRequest { + #[Override] public function rules(): array { return [ @@ -407,6 +427,7 @@ class StorePostRequest extends FormRequest ]; } + #[Override] protected function prepareForValidation(array $data): array { $data['slug'] = url_title($data['title'] ?? '', '-', true); @@ -415,6 +436,7 @@ class StorePostRequest extends FormRequest } // Override while still flashing the prepared values on redirect. + #[Override] protected function failedValidation(array $errors, array $preparedData): ResponseInterface { if ( diff --git a/docs/incoming/restful.md b/docs/incoming/restful.md index 1ea44febd77d..b10e29d350c4 100644 --- a/docs/incoming/restful.md +++ b/docs/incoming/restful.md @@ -121,12 +121,14 @@ Extend it, overriding the `modelName` and `format` properties, and then implemen namespace App\Controllers; use CodeIgniter\RESTful\ResourceController; +use Override; class Photos extends ResourceController { protected $modelName = 'App\Models\Photos'; protected $format = 'json'; + #[Override] public function index() { return $this->respond($this->model->findAll()); @@ -259,11 +261,13 @@ Extend it, overriding the `modelName` property, and then implement those methods namespace App\Controllers; use CodeIgniter\RESTful\ResourcePresenter; +use Override; class Photos extends ResourcePresenter { protected $modelName = 'App\Models\Photos'; + #[Override] public function index() { return view('templates/list', $this->model->findAll()); diff --git a/docs/installation/upgrade_migrations.md b/docs/installation/upgrade_migrations.md index df9ad66bca0e..6a9ef78f169b 100644 --- a/docs/installation/upgrade_migrations.md +++ b/docs/installation/upgrade_migrations.md @@ -88,9 +88,11 @@ Path: **app/Database/Migrations**: namespace App\Database\Migrations; use CodeIgniter\Database\Migration; +use Override; class AddBlog extends Migration { + #[Override] public function up() { $this->forge->addField([ @@ -113,6 +115,7 @@ class AddBlog extends Migration $this->forge->createTable('blog'); } + #[Override] public function down() { $this->forge->dropTable('blog'); diff --git a/docs/libraries/file_collections.md b/docs/libraries/file_collections.md index b4554b7c45b4..c41a97873596 100644 --- a/docs/libraries/file_collections.md +++ b/docs/libraries/file_collections.md @@ -63,9 +63,11 @@ Example: namespace App; use CodeIgniter\Files\FileCollection; +use Override; class ConfigCollection extends FileCollection { + #[Override] protected function define(): void { $this->add(APPPATH . 'Config', true)->retainPattern('*.php'); diff --git a/docs/libraries/publisher.md b/docs/libraries/publisher.md index ac74687cf574..fcffc6679840 100644 --- a/docs/libraries/publisher.md +++ b/docs/libraries/publisher.md @@ -163,6 +163,7 @@ namespace App\Commands; use CodeIgniter\CLI\BaseCommand; use CodeIgniter\Publisher\Publisher; +use Override; use Throwable; class DailyPhoto extends BaseCommand @@ -171,6 +172,7 @@ class DailyPhoto extends BaseCommand protected $name = 'publish:daily'; protected $description = 'Publishes the latest daily photo to the homepage.'; + #[Override] public function run(array $params) { $publisher = new Publisher('/path/to/photos/', FCPATH . 'assets/images'); @@ -202,6 +204,7 @@ You want to integrate the frontend library "Bootstrap" into your project, but th namespace App\Publishers; use CodeIgniter\Publisher\Publisher; +use Override; class BootstrapPublisher extends Publisher { @@ -227,6 +230,7 @@ class BootstrapPublisher extends Publisher * Use the "publish" method to indicate that this * class is ready to be discovered and automated. */ + #[Override] public function publish(): bool { return $this @@ -291,6 +295,7 @@ namespace Math\Auth\Commands; use CodeIgniter\CLI\BaseCommand; use CodeIgniter\Publisher\Publisher; +use Override; use Throwable; class AuthPublish extends BaseCommand @@ -299,6 +304,7 @@ class AuthPublish extends BaseCommand protected $name = 'auth:publish'; protected $description = 'Publish Auth components into the current application.'; + #[Override] public function run(array $params) { // Use the Autoloader to figure out the module path diff --git a/docs/libraries/throttler.md b/docs/libraries/throttler.md index 1a051707c9be..9e3f07e4dca2 100644 --- a/docs/libraries/throttler.md +++ b/docs/libraries/throttler.md @@ -38,6 +38,7 @@ namespace App\Filters; use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; class Throttle implements FilterInterface { @@ -49,6 +50,7 @@ class Throttle implements FilterInterface * * @return ResponseInterface|void */ + #[Override] public function before(RequestInterface $request, $arguments = null) { $throttler = service('throttler'); @@ -67,6 +69,7 @@ class Throttle implements FilterInterface * * @return void */ + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { // ... diff --git a/docs/models/entities.md b/docs/models/entities.md index 6e9104cd0bf7..dc463c7cd9fd 100644 --- a/docs/models/entities.md +++ b/docs/models/entities.md @@ -628,15 +628,18 @@ First, you need to create a handler class for your type. Let's say the class wil namespace App\Entities\Cast; use CodeIgniter\Entity\Cast\BaseCast; +use Override; // The class must inherit the CodeIgniter\Entity\Cast\BaseCast class class CastBase64 extends BaseCast { + #[Override] public static function get($value, array $params = []) { return base64_decode($value, true); } + #[Override] public static function set($value, array $params = []) { return base64_encode($value); @@ -680,9 +683,11 @@ If you don't need to change values when getting or setting a value, just don't i namespace App\Entities\Cast; use CodeIgniter\Entity\Cast\BaseCast; +use Override; class CastBase64 extends BaseCast { + #[Override] public static function get($value, array $params = []) { return base64_decode($value, true); @@ -721,9 +726,11 @@ class MyEntity extends Entity namespace App\Entities\Cast; use CodeIgniter\Entity\Cast\BaseCast; +use Override; class SomeHandler extends BaseCast { + #[Override] public static function get($value, array $params = []) { var_dump($params); diff --git a/docs/models/model.md b/docs/models/model.md index 3db964ec480f..e9e176218875 100644 --- a/docs/models/model.md +++ b/docs/models/model.md @@ -556,10 +556,12 @@ namespace App\Models\Cast; use CodeIgniter\DataCaster\Cast\BaseCast; use InvalidArgumentException; +use Override; // The class must inherit the CodeIgniter\DataCaster\Cast\BaseCast class class CastBase64 extends BaseCast { + #[Override] public static function get( mixed $value, array $params = [], @@ -578,6 +580,7 @@ class CastBase64 extends BaseCast return $decoded; } + #[Override] public static function set( mixed $value, array $params = [], @@ -601,9 +604,11 @@ namespace App\Models\Cast; use CodeIgniter\DataCaster\Cast\BaseCast; use InvalidArgumentException; +use Override; class CastBase64 extends BaseCast { + #[Override] public static function get( mixed $value, array $params = [], @@ -690,9 +695,11 @@ class MyModel extends Model namespace App\Models\Cast; use CodeIgniter\DataCaster\Cast\BaseCast; +use Override; class SomeHandler extends BaseCast { + #[Override] public static function get( mixed $value, array $params = [], diff --git a/docs/outgoing/api_transformers.md b/docs/outgoing/api_transformers.md index 4a8e259922e8..a39e3cf4a284 100644 --- a/docs/outgoing/api_transformers.md +++ b/docs/outgoing/api_transformers.md @@ -12,9 +12,11 @@ The following example shows a common usage pattern for transformers in your appl namespace App\Transformers; use CodeIgniter\API\BaseTransformer; +use Override; class UserTransformer extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return [ @@ -47,9 +49,11 @@ To create a transformer, extend the `BaseTransformer` class and implement the `t namespace App\Transformers; use CodeIgniter\API\BaseTransformer; +use Override; class UserTransformer extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return [ @@ -161,9 +165,11 @@ The transformer automatically supports field filtering through the `fields` quer namespace App\Transformers; use CodeIgniter\API\BaseTransformer; +use Override; class UserTransformer extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return [ @@ -199,9 +205,11 @@ By default, clients can request any field defined in your `toArray()` method. Yo namespace App\Transformers; use CodeIgniter\API\BaseTransformer; +use Override; class UserTransformer extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return [ @@ -213,6 +221,7 @@ class UserTransformer extends BaseTransformer ]; } + #[Override] protected function getAllowedFields(): ?array { // Only these fields can be requested @@ -237,12 +246,14 @@ To opt a transformer into this, declare its resource type via the `$resourceType namespace App\Transformers; use CodeIgniter\API\BaseTransformer; +use Override; class PostTransformer extends BaseTransformer { // Enables ?fields[posts]=... for this resource type. protected ?string $resourceType = 'posts'; + #[Override] public function toArray(mixed $resource): array { return [ @@ -296,9 +307,11 @@ To support including related resources, create methods prefixed with `include` f namespace App\Transformers; use CodeIgniter\API\BaseTransformer; +use Override; class UserTransformer extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return [ @@ -366,9 +379,11 @@ namespace App\Transformers; use App\Transformers\CommentTransformer; use App\Transformers\PostTransformer; use CodeIgniter\API\BaseTransformer; +use Override; class UserTransformer extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return [ @@ -378,6 +393,7 @@ class UserTransformer extends BaseTransformer ]; } + #[Override] protected function getAllowedIncludes(): ?array { // Only these relationships can be included @@ -417,9 +433,11 @@ If you want to disable all includes, return an empty array: namespace App\Transformers; use CodeIgniter\API\BaseTransformer; +use Override; class UserTransformer extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return [ @@ -429,6 +447,7 @@ class UserTransformer extends BaseTransformer ]; } + #[Override] protected function getAllowedIncludes(): ?array { // Return empty array to disable all includes @@ -552,9 +571,11 @@ If you don't pass a resource to `transform()`, it will use the data from your `t namespace App\Transformers; use CodeIgniter\API\BaseTransformer; +use Override; class StaticDataTransformer extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return [ @@ -611,9 +632,11 @@ This abstract method must be implemented by child classes to define the structur namespace App\Transformers; use CodeIgniter\API\BaseTransformer; +use Override; class ProductTransformer extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return [ @@ -702,9 +725,11 @@ Override this method to restrict which fields can be requested via the `fields` namespace App\Transformers; use CodeIgniter\API\BaseTransformer; +use Override; class UserTransformer extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return [ @@ -715,6 +740,7 @@ class UserTransformer extends BaseTransformer ]; } + #[Override] protected function getAllowedFields(): ?array { // Clients can only request id, name, and created_at @@ -737,9 +763,11 @@ Override this method to restrict which related resources can be included via the namespace App\Transformers; use CodeIgniter\API\BaseTransformer; +use Override; class UserTransformer extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return [ @@ -749,6 +777,7 @@ class UserTransformer extends BaseTransformer ]; } + #[Override] protected function getAllowedIncludes(): ?array { // Only 'posts' can be included via ?include=posts diff --git a/docs/outgoing/view_cells.md b/docs/outgoing/view_cells.md index 5397f02bc521..32c082405f24 100644 --- a/docs/outgoing/view_cells.md +++ b/docs/outgoing/view_cells.md @@ -207,12 +207,14 @@ To take advantage of the full features of controlled Cells, you should use `$thi namespace App\Cells; use CodeIgniter\View\Cells\Cell; +use Override; class AlertMessageCell extends Cell { public $type; public $message; + #[Override] public function render(): string { return $this->view('my/custom/view', ['extra' => 'data']); diff --git a/docs/outgoing/view_decorators.md b/docs/outgoing/view_decorators.md index 7d6061ff3e7c..e1068ef78126 100644 --- a/docs/outgoing/view_decorators.md +++ b/docs/outgoing/view_decorators.md @@ -18,9 +18,11 @@ Creating your own view decorators requires creating a new class that implements namespace App\Views\Decorators; use CodeIgniter\View\ViewDecoratorInterface; +use Override; class MyDecorator implements ViewDecoratorInterface { + #[Override] public static function decorate(string $html): string { // Modify the output here diff --git a/docs/testing/database.md b/docs/testing/database.md index 8c662d852ab8..0f3886f45479 100644 --- a/docs/testing/database.md +++ b/docs/testing/database.md @@ -29,11 +29,13 @@ namespace App\Database; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use Override; class MyTests extends CIUnitTestCase { use DatabaseTestTrait; + #[Override] protected function setUp(): void { parent::setUp(); @@ -41,6 +43,7 @@ class MyTests extends CIUnitTestCase // Do something here.... } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/docs/testing/fabricator.md b/docs/testing/fabricator.md index c3c90ffc2754..d778a7ff5123 100644 --- a/docs/testing/fabricator.md +++ b/docs/testing/fabricator.md @@ -12,14 +12,17 @@ Often you will need sample data for your application to run its tests. The `Fabr namespace App\Models; use CodeIgniter\Test\Interfaces\FabricatorModel; +use Override; class MyModel implements FabricatorModel { + #[Override] public function find($id = null) { // TODO: Implement find() method. } + #[Override] public function insert($row = null, bool $returnID = true) { // TODO: Implement insert() method. @@ -132,9 +135,11 @@ namespace Tests\Support\Models; use App\Models\UserModel; use Faker\Generator; +use Override; class UserFabricator extends UserModel { + #[Override] public function fake(Generator &$faker) { // ... diff --git a/docs/testing/feature.md b/docs/testing/feature.md index fc2a4a723d76..88acf2281411 100644 --- a/docs/testing/feature.md +++ b/docs/testing/feature.md @@ -14,12 +14,14 @@ namespace Tests\Feature; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use CodeIgniter\Test\FeatureTestTrait; +use Override; class FooTest extends CIUnitTestCase { use DatabaseTestTrait; use FeatureTestTrait; + #[Override] protected function setUp(): void { parent::setUp(); @@ -27,6 +29,7 @@ class FooTest extends CIUnitTestCase $this->myClassMethod(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/docs/testing/overview.md b/docs/testing/overview.md index e157363073ae..2455ef609e04 100644 --- a/docs/testing/overview.md +++ b/docs/testing/overview.md @@ -113,9 +113,11 @@ If you implement any of these special functions, make sure you run their parent namespace App\Models; use CodeIgniter\Test\CIUnitTestCase; +use Override; final class UserModelTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); // Do not forget @@ -413,10 +415,12 @@ namespace Tests; use App\Models\UserModel; use CodeIgniter\Config\Factories; use CodeIgniter\Test\CIUnitTestCase; +use Override; use Tests\Support\Mock\MockUserModel; final class SomeTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); @@ -443,9 +447,11 @@ namespace Tests; use CodeIgniter\I18n\Time; use CodeIgniter\Test\CIUnitTestCase; +use Override; final class TimeDependentCodeTest extends CIUnitTestCase { + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/docs/testing/packages.md b/docs/testing/packages.md index f48241df1672..58a59d31344d 100644 --- a/docs/testing/packages.md +++ b/docs/testing/packages.md @@ -33,19 +33,23 @@ The orchestrator class is then: namespace Acme\Blog\Tests; use CodeIgniter\Test\Orchestrator\AbstractOrchestrator; +use Override; final class BlogOrchestrator extends AbstractOrchestrator { + #[Override] protected function getPackageRoot(): string { return dirname(__DIR__); } + #[Override] protected function getFixtures(): array { return [__DIR__ . '/Fixtures']; } + #[Override] protected function getEnv(): array { return ['app.baseURL' => 'http://localhost/']; diff --git a/docs/testing/session_testing.md b/docs/testing/session_testing.md index dadffe79ce8e..e5726f3a008b 100644 --- a/docs/testing/session_testing.md +++ b/docs/testing/session_testing.md @@ -61,6 +61,7 @@ class SessionTest extends CIUnitTestCase { protected Session $testSession; + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/phpstan.dist.neon b/phpstan.dist.neon index 394b6dd62614..cae51ff7d5c0 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -35,6 +35,7 @@ parameters: identifier: trait.unused path: system/CLI/GeneratorTrait.php checkMissingCallableSignature: true + checkMissingOverrideMethodAttribute: true treatPhpDocTypesAsCertain: false strictRules: allRules: false diff --git a/rector.php b/rector.php index f3ce95569a19..a704d321bda8 100644 --- a/rector.php +++ b/rector.php @@ -29,6 +29,7 @@ use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; use Rector\Php83\Rector\ClassConst\AddTypeToConstRector; use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector; +use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\NoSetupWithParentCallOverrideRector; use Rector\PHPUnit\CodeQuality\Rector\StmtsAwareInterface\DeclareStrictTypesTestsRector; use Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector; use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; @@ -86,6 +87,7 @@ YieldDataProviderRector::class, AddTypeToConstRector::class, + NoSetupWithParentCallOverrideRector::class, RemoveUnusedPrivateMethodRector::class => [ // private method called via getPrivateMethodInvoker diff --git a/system/API/BaseTransformer.php b/system/API/BaseTransformer.php index 1496301ca58d..4a1ddebdcb9c 100644 --- a/system/API/BaseTransformer.php +++ b/system/API/BaseTransformer.php @@ -15,6 +15,7 @@ use CodeIgniter\HTTP\IncomingRequest; use InvalidArgumentException; +use Override; /** * Base class for transforming resources into arrays. @@ -160,12 +161,14 @@ private function splitList(string $value): array * * @param mixed $resource The resource being transformed */ + #[Override] abstract public function toArray(mixed $resource): array; /** * Transforms the given resource into an array using * the $this->toArray(). */ + #[Override] public function transform(array|object|null $resource = null): array { // Store the resource so include methods can access it @@ -190,6 +193,7 @@ public function transform(array|object|null $resource = null): array * If the request's 'fields' query variable is set, only those fields will be included * in the transformed output. */ + #[Override] public function transformMany(array $resources): array { return array_map($this->transform(...), $resources); diff --git a/system/Autoloader/FileLocator.php b/system/Autoloader/FileLocator.php index 845f4353f20a..ef101c1509ff 100644 --- a/system/Autoloader/FileLocator.php +++ b/system/Autoloader/FileLocator.php @@ -13,6 +13,8 @@ namespace CodeIgniter\Autoloader; +use Override; + /** * Allows loading non-class files in a namespaced manner. * Works with Helpers, Views, etc. @@ -53,6 +55,7 @@ public function __construct(Autoloader $autoloader) * * @return false|non-empty-string The path to the file, or false if not found. */ + #[Override] public function locateFile(string $file, ?string $folder = null, string $ext = 'php') { $file = $this->ensureExt($file, $ext); @@ -124,6 +127,7 @@ public function locateFile(string $file, ?string $folder = null, string $ext = ' /** * Examines a file and returns the fully qualified class name. */ + #[Override] public function getClassname(string $file): string { if (is_dir($file)) { @@ -186,6 +190,7 @@ public function getClassname(string $file): string * * @return list */ + #[Override] public function search(string $path, string $ext = 'php', bool $prioritizeApp = true): array { $path = $this->ensureExt($path, $ext); @@ -265,6 +270,7 @@ protected function getNamespaces() return array_merge($namespaces, $system); } + #[Override] public function findQualifiedNameFromPath(string $path) { $resolvedPath = realpath($path); @@ -318,6 +324,7 @@ public function findQualifiedNameFromPath(string $path) * * @return list List of file paths */ + #[Override] public function listFiles(string $path): array { if ($path === '') { @@ -340,6 +347,7 @@ public function listFiles(string $path): array * * @return list List of file paths */ + #[Override] public function listNamespaceFiles(string $prefix, string $path): array { if ($path === '' || $prefix === '') { diff --git a/system/Autoloader/FileLocatorCached.php b/system/Autoloader/FileLocatorCached.php index 0690a6af7b66..b9dc6b059072 100644 --- a/system/Autoloader/FileLocatorCached.php +++ b/system/Autoloader/FileLocatorCached.php @@ -15,6 +15,7 @@ use CodeIgniter\Cache\CacheInterface; use CodeIgniter\Cache\FactoriesCache\FileVarExportHandler; +use Override; /** * FileLocator with Cache @@ -87,6 +88,7 @@ public function deleteCache(): void $this->cacheHandler->delete($this->cacheKey); } + #[Override] public function findQualifiedNameFromPath(string $path): false|string { if (isset($this->cache['findQualifiedNameFromPath'][$path])) { @@ -101,6 +103,7 @@ public function findQualifiedNameFromPath(string $path): false|string return $classname; } + #[Override] public function getClassname(string $file): string { if (isset($this->cache['getClassname'][$file])) { @@ -118,6 +121,7 @@ public function getClassname(string $file): string /** * @return list */ + #[Override] public function search(string $path, string $ext = 'php', bool $prioritizeApp = true): array { if (isset($this->cache['search'][$path][$ext][$prioritizeApp])) { @@ -132,6 +136,7 @@ public function search(string $path, string $ext = 'php', bool $prioritizeApp = return $foundPaths; } + #[Override] public function listFiles(string $path): array { if (isset($this->cache['listFiles'][$path])) { @@ -146,6 +151,7 @@ public function listFiles(string $path): array return $files; } + #[Override] public function listNamespaceFiles(string $prefix, string $path): array { if (isset($this->cache['listNamespaceFiles'][$prefix][$path])) { @@ -160,6 +166,7 @@ public function listNamespaceFiles(string $prefix, string $path): array return $files; } + #[Override] public function locateFile(string $file, ?string $folder = null, string $ext = 'php'): false|string { $folderKey = $folder ?? ''; diff --git a/system/CLI/AbstractGeneratorCommand.php b/system/CLI/AbstractGeneratorCommand.php index 57a1cc294810..abad4accff40 100644 --- a/system/CLI/AbstractGeneratorCommand.php +++ b/system/CLI/AbstractGeneratorCommand.php @@ -18,6 +18,7 @@ use CodeIgniter\CLI\Input\Option; use CodeIgniter\Exceptions\LogicException; use Config\Generators; +use Override; use Throwable; /** @@ -74,6 +75,7 @@ public function __construct(Commands $commands) parent::__construct($commands); } + #[Override] protected function configure(): void { $this->addArgument(new Argument( @@ -83,6 +85,7 @@ protected function configure(): void )); } + #[Override] protected function provideDefaultOptions(): void { $this->provideGeneratorOptions(); @@ -127,11 +130,13 @@ final protected function addForceOption(): static )); } + #[Override] protected function getArgumentPromptLabels(): array { return ['name' => lang($this->classNameLang)]; } + #[Override] protected function execute(array $arguments, array $options): int { return $this->generateClass(); diff --git a/system/CLI/NullInputOutput.php b/system/CLI/NullInputOutput.php index 1686f564adae..69e000edd023 100644 --- a/system/CLI/NullInputOutput.php +++ b/system/CLI/NullInputOutput.php @@ -13,15 +13,19 @@ namespace CodeIgniter\CLI; +use Override; + /** * An InputOutput sink that discards all output and never reads input. */ final class NullInputOutput extends InputOutput { + #[Override] public function fwrite($handle, string $string): void { } + #[Override] public function input(?string $prefix = null): string { return ''; diff --git a/system/Cache/Handlers/ApcuHandler.php b/system/Cache/Handlers/ApcuHandler.php index f8b49128c607..3c26bfa8a84d 100644 --- a/system/Cache/Handlers/ApcuHandler.php +++ b/system/Cache/Handlers/ApcuHandler.php @@ -17,6 +17,7 @@ use Closure; use CodeIgniter\I18n\Time; use Config\Cache; +use Override; /** * APCu cache handler @@ -31,10 +32,12 @@ public function __construct(Cache $config) $this->prefix = $config->prefix; } + #[Override] public function initialize(): void { } + #[Override] public function get(string $key): mixed { $key = static::validateKey($key, $this->prefix); @@ -46,6 +49,7 @@ public function get(string $key): mixed return $success ? $data : null; } + #[Override] public function save(string $key, $value, int $ttl = 60): bool { $key = static::validateKey($key, $this->prefix); @@ -53,6 +57,7 @@ public function save(string $key, $value, int $ttl = 60): bool return apcu_store($key, $value, $ttl); } + #[Override] public function remember(string $key, callable|int $ttl, Closure $callback): mixed { if (is_callable($ttl)) { @@ -64,6 +69,7 @@ public function remember(string $key, callable|int $ttl, Closure $callback): mix return apcu_entry($key, $callback, $ttl); } + #[Override] public function delete(string $key): bool { $key = static::validateKey($key, $this->prefix); @@ -71,6 +77,7 @@ public function delete(string $key): bool return apcu_delete($key); } + #[Override] public function deleteMatching(string $pattern): int { $matchedKeys = array_filter( @@ -85,6 +92,7 @@ public function deleteMatching(string $pattern): int return 0; } + #[Override] public function increment(string $key, int $offset = 1): false|int { $key = static::validateKey($key, $this->prefix); @@ -92,6 +100,7 @@ public function increment(string $key, int $offset = 1): false|int return apcu_inc($key, $offset); } + #[Override] public function decrement(string $key, int $offset = 1): false|int { $key = static::validateKey($key, $this->prefix); @@ -99,16 +108,19 @@ public function decrement(string $key, int $offset = 1): false|int return apcu_dec($key, $offset); } + #[Override] public function clean(): bool { return apcu_clear_cache(); } + #[Override] public function getCacheInfo(): array|false { return apcu_cache_info(true); } + #[Override] public function getMetaData(string $key): ?array { $key = static::validateKey($key, $this->prefix); @@ -125,6 +137,7 @@ public function getMetaData(string $key): ?array return null; } + #[Override] public function isSupported(): bool { return extension_loaded('apcu') && apcu_enabled(); diff --git a/system/Cache/Handlers/BaseHandler.php b/system/Cache/Handlers/BaseHandler.php index 51bed3b32997..3aff45fb4c99 100644 --- a/system/Cache/Handlers/BaseHandler.php +++ b/system/Cache/Handlers/BaseHandler.php @@ -17,6 +17,7 @@ use CodeIgniter\Cache\CacheInterface; use CodeIgniter\Exceptions\InvalidArgumentException; use Config\Cache; +use Override; /** * Base class for cache handling @@ -62,6 +63,7 @@ public static function validateKey($key, $prefix = ''): string return strlen($prefix . $key) > static::MAX_KEY_LENGTH ? $prefix . md5($key) : $prefix . $key; } + #[Override] public function remember(string $key, callable|int $ttl, Closure $callback): mixed { $value = $this->get($key); diff --git a/system/Cache/Handlers/DummyHandler.php b/system/Cache/Handlers/DummyHandler.php index fa32593e371a..e3e7c91a8f36 100644 --- a/system/Cache/Handlers/DummyHandler.php +++ b/system/Cache/Handlers/DummyHandler.php @@ -14,66 +14,79 @@ namespace CodeIgniter\Cache\Handlers; use Closure; +use Override; /** * Dummy cache handler */ class DummyHandler extends BaseHandler { + #[Override] public function initialize(): void { } + #[Override] public function get(string $key): mixed { return null; } + #[Override] public function remember(string $key, callable|int $ttl, Closure $callback): mixed { return null; } + #[Override] public function save(string $key, mixed $value, int $ttl = 60): bool { return true; } + #[Override] public function delete(string $key): bool { return true; } + #[Override] public function deleteMatching(string $pattern): int { return 0; } + #[Override] public function increment(string $key, int $offset = 1): bool { return true; } + #[Override] public function decrement(string $key, int $offset = 1): bool { return true; } + #[Override] public function clean(): bool { return true; } + #[Override] public function getCacheInfo(): ?array { return null; } + #[Override] public function getMetaData(string $key): ?array { return null; } + #[Override] public function isSupported(): bool { return true; diff --git a/system/Cache/Handlers/FileHandler.php b/system/Cache/Handlers/FileHandler.php index 1e4b6df8c57c..d0b10dfb202e 100644 --- a/system/Cache/Handlers/FileHandler.php +++ b/system/Cache/Handlers/FileHandler.php @@ -20,6 +20,7 @@ use CodeIgniter\I18n\Time; use Config\Cache; use FilesystemIterator; +use Override; use Throwable; use UnexpectedValueException; @@ -79,10 +80,12 @@ public function __construct(Cache $config) helper('filesystem'); } + #[Override] public function initialize(): void { } + #[Override] public function get(string $key): mixed { $key = static::validateKey($key, $this->prefix); @@ -91,6 +94,7 @@ public function get(string $key): mixed return is_array($data) ? $data['data'] : null; } + #[Override] public function save(string $key, mixed $value, int $ttl = 60): bool { $key = static::validateKey($key, $this->prefix); @@ -117,6 +121,7 @@ public function save(string $key, mixed $value, int $ttl = 60): bool return false; } + #[Override] public function delete(string $key): bool { $key = static::validateKey($key, $this->prefix); @@ -124,6 +129,7 @@ public function delete(string $key): bool return is_file($this->path . $key) && unlink($this->path . $key); } + #[Override] public function deleteMatching(string $pattern): int { // The pattern is matched against file names only and never becomes part @@ -152,6 +158,7 @@ public function deleteMatching(string $pattern): int return $deleted; } + #[Override] public function increment(string $key, int $offset = 1): bool|int { $prefixedKey = static::validateKey($key, $this->prefix); @@ -172,21 +179,25 @@ public function increment(string $key, int $offset = 1): bool|int return $this->save($key, $value, $ttl) ? $value : false; } + #[Override] public function decrement(string $key, int $offset = 1): bool|int { return $this->increment($key, -$offset); } + #[Override] public function clean(): bool { return delete_files($this->path, false, true); } + #[Override] public function getCacheInfo(): array { return get_dir_file_info($this->path); } + #[Override] public function getMetaData(string $key): ?array { $key = static::validateKey($key, $this->prefix); @@ -202,11 +213,13 @@ public function getMetaData(string $key): ?array ]; } + #[Override] public function isSupported(): bool { return is_writable($this->path); } + #[Override] public function lockStore(): LockStoreInterface { return $this->lockStore; diff --git a/system/Cache/Handlers/MemcachedHandler.php b/system/Cache/Handlers/MemcachedHandler.php index 041acfd18c81..4327f9419bef 100644 --- a/system/Cache/Handlers/MemcachedHandler.php +++ b/system/Cache/Handlers/MemcachedHandler.php @@ -24,6 +24,7 @@ use Exception; use Memcache; use Memcached; +use Override; /** * Mamcached cache handler @@ -61,6 +62,7 @@ public function __construct(Cache $config) $this->config = array_merge($this->config, $config->memcached); } + #[Override] public function initialize(): void { try { @@ -107,6 +109,7 @@ public function initialize(): void } } + #[Override] public function get(string $key): mixed { $data = []; @@ -132,6 +135,7 @@ public function get(string $key): mixed return is_array($data) ? $data[0] : $data; } + #[Override] public function save(string $key, mixed $value, int $ttl = 60): bool { $key = static::validateKey($key, $this->prefix); @@ -155,6 +159,7 @@ public function save(string $key, mixed $value, int $ttl = 60): bool return false; } + #[Override] public function delete(string $key): bool { $key = static::validateKey($key, $this->prefix); @@ -162,11 +167,13 @@ public function delete(string $key): bool return $this->memcached->delete($key); } + #[Override] public function deleteMatching(string $pattern): never { throw new BadMethodCallException('The deleteMatching method is not implemented for Memcached. You must select File, Redis or Predis handlers to use it.'); } + #[Override] public function increment(string $key, int $offset = 1): false|int { if (! $this->config['raw']) { @@ -178,6 +185,7 @@ public function increment(string $key, int $offset = 1): false|int return $this->memcached->increment($key, $offset, $offset, 60); } + #[Override] public function decrement(string $key, int $offset = 1): false|int { if (! $this->config['raw']) { @@ -193,16 +201,19 @@ public function decrement(string $key, int $offset = 1): false|int return $this->memcached->decrement($key, $offset, 0, 60); } + #[Override] public function clean(): bool { return $this->memcached->flush(); } + #[Override] public function getCacheInfo(): array|false { return $this->memcached->getStats(); } + #[Override] public function getMetaData(string $key): ?array { $key = static::validateKey($key, $this->prefix); @@ -222,11 +233,13 @@ public function getMetaData(string $key): ?array ]; } + #[Override] public function isSupported(): bool { return extension_loaded('memcached') || extension_loaded('memcache'); } + #[Override] public function lockStore(): LockStoreInterface { if (! $this->memcached instanceof Memcached) { @@ -236,6 +249,7 @@ public function lockStore(): LockStoreInterface return $this->lockStore ??= new MemcachedLockStore($this->memcached, $this->prefix); } + #[Override] public function ping(): bool { $version = $this->memcached->getVersion(); @@ -259,6 +273,7 @@ public function ping(): bool return false; } + #[Override] public function reconnect(): bool { if ($this->memcached instanceof Memcached) { diff --git a/system/Cache/Handlers/PredisHandler.php b/system/Cache/Handlers/PredisHandler.php index 5cdd29478070..80a48b564e5c 100644 --- a/system/Cache/Handlers/PredisHandler.php +++ b/system/Cache/Handlers/PredisHandler.php @@ -20,6 +20,7 @@ use CodeIgniter\I18n\Time; use Config\Cache; use Exception; +use Override; use Predis\Client; use Predis\Collection\Iterator\Keyspace; use Predis\Response\Status; @@ -71,6 +72,7 @@ public function __construct(Cache $config) $this->config = array_merge($this->config, $config->redis); } + #[Override] public function initialize(): void { try { @@ -82,6 +84,7 @@ public function initialize(): void } } + #[Override] public function get(string $key): mixed { $key = static::validateKey($key); @@ -102,6 +105,7 @@ public function get(string $key): mixed }; } + #[Override] public function save(string $key, mixed $value, int $ttl = 60): bool { $key = static::validateKey($key); @@ -135,6 +139,7 @@ public function save(string $key, mixed $value, int $ttl = 60): bool return true; } + #[Override] public function delete(string $key): bool { $key = static::validateKey($key); @@ -142,6 +147,7 @@ public function delete(string $key): bool return $this->redis->del($key) === 1; } + #[Override] public function deleteMatching(string $pattern): int { $matchedKeys = []; @@ -157,6 +163,7 @@ public function deleteMatching(string $pattern): int return $this->redis->del($matchedKeys); } + #[Override] public function increment(string $key, int $offset = 1): int { $key = static::validateKey($key); @@ -164,6 +171,7 @@ public function increment(string $key, int $offset = 1): int return $this->redis->hincrby($key, '__ci_value', $offset); } + #[Override] public function decrement(string $key, int $offset = 1): int { $key = static::validateKey($key); @@ -171,16 +179,19 @@ public function decrement(string $key, int $offset = 1): int return $this->redis->hincrby($key, '__ci_value', -$offset); } + #[Override] public function clean(): bool { return $this->redis->flushdb()->getPayload() === 'OK'; } + #[Override] public function getCacheInfo(): array { return $this->redis->info(); } + #[Override] public function getMetaData(string $key): ?array { $key = static::validateKey($key); @@ -201,17 +212,20 @@ public function getMetaData(string $key): ?array return null; } + #[Override] public function isSupported(): bool { return class_exists(Client::class); } + #[Override] public function lockStore(): LockStoreInterface { // Predis applies the configured prefix at the client level. return $this->lockStore ??= new PredisLockStore($this->redis); } + #[Override] public function ping(): bool { try { @@ -227,6 +241,7 @@ public function ping(): bool } } + #[Override] public function reconnect(): bool { try { diff --git a/system/Cache/Handlers/RedisHandler.php b/system/Cache/Handlers/RedisHandler.php index b0f09f7c8c9a..0e0b70cd3b18 100644 --- a/system/Cache/Handlers/RedisHandler.php +++ b/system/Cache/Handlers/RedisHandler.php @@ -19,6 +19,7 @@ use CodeIgniter\Exceptions\CriticalError; use CodeIgniter\I18n\Time; use Config\Cache; +use Override; use Redis; use RedisException; @@ -67,6 +68,7 @@ public function __construct(Cache $config) $this->config = array_merge($this->config, $config->redis); } + #[Override] public function initialize(): void { $config = $this->config; @@ -102,6 +104,7 @@ public function initialize(): void } } + #[Override] public function get(string $key): mixed { $key = static::validateKey($key, $this->prefix); @@ -118,6 +121,7 @@ public function get(string $key): mixed }; } + #[Override] public function save(string $key, mixed $value, int $ttl = 60): bool { $key = static::validateKey($key, $this->prefix); @@ -151,6 +155,7 @@ public function save(string $key, mixed $value, int $ttl = 60): bool return true; } + #[Override] public function delete(string $key): bool { $key = static::validateKey($key, $this->prefix); @@ -158,6 +163,7 @@ public function delete(string $key): bool return $this->redis->del($key) === 1; } + #[Override] public function deleteMatching(string $pattern): int { /** @var list $matchedKeys */ @@ -177,6 +183,7 @@ public function deleteMatching(string $pattern): int return (int) $this->redis->del($matchedKeys); } + #[Override] public function increment(string $key, int $offset = 1): int { $key = static::validateKey($key, $this->prefix); @@ -184,21 +191,25 @@ public function increment(string $key, int $offset = 1): int return $this->redis->hIncrBy($key, '__ci_value', $offset); } + #[Override] public function decrement(string $key, int $offset = 1): int { return $this->increment($key, -$offset); } + #[Override] public function clean(): bool { return $this->redis->flushDB(); } + #[Override] public function getCacheInfo(): array { return $this->redis->info(); } + #[Override] public function getMetaData(string $key): ?array { $value = $this->get($key); @@ -218,11 +229,13 @@ public function getMetaData(string $key): ?array return null; } + #[Override] public function isSupported(): bool { return extension_loaded('redis'); } + #[Override] public function lockStore(): LockStoreInterface { assert($this->redis instanceof Redis); @@ -230,6 +243,7 @@ public function lockStore(): LockStoreInterface return $this->lockStore ??= new RedisLockStore($this->redis, $this->prefix); } + #[Override] public function ping(): bool { if (! isset($this->redis)) { @@ -245,6 +259,7 @@ public function ping(): bool } } + #[Override] public function reconnect(): bool { if (isset($this->redis)) { diff --git a/system/Cache/Handlers/WincacheHandler.php b/system/Cache/Handlers/WincacheHandler.php index 5d520a05185e..7d17ff6f7aba 100644 --- a/system/Cache/Handlers/WincacheHandler.php +++ b/system/Cache/Handlers/WincacheHandler.php @@ -16,6 +16,7 @@ use CodeIgniter\Exceptions\BadMethodCallException; use CodeIgniter\I18n\Time; use Config\Cache; +use Override; /** * Cache handler for WinCache from Microsoft & IIS. @@ -32,10 +33,12 @@ public function __construct(Cache $config) $this->prefix = $config->prefix; } + #[Override] public function initialize(): void { } + #[Override] public function get(string $key): mixed { $key = static::validateKey($key, $this->prefix); @@ -47,6 +50,7 @@ public function get(string $key): mixed return $success ? $data : null; } + #[Override] public function save(string $key, mixed $value, int $ttl = 60): bool { $key = static::validateKey($key, $this->prefix); @@ -54,6 +58,7 @@ public function save(string $key, mixed $value, int $ttl = 60): bool return wincache_ucache_set($key, $value, $ttl); } + #[Override] public function delete(string $key): bool { $key = static::validateKey($key, $this->prefix); @@ -61,11 +66,13 @@ public function delete(string $key): bool return wincache_ucache_delete($key); } + #[Override] public function deleteMatching(string $pattern): never { throw new BadMethodCallException('The deleteMatching method is not implemented for Wincache. You must select File, Redis or Predis handlers to use it.'); } + #[Override] public function increment(string $key, int $offset = 1): bool { $key = static::validateKey($key, $this->prefix); @@ -75,6 +82,7 @@ public function increment(string $key, int $offset = 1): bool return $result !== false; } + #[Override] public function decrement(string $key, int $offset = 1): bool { $key = static::validateKey($key, $this->prefix); @@ -84,16 +92,19 @@ public function decrement(string $key, int $offset = 1): bool return $result !== false; } + #[Override] public function clean(): bool { return wincache_ucache_clear(); } + #[Override] public function getCacheInfo(): array|false { return wincache_ucache_info(true); } + #[Override] public function getMetaData(string $key): ?array { $key = static::validateKey($key, $this->prefix); @@ -114,6 +125,7 @@ public function getMetaData(string $key): ?array return null; } + #[Override] public function isSupported(): bool { return extension_loaded('wincache') && ini_get('wincache.ucenabled'); diff --git a/system/Cache/LockStores/FileLockStore.php b/system/Cache/LockStores/FileLockStore.php index 0e732098ce70..d5e81365d933 100644 --- a/system/Cache/LockStores/FileLockStore.php +++ b/system/Cache/LockStores/FileLockStore.php @@ -16,6 +16,7 @@ use CodeIgniter\Cache\Handlers\FileHandler; use CodeIgniter\Cache\LockStoreInterface; use CodeIgniter\I18n\Time; +use Override; use Throwable; class FileLockStore implements LockStoreInterface @@ -27,6 +28,7 @@ public function __construct( ) { } + #[Override] public function acquireLock(string $key, string $owner, int $ttl): bool { return $this->withLockFile($key, static function ($handle) use ($owner, $ttl): bool { @@ -41,6 +43,7 @@ public function acquireLock(string $key, string $owner, int $ttl): bool }); } + #[Override] public function releaseLock(string $key, string $owner): bool { return $this->withLockFile($key, static function ($handle) use ($owner): bool { @@ -54,11 +57,13 @@ public function releaseLock(string $key, string $owner): bool }); } + #[Override] public function forceReleaseLock(string $key): bool { return $this->withLockFile($key, static fn ($handle): bool => self::clearLockFile($handle)); } + #[Override] public function refreshLock(string $key, string $owner, int $ttl): bool { return $this->withLockFile($key, static function ($handle) use ($owner, $ttl): bool { @@ -73,6 +78,7 @@ public function refreshLock(string $key, string $owner, int $ttl): bool }); } + #[Override] public function getLockOwner(string $key): ?string { $owner = null; diff --git a/system/Cache/LockStores/MemcachedLockStore.php b/system/Cache/LockStores/MemcachedLockStore.php index a35cc045a793..636f0da3af93 100644 --- a/system/Cache/LockStores/MemcachedLockStore.php +++ b/system/Cache/LockStores/MemcachedLockStore.php @@ -16,6 +16,7 @@ use CodeIgniter\Cache\Handlers\MemcachedHandler; use CodeIgniter\Cache\LockStoreInterface; use Memcached; +use Override; class MemcachedLockStore implements LockStoreInterface { @@ -27,6 +28,7 @@ public function __construct( ) { } + #[Override] public function acquireLock(string $key, string $owner, int $ttl): bool { $key = MemcachedHandler::validateKey($key, $this->prefix); @@ -34,6 +36,7 @@ public function acquireLock(string $key, string $owner, int $ttl): bool return $this->memcached->add($key, $owner, $ttl); } + #[Override] public function releaseLock(string $key, string $owner): bool { $key = MemcachedHandler::validateKey($key, $this->prefix); @@ -53,6 +56,7 @@ public function releaseLock(string $key, string $owner): bool return $this->memcached->delete($key); } + #[Override] public function forceReleaseLock(string $key): bool { $key = MemcachedHandler::validateKey($key, $this->prefix); @@ -64,6 +68,7 @@ public function forceReleaseLock(string $key): bool return $this->memcached->getResultCode() === Memcached::RES_NOTFOUND; } + #[Override] public function refreshLock(string $key, string $owner, int $ttl): bool { $key = MemcachedHandler::validateKey($key, $this->prefix); @@ -77,6 +82,7 @@ public function refreshLock(string $key, string $owner, int $ttl): bool return $this->memcached->cas($cas, $key, $owner, $ttl); } + #[Override] public function getLockOwner(string $key): ?string { $key = MemcachedHandler::validateKey($key, $this->prefix); diff --git a/system/Cache/LockStores/PredisLockStore.php b/system/Cache/LockStores/PredisLockStore.php index d15d3c6394eb..9ca16771c874 100644 --- a/system/Cache/LockStores/PredisLockStore.php +++ b/system/Cache/LockStores/PredisLockStore.php @@ -15,6 +15,7 @@ use CodeIgniter\Cache\Handlers\PredisHandler; use CodeIgniter\Cache\LockStoreInterface; +use Override; use Predis\Client; use Predis\Response\Status; @@ -24,6 +25,7 @@ public function __construct(private readonly Client $redis) { } + #[Override] public function acquireLock(string $key, string $owner, int $ttl): bool { $key = PredisHandler::validateKey($key); @@ -32,6 +34,7 @@ public function acquireLock(string $key, string $owner, int $ttl): bool return $result instanceof Status && $result->getPayload() === 'OK'; } + #[Override] public function releaseLock(string $key, string $owner): bool { $key = PredisHandler::validateKey($key); @@ -47,6 +50,7 @@ public function releaseLock(string $key, string $owner): bool return $this->redis->eval($script, 1, $key, $owner) === 1; } + #[Override] public function forceReleaseLock(string $key): bool { $key = PredisHandler::validateKey($key); @@ -55,6 +59,7 @@ public function forceReleaseLock(string $key): bool return is_int($deleted) && $deleted >= 0; } + #[Override] public function refreshLock(string $key, string $owner, int $ttl): bool { $key = PredisHandler::validateKey($key); @@ -70,6 +75,7 @@ public function refreshLock(string $key, string $owner, int $ttl): bool return $this->redis->eval($script, 1, $key, $owner, (string) $ttl) === 1; } + #[Override] public function getLockOwner(string $key): ?string { $key = PredisHandler::validateKey($key); diff --git a/system/Cache/LockStores/RedisLockStore.php b/system/Cache/LockStores/RedisLockStore.php index 76623bc82c70..47097a554cf5 100644 --- a/system/Cache/LockStores/RedisLockStore.php +++ b/system/Cache/LockStores/RedisLockStore.php @@ -15,6 +15,7 @@ use CodeIgniter\Cache\Handlers\RedisHandler; use CodeIgniter\Cache\LockStoreInterface; +use Override; use Redis; class RedisLockStore implements LockStoreInterface @@ -25,6 +26,7 @@ public function __construct( ) { } + #[Override] public function acquireLock(string $key, string $owner, int $ttl): bool { $key = RedisHandler::validateKey($key, $this->prefix); @@ -32,6 +34,7 @@ public function acquireLock(string $key, string $owner, int $ttl): bool return (bool) $this->redis->set($key, $owner, ['nx', 'ex' => $ttl]); } + #[Override] public function releaseLock(string $key, string $owner): bool { $key = RedisHandler::validateKey($key, $this->prefix); @@ -47,6 +50,7 @@ public function releaseLock(string $key, string $owner): bool return (int) $this->redis->eval($script, [$key, $owner], 1) === 1; } + #[Override] public function forceReleaseLock(string $key): bool { $key = RedisHandler::validateKey($key, $this->prefix); @@ -55,6 +59,7 @@ public function forceReleaseLock(string $key): bool return is_int($deleted) && $deleted >= 0; } + #[Override] public function refreshLock(string $key, string $owner, int $ttl): bool { $key = RedisHandler::validateKey($key, $this->prefix); @@ -70,6 +75,7 @@ public function refreshLock(string $key, string $owner, int $ttl): bool return (int) $this->redis->eval($script, [$key, $owner, $ttl], 1) === 1; } + #[Override] public function getLockOwner(string $key): ?string { $key = RedisHandler::validateKey($key, $this->prefix); diff --git a/system/Commands/Cache/ClearCache.php b/system/Commands/Cache/ClearCache.php index 82876c44cca4..06c3c4b241cd 100644 --- a/system/Commands/Cache/ClearCache.php +++ b/system/Commands/Cache/ClearCache.php @@ -18,6 +18,7 @@ use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Argument; use Config\Cache; +use Override; /** * Clears the current system caches. @@ -25,6 +26,7 @@ #[Command(name: 'cache:clear', description: 'Clears the current system caches.', group: 'Cache')] class ClearCache extends AbstractCommand { + #[Override] protected function configure(): void { $this->addArgument(new Argument( @@ -34,6 +36,7 @@ protected function configure(): void )); } + #[Override] protected function execute(array $arguments, array $options): int { $driver = $arguments['driver']; diff --git a/system/Commands/Cache/InfoCache.php b/system/Commands/Cache/InfoCache.php index 7ff69727738d..0ce9974e0b05 100644 --- a/system/Commands/Cache/InfoCache.php +++ b/system/Commands/Cache/InfoCache.php @@ -18,6 +18,7 @@ use CodeIgniter\CLI\Table; use CodeIgniter\I18n\Time; use Config\Cache; +use Override; /** * Shows file cache information in the current system. @@ -25,6 +26,7 @@ #[Command(name: 'cache:info', description: 'Shows file cache information in the current system.', group: 'Cache')] class InfoCache extends AbstractCommand { + #[Override] protected function execute(array $arguments, array $options): int { $config = config(Cache::class); diff --git a/system/Commands/Database/CreateDatabase.php b/system/Commands/Database/CreateDatabase.php index 5f6dec8c74da..2771e6256165 100644 --- a/system/Commands/Database/CreateDatabase.php +++ b/system/Commands/Database/CreateDatabase.php @@ -20,6 +20,7 @@ use CodeIgniter\Config\Factories; use CodeIgniter\Database\SQLite3\Connection as SQLite3Connection; use Config\Database; +use Override; use Throwable; /** @@ -33,6 +34,7 @@ class CreateDatabase extends AbstractCommand */ private const VALID_EXTENSIONS = ['db', 'sqlite']; + #[Override] protected function configure(): void { $this @@ -49,6 +51,7 @@ protected function configure(): void )); } + #[Override] protected function interact(array &$arguments, array &$options): void { if ($arguments === []) { @@ -65,6 +68,7 @@ protected function interact(array &$arguments, array &$options): void } } + #[Override] protected function execute(array $arguments, array $options): int { $name = $arguments['db_name']; diff --git a/system/Commands/Database/Migrate.php b/system/Commands/Database/Migrate.php index 864404f30add..7fafad3a966d 100644 --- a/system/Commands/Database/Migrate.php +++ b/system/Commands/Database/Migrate.php @@ -18,6 +18,7 @@ use CodeIgniter\CLI\Input\Option; use CodeIgniter\CLI\SignalTrait; use CodeIgniter\Database\MigrationRunner; +use Override; use Throwable; /** @@ -32,6 +33,7 @@ class Migrate extends AbstractCommand { use SignalTrait; + #[Override] protected function configure(): void { $this @@ -55,6 +57,7 @@ protected function configure(): void )); } + #[Override] protected function execute(array $arguments, array $options): int { /** @var MigrationRunner $runner */ diff --git a/system/Commands/Database/MigrateRefresh.php b/system/Commands/Database/MigrateRefresh.php index 4a20f3c24b8e..fade3664f275 100644 --- a/system/Commands/Database/MigrateRefresh.php +++ b/system/Commands/Database/MigrateRefresh.php @@ -17,6 +17,7 @@ use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Option; use CodeIgniter\CLI\SignalTrait; +use Override; /** * Does a rollback followed by a latest to refresh the current state of the database. @@ -30,6 +31,7 @@ class MigrateRefresh extends AbstractCommand { use SignalTrait; + #[Override] protected function configure(): void { $this @@ -58,6 +60,7 @@ protected function configure(): void )); } + #[Override] protected function interact(array &$arguments, array &$options): void { if (! service('environment')->isProduction()) { @@ -73,6 +76,7 @@ protected function interact(array &$arguments, array &$options): void } } + #[Override] protected function execute(array $arguments, array $options): int { if (service('environment')->isProduction() && $options['force'] === false) { diff --git a/system/Commands/Database/MigrateRollback.php b/system/Commands/Database/MigrateRollback.php index 9fa65e143257..e436c9dd0f61 100644 --- a/system/Commands/Database/MigrateRollback.php +++ b/system/Commands/Database/MigrateRollback.php @@ -18,6 +18,7 @@ use CodeIgniter\CLI\Input\Option; use CodeIgniter\CLI\SignalTrait; use CodeIgniter\Database\MigrationRunner; +use Override; use Throwable; /** @@ -32,6 +33,7 @@ class MigrateRollback extends AbstractCommand { use SignalTrait; + #[Override] protected function configure(): void { $this @@ -49,6 +51,7 @@ protected function configure(): void )); } + #[Override] protected function interact(array &$arguments, array &$options): void { if (! service('environment')->isProduction()) { @@ -64,6 +67,7 @@ protected function interact(array &$arguments, array &$options): void } } + #[Override] protected function execute(array $arguments, array $options): int { if (service('environment')->isProduction() && $options['force'] === false) { diff --git a/system/Commands/Database/MigrateStatus.php b/system/Commands/Database/MigrateStatus.php index 068c64ed2928..26dcb70eea66 100644 --- a/system/Commands/Database/MigrateStatus.php +++ b/system/Commands/Database/MigrateStatus.php @@ -18,6 +18,7 @@ use CodeIgniter\CLI\Input\Option; use CodeIgniter\CLI\Table; use CodeIgniter\Database\MigrationRunner; +use Override; /** * Displays a list of all migrations and whether they've been run or not. @@ -43,6 +44,7 @@ class MigrateStatus extends AbstractCommand 'Psr\Log', ]; + #[Override] protected function configure(): void { $this->addOption(new Option( @@ -54,6 +56,7 @@ protected function configure(): void )); } + #[Override] protected function execute(array $arguments, array $options): int { /** @var MigrationRunner $runner */ diff --git a/system/Commands/Database/Seed.php b/system/Commands/Database/Seed.php index 9e1351c5b341..6d4776547bb7 100644 --- a/system/Commands/Database/Seed.php +++ b/system/Commands/Database/Seed.php @@ -18,6 +18,7 @@ use CodeIgniter\CLI\Input\Argument; use CodeIgniter\Database\Seeder; use Config\Database; +use Override; use Throwable; /** @@ -30,6 +31,7 @@ )] class Seed extends AbstractCommand { + #[Override] protected function configure(): void { $this->addArgument(new Argument( @@ -39,6 +41,7 @@ protected function configure(): void )); } + #[Override] protected function interact(array &$arguments, array &$options): void { if ($arguments === []) { @@ -46,6 +49,7 @@ protected function interact(array &$arguments, array &$options): void } } + #[Override] protected function execute(array $arguments, array $options): int { $seedName = $arguments['seeder_name']; diff --git a/system/Commands/Database/ShowTableInfo.php b/system/Commands/Database/ShowTableInfo.php index 835048c83737..f1b9ba66e3f5 100644 --- a/system/Commands/Database/ShowTableInfo.php +++ b/system/Commands/Database/ShowTableInfo.php @@ -23,6 +23,7 @@ use CodeIgniter\Database\TableName; use CodeIgniter\Exceptions\InvalidArgumentException; use Config\Database; +use Override; /** * Retrieves information on the selected table. @@ -43,6 +44,7 @@ class ShowTableInfo extends AbstractCommand private string $dbPrefix; + #[Override] protected function configure(): void { $this @@ -91,6 +93,7 @@ protected function configure(): void ->addUsage('db:table my_table --limit-rows 5 --limit-field-value 10 --desc'); } + #[Override] protected function interact(array &$arguments, array &$options): void { if ($this->hasUnboundOption('show', $options)) { @@ -114,6 +117,7 @@ protected function interact(array &$arguments, array &$options): void } } + #[Override] protected function execute(array $arguments, array $options): int { $output = $this->getOutput(); diff --git a/system/Commands/Encryption/GenerateKey.php b/system/Commands/Encryption/GenerateKey.php index a85d5aada002..f6c1fbf968a6 100644 --- a/system/Commands/Encryption/GenerateKey.php +++ b/system/Commands/Encryption/GenerateKey.php @@ -19,6 +19,7 @@ use CodeIgniter\Config\DotEnv; use CodeIgniter\Encryption\Encryption; use Config\Paths; +use Override; /** * Generates a new encryption key and writes it in an `.env` file. @@ -31,6 +32,7 @@ class GenerateKey extends AbstractCommand */ private const VALID_PREFIXES = ['hex2bin', 'base64']; + #[Override] protected function configure(): void { $this @@ -57,6 +59,7 @@ protected function configure(): void )); } + #[Override] protected function interact(array &$arguments, array &$options): void { $prefix = $this->getUnboundOption('prefix', $options); @@ -85,6 +88,7 @@ protected function interact(array &$arguments, array &$options): void } } + #[Override] protected function execute(array $arguments, array $options): int { $prefix = $options['prefix']; diff --git a/system/Commands/Encryption/RotateKey.php b/system/Commands/Encryption/RotateKey.php index c24faaea5f5e..f354b36fb31f 100644 --- a/system/Commands/Encryption/RotateKey.php +++ b/system/Commands/Encryption/RotateKey.php @@ -17,6 +17,7 @@ use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Option; use Config\Paths; +use Override; /** * Rotates the encryption key, demoting the current key to `previousKeys`. @@ -33,6 +34,7 @@ class RotateKey extends AbstractCommand */ private const VALID_PREFIXES = ['hex2bin', 'base64']; + #[Override] protected function configure(): void { $this @@ -61,6 +63,7 @@ protected function configure(): void )); } + #[Override] protected function interact(array &$arguments, array &$options): void { $prefix = $this->getUnboundOption('prefix', $options); @@ -85,6 +88,7 @@ protected function interact(array &$arguments, array &$options): void } } + #[Override] protected function execute(array $arguments, array $options): int { $prefix = $options['prefix']; diff --git a/system/Commands/Generators/CellGenerator.php b/system/Commands/Generators/CellGenerator.php index 8aac67a0e7b4..d3eae1514e9c 100644 --- a/system/Commands/Generators/CellGenerator.php +++ b/system/Commands/Generators/CellGenerator.php @@ -17,6 +17,7 @@ use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Attributes\GeneratorCommand; use Config\Generators; +use Override; #[Command(name: 'make:cell', description: 'Generates a new Controlled Cell file and its view.', group: 'Generators')] #[GeneratorCommand( @@ -27,16 +28,19 @@ classNameLang: 'CLI.generator.className.cell', )] class CellGenerator extends AbstractGeneratorCommand { + #[Override] protected function provideGeneratorOptions(): void { $this->addNamespaceOption()->addForceOption(); } + #[Override] protected function shouldAppendSuffix(): bool { return true; } + #[Override] protected function execute(array $arguments, array $options): int { $views = config(Generators::class)->views[$this->getName()] ?? []; diff --git a/system/Commands/Generators/CommandGenerator.php b/system/Commands/Generators/CommandGenerator.php index 07aa44f772a5..4c3d64ba89f1 100644 --- a/system/Commands/Generators/CommandGenerator.php +++ b/system/Commands/Generators/CommandGenerator.php @@ -17,6 +17,7 @@ use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Attributes\GeneratorCommand; use CodeIgniter\CLI\Input\Option; +use Override; #[Command(name: 'make:command', description: 'Generates a new spark command.', group: 'Generators')] #[GeneratorCommand( @@ -27,6 +28,7 @@ classNameLang: 'CLI.generator.className.command', )] class CommandGenerator extends AbstractGeneratorCommand { + #[Override] protected function configure(): void { parent::configure(); @@ -55,6 +57,7 @@ protected function configure(): void )); } + #[Override] protected function interact(array &$arguments, array &$options): void { $type = $this->getUnboundOption('type', $options); @@ -69,6 +72,7 @@ protected function interact(array &$arguments, array &$options): void ); } + #[Override] protected function execute(array $arguments, array $options): int { $type = $this->getValidatedOption('type'); @@ -82,6 +86,7 @@ protected function execute(array $arguments, array $options): int return $this->generateClass(); } + #[Override] protected function getReplacements(string $class): array { $group = $this->getValidatedOption('group'); @@ -93,6 +98,7 @@ protected function getReplacements(string $class): array return ['{command}' => $this->getValidatedOption('command'), '{group}' => $group]; } + #[Override] protected function getTemplateData(string $class): array { return ['type' => $this->getValidatedOption('type')]; diff --git a/system/Commands/Generators/ConfigGenerator.php b/system/Commands/Generators/ConfigGenerator.php index 8c78e5ae1dda..41e78db48ca0 100644 --- a/system/Commands/Generators/ConfigGenerator.php +++ b/system/Commands/Generators/ConfigGenerator.php @@ -16,6 +16,7 @@ use CodeIgniter\CLI\AbstractGeneratorCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Attributes\GeneratorCommand; +use Override; #[Command(name: 'make:config', description: 'Generates a new config file.', group: 'Generators')] #[GeneratorCommand( @@ -26,6 +27,7 @@ classNameLang: 'CLI.generator.className.config', )] class ConfigGenerator extends AbstractGeneratorCommand { + #[Override] protected function getReplacements(string $class): array { $segments = explode('\\', $class); diff --git a/system/Commands/Generators/ControllerGenerator.php b/system/Commands/Generators/ControllerGenerator.php index 172be8cd6e68..4825952e9580 100644 --- a/system/Commands/Generators/ControllerGenerator.php +++ b/system/Commands/Generators/ControllerGenerator.php @@ -20,6 +20,7 @@ use CodeIgniter\Controller; use CodeIgniter\RESTful\ResourceController; use CodeIgniter\RESTful\ResourcePresenter; +use Override; #[Command(name: 'make:controller', description: 'Generates a new controller file.', group: 'Generators')] #[GeneratorCommand( @@ -30,6 +31,7 @@ classNameLang: 'CLI.generator.className.controller', )] class ControllerGenerator extends AbstractGeneratorCommand { + #[Override] protected function configure(): void { parent::configure(); @@ -49,6 +51,7 @@ protected function configure(): void )); } + #[Override] protected function interact(array &$arguments, array &$options): void { $type = $this->getUnboundOption('restful', $options); @@ -63,6 +66,7 @@ protected function interact(array &$arguments, array &$options): void ); } + #[Override] protected function execute(array $arguments, array $options): int { $type = $this->getResourceType(); @@ -76,6 +80,7 @@ protected function execute(array $arguments, array $options): int return $this->generateClass(); } + #[Override] protected function getReplacements(string $class): array { $parent = $this->getParentClass(); @@ -83,6 +88,7 @@ protected function getReplacements(string $class): array return ['{useStatement}' => $parent, '{extends}' => class_basename($parent)]; } + #[Override] protected function getTemplateData(string $class): array { return ['type' => $this->getValidatedOption('bare') === true ? null : $this->getResourceType()]; diff --git a/system/Commands/Generators/MigrationGenerator.php b/system/Commands/Generators/MigrationGenerator.php index e5e012649a76..13ec59473037 100644 --- a/system/Commands/Generators/MigrationGenerator.php +++ b/system/Commands/Generators/MigrationGenerator.php @@ -20,6 +20,7 @@ use Config\Database; use Config\Migrations; use Config\Session as SessionConfig; +use Override; #[Command(name: 'make:migration', description: 'Generates a new migration file.', group: 'Generators')] #[GeneratorCommand( @@ -30,6 +31,7 @@ classNameLang: 'CLI.generator.className.migration', )] class MigrationGenerator extends AbstractGeneratorCommand { + #[Override] protected function configure(): void { parent::configure(); @@ -56,11 +58,13 @@ protected function configure(): void )); } + #[Override] protected function provideGeneratorOptions(): void { $this->addNamespaceOption()->addSuffixOption(); } + #[Override] protected function initialize(array &$arguments, array &$options): void { if (! $this->hasUnboundOption('session', $options)) { @@ -72,6 +76,7 @@ protected function initialize(array &$arguments, array &$options): void $arguments[0] = sprintf('_create_%s_table', is_string($table) ? $table : 'ci_sessions'); } + #[Override] protected function execute(array $arguments, array $options): int { if ($this->getValidatedOption('session') === true) { @@ -95,6 +100,7 @@ protected function execute(array $arguments, array $options): int return $this->generateClass(); } + #[Override] protected function getTemplateData(string $class): array { if ($this->getValidatedOption('session') !== true) { @@ -112,6 +118,7 @@ protected function getTemplateData(string $class): array ]; } + #[Override] protected function basename(string $filename): string { return gmdate(config(Migrations::class)->timestampFormat) . basename($filename); diff --git a/system/Commands/Generators/ModelGenerator.php b/system/Commands/Generators/ModelGenerator.php index f736a559537e..fce16f58fb2f 100644 --- a/system/Commands/Generators/ModelGenerator.php +++ b/system/Commands/Generators/ModelGenerator.php @@ -17,6 +17,7 @@ use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Attributes\GeneratorCommand; use CodeIgniter\CLI\Input\Option; +use Override; #[Command(name: 'make:model', description: 'Generates a new model file.', group: 'Generators')] #[GeneratorCommand( @@ -29,6 +30,7 @@ class ModelGenerator extends AbstractGeneratorCommand { private const RETURN_TYPES = ['array', 'object', 'entity']; + #[Override] protected function configure(): void { parent::configure(); @@ -58,6 +60,7 @@ protected function configure(): void )); } + #[Override] protected function interact(array &$arguments, array &$options): void { $return = $this->getUnboundOption('return', $options); @@ -72,6 +75,7 @@ protected function interact(array &$arguments, array &$options): void ); } + #[Override] protected function execute(array $arguments, array $options): int { $return = $this->getValidatedOption('return'); @@ -102,6 +106,7 @@ protected function execute(array $arguments, array $options): int ); } + #[Override] protected function getReplacements(string $class): array { $table = $this->getValidatedOption('table'); @@ -118,6 +123,7 @@ protected function getReplacements(string $class): array ]; } + #[Override] protected function getTemplateData(string $class): array { return ['dbGroup' => $this->getValidatedOption('dbgroup')]; diff --git a/system/Commands/Generators/ScaffoldGenerator.php b/system/Commands/Generators/ScaffoldGenerator.php index bfcb6f05f6ef..c412b73a35f5 100644 --- a/system/Commands/Generators/ScaffoldGenerator.php +++ b/system/Commands/Generators/ScaffoldGenerator.php @@ -18,10 +18,12 @@ use CodeIgniter\CLI\Input\Argument; use CodeIgniter\CLI\Input\Option; use CodeIgniter\CLI\PromptsForMissingInputInterface; +use Override; #[Command(name: 'make:scaffold', description: 'Generates a complete set of scaffold files.', group: 'Generators')] class ScaffoldGenerator extends AbstractCommand implements PromptsForMissingInputInterface { + #[Override] protected function configure(): void { $this @@ -76,11 +78,13 @@ protected function configure(): void )); } + #[Override] protected function getArgumentPromptLabels(): array { return ['name' => lang('CLI.generator.className.default')]; } + #[Override] protected function execute(array $arguments, array $options): int { $name = [$arguments['name']]; diff --git a/system/Commands/Generators/TestGenerator.php b/system/Commands/Generators/TestGenerator.php index 2454b51ccf03..0930192c8c0d 100644 --- a/system/Commands/Generators/TestGenerator.php +++ b/system/Commands/Generators/TestGenerator.php @@ -16,6 +16,7 @@ use CodeIgniter\CLI\AbstractGeneratorCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Attributes\GeneratorCommand; +use Override; #[Command(name: 'make:test', description: 'Generates a new test file.', group: 'Generators')] #[GeneratorCommand( @@ -27,11 +28,13 @@ class TestGenerator extends AbstractGeneratorCommand { private const DEFAULT_NAMESPACE = 'Tests'; + #[Override] protected function provideGeneratorOptions(): void { $this->addNamespaceOption(self::DEFAULT_NAMESPACE)->addForceOption(); } + #[Override] protected function initialize(array &$arguments, array &$options): void { $autoloader = service('autoloader'); @@ -39,11 +42,13 @@ protected function initialize(array &$arguments, array &$options): void $autoloader->addNamespace(self::DEFAULT_NAMESPACE, ROOTPATH . 'tests'); } + #[Override] protected function shouldAppendSuffix(): bool { return true; } + #[Override] protected function getNamespace(): string { if ($this->hasUnboundOption('namespace')) { @@ -69,6 +74,7 @@ protected function getNamespace(): string return self::DEFAULT_NAMESPACE; } + #[Override] protected function getBasePath(string $namespace): ?string { foreach (service('autoloader')->getNamespace($namespace) as $candidate) { diff --git a/system/Commands/Help.php b/system/Commands/Help.php index 683c86fe2ec1..b6fc7df2151f 100644 --- a/system/Commands/Help.php +++ b/system/Commands/Help.php @@ -18,6 +18,7 @@ use CodeIgniter\CLI\Input\Argument; use CodeIgniter\CLI\Input\Option; use CodeIgniter\CLI\Output; +use Override; /** * Displays the basic usage information for a given command. @@ -25,6 +26,7 @@ #[Command(name: 'help', description: 'Displays basic usage information.', group: 'CodeIgniter')] class Help extends AbstractCommand { + #[Override] protected function configure(): void { $this->addArgument(new Argument( @@ -34,6 +36,7 @@ protected function configure(): void )); } + #[Override] protected function execute(array $arguments, array $options): int { $command = $arguments['command_name']; diff --git a/system/Commands/Housekeeping/ClearDebugbar.php b/system/Commands/Housekeeping/ClearDebugbar.php index b0af07dd0803..dd04e7d04ee7 100644 --- a/system/Commands/Housekeeping/ClearDebugbar.php +++ b/system/Commands/Housekeeping/ClearDebugbar.php @@ -15,6 +15,7 @@ use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; +use Override; /** * Clears all debugbar JSON files. @@ -22,6 +23,7 @@ #[Command(name: 'debugbar:clear', description: 'Clears all debugbar JSON files.', group: 'Housekeeping')] class ClearDebugbar extends AbstractCommand { + #[Override] protected function execute(array $arguments, array $options): int { helper('filesystem'); diff --git a/system/Commands/Housekeeping/ClearLogs.php b/system/Commands/Housekeeping/ClearLogs.php index 6115d7d534f0..6f5f3dfb3f36 100644 --- a/system/Commands/Housekeeping/ClearLogs.php +++ b/system/Commands/Housekeeping/ClearLogs.php @@ -16,6 +16,7 @@ use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Option; +use Override; /** * Clears all log files. @@ -23,6 +24,7 @@ #[Command(name: 'logs:clear', description: 'Clears all log files.', group: 'Housekeeping')] class ClearLogs extends AbstractCommand { + #[Override] protected function configure(): void { $this->addOption(new Option( @@ -32,6 +34,7 @@ protected function configure(): void )); } + #[Override] protected function interact(array &$arguments, array &$options): void { if ($this->hasUnboundOption('force', $options)) { @@ -45,6 +48,7 @@ protected function interact(array &$arguments, array &$options): void $options['force'] = null; // simulate the presence of the --force option } + #[Override] protected function execute(array $arguments, array $options): int { $output = $this->getOutput(); diff --git a/system/Commands/ListCommands.php b/system/Commands/ListCommands.php index 3a36280a9780..44ad2fb4a8a2 100644 --- a/system/Commands/ListCommands.php +++ b/system/Commands/ListCommands.php @@ -17,6 +17,7 @@ use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Option; use CodeIgniter\CLI\Output; +use Override; /** * Lists the available commands. @@ -24,6 +25,7 @@ #[Command(name: 'list', description: 'Lists the available commands.', group: 'CodeIgniter')] class ListCommands extends AbstractCommand { + #[Override] protected function configure(): void { $this->addOption(new Option( @@ -32,6 +34,7 @@ protected function configure(): void )); } + #[Override] protected function execute(array $arguments, array $options): int { $output = $this->getOutput(); diff --git a/system/Commands/Server/Serve.php b/system/Commands/Server/Serve.php index a1417635ecc7..aae31f153270 100644 --- a/system/Commands/Server/Serve.php +++ b/system/Commands/Server/Serve.php @@ -16,6 +16,7 @@ use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Option; +use Override; /** * Launches the CodeIgniter PHP-Development Server. @@ -30,6 +31,7 @@ class Serve extends AbstractCommand */ private const RETRIES = 10; + #[Override] protected function configure(): void { $this @@ -38,6 +40,7 @@ protected function configure(): void ->addOption(new Option(name: 'port', description: 'The port to serve on.', requiresValue: true, default: '8080')); } + #[Override] protected function execute(array $arguments, array $options): int { $basePort = (int) $options['port']; diff --git a/system/Commands/Translation/LocalizationFinder.php b/system/Commands/Translation/LocalizationFinder.php index ddab421d8ed6..05379db4482a 100644 --- a/system/Commands/Translation/LocalizationFinder.php +++ b/system/Commands/Translation/LocalizationFinder.php @@ -22,6 +22,7 @@ use CodeIgniter\Helpers\Array\ArrayHelper; use Config\App; use Locale; +use Override; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; use SplFileInfo; @@ -38,6 +39,7 @@ class LocalizationFinder extends AbstractCommand { private string $languagePath; + #[Override] protected function configure(): void { $this @@ -59,6 +61,7 @@ protected function configure(): void )); } + #[Override] protected function execute(array $arguments, array $options): int { $locale = $options['locale']; diff --git a/system/Commands/Translation/LocalizationSync.php b/system/Commands/Translation/LocalizationSync.php index 3574c2e19482..60a68a544b24 100644 --- a/system/Commands/Translation/LocalizationSync.php +++ b/system/Commands/Translation/LocalizationSync.php @@ -22,6 +22,7 @@ use ErrorException; use FilesystemIterator; use Locale; +use Override; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; use SplFileInfo; @@ -38,6 +39,7 @@ class LocalizationSync extends AbstractCommand { private string $languagePath; + #[Override] protected function configure(): void { $this @@ -55,6 +57,7 @@ protected function configure(): void )); } + #[Override] protected function execute(array $arguments, array $options): int { $locale = $options['locale']; diff --git a/system/Commands/Utilities/ConfigCheck.php b/system/Commands/Utilities/ConfigCheck.php index a278fa9edf1a..bed773e6f374 100644 --- a/system/Commands/Utilities/ConfigCheck.php +++ b/system/Commands/Utilities/ConfigCheck.php @@ -21,6 +21,7 @@ use CodeIgniter\Config\BaseConfig; use Config\Optimize; use Kint\Kint; +use Override; /** * Check the Config values. @@ -28,6 +29,7 @@ #[Command(name: 'config:check', description: 'Check your config values.', group: 'CodeIgniter')] class ConfigCheck extends AbstractCommand { + #[Override] protected function configure(): void { $this->addArgument(new Argument( @@ -37,6 +39,7 @@ protected function configure(): void )); } + #[Override] protected function execute(array $arguments, array $options): int { /** @var class-string $class */ diff --git a/system/Commands/Utilities/Environment.php b/system/Commands/Utilities/Environment.php index faab81128bdf..1d8bf6fe3454 100644 --- a/system/Commands/Utilities/Environment.php +++ b/system/Commands/Utilities/Environment.php @@ -19,6 +19,7 @@ use CodeIgniter\CLI\Output; use CodeIgniter\Config\DotEnv; use Config\Paths; +use Override; /** * Command to display the current environment, @@ -38,6 +39,7 @@ class Environment extends AbstractCommand 'development', ]; + #[Override] protected function configure(): void { $this->addArgument(new Argument( @@ -47,6 +49,7 @@ protected function configure(): void )); } + #[Override] protected function execute(array $arguments, array $options): int { $env = $arguments['environment']; diff --git a/system/Commands/Utilities/FilterCheck.php b/system/Commands/Utilities/FilterCheck.php index fede0a163cfb..830605bc8361 100644 --- a/system/Commands/Utilities/FilterCheck.php +++ b/system/Commands/Utilities/FilterCheck.php @@ -19,6 +19,7 @@ use CodeIgniter\CLI\Output; use CodeIgniter\CLI\Table; use CodeIgniter\Commands\Utilities\Routes\FilterCollector; +use Override; /** * Check filters for a route. @@ -26,6 +27,7 @@ #[Command(name: 'filter:check', description: 'Check filters for a route.', group: 'CodeIgniter')] class FilterCheck extends AbstractCommand { + #[Override] protected function configure(): void { $this @@ -41,6 +43,7 @@ protected function configure(): void )); } + #[Override] protected function execute(array $arguments, array $options): int { $method = $arguments['method']; diff --git a/system/Commands/Utilities/Namespaces.php b/system/Commands/Utilities/Namespaces.php index a14b90e4fbec..91bf0282adaf 100644 --- a/system/Commands/Utilities/Namespaces.php +++ b/system/Commands/Utilities/Namespaces.php @@ -18,6 +18,7 @@ use CodeIgniter\CLI\Input\Option; use CodeIgniter\CLI\Table; use Config\Autoload; +use Override; /** * Lists namespaces set in Config\Autoload with their full server path. @@ -29,6 +30,7 @@ )] class Namespaces extends AbstractCommand { + #[Override] protected function configure(): void { $this @@ -51,6 +53,7 @@ protected function configure(): void )); } + #[Override] protected function execute(array $arguments, array $options): int { $namespaces = $options['config-only'] !== false diff --git a/system/Commands/Utilities/Optimize.php b/system/Commands/Utilities/Optimize.php index 223fd9707df0..4e947c2d7350 100644 --- a/system/Commands/Utilities/Optimize.php +++ b/system/Commands/Utilities/Optimize.php @@ -20,6 +20,7 @@ use CodeIgniter\CLI\Output; use CodeIgniter\Exceptions\RuntimeException; use CodeIgniter\Publisher\Publisher; +use Override; /** * Optimize for production. @@ -27,6 +28,7 @@ #[Command(name: 'optimize', description: 'Optimize for production.', group: 'CodeIgniter')] final class Optimize extends AbstractCommand { + #[Override] protected function execute(array $arguments, array $options): int { $output = $this->getOutput(); diff --git a/system/Commands/Utilities/PhpIniCheck.php b/system/Commands/Utilities/PhpIniCheck.php index 83f9ab30616d..5149a7202cbe 100644 --- a/system/Commands/Utilities/PhpIniCheck.php +++ b/system/Commands/Utilities/PhpIniCheck.php @@ -17,6 +17,7 @@ use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Argument; use CodeIgniter\Security\CheckPhpIni; +use Override; /** * Check php.ini values. @@ -28,6 +29,7 @@ )] final class PhpIniCheck extends AbstractCommand { + #[Override] protected function configure(): void { $this @@ -39,6 +41,7 @@ protected function configure(): void ->addUsage('phpini:check opcache'); } + #[Override] protected function execute(array $arguments, array $options): int { $section = $arguments['section']; diff --git a/system/Commands/Utilities/Publish.php b/system/Commands/Utilities/Publish.php index e13d6b9c219b..404c0087125f 100644 --- a/system/Commands/Utilities/Publish.php +++ b/system/Commands/Utilities/Publish.php @@ -19,6 +19,7 @@ use CodeIgniter\CLI\Input\Option; use CodeIgniter\CLI\Output; use CodeIgniter\Publisher\Publisher; +use Override; /** * Discovers all Publisher classes from the "Publishers/" directory @@ -32,6 +33,7 @@ )] class Publish extends AbstractCommand { + #[Override] protected function configure(): void { $this @@ -48,6 +50,7 @@ protected function configure(): void )); } + #[Override] protected function execute(array $arguments, array $options): int { $directory = $arguments['directory']; diff --git a/system/Commands/Utilities/Routes.php b/system/Commands/Utilities/Routes.php index 4db0a56a01fd..ba3c5a031d99 100644 --- a/system/Commands/Utilities/Routes.php +++ b/system/Commands/Utilities/Routes.php @@ -27,6 +27,7 @@ use CodeIgniter\Router\Router; use Config\Feature; use Config\Routing; +use Override; /** * Lists all the routes. This will include any Routes files @@ -39,6 +40,7 @@ class Routes extends AbstractCommand private SampleURIGenerator $uriGenerator; private FilterCollector $filterCollector; + #[Override] protected function configure(): void { $this @@ -54,6 +56,7 @@ protected function configure(): void )); } + #[Override] protected function execute(array $arguments, array $options): int { $sortByHandler = $options['sort-by-handler'] !== false; diff --git a/system/Commands/Worker/WorkerInstall.php b/system/Commands/Worker/WorkerInstall.php index abb02bd2a9db..640e0c3108ba 100644 --- a/system/Commands/Worker/WorkerInstall.php +++ b/system/Commands/Worker/WorkerInstall.php @@ -17,6 +17,7 @@ use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Option; use CodeIgniter\CLI\Output; +use Override; /** * Installs the files needed to run CodeIgniter 4 in FrankenPHP worker mode. @@ -38,6 +39,7 @@ class WorkerInstall extends AbstractCommand 'Caddyfile.tpl' => 'Caddyfile', ]; + #[Override] protected function configure(): void { $this->addOption(new Option( @@ -47,6 +49,7 @@ protected function configure(): void )); } + #[Override] protected function execute(array $arguments, array $options): int { $force = $options['force'] === true; diff --git a/system/Commands/Worker/WorkerUninstall.php b/system/Commands/Worker/WorkerUninstall.php index fc0b700ddd57..4e4ee6525988 100644 --- a/system/Commands/Worker/WorkerUninstall.php +++ b/system/Commands/Worker/WorkerUninstall.php @@ -16,6 +16,7 @@ use CodeIgniter\CLI\AbstractCommand; use CodeIgniter\CLI\Attributes\Command; use CodeIgniter\CLI\Input\Option; +use Override; /** * Removes the files created by the worker:install command. @@ -37,6 +38,7 @@ class WorkerUninstall extends AbstractCommand 'Caddyfile', ]; + #[Override] protected function configure(): void { $this->addOption(new Option( @@ -46,6 +48,7 @@ protected function configure(): void )); } + #[Override] protected function interact(array &$arguments, array &$options): void { if ($this->hasUnboundOption('force', $options)) { @@ -61,6 +64,7 @@ protected function interact(array &$arguments, array &$options): void } } + #[Override] protected function execute(array $arguments, array $options): int { $existing = $this->existingFiles(); diff --git a/system/Config/Publisher.php b/system/Config/Publisher.php index 3038644e4aeb..42aa20277165 100644 --- a/system/Config/Publisher.php +++ b/system/Config/Publisher.php @@ -13,6 +13,8 @@ namespace CodeIgniter\Config; +use Override; + /** * Publisher Configuration * @@ -38,6 +40,7 @@ class Publisher extends BaseConfig /** * Disables Registrars to prevent modules from altering the restrictions. */ + #[Override] final protected function registerProperties(): void { } diff --git a/system/Cookie/Cookie.php b/system/Cookie/Cookie.php index 9c253530311f..0c8dadb01a33 100644 --- a/system/Cookie/Cookie.php +++ b/system/Cookie/Cookie.php @@ -20,6 +20,7 @@ use CodeIgniter\I18n\Time; use Config\Cookie as CookieConfig; use DateTimeInterface; +use Override; /** * A `Cookie` class represents an immutable HTTP cookie value object. @@ -301,6 +302,7 @@ final public function __construct(string $name, string $value = '', array $optio /** * {@inheritDoc} */ + #[Override] public function getId(): string { return implode(';', [$this->getPrefixedName(), $this->getPath(), $this->getDomain()]); @@ -309,6 +311,7 @@ public function getId(): string /** * {@inheritDoc} */ + #[Override] public function getPrefix(): string { return $this->prefix; @@ -317,6 +320,7 @@ public function getPrefix(): string /** * {@inheritDoc} */ + #[Override] public function getName(): string { return $this->name; @@ -325,6 +329,7 @@ public function getName(): string /** * {@inheritDoc} */ + #[Override] public function getPrefixedName(): string { $name = $this->getPrefix(); @@ -344,6 +349,7 @@ public function getPrefixedName(): string /** * {@inheritDoc} */ + #[Override] public function getValue(): string { return $this->value; @@ -352,6 +358,7 @@ public function getValue(): string /** * {@inheritDoc} */ + #[Override] public function getExpiresTimestamp(): int { return $this->expires; @@ -360,6 +367,7 @@ public function getExpiresTimestamp(): int /** * {@inheritDoc} */ + #[Override] public function getExpiresString(): string { return gmdate(self::EXPIRES_FORMAT, $this->expires); @@ -368,6 +376,7 @@ public function getExpiresString(): string /** * {@inheritDoc} */ + #[Override] public function isExpired(): bool { return $this->expires === 0 || $this->expires < Time::now()->getTimestamp(); @@ -376,6 +385,7 @@ public function isExpired(): bool /** * {@inheritDoc} */ + #[Override] public function getMaxAge(): int { $maxAge = $this->expires - Time::now()->getTimestamp(); @@ -386,6 +396,7 @@ public function getMaxAge(): int /** * {@inheritDoc} */ + #[Override] public function getPath(): string { return $this->path; @@ -394,6 +405,7 @@ public function getPath(): string /** * {@inheritDoc} */ + #[Override] public function getDomain(): string { return $this->domain; @@ -402,6 +414,7 @@ public function getDomain(): string /** * {@inheritDoc} */ + #[Override] public function isSecure(): bool { return $this->secure; @@ -410,6 +423,7 @@ public function isSecure(): bool /** * {@inheritDoc} */ + #[Override] public function isHTTPOnly(): bool { return $this->httponly; @@ -418,6 +432,7 @@ public function isHTTPOnly(): bool /** * {@inheritDoc} */ + #[Override] public function getSameSite(): string { return $this->samesite; @@ -426,6 +441,7 @@ public function getSameSite(): string /** * {@inheritDoc} */ + #[Override] public function isRaw(): bool { return $this->raw; @@ -434,6 +450,7 @@ public function isRaw(): bool /** * {@inheritDoc} */ + #[Override] public function getOptions(): array { // This is the order of options in `setcookie`. DO NOT CHANGE. @@ -454,6 +471,7 @@ public function getOptions(): array /** * {@inheritDoc} */ + #[Override] public function withPrefix(string $prefix = '') { $this->validatePrefix($prefix, $this->secure, $this->path, $this->domain); @@ -468,6 +486,7 @@ public function withPrefix(string $prefix = '') /** * {@inheritDoc} */ + #[Override] public function withName(string $name) { $this->validateName($name, $this->raw); @@ -482,6 +501,7 @@ public function withName(string $name) /** * {@inheritDoc} */ + #[Override] public function withValue(string $value) { $this->validateValue($value, $this->raw); @@ -496,6 +516,7 @@ public function withValue(string $value) /** * {@inheritDoc} */ + #[Override] public function withExpires($expires) { $cookie = clone $this; @@ -508,6 +529,7 @@ public function withExpires($expires) /** * {@inheritDoc} */ + #[Override] public function withExpired() { $cookie = clone $this; @@ -520,6 +542,7 @@ public function withExpired() /** * {@inheritDoc} */ + #[Override] public function withPath(?string $path) { $path = in_array($path, [null, '', '0'], true) ? self::$defaults['path'] : $path; @@ -536,6 +559,7 @@ public function withPath(?string $path) /** * {@inheritDoc} */ + #[Override] public function withDomain(?string $domain) { $domain ??= self::$defaults['domain']; @@ -552,6 +576,7 @@ public function withDomain(?string $domain) /** * {@inheritDoc} */ + #[Override] public function withSecure(bool $secure = true) { $this->validatePrefix($this->prefix, $secure, $this->path, $this->domain); @@ -567,6 +592,7 @@ public function withSecure(bool $secure = true) /** * {@inheritDoc} */ + #[Override] public function withHTTPOnly(bool $httponly = true) { $cookie = clone $this; @@ -579,6 +605,7 @@ public function withHTTPOnly(bool $httponly = true) /** * {@inheritDoc} */ + #[Override] public function withSameSite(string $samesite) { $this->validateSameSite($samesite, $this->secure); @@ -593,6 +620,7 @@ public function withSameSite(string $samesite) /** * {@inheritDoc} */ + #[Override] public function withRaw(bool $raw = true) { $this->validateName($this->name, $raw); @@ -614,6 +642,7 @@ public function withRaw(bool $raw = true) * * @param string $offset */ + #[Override] public function offsetExists($offset): bool { return $offset === 'expire' ? true : property_exists($this, $offset); @@ -626,6 +655,7 @@ public function offsetExists($offset): bool * * @throws InvalidArgumentException */ + #[Override] public function offsetGet($offset): bool|int|string { if (! $this->offsetExists($offset)) { @@ -643,6 +673,7 @@ public function offsetGet($offset): bool|int|string * * @throws LogicException */ + #[Override] public function offsetSet($offset, $value): void { throw new LogicException(sprintf('Cannot set values of properties of %s as it is immutable.', static::class)); @@ -655,6 +686,7 @@ public function offsetSet($offset, $value): void * * @throws LogicException */ + #[Override] public function offsetUnset($offset): void { throw new LogicException(sprintf('Cannot unset values of properties of %s as it is immutable.', static::class)); @@ -667,6 +699,7 @@ public function offsetUnset($offset): void /** * {@inheritDoc} */ + #[Override] public function toHeaderString(): string { return $this->__toString(); @@ -675,6 +708,7 @@ public function toHeaderString(): string /** * {@inheritDoc} */ + #[Override] public function __toString(): string { $cookieHeader = []; @@ -726,6 +760,7 @@ public function __toString(): string /** * {@inheritDoc} */ + #[Override] public function toArray(): array { return [ diff --git a/system/Cookie/CookieInterface.php b/system/Cookie/CookieInterface.php index af86dd4c0c60..a4e01cf76d44 100644 --- a/system/Cookie/CookieInterface.php +++ b/system/Cookie/CookieInterface.php @@ -13,6 +13,8 @@ namespace CodeIgniter\Cookie; +use Override; + /** * Interface for a value object representation of an HTTP cookie. * @@ -166,6 +168,7 @@ public function toHeaderString(): string; * * @return string */ + #[Override] public function __toString(); /** diff --git a/system/Cookie/CookieStore.php b/system/Cookie/CookieStore.php index aaea3d1f0301..3e6b7734ad3e 100644 --- a/system/Cookie/CookieStore.php +++ b/system/Cookie/CookieStore.php @@ -17,6 +17,7 @@ use CodeIgniter\Cookie\Exceptions\CookieException; use Countable; use IteratorAggregate; +use Override; use Traversable; /** @@ -177,6 +178,7 @@ public function clear(): void /** * Gets the Cookie count in this collection. */ + #[Override] public function count(): int { return count($this->cookies); @@ -187,6 +189,7 @@ public function count(): int * * @return Traversable */ + #[Override] public function getIterator(): Traversable { return new ArrayIterator($this->cookies); diff --git a/system/DataCaster/Cast/ArrayCast.php b/system/DataCaster/Cast/ArrayCast.php index 81f343b3e4a8..c23691b22edb 100644 --- a/system/DataCaster/Cast/ArrayCast.php +++ b/system/DataCaster/Cast/ArrayCast.php @@ -13,6 +13,8 @@ namespace CodeIgniter\DataCaster\Cast; +use Override; + /** * (PHP) [array --> string] --> (DB driver) --> (DB column) string * [ <-- string] <-- (DB driver) <-- (DB column) string @@ -21,6 +23,7 @@ */ class ArrayCast extends BaseCast { + #[Override] public static function get( mixed $value, array $params = [], @@ -37,6 +40,7 @@ public static function get( return (array) $value; } + #[Override] public static function set( mixed $value, array $params = [], diff --git a/system/DataCaster/Cast/BaseCast.php b/system/DataCaster/Cast/BaseCast.php index e6cc5ae98f1c..9fdb1dad2aec 100644 --- a/system/DataCaster/Cast/BaseCast.php +++ b/system/DataCaster/Cast/BaseCast.php @@ -14,6 +14,7 @@ namespace CodeIgniter\DataCaster\Cast; use CodeIgniter\Exceptions\InvalidArgumentException; +use Override; /** * @template TPhpNativeValue @@ -23,6 +24,7 @@ */ abstract class BaseCast implements CastInterface { + #[Override] public static function get( mixed $value, array $params = [], @@ -31,6 +33,7 @@ public static function get( return $value; } + #[Override] public static function set( mixed $value, array $params = [], diff --git a/system/DataCaster/Cast/BooleanCast.php b/system/DataCaster/Cast/BooleanCast.php index 79b9dfe6d8d9..915c0287afdb 100644 --- a/system/DataCaster/Cast/BooleanCast.php +++ b/system/DataCaster/Cast/BooleanCast.php @@ -13,6 +13,8 @@ namespace CodeIgniter\DataCaster\Cast; +use Override; + /** * (PHP) [bool --> bool ] --> (DB driver) --> (DB column) bool|int(0/1) * [ <-- string|int] <-- (DB driver) <-- (DB column) bool|int(0/1) @@ -21,6 +23,7 @@ */ class BooleanCast extends BaseCast { + #[Override] public static function get( mixed $value, array $params = [], diff --git a/system/DataCaster/Cast/CSVCast.php b/system/DataCaster/Cast/CSVCast.php index 3c09e1cc6103..7cada236ba8d 100644 --- a/system/DataCaster/Cast/CSVCast.php +++ b/system/DataCaster/Cast/CSVCast.php @@ -13,6 +13,8 @@ namespace CodeIgniter\DataCaster\Cast; +use Override; + /** * (PHP) [array --> string] --> (DB driver) --> (DB column) string * [ <-- string] <-- (DB driver) <-- (DB column) string @@ -21,6 +23,7 @@ */ class CSVCast extends BaseCast { + #[Override] public static function get( mixed $value, array $params = [], @@ -33,6 +36,7 @@ public static function get( return explode(',', $value); } + #[Override] public static function set( mixed $value, array $params = [], diff --git a/system/DataCaster/Cast/DatetimeCast.php b/system/DataCaster/Cast/DatetimeCast.php index 043b7ccd81ea..4a81f1d0449d 100644 --- a/system/DataCaster/Cast/DatetimeCast.php +++ b/system/DataCaster/Cast/DatetimeCast.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BaseConnection; use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\I18n\Time; +use Override; /** * (PHP) [Time --> string] --> (DB driver) --> (DB column) datetime @@ -25,6 +26,7 @@ */ class DatetimeCast extends BaseCast { + #[Override] public static function get( mixed $value, array $params = [], @@ -46,6 +48,7 @@ public static function get( return Time::createFromFormat($format, $value); } + #[Override] public static function set( mixed $value, array $params = [], diff --git a/system/DataCaster/Cast/EncryptedCast.php b/system/DataCaster/Cast/EncryptedCast.php index 5f74263013c8..67bc32fdf66f 100644 --- a/system/DataCaster/Cast/EncryptedCast.php +++ b/system/DataCaster/Cast/EncryptedCast.php @@ -14,6 +14,7 @@ namespace CodeIgniter\DataCaster\Cast; use CodeIgniter\DataCaster\Exceptions\CastException; +use Override; use SensitiveParameter; /** @@ -24,6 +25,7 @@ */ class EncryptedCast extends BaseCast { + #[Override] public static function get( #[SensitiveParameter] mixed $value, @@ -47,6 +49,7 @@ public static function get( return service('encrypter')->decrypt($decoded); } + #[Override] public static function set( #[SensitiveParameter] mixed $value, diff --git a/system/DataCaster/Cast/EncryptedJsonCast.php b/system/DataCaster/Cast/EncryptedJsonCast.php index 42ea1eb28d82..66932dde1e07 100644 --- a/system/DataCaster/Cast/EncryptedJsonCast.php +++ b/system/DataCaster/Cast/EncryptedJsonCast.php @@ -13,6 +13,7 @@ namespace CodeIgniter\DataCaster\Cast; +use Override; use SensitiveParameter; use stdClass; @@ -27,6 +28,7 @@ class EncryptedJsonCast extends BaseCast /** * @return array|stdClass|null */ + #[Override] public static function get( #[SensitiveParameter] mixed $value, @@ -42,6 +44,7 @@ public static function get( return JsonCast::get($json, $params, $helper); } + #[Override] public static function set( #[SensitiveParameter] mixed $value, diff --git a/system/DataCaster/Cast/EnumCast.php b/system/DataCaster/Cast/EnumCast.php index fcf611fe63d2..8f2e3649701f 100644 --- a/system/DataCaster/Cast/EnumCast.php +++ b/system/DataCaster/Cast/EnumCast.php @@ -15,6 +15,7 @@ use BackedEnum; use CodeIgniter\DataCaster\Exceptions\CastException; +use Override; use ReflectionEnum; use UnitEnum; @@ -28,6 +29,7 @@ */ class EnumCast extends BaseCast { + #[Override] public static function get( mixed $value, array $params = [], @@ -76,6 +78,7 @@ public static function get( return $enum; } + #[Override] public static function set( mixed $value, array $params = [], diff --git a/system/DataCaster/Cast/FloatCast.php b/system/DataCaster/Cast/FloatCast.php index 3b4141d46b53..b22197e750f1 100644 --- a/system/DataCaster/Cast/FloatCast.php +++ b/system/DataCaster/Cast/FloatCast.php @@ -14,6 +14,7 @@ namespace CodeIgniter\DataCaster\Cast; use CodeIgniter\DataCaster\Exceptions\CastException; +use Override; /** * (PHP) [float --> float ] --> (DB driver) --> (DB column) float @@ -23,6 +24,7 @@ */ class FloatCast extends BaseCast { + #[Override] public static function get( mixed $value, array $params = [], diff --git a/system/DataCaster/Cast/IntBoolCast.php b/system/DataCaster/Cast/IntBoolCast.php index 49b8861a4c6e..024cf47015c6 100644 --- a/system/DataCaster/Cast/IntBoolCast.php +++ b/system/DataCaster/Cast/IntBoolCast.php @@ -13,6 +13,8 @@ namespace CodeIgniter\DataCaster\Cast; +use Override; + /** * Int Bool Cast * @@ -23,6 +25,7 @@ */ final class IntBoolCast extends BaseCast { + #[Override] public static function get( mixed $value, array $params = [], @@ -35,6 +38,7 @@ public static function get( return (bool) $value; } + #[Override] public static function set( mixed $value, array $params = [], diff --git a/system/DataCaster/Cast/IntegerCast.php b/system/DataCaster/Cast/IntegerCast.php index 9b02cf6fbbb9..e4fa93ce648f 100644 --- a/system/DataCaster/Cast/IntegerCast.php +++ b/system/DataCaster/Cast/IntegerCast.php @@ -13,6 +13,8 @@ namespace CodeIgniter\DataCaster\Cast; +use Override; + /** * (PHP) [int --> int ] --> (DB driver) --> (DB column) int * [ <-- int|string] <-- (DB driver) <-- (DB column) int @@ -21,6 +23,7 @@ */ class IntegerCast extends BaseCast { + #[Override] public static function get( mixed $value, array $params = [], diff --git a/system/DataCaster/Cast/JsonCast.php b/system/DataCaster/Cast/JsonCast.php index 2a3fd5a729dd..0a250844fadf 100644 --- a/system/DataCaster/Cast/JsonCast.php +++ b/system/DataCaster/Cast/JsonCast.php @@ -15,6 +15,7 @@ use CodeIgniter\DataCaster\Exceptions\CastException; use JsonException; +use Override; use stdClass; /** @@ -25,6 +26,7 @@ */ class JsonCast extends BaseCast { + #[Override] public static function get( mixed $value, array $params = [], @@ -47,6 +49,7 @@ public static function get( return $output; } + #[Override] public static function set( mixed $value, array $params = [], diff --git a/system/DataCaster/Cast/TimestampCast.php b/system/DataCaster/Cast/TimestampCast.php index 7dceaa7b1846..58a3b589b068 100644 --- a/system/DataCaster/Cast/TimestampCast.php +++ b/system/DataCaster/Cast/TimestampCast.php @@ -14,6 +14,7 @@ namespace CodeIgniter\DataCaster\Cast; use CodeIgniter\I18n\Time; +use Override; /** * (PHP) [Time --> int ] --> (DB driver) --> (DB column) int @@ -23,6 +24,7 @@ */ class TimestampCast extends BaseCast { + #[Override] public static function get( mixed $value, array $params = [], @@ -35,6 +37,7 @@ public static function get( return Time::createFromTimestamp((int) $value, date_default_timezone_get()); } + #[Override] public static function set( mixed $value, array $params = [], diff --git a/system/DataCaster/Cast/URICast.php b/system/DataCaster/Cast/URICast.php index f9f9487e42fb..4609994a6c16 100644 --- a/system/DataCaster/Cast/URICast.php +++ b/system/DataCaster/Cast/URICast.php @@ -14,6 +14,7 @@ namespace CodeIgniter\DataCaster\Cast; use CodeIgniter\HTTP\URI; +use Override; /** * (PHP) [URI --> string] --> (DB driver) --> (DB column) string @@ -23,6 +24,7 @@ */ class URICast extends BaseCast { + #[Override] public static function get( mixed $value, array $params = [], @@ -35,6 +37,7 @@ public static function get( return new URI($value); } + #[Override] public static function set( mixed $value, array $params = [], diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index 7a9bc12ae567..8fb0b10a5c8d 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -26,6 +26,7 @@ use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\I18n\Time; use Exception; +use Override; use ReflectionClass; use ReflectionNamedType; use ReflectionType; @@ -568,6 +569,7 @@ private function getBuiltinPropertyTypesMap(array $properties): array * * @throws DatabaseException */ + #[Override] public function initialize() { /* If an established connection is available, then there's @@ -671,6 +673,7 @@ public function close() * * @return void */ + #[Override] public function reconnect() { if ($this->ping() === false) { @@ -736,6 +739,7 @@ protected function _ping(): bool * * @return false|TConnection */ + #[Override] public function persistentConnect() { return $this->connect(true); @@ -749,6 +753,7 @@ public function persistentConnect() * * @return false|TConnection */ + #[Override] public function getConnection(?string $alias = null) { // @todo work with read/write connections @@ -758,6 +763,7 @@ public function getConnection(?string $alias = null) /** * Returns the name of the current database being used. */ + #[Override] public function getDatabase(): string { return is_string($this->database) ? $this->database : ''; @@ -786,6 +792,7 @@ public function getPrefix(): string /** * The name of the platform in use (MySQLi, Postgre, SQLite3, OCI8, etc) */ + #[Override] public function getPlatform(): string { return $this->DBDriver; @@ -846,6 +853,7 @@ abstract protected function execute(string $sql); * * @todo BC set $queryClass default as null in 4.1 */ + #[Override] public function query(string $sql, $binds = null, bool $setEscapeFlags = true, string $queryClass = '') { $queryClass = $queryClass !== '' && $queryClass !== '0' ? $queryClass : $this->queryClass; @@ -955,6 +963,7 @@ public function query(string $sql, $binds = null, bool $setEscapeFlags = true, s * * @return false|TResult */ + #[Override] public function simpleQuery(string $sql) { if ($this->connID === false) { @@ -1060,6 +1069,7 @@ public function transStatus(): bool /** * Checks whether this connection is inside an active transaction. */ + #[Override] public function inTransaction(): bool { return $this->transDepth > 0; @@ -1072,6 +1082,7 @@ public function inTransaction(): bool * * @param callable(): void $callback */ + #[Override] public function afterCommit(callable $callback): static { if ($this->transDepth === 0) { @@ -1092,6 +1103,7 @@ public function afterCommit(callable $callback): static * * @param callable(): void $callback */ + #[Override] public function afterRollback(callable $callback): static { if ($this->transDepth === 0) { @@ -1115,6 +1127,7 @@ public function afterRollback(callable $callback): static * * @return false|TReturn */ + #[Override] public function transaction( callable $callback, int $attempts = 1, @@ -1363,6 +1376,7 @@ abstract protected function _transRollback(): bool; * * @throws DatabaseException */ + #[Override] public function table($tableName) { if (in_array($tableName, ['', '0', []], true)) { @@ -1434,6 +1448,7 @@ public function prepare(Closure $func, array $options = []) * * @return Query */ + #[Override] public function getLastQuery() { return $this->lastQuery; @@ -1789,6 +1804,7 @@ abstract public function affectedRows(): int; * * @return ($str is array ? array : float|int|string) */ + #[Override] public function escape($str) { if (is_array($str)) { @@ -1899,6 +1915,7 @@ protected function _escapeString(string $str): string * * @throws DatabaseException */ + #[Override] public function callFunction(string $functionName, ...$params): bool { $driver = $this->getDriverFunctionPrefix(); @@ -2208,6 +2225,7 @@ public function resetDataCache() * * @param string $sql */ + #[Override] public function isWriteType($sql): bool { return (bool) preg_match('/^\s*(WITH\s.+(\s|[)]))?"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX|MERGE)\s(?!.*\sRETURNING\s)/is', $sql); @@ -2220,6 +2238,7 @@ public function isWriteType($sql): bool * * @return array{code: int|string|null, message: string|null} */ + #[Override] abstract public function error(): array; /** diff --git a/system/Database/BasePreparedQuery.php b/system/Database/BasePreparedQuery.php index b9ac5038b874..4eb4012205fe 100644 --- a/system/Database/BasePreparedQuery.php +++ b/system/Database/BasePreparedQuery.php @@ -19,6 +19,7 @@ use CodeIgniter\Events\Events; use CodeIgniter\Exceptions\BadMethodCallException; use ErrorException; +use Override; use Throwable; /** @@ -77,6 +78,7 @@ public function __construct(BaseConnection $db) $this->db = $db; } + #[Override] public function prepare(string $sql, array $options = [], string $queryClass = Query::class) { // We only support positional placeholders (?), so convert @@ -108,6 +110,7 @@ abstract public function _prepare(string $sql, array $options = []); /** * @throws DatabaseException */ + #[Override] public function execute(...$data) { foreach ($data as $key => $value) { @@ -235,6 +238,7 @@ private function createDatabaseException(?Throwable $previous): ?DatabaseExcepti * * @throws BadMethodCallException */ + #[Override] public function close(): bool { if (! isset($this->statement)) { @@ -250,6 +254,7 @@ public function close(): bool abstract protected function _close(): bool; + #[Override] public function getQueryString(): string { if (! $this->query instanceof QueryInterface) { @@ -267,11 +272,13 @@ public function hasError(): bool return $this->errorString !== ''; } + #[Override] public function getErrorCode(): int { return $this->errorCode; } + #[Override] public function getErrorMessage(): string { return $this->errorString; diff --git a/system/Database/BaseResult.php b/system/Database/BaseResult.php index 5855eb064c86..d913dd504fb0 100644 --- a/system/Database/BaseResult.php +++ b/system/Database/BaseResult.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Database; use CodeIgniter\Entity\Entity; +use Override; use stdClass; /** @@ -78,6 +79,7 @@ public function __construct(&$connID, &$resultID) $this->resultID = $resultID; } + #[Override] public function getResult(string $type = 'object'): array { if ($type === 'array') { @@ -91,6 +93,7 @@ public function getResult(string $type = 'object'): array return $this->getCustomResultObject($type); } + #[Override] public function getCustomResultObject(string $className) { if (isset($this->customResultObject[$className])) { @@ -137,6 +140,7 @@ public function getCustomResultObject(string $className) return $this->customResultObject[$className]; } + #[Override] public function getResultArray(): array { if ($this->resultArray !== []) { @@ -169,6 +173,7 @@ public function getResultArray(): array return $this->resultArray; } + #[Override] public function getResultObject(): array { if ($this->resultObject !== []) { @@ -205,6 +210,7 @@ public function getResultObject(): array return $this->resultObject; } + #[Override] public function getRow($n = 0, string $type = 'object') { // $n is a column name. @@ -233,6 +239,7 @@ public function getRow($n = 0, string $type = 'object') return $this->getCustomRowObject($n, $type); } + #[Override] public function getCustomRowObject(int $n, string $className) { if (! isset($this->customResultObject[$className])) { @@ -250,6 +257,7 @@ public function getCustomRowObject(int $n, string $className) return $this->customResultObject[$className][$this->currentRow] ?? null; } + #[Override] public function getRowArray(int $n = 0) { $result = $this->getResultArray(); @@ -264,6 +272,7 @@ public function getRowArray(int $n = 0) return $result[$this->currentRow] ?? null; } + #[Override] public function getRowObject(int $n = 0) { $result = $this->getResultObject(); @@ -278,6 +287,7 @@ public function getRowObject(int $n = 0) return $result[$this->currentRow] ?? null; } + #[Override] public function setRow($key, $value = null) { // We cache the row data for subsequent uses @@ -298,6 +308,7 @@ public function setRow($key, $value = null) } } + #[Override] public function getFirstRow(string $type = 'object') { $result = $this->getResult($type); @@ -305,6 +316,7 @@ public function getFirstRow(string $type = 'object') return ($result === []) ? null : $result[0]; } + #[Override] public function getLastRow(string $type = 'object') { $result = $this->getResult($type); @@ -312,6 +324,7 @@ public function getLastRow(string $type = 'object') return ($result === []) ? null : $result[count($result) - 1]; } + #[Override] public function getNextRow(string $type = 'object') { $result = $this->getResult($type); @@ -322,6 +335,7 @@ public function getNextRow(string $type = 'object') return isset($result[$this->currentRow + 1]) ? $result[++$this->currentRow] : null; } + #[Override] public function getPreviousRow(string $type = 'object') { $result = $this->getResult($type); @@ -336,6 +350,7 @@ public function getPreviousRow(string $type = 'object') return $result[$this->currentRow] ?? null; } + #[Override] public function getUnbufferedRow(string $type = 'object') { if ($type === 'array') { @@ -354,6 +369,7 @@ public function getUnbufferedRow(string $type = 'object') * back on counting resultArray or resultObject, finally fetching resultArray * if nothing was previously fetched */ + #[Override] public function getNumRows(): int { if (is_int($this->numRows)) { diff --git a/system/Database/Exceptions/DatabaseException.php b/system/Database/Exceptions/DatabaseException.php index 48e335095910..67714073eced 100644 --- a/system/Database/Exceptions/DatabaseException.php +++ b/system/Database/Exceptions/DatabaseException.php @@ -15,6 +15,7 @@ use CodeIgniter\Exceptions\HasExitCodeInterface; use CodeIgniter\Exceptions\RuntimeException; +use Override; use Throwable; class DatabaseException extends RuntimeException implements ExceptionInterface, HasExitCodeInterface @@ -43,6 +44,7 @@ public function getDatabaseCode(): int|string return $this->databaseCode; } + #[Override] public function getExitCode(): int { return EXIT_DATABASE; diff --git a/system/Database/MySQLi/Builder.php b/system/Database/MySQLi/Builder.php index 9fde0c8a7c83..4ae0680fb241 100644 --- a/system/Database/MySQLi/Builder.php +++ b/system/Database/MySQLi/Builder.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Database\RawSql; +use Override; /** * Builder for MySQLi @@ -51,6 +52,7 @@ class Builder extends BaseBuilder * * Note: This is only used (and overridden) by MySQL. */ + #[Override] protected function _fromTables(): string { if ($this->QBJoin !== [] && count($this->QBFrom) > 1) { @@ -63,6 +65,7 @@ protected function _fromTables(): string /** * Compile the SELECT lock clause. */ + #[Override] protected function compileSelectLock(): string { if ($this->QBSelectLock === null) { @@ -95,6 +98,7 @@ protected function compileSelectLock(): string /** * Generates a platform-specific batch update string from the supplied data */ + #[Override] protected function _updateBatch(string $table, array $keys, array $values): string { $sql = $this->QBOptions['sql'] ?? ''; diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index 6ad1f0d5265a..f3fe8076889d 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -19,6 +19,7 @@ use mysqli; use mysqli_result; use mysqli_sql_exception; +use Override; use stdClass; use Throwable; @@ -109,6 +110,7 @@ class Connection extends BaseConnection /** * Checks whether the native database error represents a unique constraint violation. */ + #[Override] protected function isUniqueConstraintViolation(int|string $code, string $message): bool { // ER_DUP_ENTRY: duplicate key value. @@ -118,6 +120,7 @@ protected function isUniqueConstraintViolation(int|string $code, string $message /** * Checks whether the native database error represents a foreign key constraint violation. */ + #[Override] protected function isForeignKeyConstraintViolation(int|string $code, string $message): bool { // ER_NO_REFERENCED_ROW, ER_ROW_IS_REFERENCED, ER_ROW_IS_REFERENCED_2, ER_NO_REFERENCED_ROW_2. @@ -127,6 +130,7 @@ protected function isForeignKeyConstraintViolation(int|string $code, string $mes /** * Checks whether the native database error represents a NOT NULL constraint violation. */ + #[Override] protected function isNotNullConstraintViolation(int|string $code, string $message): bool { // ER_BAD_NULL_ERROR, ER_BAD_NULL_ERROR_NOT_IGNORED: column cannot be null. @@ -136,6 +140,7 @@ protected function isNotNullConstraintViolation(int|string $code, string $messag /** * Checks whether the native database error represents a CHECK constraint violation. */ + #[Override] protected function isCheckConstraintViolation(int|string $code, string $message): bool { if ($code === 3819) { @@ -149,6 +154,7 @@ protected function isCheckConstraintViolation(int|string $code, string $message) /** * Checks whether the native database code represents a retryable transaction failure. */ + #[Override] protected function isRetryableTransactionErrorCode(int|string $code): bool { // ER_LOCK_DEADLOCK: InnoDB rolls back the full transaction. @@ -162,6 +168,7 @@ protected function isRetryableTransactionErrorCode(int|string $code): bool * * @throws DatabaseException */ + #[Override] public function connect(bool $persistent = false) { // Do we have a socket path? @@ -302,6 +309,7 @@ public function connect(bool $persistent = false) return false; } + #[Override] protected function _close() { $this->connID->close(); @@ -310,6 +318,7 @@ protected function _close() /** * Select a specific database table to use. */ + #[Override] public function setDatabase(string $databaseName): bool { if ($databaseName === '') { @@ -332,6 +341,7 @@ public function setDatabase(string $databaseName): bool /** * Returns a string containing the version of the database being used. */ + #[Override] public function getVersion(): string { if (isset($this->dataCache['version'])) { @@ -350,6 +360,7 @@ public function getVersion(): string * * @return false|mysqli_result */ + #[Override] protected function execute(string $sql) { while ($this->connID->more_results()) { @@ -414,6 +425,7 @@ protected function prepQuery(string $sql): string /** * Returns the total number of rows affected by this query. */ + #[Override] public function affectedRows(): int { return $this->connID->affected_rows ?? 0; @@ -422,6 +434,7 @@ public function affectedRows(): int /** * Platform-dependant string escape */ + #[Override] protected function _escapeString(string $str): string { if (! $this->connID) { @@ -464,6 +477,7 @@ public function escapeLikeStringDirect($str) /** * Uses escapeLikeStringDirect(). */ + #[Override] protected function _listTables(bool $prefixLimit = false, ?string $tableName = null): string { $sql = 'SHOW TABLES FROM ' . $this->escapeIdentifier($this->database); @@ -479,6 +493,7 @@ protected function _listTables(bool $prefixLimit = false, ?string $tableName = n return $sql; } + #[Override] protected function _listColumns($table = ''): string { $tableName = $this->protectIdentifiers( @@ -494,6 +509,7 @@ protected function _listColumns($table = ''): string /** * @throws DatabaseException */ + #[Override] protected function _fieldData(string $table): array { $table = $this->protectIdentifiers($table, true, null, false); @@ -523,6 +539,7 @@ protected function _fieldData(string $table): array * @throws DatabaseException * @throws LogicException */ + #[Override] protected function _indexData(string $table): array { $table = $this->protectIdentifiers($table, true, null, false); @@ -566,6 +583,7 @@ protected function _indexData(string $table): array /** * @throws DatabaseException */ + #[Override] protected function _foreignKeyData(string $table): array { $sql = ' @@ -616,6 +634,7 @@ protected function _foreignKeyData(string $table): array * * @return string */ + #[Override] protected function _disableForeignKeyChecks() { return 'SET FOREIGN_KEY_CHECKS=0'; @@ -626,6 +645,7 @@ protected function _disableForeignKeyChecks() * * @return string */ + #[Override] protected function _enableForeignKeyChecks() { return 'SET FOREIGN_KEY_CHECKS=1'; @@ -638,6 +658,7 @@ protected function _enableForeignKeyChecks() * * @return array{code: int|string|null, message: string|null} */ + #[Override] public function error(): array { if ($this->mysqli instanceof mysqli && $this->mysqli->connect_errno !== 0) { @@ -656,11 +677,13 @@ public function error(): array /** * Insert ID */ + #[Override] public function insertID(): int { return $this->connID->insert_id; } + #[Override] protected function _transBegin(): bool { if (! $this->connID->begin_transaction()) { @@ -672,6 +695,7 @@ protected function _transBegin(): bool return true; } + #[Override] protected function _transCommit(): bool { // mysqli::commit() returns true after 1213. End the transaction @@ -685,6 +709,7 @@ protected function _transCommit(): bool return $this->connID->commit(); } + #[Override] protected function _transRollback(): bool { if (! $this->connID->rollback()) { diff --git a/system/Database/MySQLi/Forge.php b/system/Database/MySQLi/Forge.php index 0cbe85a3d470..9007c78de908 100644 --- a/system/Database/MySQLi/Forge.php +++ b/system/Database/MySQLi/Forge.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Database\MySQLi; use CodeIgniter\Database\Forge as BaseForge; +use Override; /** * Forge for MySQLi @@ -98,6 +99,7 @@ class Forge extends BaseForge * * @param array $attributes Associative array of table attributes */ + #[Override] protected function _createTableAttributes(array $attributes): string { $sql = ''; @@ -125,6 +127,7 @@ protected function _createTableAttributes(array $attributes): string return $sql; } + #[Override] protected function _alterTable(string $alterType, string $table, $processedFields) { if ($alterType === 'DROP') { @@ -153,6 +156,7 @@ protected function _alterTable(string $alterType, string $table, $processedField /** * Process column */ + #[Override] protected function _processColumn(array $processedField): string { $extraClause = isset($processedField['after']) ? ' AFTER ' . $this->db->escapeIdentifiers($processedField['after']) : ''; @@ -173,6 +177,7 @@ protected function _processColumn(array $processedField): string . $extraClause; } + #[Override] protected function _processIndexes(string $table, bool $asQuery = false): array { $sqls = ['']; @@ -222,6 +227,7 @@ protected function _processIndexes(string $table, bool $asQuery = false): array /** * Drop Key */ + #[Override] public function dropKey(string $table, string $keyName, bool $prefixKeyName = true): bool { $sql = sprintf( @@ -236,6 +242,7 @@ public function dropKey(string $table, string $keyName, bool $prefixKeyName = tr /** * Drop Primary Key */ + #[Override] public function dropPrimaryKey(string $table, string $keyName = ''): bool { $sql = sprintf( diff --git a/system/Database/MySQLi/PreparedQuery.php b/system/Database/MySQLi/PreparedQuery.php index ac7bf6ae6c60..b9b94c9c1d3a 100644 --- a/system/Database/MySQLi/PreparedQuery.php +++ b/system/Database/MySQLi/PreparedQuery.php @@ -19,6 +19,7 @@ use mysqli_result; use mysqli_sql_exception; use mysqli_stmt; +use Override; /** * Prepared query for MySQLi @@ -27,6 +28,7 @@ */ class PreparedQuery extends BasePreparedQuery { + #[Override] public function _prepare(string $sql, array $options = []): PreparedQuery { // Mysqli driver doesn't like statements @@ -45,6 +47,7 @@ public function _prepare(string $sql, array $options = []): PreparedQuery return $this; } + #[Override] public function _execute(array $data): bool { if (! isset($this->statement)) { @@ -106,11 +109,13 @@ public function _execute(array $data): bool /** * @return false|mysqli_result */ + #[Override] public function _getResult() { return $this->statement->get_result(); } + #[Override] protected function _close(): bool { return $this->statement->close(); diff --git a/system/Database/MySQLi/Result.php b/system/Database/MySQLi/Result.php index 956a4e0a705c..79c396a647e7 100644 --- a/system/Database/MySQLi/Result.php +++ b/system/Database/MySQLi/Result.php @@ -17,6 +17,7 @@ use CodeIgniter\Entity\Entity; use mysqli; use mysqli_result; +use Override; use stdClass; /** @@ -26,11 +27,13 @@ */ class Result extends BaseResult { + #[Override] public function getFieldCount(): int { return $this->resultID->field_count; } + #[Override] public function getFieldNames(): array { $fieldNames = []; @@ -43,6 +46,7 @@ public function getFieldNames(): array return $fieldNames; } + #[Override] public function getFieldData(): array { static $dataTypes = [ @@ -94,6 +98,7 @@ public function getFieldData(): array return $retVal; } + #[Override] public function freeResult() { if (is_object($this->resultID)) { @@ -102,16 +107,19 @@ public function freeResult() } } + #[Override] public function dataSeek(int $n = 0) { return $this->resultID->data_seek($n); } + #[Override] protected function fetchAssoc() { return $this->resultID->fetch_assoc(); } + #[Override] protected function fetchObject(string $className = stdClass::class) { if (is_subclass_of($className, Entity::class)) { @@ -123,6 +131,7 @@ protected function fetchObject(string $className = stdClass::class) return $this->resultID->fetch_object($className); } + #[Override] public function getNumRows(): int { if (! is_int($this->numRows)) { diff --git a/system/Database/MySQLi/Utils.php b/system/Database/MySQLi/Utils.php index 16f0d0f98ec7..7f7df4cec481 100644 --- a/system/Database/MySQLi/Utils.php +++ b/system/Database/MySQLi/Utils.php @@ -15,6 +15,7 @@ use CodeIgniter\Database\BaseUtils; use CodeIgniter\Database\Exceptions\DatabaseException; +use Override; /** * Utils for MySQLi @@ -36,6 +37,7 @@ class Utils extends BaseUtils /** * @return never */ + #[Override] public function _backup(?array $prefs = null) { throw new DatabaseException('Unsupported feature of the database platform you are using.'); diff --git a/system/Database/OCI8/Builder.php b/system/Database/OCI8/Builder.php index ae666f5f9385..dfd54fa72d21 100644 --- a/system/Database/OCI8/Builder.php +++ b/system/Database/OCI8/Builder.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Database\RawSql; +use Override; use stdClass; /** @@ -54,6 +55,7 @@ class Builder extends BaseBuilder /** * Generates a platform-specific insert string from the supplied data. */ + #[Override] protected function _insertBatch(string $table, array $keys, array $values): string { $sql = $this->QBOptions['sql'] ?? ''; @@ -91,6 +93,7 @@ protected function _insertBatch(string $table, array $keys, array $values): stri /** * Generates a platform-specific replace string from the supplied data */ + #[Override] protected function _replace(string $table, array $keys, array $values): string { $fieldNames = array_map(static fn ($columnName): string => trim($columnName, '"'), $keys); @@ -138,6 +141,7 @@ protected function _replace(string $table, array $keys, array $values): string * If the database does not support the truncate() command, * then this method maps to 'DELETE FROM table' */ + #[Override] protected function _truncate(string $table): string { return 'TRUNCATE TABLE ' . $table; @@ -152,6 +156,7 @@ protected function _truncate(string $table): string * * @throws DatabaseException */ + #[Override] public function delete($where = '', ?int $limit = null, bool $resetData = true) { if ($limit !== null && $limit !== 0) { @@ -164,6 +169,7 @@ public function delete($where = '', ?int $limit = null, bool $resetData = true) /** * Generates a platform-specific delete string from the supplied data */ + #[Override] protected function _delete(string $table): string { if ($this->QBLimit) { @@ -177,6 +183,7 @@ protected function _delete(string $table): string /** * Generates a platform-specific update string from the supplied data */ + #[Override] protected function _update(string $table, array $values): string { $valStr = []; @@ -197,6 +204,7 @@ protected function _update(string $table, array $values): string /** * Generates a platform-specific LIMIT clause. */ + #[Override] protected function _limit(string $sql, bool $offsetIgnore = false): string { $offset = (int) ($offsetIgnore === false ? $this->QBOffset : 0); @@ -212,6 +220,7 @@ protected function _limit(string $sql, bool $offsetIgnore = false): string /** * Compile the SELECT lock clause. */ + #[Override] protected function compileSelectLock(): string { if ($this->QBSelectLock === null) { @@ -236,6 +245,7 @@ protected function compileSelectLock(): string /** * Ensures the current driver supports explaining Query Builder selects. */ + #[Override] protected function assertExplainSupported(): never { throw new DatabaseException('OCI8 does not support explain().'); @@ -244,6 +254,7 @@ protected function assertExplainSupported(): never /** * Generates a platform-specific batch update string from the supplied data */ + #[Override] protected function _updateBatch(string $table, array $keys, array $values): string { $sql = $this->QBOptions['sql'] ?? ''; @@ -343,6 +354,7 @@ protected function _updateBatch(string $table, array $keys, array $values): stri * * @throws DatabaseException */ + #[Override] protected function _upsertBatch(string $table, array $keys, array $values): string { $sql = $this->QBOptions['sql'] ?? ''; @@ -450,6 +462,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri /** * Generates a platform-specific batch update string from the supplied data */ + #[Override] protected function _deleteBatch(string $table, array $keys, array $values): string { $sql = $this->QBOptions['sql'] ?? ''; @@ -529,6 +542,7 @@ protected function _deleteBatch(string $table, array $keys, array $values): stri /** * Gets column names from a select query */ + #[Override] protected function fieldsFromQuery(string $sql): array { return $this->db->query('SELECT * FROM (' . $sql . ') "_u_" WHERE ROWNUM = 1')->getFieldNames(); diff --git a/system/Database/OCI8/Connection.php b/system/Database/OCI8/Connection.php index 55d6faed75c6..af6a32d40621 100644 --- a/system/Database/OCI8/Connection.php +++ b/system/Database/OCI8/Connection.php @@ -18,6 +18,7 @@ use CodeIgniter\Database\Query; use CodeIgniter\Database\TableName; use ErrorException; +use Override; use stdClass; /** @@ -122,6 +123,7 @@ class Connection extends BaseConnection /** * Checks whether the native database error represents a unique constraint violation. */ + #[Override] protected function isUniqueConstraintViolation(int|string $code, string $message): bool { // ORA-00001: unique constraint violated. @@ -131,6 +133,7 @@ protected function isUniqueConstraintViolation(int|string $code, string $message /** * Checks whether the native database error represents a foreign key constraint violation. */ + #[Override] protected function isForeignKeyConstraintViolation(int|string $code, string $message): bool { // ORA-02291: parent key not found; ORA-02292: child record found. @@ -140,6 +143,7 @@ protected function isForeignKeyConstraintViolation(int|string $code, string $mes /** * Checks whether the native database error represents a NOT NULL constraint violation. */ + #[Override] protected function isNotNullConstraintViolation(int|string $code, string $message): bool { // ORA-01400: cannot insert NULL; ORA-01407: cannot update to NULL. @@ -149,6 +153,7 @@ protected function isNotNullConstraintViolation(int|string $code, string $messag /** * Checks whether the native database error represents a CHECK constraint violation. */ + #[Override] protected function isCheckConstraintViolation(int|string $code, string $message): bool { // ORA-02290: check constraint violated. @@ -158,6 +163,7 @@ protected function isCheckConstraintViolation(int|string $code, string $message) /** * Checks whether the native database code represents a retryable transaction failure. */ + #[Override] protected function isRetryableTransactionErrorCode(int|string $code): bool { return in_array((int) $code, [60, 8177], true); @@ -186,6 +192,7 @@ private function isValidDSN(): bool * * @return false|resource */ + #[Override] public function connect(bool $persistent = false) { if (! $this->isValidDSN()) { @@ -209,6 +216,7 @@ public function connect(bool $persistent = false) return $this->connID; } + #[Override] protected function _close() { if (is_resource($this->cursorId)) { @@ -223,6 +231,7 @@ protected function _close() /** * Ping the database connection. */ + #[Override] protected function _ping(): bool { try { @@ -237,6 +246,7 @@ protected function _ping(): bool /** * Select a specific database table to use. */ + #[Override] public function setDatabase(string $databaseName): bool { return false; @@ -245,6 +255,7 @@ public function setDatabase(string $databaseName): bool /** * Returns a string containing the version of the database being used. */ + #[Override] public function getVersion(): string { if (isset($this->dataCache['version'])) { @@ -271,6 +282,7 @@ public function getVersion(): string * * @return false|resource */ + #[Override] protected function execute(string $sql) { try { @@ -346,11 +358,13 @@ public function parseInsertTableName(string $sql): string /** * Returns the total number of rows affected by this query. */ + #[Override] public function affectedRows(): int { return oci_num_rows($this->stmtId); } + #[Override] protected function _listTables(bool $prefixLimit = false, ?string $tableName = null): string { $sql = 'SELECT "TABLE_NAME" FROM "USER_TABLES"'; @@ -367,6 +381,7 @@ protected function _listTables(bool $prefixLimit = false, ?string $tableName = n return $sql; } + #[Override] protected function _listColumns($table = ''): string { if ($table instanceof TableName) { @@ -388,6 +403,7 @@ protected function _listColumns($table = ''): string /** * @throws DatabaseException */ + #[Override] protected function _fieldData(string $table): array { if (str_contains($table, '.')) { @@ -441,6 +457,7 @@ private function normalizeDefault(?string $default): ?string /** * @throws DatabaseException */ + #[Override] protected function _indexData(string $table): array { if (str_contains($table, '.')) { @@ -486,6 +503,7 @@ protected function _indexData(string $table): array /** * @throws DatabaseException */ + #[Override] protected function _foreignKeyData(string $table): array { $sql = 'SELECT @@ -534,6 +552,7 @@ protected function _foreignKeyData(string $table): array * * @return string */ + #[Override] protected function _disableForeignKeyChecks() { return <<<'SQL' @@ -558,6 +577,7 @@ protected function _disableForeignKeyChecks() * * @return string */ + #[Override] protected function _enableForeignKeyChecks() { return <<<'SQL' @@ -648,6 +668,7 @@ protected function bindParams($params) * * return ['code' => null, 'message' => null); */ + #[Override] public function error(): array { // oci_error() is resource-specific: check each resource in priority order @@ -671,6 +692,7 @@ public function error(): array return is_array($error) ? $error : ['code' => '', 'message' => '']; } + #[Override] public function insertID(): int { if ($this->lastInsertedTableName === null || $this->lastInsertedTableName === '') { @@ -774,6 +796,7 @@ protected function buildDSN() $this->DSN = ''; } + #[Override] protected function _transBegin(): bool { $this->commitMode = OCI_NO_AUTO_COMMIT; @@ -781,6 +804,7 @@ protected function _transBegin(): bool return true; } + #[Override] protected function _transCommit(): bool { $this->commitMode = OCI_COMMIT_ON_SUCCESS; @@ -788,6 +812,7 @@ protected function _transCommit(): bool return oci_commit($this->connID); } + #[Override] protected function _transRollback(): bool { $this->commitMode = OCI_COMMIT_ON_SUCCESS; @@ -799,6 +824,7 @@ protected function _transRollback(): bool * Restore OCI_COMMIT_ON_SUCCESS. close() does not, and * OCI_NO_AUTO_COMMIT would leave later writes uncommitted. */ + #[Override] protected function abandonLostTransaction(): void { $this->commitMode = OCI_COMMIT_ON_SUCCESS; @@ -809,6 +835,7 @@ protected function abandonLostTransaction(): void /** * Returns the name of the current database being used. */ + #[Override] public function getDatabase(): string { if (is_string($this->database) && $this->database !== '') { @@ -821,6 +848,7 @@ public function getDatabase(): string /** * Get the prefix of the function to access the DB. */ + #[Override] protected function getDriverFunctionPrefix(): string { return 'oci_'; diff --git a/system/Database/OCI8/Forge.php b/system/Database/OCI8/Forge.php index 09b7f02a29f1..d938fa67e731 100644 --- a/system/Database/OCI8/Forge.php +++ b/system/Database/OCI8/Forge.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Database\OCI8; use CodeIgniter\Database\Forge as BaseForge; +use Override; /** * Forge for OCI8 @@ -71,6 +72,7 @@ class Forge extends BaseForge */ protected $fkAllowActions = ['CASCADE', 'SET NULL', 'NO ACTION']; + #[Override] protected function _alterTable(string $alterType, string $table, $processedFields) { $sql = 'ALTER TABLE ' . $this->db->escapeIdentifiers($table); @@ -149,6 +151,7 @@ protected function _alterTable(string $alterType, string $table, $processedField * * @return void */ + #[Override] protected function _attributeAutoIncrement(array &$attributes, array &$field) { if (($attributes['AUTO_INCREMENT'] ?? false) === true @@ -162,6 +165,7 @@ protected function _attributeAutoIncrement(array &$attributes, array &$field) /** * Process column */ + #[Override] protected function _processColumn(array $processedField): string { $constraint = ''; @@ -189,6 +193,7 @@ protected function _processColumn(array $processedField): string * * @return void */ + #[Override] protected function _attributeType(array &$attributes) { // Reset field lengths for data types that don't support it @@ -257,6 +262,7 @@ protected function _attributeType(array &$attributes) * * @return bool|string */ + #[Override] protected function _dropTable(string $table, bool $ifExists, bool $cascade) { $sql = parent::_dropTable($table, $ifExists, $cascade); @@ -273,6 +279,7 @@ protected function _dropTable(string $table, bool $ifExists, bool $cascade) /** * Constructs sql to check if key is a constraint. */ + #[Override] protected function _dropKeyAsConstraint(string $table, string $constraintName): string { return sprintf( diff --git a/system/Database/OCI8/PreparedQuery.php b/system/Database/OCI8/PreparedQuery.php index 2499d5491b6d..0c821240440c 100644 --- a/system/Database/OCI8/PreparedQuery.php +++ b/system/Database/OCI8/PreparedQuery.php @@ -18,6 +18,7 @@ use CodeIgniter\Exceptions\BadMethodCallException; use ErrorException; use OCILob; +use Override; /** * Prepared query for OCI8 @@ -31,6 +32,7 @@ class PreparedQuery extends BasePreparedQuery */ private ?string $lastInsertTableName = null; + #[Override] public function _prepare(string $sql, array $options = []): PreparedQuery { if (! $this->statement = oci_parse($this->db->connID, $this->parameterize($sql))) { @@ -48,6 +50,7 @@ public function _prepare(string $sql, array $options = []): PreparedQuery return $this; } + #[Override] public function _execute(array $data): bool { if (! isset($this->statement)) { @@ -100,11 +103,13 @@ public function _execute(array $data): bool /** * @return resource|null */ + #[Override] public function _getResult() { return $this->statement; } + #[Override] protected function _close(): bool { return oci_free_statement($this->statement); diff --git a/system/Database/OCI8/Result.php b/system/Database/OCI8/Result.php index 290e68673b64..1d240af18e66 100644 --- a/system/Database/OCI8/Result.php +++ b/system/Database/OCI8/Result.php @@ -15,6 +15,7 @@ use CodeIgniter\Database\BaseResult; use CodeIgniter\Entity\Entity; +use Override; use stdClass; /** @@ -24,16 +25,19 @@ */ class Result extends BaseResult { + #[Override] public function getFieldCount(): int { return oci_num_fields($this->resultID); } + #[Override] public function getFieldNames(): array { return array_map(fn ($fieldIndex): false|string => oci_field_name($this->resultID, $fieldIndex), range(1, $this->getFieldCount())); } + #[Override] public function getFieldData(): array { return array_map(fn ($fieldIndex): stdClass => (object) [ @@ -43,6 +47,7 @@ public function getFieldData(): array ], range(1, $this->getFieldCount())); } + #[Override] public function freeResult() { if (is_resource($this->resultID)) { @@ -54,6 +59,7 @@ public function freeResult() /** * @return false */ + #[Override] public function dataSeek(int $n = 0) { // We can't support data seek by oci @@ -63,11 +69,13 @@ public function dataSeek(int $n = 0) /** * @return array|false */ + #[Override] protected function fetchAssoc() { return oci_fetch_assoc($this->resultID); } + #[Override] protected function fetchObject(string $className = stdClass::class) { $row = oci_fetch_object($this->resultID); diff --git a/system/Database/OCI8/Utils.php b/system/Database/OCI8/Utils.php index 4995446076fb..adb370ee336e 100644 --- a/system/Database/OCI8/Utils.php +++ b/system/Database/OCI8/Utils.php @@ -15,6 +15,7 @@ use CodeIgniter\Database\BaseUtils; use CodeIgniter\Database\Exceptions\DatabaseException; +use Override; /** * Utils for OCI8 @@ -31,6 +32,7 @@ class Utils extends BaseUtils /** * @return never */ + #[Override] public function _backup(?array $prefs = null) { throw new DatabaseException('Unsupported feature of the database platform you are using.'); diff --git a/system/Database/Postgre/Builder.php b/system/Database/Postgre/Builder.php index bbc9091212ff..0d02e247fb0e 100644 --- a/system/Database/Postgre/Builder.php +++ b/system/Database/Postgre/Builder.php @@ -19,6 +19,7 @@ use CodeIgniter\Database\Query; use CodeIgniter\Database\RawSql; use CodeIgniter\Exceptions\InvalidArgumentException; +use Override; use TypeError; /** @@ -53,6 +54,7 @@ class Builder extends BaseBuilder * * @return string */ + #[Override] protected function compileIgnore(string $statement) { $sql = parent::compileIgnore($statement); @@ -67,6 +69,7 @@ protected function compileIgnore(string $statement) /** * Compile the SELECT lock clause. */ + #[Override] protected function compileSelectLock(): string { if ($this->QBSelectLock === null) { @@ -90,6 +93,7 @@ protected function compileSelectLock(): string * * @return $this */ + #[Override] public function orderBy(string $orderBy, string $direction = '', ?bool $escape = null) { $direction = strtoupper(trim($direction)); @@ -116,6 +120,7 @@ public function orderBy(string $orderBy, string $direction = '', ?bool $escape = * @param array|list $columns A list of columns or array of column => value pairs to increment. * @param int $value The value to increment by if $columns is a list of column names. */ + #[Override] public function incrementMany(array $columns, int $value = 1): bool { if ($columns === []) { @@ -158,6 +163,7 @@ public function incrementMany(array $columns, int $value = 1): bool * @param array|list $columns A list of columns or array of column => value pairs to decrement. * @param int $value The value to decrement by if $columns is a list of column names. */ + #[Override] public function decrementMany(array $columns, int $value = 1): bool { if ($columns === []) { @@ -206,6 +212,7 @@ public function decrementMany(array $columns, int $value = 1): bool * * @throws DatabaseException */ + #[Override] public function replace(?array $set = null) { if ($set !== null) { @@ -254,6 +261,7 @@ public function replace(?array $set = null) /** * Generates a platform-specific insert string from the supplied data */ + #[Override] protected function _insert(string $table, array $keys, array $unescapedKeys): string { return trim(sprintf('INSERT INTO %s (%s) VALUES (%s) %s', $table, implode(', ', $keys), implode(', ', $unescapedKeys), $this->compileIgnore('insert'))); @@ -262,6 +270,7 @@ protected function _insert(string $table, array $keys, array $unescapedKeys): st /** * Generates a platform-specific insert string from the supplied data. */ + #[Override] protected function _insertBatch(string $table, array $keys, array $values): string { $sql = $this->QBOptions['sql'] ?? ''; @@ -293,6 +302,7 @@ protected function _insertBatch(string $table, array $keys, array $values): stri * * @throws DatabaseException */ + #[Override] public function delete($where = '', ?int $limit = null, bool $resetData = true) { if ($limit !== null && $limit !== 0 || ($this->QBLimit !== false && $this->QBLimit !== 0)) { @@ -305,6 +315,7 @@ public function delete($where = '', ?int $limit = null, bool $resetData = true) /** * Generates a platform-specific LIMIT clause. */ + #[Override] protected function _limit(string $sql, bool $offsetIgnore = false): string { return $sql . ' LIMIT ' . $this->QBLimit . ($this->QBOffset ? " OFFSET {$this->QBOffset}" : ''); @@ -315,6 +326,7 @@ protected function _limit(string $sql, bool $offsetIgnore = false): string * * @throws DatabaseException */ + #[Override] protected function _update(string $table, array $values): string { if ($this->QBLimit !== false && $this->QBLimit !== 0) { @@ -329,6 +341,7 @@ protected function _update(string $table, array $values): string /** * Generates a platform-specific delete string from the supplied data */ + #[Override] protected function _delete(string $table): string { $this->QBLimit = false; @@ -342,6 +355,7 @@ protected function _delete(string $table): string * If the database does not support the truncate() command, * then this method maps to 'DELETE FROM table' */ + #[Override] protected function _truncate(string $table): string { return 'TRUNCATE ' . $table . ' RESTART IDENTITY'; @@ -355,6 +369,7 @@ protected function _truncate(string $table): string * * @see https://www.postgresql.org/docs/9.2/static/functions-matching.html */ + #[Override] protected function _like_statement(?string $prefix, string $column, ?string $not, string $bind, bool $insensitiveSearch = false): string { $op = $insensitiveSearch ? 'ILIKE' : 'LIKE'; @@ -369,6 +384,7 @@ protected function _like_statement(?string $prefix, string $column, ?string $not * * @return $this */ + #[Override] public function join(RawSql|string $table, $cond, string $type = '', ?bool $escape = null) { if (! in_array('FULL OUTER', $this->joinTypes, true)) { @@ -387,6 +403,7 @@ public function join(RawSql|string $table, $cond, string $type = '', ?bool $esca * @param list $keys QBKeys * @param list> $values QBSet */ + #[Override] protected function _updateBatch(string $table, array $keys, array $values): string { $sql = $this->QBOptions['sql'] ?? ''; @@ -558,6 +575,7 @@ private function getFieldType(string $table, string $fieldName): ?string * * @throws DatabaseException */ + #[Override] protected function _upsertBatch(string $table, array $keys, array $values): string { $sql = $this->QBOptions['sql'] ?? ''; @@ -652,6 +670,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri /** * Generates a platform-specific batch update string from the supplied data */ + #[Override] protected function _deleteBatch(string $table, array $keys, array $values): string { $sql = $this->QBOptions['sql'] ?? ''; diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php index c3683d16a0c1..e6ae70140dff 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -19,6 +19,7 @@ use CodeIgniter\Database\RawSql; use CodeIgniter\Database\TableName; use ErrorException; +use Override; use PgSql\Connection as PgSqlConnection; use PgSql\Result as PgSqlResult; use stdClass; @@ -81,6 +82,7 @@ class Connection extends BaseConnection /** * Checks whether the native database error represents a unique constraint violation. */ + #[Override] protected function isUniqueConstraintViolation(int|string $code, string $message): bool { return $code === '23505'; @@ -89,6 +91,7 @@ protected function isUniqueConstraintViolation(int|string $code, string $message /** * Checks whether the native database error represents a foreign key constraint violation. */ + #[Override] protected function isForeignKeyConstraintViolation(int|string $code, string $message): bool { return $code === '23503'; @@ -97,6 +100,7 @@ protected function isForeignKeyConstraintViolation(int|string $code, string $mes /** * Checks whether the native database error represents a NOT NULL constraint violation. */ + #[Override] protected function isNotNullConstraintViolation(int|string $code, string $message): bool { return $code === '23502'; @@ -105,6 +109,7 @@ protected function isNotNullConstraintViolation(int|string $code, string $messag /** * Checks whether the native database error represents a CHECK constraint violation. */ + #[Override] protected function isCheckConstraintViolation(int|string $code, string $message): bool { return $code === '23514'; @@ -113,6 +118,7 @@ protected function isCheckConstraintViolation(int|string $code, string $message) /** * Checks whether the native database error represents a constraint violation. */ + #[Override] protected function isConstraintViolation(int|string $code, string $message): bool { return is_string($code) && str_starts_with($code, '23'); @@ -121,6 +127,7 @@ protected function isConstraintViolation(int|string $code, string $message): boo /** * Checks whether the native database code represents a retryable transaction failure. */ + #[Override] protected function isRetryableTransactionErrorCode(int|string $code): bool { return in_array($code, ['40001', '40P01'], true); @@ -131,6 +138,7 @@ protected function isRetryableTransactionErrorCode(int|string $code): bool * * @return false|PgSqlConnection */ + #[Override] public function connect(bool $persistent = false) { if ($this->DSN === null || $this->DSN === '') { @@ -218,6 +226,7 @@ private function convertDSN() $this->DSN = $output; } + #[Override] protected function _close() { pg_close($this->connID); @@ -226,6 +235,7 @@ protected function _close() /** * Ping the database connection. */ + #[Override] protected function _ping(): bool { return pg_ping($this->connID); @@ -234,6 +244,7 @@ protected function _ping(): bool /** * Select a specific database table to use. */ + #[Override] public function setDatabase(string $databaseName): bool { return false; @@ -242,6 +253,7 @@ public function setDatabase(string $databaseName): bool /** * Returns a string containing the version of the database being used. */ + #[Override] public function getVersion(): string { if (isset($this->dataCache['version'])) { @@ -265,6 +277,7 @@ public function getVersion(): string * * @return false|PgSqlResult */ + #[Override] protected function execute(string $sql) { $this->lastFailedResult = null; @@ -375,6 +388,7 @@ private function handleConnectionError(): false /** * Get the prefix of the function to access the DB. */ + #[Override] protected function getDriverFunctionPrefix(): string { return 'pg_'; @@ -383,6 +397,7 @@ protected function getDriverFunctionPrefix(): string /** * Returns the total number of rows affected by this query. */ + #[Override] public function affectedRows(): int { if ($this->resultID === false) { @@ -392,6 +407,7 @@ public function affectedRows(): int return pg_affected_rows($this->resultID); } + #[Override] public function escape($str) { if (! $this->connID) { @@ -424,6 +440,7 @@ public function escape($str) /** * Platform-dependant string escape */ + #[Override] protected function _escapeString(string $str): string { if (! $this->connID) { @@ -433,6 +450,7 @@ protected function _escapeString(string $str): string return pg_escape_string($this->connID, $str); } + #[Override] protected function _listTables(bool $prefixLimit = false, ?string $tableName = null): string { $sql = 'SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" = \'' . $this->schema . "'"; @@ -450,6 +468,7 @@ protected function _listTables(bool $prefixLimit = false, ?string $tableName = n return $sql; } + #[Override] protected function _listColumns($table = ''): string { if ($table instanceof TableName) { @@ -467,6 +486,7 @@ protected function _listColumns($table = ''): string /** * @throws DatabaseException */ + #[Override] protected function _fieldData(string $table): array { $sql = 'SELECT "column_name", "data_type", "character_maximum_length", "numeric_precision", "column_default", "is_nullable" @@ -498,6 +518,7 @@ protected function _fieldData(string $table): array /** * @throws DatabaseException */ + #[Override] protected function _indexData(string $table): array { $sql = 'SELECT "indexname", "indexdef" @@ -533,6 +554,7 @@ protected function _indexData(string $table): array /** * @throws DatabaseException */ + #[Override] protected function _foreignKeyData(string $table): array { $sql = 'SELECT c.constraint_name, @@ -578,6 +600,7 @@ protected function _foreignKeyData(string $table): array * * @return string */ + #[Override] protected function _disableForeignKeyChecks() { return 'SET CONSTRAINTS ALL DEFERRED'; @@ -588,6 +611,7 @@ protected function _disableForeignKeyChecks() * * @return string */ + #[Override] protected function _enableForeignKeyChecks() { return 'SET CONSTRAINTS ALL IMMEDIATE;'; @@ -600,6 +624,7 @@ protected function _enableForeignKeyChecks() * * @return array{code: int|string|null, message: string|null} */ + #[Override] public function error(): array { if ($this->lastFailedResult instanceof PgSqlResult) { @@ -621,6 +646,7 @@ public function error(): array /** * @return int|string */ + #[Override] public function insertID() { $v = pg_version($this->connID); @@ -758,16 +784,19 @@ private function executeTransactionCommand(string $sql): bool /** * Begin Transaction */ + #[Override] protected function _transBegin(): bool { return $this->executeTransactionCommand('BEGIN'); } + #[Override] protected function _transCommit(): bool { return $this->executeTransactionCommand('COMMIT'); } + #[Override] protected function _transRollback(): bool { return $this->executeTransactionCommand('ROLLBACK'); diff --git a/system/Database/Postgre/Forge.php b/system/Database/Postgre/Forge.php index 8806ed3dce0f..6a4bb202be60 100644 --- a/system/Database/Postgre/Forge.php +++ b/system/Database/Postgre/Forge.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Database\Postgre; use CodeIgniter\Database\Forge as BaseForge; +use Override; /** * Forge for Postgre @@ -72,11 +73,13 @@ class Forge extends BaseForge * * @param array $attributes Associative array of table attributes */ + #[Override] protected function _createTableAttributes(array $attributes): string { return ''; } + #[Override] protected function _alterTable(string $alterType, string $table, $processedFields) { if (in_array($alterType, ['DROP', 'ADD'], true)) { @@ -126,6 +129,7 @@ protected function _alterTable(string $alterType, string $table, $processedField /** * Process column */ + #[Override] protected function _processColumn(array $processedField): string { return $this->db->escapeIdentifiers($processedField['name']) @@ -139,6 +143,7 @@ protected function _processColumn(array $processedField): string /** * Performs a data type mapping between different databases. */ + #[Override] protected function _attributeType(array &$attributes) { // Reset field lengths for data types that don't support it @@ -173,6 +178,7 @@ protected function _attributeType(array &$attributes) /** * Field attribute AUTO_INCREMENT */ + #[Override] protected function _attributeAutoIncrement(array &$attributes, array &$field) { if (($attributes['AUTO_INCREMENT'] ?? false) === true) { @@ -183,6 +189,7 @@ protected function _attributeAutoIncrement(array &$attributes, array &$field) /** * Generates a platform-specific DROP TABLE string */ + #[Override] protected function _dropTable(string $table, bool $ifExists, bool $cascade): string { $sql = parent::_dropTable($table, $ifExists, $cascade); @@ -197,6 +204,7 @@ protected function _dropTable(string $table, bool $ifExists, bool $cascade): str /** * Constructs sql to check if key is a constraint. */ + #[Override] protected function _dropKeyAsConstraint(string $table, string $constraintName): string { return sprintf( diff --git a/system/Database/Postgre/PreparedQuery.php b/system/Database/Postgre/PreparedQuery.php index 4528acb3899b..6b2bb5bc973a 100644 --- a/system/Database/Postgre/PreparedQuery.php +++ b/system/Database/Postgre/PreparedQuery.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BasePreparedQuery; use CodeIgniter\Exceptions\BadMethodCallException; use Exception; +use Override; use PgSql\Connection as PgSqlConnection; use PgSql\Result as PgSqlResult; @@ -45,6 +46,7 @@ class PreparedQuery extends BasePreparedQuery /** * @throws Exception */ + #[Override] public function _prepare(string $sql, array $options = []): PreparedQuery { $this->name = (string) random_int(1, 10_000_000_000_000_000); @@ -67,6 +69,7 @@ public function _prepare(string $sql, array $options = []): PreparedQuery return $this; } + #[Override] public function _execute(array $data): bool { if (! isset($this->statement)) { @@ -131,11 +134,13 @@ public function _execute(array $data): bool /** * @return PgSqlResult|null */ + #[Override] public function _getResult() { return $this->result; } + #[Override] protected function _close(): bool { return pg_query($this->db->connID, 'DEALLOCATE "' . $this->db->escapeIdentifiers($this->name) . '"') !== false; diff --git a/system/Database/Postgre/Result.php b/system/Database/Postgre/Result.php index d071ff27f6f5..383d9cbbbad8 100644 --- a/system/Database/Postgre/Result.php +++ b/system/Database/Postgre/Result.php @@ -15,6 +15,7 @@ use CodeIgniter\Database\BaseResult; use CodeIgniter\Entity\Entity; +use Override; use PgSql\Connection as PgSqlConnection; use PgSql\Result as PgSqlResult; use stdClass; @@ -26,11 +27,13 @@ */ class Result extends BaseResult { + #[Override] public function getFieldCount(): int { return pg_num_fields($this->resultID); } + #[Override] public function getFieldNames(): array { $fieldNames = []; @@ -42,6 +45,7 @@ public function getFieldNames(): array return $fieldNames; } + #[Override] public function getFieldData(): array { $retVal = []; @@ -60,6 +64,7 @@ public function getFieldData(): array return $retVal; } + #[Override] public function freeResult() { if ($this->resultID !== false) { @@ -68,6 +73,7 @@ public function freeResult() } } + #[Override] public function dataSeek(int $n = 0) { return pg_result_seek($this->resultID, $n); @@ -76,11 +82,13 @@ public function dataSeek(int $n = 0) /** * @return array|false */ + #[Override] protected function fetchAssoc() { return pg_fetch_assoc($this->resultID); } + #[Override] protected function fetchObject(string $className = stdClass::class) { if (is_subclass_of($className, Entity::class)) { @@ -92,6 +100,7 @@ protected function fetchObject(string $className = stdClass::class) return pg_fetch_object($this->resultID, null, $className); } + #[Override] public function getNumRows(): int { if (! is_int($this->numRows)) { diff --git a/system/Database/Postgre/Utils.php b/system/Database/Postgre/Utils.php index ab2e3bd6d056..6b99db08dbfb 100644 --- a/system/Database/Postgre/Utils.php +++ b/system/Database/Postgre/Utils.php @@ -15,6 +15,7 @@ use CodeIgniter\Database\BaseUtils; use CodeIgniter\Database\Exceptions\DatabaseException; +use Override; /** * Utils for Postgre @@ -36,6 +37,7 @@ class Utils extends BaseUtils /** * @return never */ + #[Override] public function _backup(?array $prefs = null) { throw new DatabaseException('Unsupported feature of the database platform you are using.'); diff --git a/system/Database/Query.php b/system/Database/Query.php index 4abc177d9532..5db39d19d3a3 100644 --- a/system/Database/Query.php +++ b/system/Database/Query.php @@ -18,6 +18,7 @@ use CodeIgniter\Database\Postgre\Connection as PostgreConnection; use CodeIgniter\Database\SQLite3\Connection as SQLite3Connection; use CodeIgniter\Database\SQLSRV\Connection as SQLSRVConnection; +use Override; use Stringable; /** @@ -105,6 +106,7 @@ public function __construct(ConnectionInterface $db) $this->db = $db; } + #[Override] public function setQuery(string $sql, mixed $binds = null, bool $setEscape = true): self { $this->originalQueryString = $sql; @@ -153,6 +155,7 @@ public function setBinds(array $binds, bool $setEscape = true) return $this; } + #[Override] public function getQuery(): string { if (! isset($this->finalQueryString) || $this->finalQueryString === '') { @@ -162,6 +165,7 @@ public function getQuery(): string return $this->finalQueryString; } + #[Override] public function setDuration(float $start, ?float $end = null): self { $this->startTime = $start; @@ -187,11 +191,13 @@ public function getStartTime(bool $returnRaw = false, int $decimals = 6) return number_format($this->startTime, $decimals); } + #[Override] public function getDuration(int $decimals = 6): string { return number_format(($this->endTime - $this->startTime), $decimals); } + #[Override] public function setError(int $code, string $error): self { $this->errorCode = $code; @@ -200,26 +206,31 @@ public function setError(int $code, string $error): self return $this; } + #[Override] public function hasError(): bool { return $this->errorString !== ''; } + #[Override] public function getErrorCode(): int { return $this->errorCode; } + #[Override] public function getErrorMessage(): string { return $this->errorString; } + #[Override] public function isWriteType(): bool { return $this->db->isWriteType($this->originalQueryString); } + #[Override] public function swapPrefix(string $orig, string $swap): self { $sql = $this->swappedQueryString ?? $this->originalQueryString; @@ -234,6 +245,7 @@ public function swapPrefix(string $orig, string $swap): self return $this; } + #[Override] public function getOriginalQuery(): string { return $this->originalQueryString; @@ -635,6 +647,7 @@ public function debugToolbarDisplay(): string /** * Return text representation of the query */ + #[Override] public function __toString(): string { return $this->getQuery(); diff --git a/system/Database/RawSql.php b/system/Database/RawSql.php index ef4acf39c3ea..0dac4753f5fb 100644 --- a/system/Database/RawSql.php +++ b/system/Database/RawSql.php @@ -13,6 +13,7 @@ namespace CodeIgniter\Database; +use Override; use Stringable; class RawSql implements Stringable @@ -27,6 +28,7 @@ public function __construct(string $sqlString) $this->string = $sqlString; } + #[Override] public function __toString(): string { return $this->string; diff --git a/system/Database/SQLSRV/Builder.php b/system/Database/SQLSRV/Builder.php index 420cd1fa53ee..eb0dc8a2854e 100644 --- a/system/Database/SQLSRV/Builder.php +++ b/system/Database/SQLSRV/Builder.php @@ -22,6 +22,7 @@ use CodeIgniter\Database\ResultInterface; use CodeIgniter\Exceptions\InvalidArgumentException; use Config\Feature; +use Override; use TypeError; /** @@ -77,6 +78,7 @@ class Builder extends BaseBuilder * Groups tables in FROM clauses if needed, so there is no confusion * about operator precedence. */ + #[Override] protected function _fromTables(): string { $from = []; @@ -124,11 +126,13 @@ private function compileTableLockHint(): string * If the database does not support the truncate() command, * then this method maps to 'DELETE FROM table' */ + #[Override] protected function _truncate(string $table): string { return 'TRUNCATE TABLE ' . $this->getFullName($table); } + #[Override] protected function compileJoinTable(RawSql|string $table, bool $escape): string { if ($table instanceof RawSql) { @@ -147,6 +151,7 @@ protected function compileJoinTable(RawSql|string $table, bool $escape): string * * @todo implement check for this instead static $insertKeyPermission */ + #[Override] protected function _insert(string $table, array $keys, array $unescapedKeys): string { $fullTableName = $this->getFullName($table); @@ -162,6 +167,7 @@ protected function _insert(string $table, array $keys, array $unescapedKeys): st * * Generates a platform-specific insert string from the supplied data. */ + #[Override] protected function _insertBatch(string $table, array $keys, array $values): string { $sql = $this->QBOptions['sql'] ?? ''; @@ -186,6 +192,7 @@ protected function _insertBatch(string $table, array $keys, array $values): stri /** * Generates a platform-specific update string from the supplied data */ + #[Override] protected function _update(string $table, array $values): string { $valstr = []; @@ -211,6 +218,7 @@ protected function _update(string $table, array $values): string * @param array|list $columns A list of columns or array of column => value pairs to increment. * @param int $value The value to increment by if $columns is a list of column names. */ + #[Override] public function incrementMany(array $columns, int $value = 1): bool { if ($columns === []) { @@ -257,6 +265,7 @@ public function incrementMany(array $columns, int $value = 1): bool * @param array|list $columns A list of columns or array of column => value pairs to decrement. * @param int $value The value to decrement by if $columns is a list of column names. */ + #[Override] public function decrementMany(array $columns, int $value = 1): bool { if ($columns === []) { @@ -345,6 +354,7 @@ private function addIdentity(string $fullTable, string $insert): string /** * Local implementation of limit */ + #[Override] protected function _limit(string $sql, bool $offsetIgnore = false): string { // SQL Server cannot handle `LIMIT 0`. @@ -376,6 +386,7 @@ protected function _limit(string $sql, bool $offsetIgnore = false): string * * @throws DatabaseException */ + #[Override] public function replace(?array $set = null) { if ($set !== null) { @@ -412,6 +423,7 @@ public function replace(?array $set = null) * Generates a platform-specific replace string from the supplied data * on match delete and insert */ + #[Override] protected function _replace(string $table, array $keys, array $values): string { // check whether the existing keys are part of the primary key. @@ -478,6 +490,7 @@ protected function _replace(string $table, array $keys, array $values): string * * @return $this */ + #[Override] protected function maxMinAvgSum(string $select = '', string $alias = '', string $type = 'MAX') { // int functions can be handled by parent @@ -515,6 +528,7 @@ protected function maxMinAvgSum(string $select = '', string $alias = '', string * * @return int|string when $test = true */ + #[Override] public function countAll(bool $reset = true) { $table = $this->QBFrom[0]; @@ -542,6 +556,7 @@ public function countAll(bool $reset = true) /** * Delete statement */ + #[Override] protected function _delete(string $table): string { return 'DELETE' . ($this->QBLimit === false || $this->QBLimit === 0 ? '' : ' TOP (' . $this->QBLimit . ') ') . ' FROM ' . $this->getFullName($table) . $this->compileWhereHaving('QBWhere'); @@ -556,6 +571,7 @@ protected function _delete(string $table): string * * @throws DatabaseException */ + #[Override] public function delete($where = '', ?int $limit = null, bool $resetData = true) { $table = $this->db->protectIdentifiers($this->QBFrom[0], true, null, false); @@ -603,6 +619,7 @@ public function delete($where = '', ?int $limit = null, bool $resetData = true) * * @param false|string $selectOverride */ + #[Override] protected function compileSelect($selectOverride = false): string { // Write the "select" portion of the query @@ -666,6 +683,7 @@ protected function compileSelect($selectOverride = false): string /** * Compile the SELECT lock clause. */ + #[Override] protected function compileSelectLock(): string { if ($this->QBSelectLock === null) { @@ -708,6 +726,7 @@ protected function compileSelectLock(): string /** * Ensures the current driver supports explaining Query Builder selects. */ + #[Override] protected function assertExplainSupported(): never { throw new DatabaseException('SQLSRV does not support explain().'); @@ -719,6 +738,7 @@ protected function assertExplainSupported(): never * * @return false|ResultInterface|string */ + #[Override] public function get(?int $limit = null, int $offset = 0, bool $reset = true) { $limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true; // @phpstan-ignore nullCoalesce.property @@ -747,6 +767,7 @@ public function get(?int $limit = null, int $offset = 0, bool $reset = true) * * @throws DatabaseException */ + #[Override] protected function _upsertBatch(string $table, array $keys, array $values): string { $sql = $this->QBOptions['sql'] ?? ''; @@ -891,6 +912,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri /** * Gets column names from a select query */ + #[Override] protected function fieldsFromQuery(string $sql): array { return $this->db->query('SELECT TOP 1 * FROM (' . $sql . ') _u_')->getFieldNames(); diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php index fa9e554eb907..ccc17f49073a 100644 --- a/system/Database/SQLSRV/Connection.php +++ b/system/Database/SQLSRV/Connection.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BaseConnection; use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Database\TableName; +use Override; use stdClass; /** @@ -92,6 +93,7 @@ class Connection extends BaseConnection /** * Checks whether the native database error represents a unique constraint violation. */ + #[Override] protected function isUniqueConstraintViolation(int|string $code, string $message): bool { $vendorCode = $this->getVendorErrorCode($code); @@ -120,6 +122,7 @@ protected function isUniqueConstraintViolation(int|string $code, string $message /** * Checks whether the native database error represents a NOT NULL constraint violation. */ + #[Override] protected function isNotNullConstraintViolation(int|string $code, string $message): bool { return $this->getVendorErrorCode($code) === 515 @@ -129,6 +132,7 @@ protected function isNotNullConstraintViolation(int|string $code, string $messag /** * Checks whether the native database error represents a constraint violation. */ + #[Override] protected function isConstraintViolation(int|string $code, string $message): bool { return $this->getSQLState($code) === '23000' @@ -138,6 +142,7 @@ protected function isConstraintViolation(int|string $code, string $message): boo /** * Checks whether the native database code represents a retryable transaction failure. */ + #[Override] protected function isRetryableTransactionErrorCode(int|string $code): bool { $vendorCode = $this->getVendorErrorCode($code); @@ -185,6 +190,7 @@ public function __construct(array $params) * * @throws DatabaseException */ + #[Override] public function connect(bool $persistent = false) { $charset = in_array(strtolower($this->charset), ['utf-8', 'utf8'], true) ? 'UTF-8' : SQLSRV_ENC_CHAR; @@ -248,6 +254,7 @@ public function getAllErrorMessages(): string return implode("\n", $errors); } + #[Override] protected function _close() { sqlsrv_close($this->connID); @@ -256,6 +263,7 @@ protected function _close() /** * Platform-dependant string escape */ + #[Override] protected function _escapeString(string $str): string { return str_replace("'", "''", remove_invisible_characters($str, false)); @@ -264,11 +272,13 @@ protected function _escapeString(string $str): string /** * Insert ID */ + #[Override] public function insertID(): int { return (int) ($this->query('SELECT SCOPE_IDENTITY() AS insert_id')->getRow()->insert_id ?? 0); } + #[Override] protected function _listTables(bool $prefixLimit = false, ?string $tableName = null): string { $sql = 'SELECT [TABLE_NAME] AS "name"' @@ -288,6 +298,7 @@ protected function _listTables(bool $prefixLimit = false, ?string $tableName = n return $sql; } + #[Override] protected function _listColumns($table = ''): string { if ($table instanceof TableName) { @@ -305,6 +316,7 @@ protected function _listColumns($table = ''): string /** * @throws DatabaseException */ + #[Override] protected function _indexData(string $table): array { $sql = 'EXEC sp_helpindex ' . $this->escape($this->schema . '.' . $table); @@ -338,6 +350,7 @@ protected function _indexData(string $table): array /** * @throws DatabaseException */ + #[Override] protected function _foreignKeyData(string $table): array { $sql = 'SELECT @@ -382,6 +395,7 @@ protected function _foreignKeyData(string $table): array * * @return string */ + #[Override] protected function _disableForeignKeyChecks() { return 'EXEC sp_MSforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT ALL"'; @@ -392,6 +406,7 @@ protected function _disableForeignKeyChecks() * * @return string */ + #[Override] protected function _enableForeignKeyChecks() { return 'EXEC sp_MSforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT ALL"'; @@ -400,6 +415,7 @@ protected function _enableForeignKeyChecks() /** * @throws DatabaseException */ + #[Override] protected function _fieldData(string $table): array { $parts = explode('.', $table); @@ -474,16 +490,19 @@ private function normalizeDefault(?string $default): ?string return $default; } + #[Override] protected function _transBegin(): bool { return sqlsrv_begin_transaction($this->connID); } + #[Override] protected function _transCommit(): bool { return sqlsrv_commit($this->connID); } + #[Override] protected function _transRollback(): bool { return sqlsrv_rollback($this->connID); @@ -496,6 +515,7 @@ protected function _transRollback(): bool * * @return array{code: int|string|null, message: string|null} */ + #[Override] public function error(): array { $error = [ @@ -526,6 +546,7 @@ public function error(): array /** * Returns the total number of rows affected by this query. */ + #[Override] public function affectedRows(): int { if ($this->resultID === false) { @@ -540,6 +561,7 @@ public function affectedRows(): int * * @return bool */ + #[Override] public function setDatabase(?string $databaseName = null) { if ($databaseName === null || $databaseName === '') { @@ -565,6 +587,7 @@ public function setDatabase(?string $databaseName = null) * * @return false|resource */ + #[Override] protected function execute(string $sql) { $stmt = ($this->scrollable === false || $this->isWriteType($sql)) @@ -599,6 +622,7 @@ protected function execute(string $sql) /** * The name of the platform in use (MySQLi, mssql, etc) */ + #[Override] public function getPlatform(): string { return $this->DBDriver; @@ -607,6 +631,7 @@ public function getPlatform(): string /** * Returns a string containing the version of the database being used. */ + #[Override] public function getVersion(): string { $info = []; @@ -632,6 +657,7 @@ public function getVersion(): string * * @param string $sql */ + #[Override] public function isWriteType($sql): bool { if (preg_match('/^\s*"?(EXEC\s*sp_rename)\s/i', $sql)) { diff --git a/system/Database/SQLSRV/Forge.php b/system/Database/SQLSRV/Forge.php index 84738b226d09..e8354c342fc5 100644 --- a/system/Database/SQLSRV/Forge.php +++ b/system/Database/SQLSRV/Forge.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BaseConnection; use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Database\Forge as BaseForge; +use Override; use Throwable; /** @@ -102,6 +103,7 @@ public function __construct(BaseConnection $db) $this->dropIndexStr = 'DROP INDEX %s ON ' . $this->db->escapeIdentifiers($this->db->schema) . '.%s'; } + #[Override] public function createDatabase(string $dbName, bool $ifNotExists = false): bool { if ($ifNotExists) { @@ -147,6 +149,7 @@ public function createDatabase(string $dbName, bool $ifNotExists = false): bool * * @see https://stackoverflow.com/questions/7469130/cannot-drop-database-because-it-is-currently-in-use */ + #[Override] public function dropDatabase(string $dbName): bool { try { @@ -161,11 +164,13 @@ public function dropDatabase(string $dbName): bool return parent::dropDatabase($dbName); } + #[Override] protected function _createTableAttributes(array $attributes): string { return ''; } + #[Override] protected function _alterTable(string $alterType, string $table, $processedFields) { // Handle DROP here @@ -301,6 +306,7 @@ protected function _dropIndex(string $table, object $indexData) return $this->db->simpleQuery($sql); } + #[Override] protected function _processIndexes(string $table, bool $asQuery = false): array { $sqls = []; @@ -341,6 +347,7 @@ protected function _processIndexes(string $table, bool $asQuery = false): array /** * Process column */ + #[Override] protected function _processColumn(array $processedField): string { return $this->db->escapeIdentifiers($processedField['name']) @@ -356,6 +363,7 @@ protected function _processColumn(array $processedField): string /** * Performs a data type mapping between different databases. */ + #[Override] protected function _attributeType(array &$attributes) { // Reset field lengths for data types that don't support it @@ -409,6 +417,7 @@ protected function _attributeType(array &$attributes) /** * Field attribute AUTO_INCREMENT */ + #[Override] protected function _attributeAutoIncrement(array &$attributes, array &$field) { if (($attributes['AUTO_INCREMENT'] ?? false) === true && str_contains(strtolower($field['type']), strtolower('INT'))) { @@ -421,6 +430,7 @@ protected function _attributeAutoIncrement(array &$attributes, array &$field) * * @todo Support for cascade */ + #[Override] protected function _dropTable(string $table, bool $ifExists, bool $cascade): string { $sql = 'DROP TABLE'; @@ -443,6 +453,7 @@ protected function _dropTable(string $table, bool $ifExists, bool $cascade): str /** * Constructs sql to check if key is a constraint. */ + #[Override] protected function _dropKeyAsConstraint(string $table, string $constraintName): string { return sprintf( diff --git a/system/Database/SQLSRV/PreparedQuery.php b/system/Database/SQLSRV/PreparedQuery.php index 78e3dfbc988d..7228cb5e9638 100644 --- a/system/Database/SQLSRV/PreparedQuery.php +++ b/system/Database/SQLSRV/PreparedQuery.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BasePreparedQuery; use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Exceptions\BadMethodCallException; +use Override; /** * Prepared query for SQLSRV @@ -41,6 +42,7 @@ public function __construct(Connection $db) * * @throws DatabaseException */ + #[Override] public function _prepare(string $sql, array $options = []): PreparedQuery { // Prepare parameters for the query @@ -66,6 +68,7 @@ public function _prepare(string $sql, array $options = []): PreparedQuery return $this; } + #[Override] public function _execute(array $data): bool { if (! isset($this->statement)) { @@ -96,11 +99,13 @@ public function _execute(array $data): bool /** * @return resource|null */ + #[Override] public function _getResult() { return $this->statement; } + #[Override] protected function _close(): bool { return sqlsrv_free_stmt($this->statement); diff --git a/system/Database/SQLSRV/Result.php b/system/Database/SQLSRV/Result.php index 5a5f3beed997..7743d841cee3 100644 --- a/system/Database/SQLSRV/Result.php +++ b/system/Database/SQLSRV/Result.php @@ -15,6 +15,7 @@ use CodeIgniter\Database\BaseResult; use CodeIgniter\Entity\Entity; +use Override; use stdClass; /** @@ -24,11 +25,13 @@ */ class Result extends BaseResult { + #[Override] public function getFieldCount(): int { return @sqlsrv_num_fields($this->resultID); } + #[Override] public function getFieldNames(): array { $fieldNames = []; @@ -40,6 +43,7 @@ public function getFieldNames(): array return $fieldNames; } + #[Override] public function getFieldData(): array { static $dataTypes = [ @@ -94,6 +98,7 @@ public function getFieldData(): array return $retVal; } + #[Override] public function freeResult() { if (is_resource($this->resultID)) { @@ -102,6 +107,7 @@ public function freeResult() } } + #[Override] public function dataSeek(int $n = 0) { if ($n > 0) { @@ -115,11 +121,13 @@ public function dataSeek(int $n = 0) return true; } + #[Override] protected function fetchAssoc() { return sqlsrv_fetch_array($this->resultID, SQLSRV_FETCH_ASSOC); } + #[Override] protected function fetchObject(string $className = stdClass::class) { if (is_subclass_of($className, Entity::class)) { @@ -131,6 +139,7 @@ protected function fetchObject(string $className = stdClass::class) return sqlsrv_fetch_object($this->resultID, $className); } + #[Override] public function getNumRows(): int { if (! is_int($this->numRows)) { diff --git a/system/Database/SQLSRV/Utils.php b/system/Database/SQLSRV/Utils.php index 1e7fe45730a2..f0b876b6e717 100644 --- a/system/Database/SQLSRV/Utils.php +++ b/system/Database/SQLSRV/Utils.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BaseUtils; use CodeIgniter\Database\ConnectionInterface; use CodeIgniter\Database\Exceptions\DatabaseException; +use Override; /** * Utils for SQLSRV @@ -44,6 +45,7 @@ public function __construct(ConnectionInterface $db) /** * @return never */ + #[Override] public function _backup(?array $prefs = null) { throw new DatabaseException('Unsupported feature of the database platform you are using.'); diff --git a/system/Database/SQLite3/Builder.php b/system/Database/SQLite3/Builder.php index 88774d21b4e4..9c60df2d25d6 100644 --- a/system/Database/SQLite3/Builder.php +++ b/system/Database/SQLite3/Builder.php @@ -17,6 +17,7 @@ use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Database\RawSql; use CodeIgniter\Exceptions\InvalidArgumentException; +use Override; /** * Builder for SQLite3 @@ -60,6 +61,7 @@ class Builder extends BaseBuilder /** * Compile the SELECT lock clause. */ + #[Override] protected function compileSelectLock(): string { if ($this->QBSelectLock === null) { @@ -75,6 +77,7 @@ protected function compileSelectLock(): string /** * Compiles an execution-plan query for the current SELECT query. */ + #[Override] protected function compileExplain(string $sql): string { return 'EXPLAIN QUERY PLAN ' . $sql; @@ -85,6 +88,7 @@ protected function compileExplain(string $sql): string * * Generates a platform-specific replace string from the supplied data */ + #[Override] protected function _replace(string $table, array $keys, array $values): string { return 'INSERT OR ' . parent::_replace($table, $keys, $values); @@ -96,6 +100,7 @@ protected function _replace(string $table, array $keys, array $values): string * If the database does not support the TRUNCATE statement, * then this method maps to 'DELETE FROM table' */ + #[Override] protected function _truncate(string $table): string { return 'DELETE FROM ' . $table; @@ -104,6 +109,7 @@ protected function _truncate(string $table): string /** * Generates a platform-specific batch update string from the supplied data */ + #[Override] protected function _updateBatch(string $table, array $keys, array $values): string { if (version_compare($this->db->getVersion(), '3.33.0') >= 0) { @@ -159,6 +165,7 @@ protected function _updateBatch(string $table, array $keys, array $values): stri * * @throws DatabaseException */ + #[Override] protected function _upsertBatch(string $table, array $keys, array $values): string { $sql = $this->QBOptions['sql'] ?? ''; @@ -242,6 +249,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri /** * Generates a platform-specific batch update string from the supplied data */ + #[Override] protected function _deleteBatch(string $table, array $keys, array $values): string { $sql = $this->QBOptions['sql'] ?? ''; diff --git a/system/Database/SQLite3/Connection.php b/system/Database/SQLite3/Connection.php index 0739552c74aa..97033eecb9b3 100644 --- a/system/Database/SQLite3/Connection.php +++ b/system/Database/SQLite3/Connection.php @@ -18,6 +18,7 @@ use CodeIgniter\Database\TableName; use CodeIgniter\Exceptions\InvalidArgumentException; use Exception; +use Override; use SQLite3; use SQLite3Result; use stdClass; @@ -69,6 +70,7 @@ class Connection extends BaseConnection /** * Checks whether the native database error represents a unique constraint violation. */ + #[Override] protected function isUniqueConstraintViolation(int|string $code, string $message): bool { // SQLite3 reports unique violations in two formats depending on version: @@ -81,6 +83,7 @@ protected function isUniqueConstraintViolation(int|string $code, string $message /** * Checks whether the native database error represents a foreign key constraint violation. */ + #[Override] protected function isForeignKeyConstraintViolation(int|string $code, string $message): bool { return str_contains($message, 'FOREIGN KEY constraint failed'); @@ -89,6 +92,7 @@ protected function isForeignKeyConstraintViolation(int|string $code, string $mes /** * Checks whether the native database error represents a NOT NULL constraint violation. */ + #[Override] protected function isNotNullConstraintViolation(int|string $code, string $message): bool { return str_contains($message, 'NOT NULL constraint failed'); @@ -97,6 +101,7 @@ protected function isNotNullConstraintViolation(int|string $code, string $messag /** * Checks whether the native database error represents a CHECK constraint violation. */ + #[Override] protected function isCheckConstraintViolation(int|string $code, string $message): bool { return str_contains($message, 'CHECK constraint failed'); @@ -105,6 +110,7 @@ protected function isCheckConstraintViolation(int|string $code, string $message) /** * Checks whether the native database error represents a constraint violation. */ + #[Override] protected function isConstraintViolation(int|string $code, string $message): bool { return $code === 19; @@ -113,6 +119,7 @@ protected function isConstraintViolation(int|string $code, string $message): boo /** * Checks whether the native database code represents a retryable transaction failure. */ + #[Override] protected function isRetryableTransactionErrorCode(int|string $code): bool { return $code === 5; @@ -121,6 +128,7 @@ protected function isRetryableTransactionErrorCode(int|string $code): bool /** * @return void */ + #[Override] public function initialize() { parent::initialize(); @@ -148,6 +156,7 @@ public function initialize() * * @throws DatabaseException */ + #[Override] public function connect(bool $persistent = false) { if ($persistent && $this->DBDebug) { @@ -171,6 +180,7 @@ public function connect(bool $persistent = false) } } + #[Override] protected function _close() { $this->connID->close(); @@ -179,6 +189,7 @@ protected function _close() /** * Select a specific database table to use. */ + #[Override] public function setDatabase(string $databaseName): bool { return false; @@ -187,6 +198,7 @@ public function setDatabase(string $databaseName): bool /** * Returns a string containing the version of the database being used. */ + #[Override] public function getVersion(): string { if (isset($this->dataCache['version'])) { @@ -203,6 +215,7 @@ public function getVersion(): string * * @return false|SQLite3Result */ + #[Override] protected function execute(string $sql) { try { @@ -233,6 +246,7 @@ protected function execute(string $sql) /** * Returns the total number of rows affected by this query. */ + #[Override] public function affectedRows(): int { return $this->connID->changes(); @@ -241,6 +255,7 @@ public function affectedRows(): int /** * Platform-dependant string escape */ + #[Override] protected function _escapeString(string $str): string { if (! $this->connID instanceof SQLite3) { @@ -250,6 +265,7 @@ protected function _escapeString(string $str): string return $this->connID->escapeString($str); } + #[Override] protected function _listTables(bool $prefixLimit = false, ?string $tableName = null): string { if ((string) $tableName !== '') { @@ -265,6 +281,7 @@ protected function _listTables(bool $prefixLimit = false, ?string $tableName = n : ''); } + #[Override] protected function _listColumns($table = ''): string { if ($table instanceof TableName) { @@ -283,6 +300,7 @@ protected function _listColumns($table = ''): string * * @throws DatabaseException */ + #[Override] public function getFieldNames($tableName) { $table = ($tableName instanceof TableName) ? $tableName->getTableName() : $tableName; @@ -325,6 +343,7 @@ public function getFieldNames($tableName) /** * @throws DatabaseException */ + #[Override] protected function _fieldData(string $table): array { $parts = explode('.', $table); @@ -364,6 +383,7 @@ protected function _fieldData(string $table): array /** * @throws DatabaseException */ + #[Override] protected function _indexData(string $table): array { $sql = "SELECT 'PRIMARY' as indexname, l.name as fieldname, 'PRIMARY' as indextype @@ -414,6 +434,7 @@ protected function _indexData(string $table): array return $retVal; } + #[Override] protected function _foreignKeyData(string $table): array { if (! $this->supportsForeignKeys()) { @@ -448,6 +469,7 @@ protected function _foreignKeyData(string $table): array * * @return string */ + #[Override] protected function _disableForeignKeyChecks() { return 'PRAGMA foreign_keys = OFF'; @@ -458,6 +480,7 @@ protected function _disableForeignKeyChecks() * * @return string */ + #[Override] protected function _enableForeignKeyChecks() { return 'PRAGMA foreign_keys = ON'; @@ -470,6 +493,7 @@ protected function _enableForeignKeyChecks() * * @return array{code: int|string|null, message: string|null} */ + #[Override] public function error(): array { return [ @@ -481,21 +505,25 @@ public function error(): array /** * Insert ID */ + #[Override] public function insertID(): int { return $this->connID->lastInsertRowID(); } + #[Override] protected function _transBegin(): bool { return $this->connID->exec('BEGIN TRANSACTION'); } + #[Override] protected function _transCommit(): bool { return $this->connID->exec('END TRANSACTION'); } + #[Override] protected function _transRollback(): bool { return $this->connID->exec('ROLLBACK'); diff --git a/system/Database/SQLite3/Forge.php b/system/Database/SQLite3/Forge.php index 2ca26bba105e..3d83a581874f 100644 --- a/system/Database/SQLite3/Forge.php +++ b/system/Database/SQLite3/Forge.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BaseConnection; use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Database\Forge as BaseForge; +use Override; /** * Forge for SQLite3 @@ -59,6 +60,7 @@ public function __construct(BaseConnection $db) } } + #[Override] public function createDatabase(string $dbName, bool $ifNotExists = false): bool { // In SQLite, a database is created when you connect to the database. @@ -71,6 +73,7 @@ public function createDatabase(string $dbName, bool $ifNotExists = false): bool * * @throws DatabaseException */ + #[Override] public function dropDatabase(string $dbName): bool { // In SQLite, a database is dropped when we delete a file @@ -107,6 +110,7 @@ public function dropDatabase(string $dbName): bool * * @throws DatabaseException */ + #[Override] public function dropColumn(string $table, $columnNames): bool { $columns = is_array($columnNames) ? $columnNames : array_map(trim(...), explode(',', $columnNames)); @@ -127,6 +131,7 @@ public function dropColumn(string $table, $columnNames): bool return $result; } + #[Override] protected function _alterTable(string $alterType, string $table, $processedFields) { switch ($alterType) { @@ -165,6 +170,7 @@ protected function _alterTable(string $alterType, string $table, $processedField /** * Process column */ + #[Override] protected function _processColumn(array $processedField): string { if ($processedField['type'] === 'TEXT' && str_starts_with($processedField['length'], "('")) { @@ -185,6 +191,7 @@ protected function _processColumn(array $processedField): string * * Performs a data type mapping between different databases. */ + #[Override] protected function _attributeType(array &$attributes) { switch (strtoupper($attributes['TYPE'])) { @@ -205,6 +212,7 @@ protected function _attributeType(array &$attributes) /** * Field attribute AUTO_INCREMENT */ + #[Override] protected function _attributeAutoIncrement(array &$attributes, array &$field) { if ( @@ -226,6 +234,7 @@ protected function _attributeAutoIncrement(array &$attributes, array &$field) * * @throws DatabaseException */ + #[Override] public function dropForeignKey(string $table, string $foreignName): bool { // If this version of SQLite doesn't support it, we're done here @@ -245,6 +254,7 @@ public function dropForeignKey(string $table, string $foreignName): bool /** * Drop Primary Key */ + #[Override] public function dropPrimaryKey(string $table, string $keyName = ''): bool { $sqlTable = new Table($this->db, $this); @@ -254,6 +264,7 @@ public function dropPrimaryKey(string $table, string $keyName = ''): bool ->run(); } + #[Override] public function addForeignKey($fieldName = '', string $tableName = '', $tableField = '', string $onUpdate = '', string $onDelete = '', string $fkName = ''): BaseForge { if ($fkName === '') { @@ -268,6 +279,7 @@ public function addForeignKey($fieldName = '', string $tableName = '', $tableFie * * @param bool $asQuery When true recreates table with key, else partial SQL used with CREATE TABLE */ + #[Override] protected function _processPrimaryKeys(string $table, bool $asQuery = false): string { if ($asQuery === false) { @@ -288,6 +300,7 @@ protected function _processPrimaryKeys(string $table, bool $asQuery = false): st * * @param bool $asQuery When true recreates table with key, else partial SQL used with CREATE TABLE */ + #[Override] protected function _processForeignKeys(string $table, bool $asQuery = false): array { if ($asQuery === false) { diff --git a/system/Database/SQLite3/PreparedQuery.php b/system/Database/SQLite3/PreparedQuery.php index d33d4c0e8be3..979459b74a5e 100644 --- a/system/Database/SQLite3/PreparedQuery.php +++ b/system/Database/SQLite3/PreparedQuery.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BasePreparedQuery; use CodeIgniter\Exceptions\BadMethodCallException; use Exception; +use Override; use SQLite3; use SQLite3Result; use SQLite3Stmt; @@ -34,6 +35,7 @@ class PreparedQuery extends BasePreparedQuery */ protected $result; + #[Override] public function _prepare(string $sql, array $options = []): PreparedQuery { if (! ($this->statement = $this->db->connID->prepare($sql))) { @@ -48,6 +50,7 @@ public function _prepare(string $sql, array $options = []): PreparedQuery return $this; } + #[Override] public function _execute(array $data): bool { if (! isset($this->statement)) { @@ -100,11 +103,13 @@ public function _execute(array $data): bool /** * @return false|SQLite3Result */ + #[Override] public function _getResult() { return $this->result; } + #[Override] protected function _close(): bool { return $this->statement->close(); diff --git a/system/Database/SQLite3/Result.php b/system/Database/SQLite3/Result.php index a3c8556fccfe..063354f269db 100644 --- a/system/Database/SQLite3/Result.php +++ b/system/Database/SQLite3/Result.php @@ -17,6 +17,7 @@ use CodeIgniter\Database\BaseResult; use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Entity\Entity; +use Override; use SQLite3; use SQLite3Result; use stdClass; @@ -28,11 +29,13 @@ */ class Result extends BaseResult { + #[Override] public function getFieldCount(): int { return $this->resultID->numColumns(); } + #[Override] public function getFieldNames(): array { $fieldNames = []; @@ -44,6 +47,7 @@ public function getFieldNames(): array return $fieldNames; } + #[Override] public function getFieldData(): array { static $dataTypes = [ @@ -71,6 +75,7 @@ public function getFieldData(): array return $retVal; } + #[Override] public function freeResult() { if (is_object($this->resultID)) { @@ -82,6 +87,7 @@ public function freeResult() /** * @throws DatabaseException */ + #[Override] public function dataSeek(int $n = 0) { if ($n !== 0) { @@ -94,11 +100,13 @@ public function dataSeek(int $n = 0) /** * @return array|false */ + #[Override] protected function fetchAssoc() { return $this->resultID->fetchArray(SQLITE3_ASSOC); } + #[Override] protected function fetchObject(string $className = stdClass::class) { // No native support for fetching rows as objects diff --git a/system/Database/SQLite3/Utils.php b/system/Database/SQLite3/Utils.php index c2102e6accab..1d3a9c99d964 100644 --- a/system/Database/SQLite3/Utils.php +++ b/system/Database/SQLite3/Utils.php @@ -15,6 +15,7 @@ use CodeIgniter\Database\BaseUtils; use CodeIgniter\Database\Exceptions\DatabaseException; +use Override; /** * Utils for SQLite3 @@ -31,6 +32,7 @@ class Utils extends BaseUtils /** * @return never */ + #[Override] public function _backup(?array $prefs = null) { throw new DatabaseException('Unsupported feature of the database platform you are using.'); diff --git a/system/Debug/ExceptionHandler.php b/system/Debug/ExceptionHandler.php index 55e996484cca..6e4491209ac0 100644 --- a/system/Debug/ExceptionHandler.php +++ b/system/Debug/ExceptionHandler.php @@ -24,6 +24,7 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Config\Paths; +use Override; use Throwable; final class ExceptionHandler extends BaseExceptionHandler implements ExceptionHandlerInterface @@ -45,6 +46,7 @@ final class ExceptionHandler extends BaseExceptionHandler implements ExceptionHa * * @param CLIRequest|IncomingRequest $request */ + #[Override] public function handle( Throwable $exception, RequestInterface $request, diff --git a/system/Debug/Toolbar/Collectors/Database.php b/system/Debug/Toolbar/Collectors/Database.php index 9f7af83957e0..62c9b77e51cf 100644 --- a/system/Debug/Toolbar/Collectors/Database.php +++ b/system/Debug/Toolbar/Collectors/Database.php @@ -17,6 +17,7 @@ use CodeIgniter\Database\Query; use CodeIgniter\I18n\Time; use Config\Toolbar; +use Override; /** * Collector for the Database tab of the Debug Toolbar. @@ -120,6 +121,7 @@ public static function collect(Query $query) * query?: string, * }> */ + #[Override] protected function formatTimelineData(): array { $data = []; @@ -160,6 +162,7 @@ protected function formatTimelineData(): array * qid: string * }>} */ + #[Override] public function display(): array { return ['queries' => array_map(static function (array $query): array { @@ -215,6 +218,7 @@ public function display(): array /** * Gets the "badge" value for the button. */ + #[Override] public function getBadgeValue(): int { return count(static::$queries); @@ -225,6 +229,7 @@ public function getBadgeValue(): int * * @return string The number of queries (in parentheses) or an empty string. */ + #[Override] public function getTitleDetails(): string { $this->getConnections(); @@ -247,6 +252,7 @@ public function getTitleDetails(): string /** * Does this collector have any data collected? */ + #[Override] public function isEmpty(): bool { return static::$queries === []; @@ -257,6 +263,7 @@ public function isEmpty(): bool * * Icon from https://icons8.com - 1em package */ + #[Override] public function icon(): string { return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADMSURBVEhLY6A3YExLSwsA4nIycQDIDIhRWEBqamo/UNF/SjDQjF6ocZgAKPkRiFeEhoYyQ4WIBiA9QAuWAPEHqBAmgLqgHcolGQD1V4DMgHIxwbCxYD+QBqcKINseKo6eWrBioPrtQBq/BcgY5ht0cUIYbBg2AJKkRxCNWkDQgtFUNJwtABr+F6igE8olGQD114HMgHIxAVDyAhA/AlpSA8RYUwoeXAPVex5qHCbIyMgwBCkAuQJIY00huDBUz/mUlBQDqHGjgBjAwAAACexpph6oHSQAAAAASUVORK5CYII='; diff --git a/system/Debug/Toolbar/Collectors/Events.php b/system/Debug/Toolbar/Collectors/Events.php index 46d20083c0bd..b19e135a3a38 100644 --- a/system/Debug/Toolbar/Collectors/Events.php +++ b/system/Debug/Toolbar/Collectors/Events.php @@ -13,6 +13,8 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; +use Override; + /** * Events collector */ @@ -56,6 +58,7 @@ class Events extends BaseCollector * * @return list */ + #[Override] protected function formatTimelineData(): array { $data = []; @@ -79,6 +82,7 @@ protected function formatTimelineData(): array * * @return array{events: array} */ + #[Override] public function display(): array { $data = [ @@ -112,6 +116,7 @@ public function display(): array /** * Gets the "badge" value for the button. */ + #[Override] public function getBadgeValue(): int { return count(\CodeIgniter\Events\Events::getPerformanceLogs()); @@ -122,6 +127,7 @@ public function getBadgeValue(): int * * Icon from https://icons8.com - 1em package */ + #[Override] public function icon(): string { return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEASURBVEhL7ZXNDcIwDIVTsRBH1uDQDdquUA6IM1xgCA6MwJUN2hk6AQzAz0vl0ETUxC5VT3zSU5w81/mRMGZysixbFEVR0jSKNt8geQU9aRpFmp/keX6AbjZ5oB74vsaN5lSzA4tLSjpBFxsjeSuRy4d2mDdQTWU7YLbXTNN05mKyovj5KL6B7q3hoy3KwdZxBlT+Ipz+jPHrBqOIynZgcZonoukb/0ckiTHqNvDXtXEAaygRbaB9FvUTjRUHsIYS0QaSp+Dw6wT4hiTmYHOcYZsdLQ2CbXa4ftuuYR4x9vYZgdb4vsFYUdmABMYeukK9/SUme3KMFQ77+Yfzh8eYF8+orDuDWU5LAAAAAElFTkSuQmCC'; diff --git a/system/Debug/Toolbar/Collectors/Files.php b/system/Debug/Toolbar/Collectors/Files.php index 35e345c04fc4..5205bd9a9694 100644 --- a/system/Debug/Toolbar/Collectors/Files.php +++ b/system/Debug/Toolbar/Collectors/Files.php @@ -13,6 +13,8 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; +use Override; + /** * Files collector */ @@ -45,6 +47,7 @@ class Files extends BaseCollector /** * Returns any information that should be shown next to the title. */ + #[Override] public function getTitleDetails(): string { return '( ' . count(get_included_files()) . ' )'; @@ -55,6 +58,7 @@ public function getTitleDetails(): string * * @return array{coreFiles: list, userFiles: list} */ + #[Override] public function display(): array { $rawFiles = get_included_files(); @@ -89,6 +93,7 @@ public function display(): array /** * Displays the number of included files as a badge in the tab button. */ + #[Override] public function getBadgeValue(): int { return count(get_included_files()); @@ -99,6 +104,7 @@ public function getBadgeValue(): int * * Icon from https://icons8.com - 1em package */ + #[Override] public function icon(): string { return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGBSURBVEhL7ZQ9S8NQGIVTBQUncfMfCO4uLgoKbuKQOWg+OkXERRE1IAXrIHbVDrqIDuLiJgj+gro7S3dnpfq88b1FMTE3VZx64HBzzvvZWxKnj15QCcPwCD5HUfSWR+JtzgmtsUcQBEva5IIm9SwSu+95CAWbUuy67qBa32ByZEDpIaZYZSZMjjQuPcQUq8yEyYEb8FSerYeQVGbAFzJkX1PyQWLhgCz0BxTCekC1Wp0hsa6yokzhed4oje6Iz6rlJEkyIKfUEFtITVtQdAibn5rMyaYsMS+a5wTv8qeXMhcU16QZbKgl3hbs+L4/pnpdc87MElZgq10p5DxGdq8I7xrvUWUKvG3NbSK7ubngYzdJwSsF7TiOh9VOgfcEz1UayNe3JUPM1RWC5GXYgTfc75B4NBmXJnAtTfpABX0iPvEd9ezALwkplCFXcr9styiNOKc1RRZpaPM9tcqBwlWzGY1qPL9wjqRBgF5BH6j8HWh2S7MHlX8PrmbK+k/8PzjOOzx1D3i1pKTTAAAAAElFTkSuQmCC'; diff --git a/system/Debug/Toolbar/Collectors/History.php b/system/Debug/Toolbar/Collectors/History.php index d306810f202c..2bb9aa07d485 100644 --- a/system/Debug/Toolbar/Collectors/History.php +++ b/system/Debug/Toolbar/Collectors/History.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; use DateTime; +use Override; /** * History collector @@ -130,6 +131,7 @@ public function setFiles(string $current, int $limit = 20) * contentType: mixed * }>} */ + #[Override] public function display(): array { return ['files' => $this->files]; @@ -138,6 +140,7 @@ public function display(): array /** * Displays the number of included files as a badge in the tab button. */ + #[Override] public function getBadgeValue(): int { return count($this->files); @@ -146,6 +149,7 @@ public function getBadgeValue(): int /** * Return true if there are no history files. */ + #[Override] public function isEmpty(): bool { return $this->files === []; @@ -156,6 +160,7 @@ public function isEmpty(): bool * * Icon from https://icons8.com - 1em package */ + #[Override] public function icon(): string { return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJySURBVEhL3ZU7aJNhGIVTpV6i4qCIgkIHxcXLErS4FBwUFNwiCKGhuTYJGaIgnRoo4qRu6iCiiIuIXXTTIkIpuqoFwaGgonUQlC5KafU5ycmNP0lTdPLA4fu+8573/a4/f6hXpFKpwUwmc9fDfweKbk+n07fgEv33TLSbtt/hvwNFT1PsG/zdTE0Gp+GFfD6/2fbVIxqNrqPIRbjg4t/hY8aztcngfDabHXbKyiiXy2vcrcPH8oDCry2FKDrA+Ar6L01E/ypyXzXaARjDGGcoeNxSDZXE0dHRA5VRE5LJ5CFy5jzJuOX2wHRHRnjbklZ6isQ3tIctBaAd4vlK3jLtkOVWqABBXd47jGHLmjTmSScttQV5J+SjfcUweFQEbsjAas5aqoCLXutJl7vtQsAzpRowYqkBinyCC8Vicb2lOih8zoldd0F8RD7qTFiqAnGrAy8stUAvi/hbqDM+YzkAFrLPdR5ZqoLXsd+Bh5YCIH7JniVdquUWxOPxDfboHhrI5XJ7HHhiqQXox+APe/Qk64+gGYVCYZs8cMpSFQj9JOoFzVqqo7k4HIvFYpscCoAjOmLffUsNUGRaQUwDlmofUa34ecsdgXdcXo4wbakBgiUFafXJV8A4DJ/2UrxUKm3E95H8RbjLcgOJRGILhnmCP+FBy5XvwN2uIPcy1AJvWgqC4xm2aU4Xb3lF4I+Tpyf8hRe5w3J7YLymSeA8Z3nSclv4WLRyFdfOjzrUFX0klJUEtZtntCNc+F69cz/FiDzEPtjzmcUMOr83kDQEX6pAJxJfpL3OX22n01YN7SZCoQnaSdoZ+Jz+PZihH3wt/xlCoT9M6nEtmRSPCQAAAABJRU5ErkJggg=='; diff --git a/system/Debug/Toolbar/Collectors/Logs.php b/system/Debug/Toolbar/Collectors/Logs.php index 92562e81e629..9460bfeaed4e 100644 --- a/system/Debug/Toolbar/Collectors/Logs.php +++ b/system/Debug/Toolbar/Collectors/Logs.php @@ -13,6 +13,8 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; +use Override; + /** * Loags collector */ @@ -54,6 +56,7 @@ class Logs extends BaseCollector * * @return array{logs: list} */ + #[Override] public function display(): array { return [ @@ -64,6 +67,7 @@ public function display(): array /** * Does this collector actually have any data to display? */ + #[Override] public function isEmpty(): bool { $this->collectLogs(); @@ -76,6 +80,7 @@ public function isEmpty(): bool * * Icon from https://icons8.com - 1em package */ + #[Override] public function icon(): string { return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACYSURBVEhLYxgFJIHU1FSjtLS0i0D8AYj7gEKMEBkqAaAFF4D4ERCvAFrwH4gDoFIMKSkpFkB+OTEYqgUTACXfA/GqjIwMQyD9H2hRHlQKJFcBEiMGQ7VgAqCBvUgK32dmZspCpagGGNPT0/1BLqeF4bQHQJePpiIwhmrBBEADR1MRfgB0+WgqAmOoFkwANHA0FY0CUgEDAwCQ0PUpNB3kqwAAAABJRU5ErkJggg=='; diff --git a/system/Debug/Toolbar/Collectors/Routes.php b/system/Debug/Toolbar/Collectors/Routes.php index f8005065c57e..ddf98cce679f 100644 --- a/system/Debug/Toolbar/Collectors/Routes.php +++ b/system/Debug/Toolbar/Collectors/Routes.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; use CodeIgniter\Router\DefinedRouteCollector; +use Override; use ReflectionException; use ReflectionFunction; use ReflectionMethod; @@ -71,6 +72,7 @@ class Routes extends BaseCollector * * @throws ReflectionException */ + #[Override] public function display(): array { $rawRoutes = service('routes', true); @@ -150,6 +152,7 @@ public function display(): array /** * Returns a count of all the routes in the system. */ + #[Override] public function getBadgeValue(): int { $rawRoutes = service('routes', true); @@ -162,6 +165,7 @@ public function getBadgeValue(): int * * Icon from https://icons8.com - 1em package */ + #[Override] public function icon(): string { return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAFDSURBVEhL7ZRNSsNQFIUjVXSiOFEcuQIHDpzpxC0IGYeE/BEInbWlCHEDLsSiuANdhKDjgm6ggtSJ+l25ldrmmTwIgtgDh/t37r1J+16cX0dRFMtpmu5pWAkrvYjjOB7AETzStBFW+inxu3KUJMmhludQpoflS1zXban4LYqiO224h6VLTHr8Z+z8EpIHFF9gG78nDVmW7UgTHKjsCyY98QP+pcq+g8Ku2s8G8X3f3/I8b038WZTp+bO38zxfFd+I6YY6sNUvFlSDk9CRhiAI1jX1I9Cfw7GG1UB8LAuwbU0ZwQnbRDeEN5qqBxZMLtE1ti9LtbREnMIuOXnyIf5rGIb7Wq8HmlZgwYBH7ORTcKH5E4mpjeGt9fBZcHE2GCQ3Vt7oTNPNg+FXLHnSsHkw/FR+Gg2bB8Ptzrst/v6C/wrH+QB+duli6MYJdQAAAABJRU5ErkJggg=='; diff --git a/system/Debug/Toolbar/Collectors/Timers.php b/system/Debug/Toolbar/Collectors/Timers.php index 9e86af2c8d9d..f341b49dfd62 100644 --- a/system/Debug/Toolbar/Collectors/Timers.php +++ b/system/Debug/Toolbar/Collectors/Timers.php @@ -13,6 +13,8 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; +use Override; + /** * Timers collector */ @@ -48,6 +50,7 @@ class Timers extends BaseCollector * * @return list */ + #[Override] protected function formatTimelineData(): array { $data = []; diff --git a/system/Debug/Toolbar/Collectors/Views.php b/system/Debug/Toolbar/Collectors/Views.php index bae742a588a2..2565721a4be7 100644 --- a/system/Debug/Toolbar/Collectors/Views.php +++ b/system/Debug/Toolbar/Collectors/Views.php @@ -15,6 +15,7 @@ use CodeIgniter\View\RendererInterface; use CodeIgniter\View\View; +use Override; /** * Views collector @@ -91,6 +92,7 @@ private function initViewer(): void * * @return list */ + #[Override] protected function formatTimelineData(): array { $this->initViewer(); @@ -129,6 +131,7 @@ protected function formatTimelineData(): array * * @return array> */ + #[Override] public function getVarData(): array { $this->initViewer(); @@ -141,6 +144,7 @@ public function getVarData(): array /** * Returns a count of all views. */ + #[Override] public function getBadgeValue(): int { $this->initViewer(); @@ -153,6 +157,7 @@ public function getBadgeValue(): int * * Icon from https://icons8.com - 1em package */ + #[Override] public function icon(): string { return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADeSURBVEhL7ZSxDcIwEEWNYA0YgGmgyAaJLTcUaaBzQQEVjMEabBQxAdw53zTHiThEovGTfnE/9rsoRUxhKLOmaa6Uh7X2+UvguLCzVxN1XW9x4EYHzik033Hp3X0LO+DaQG8MDQcuq6qao4qkHuMgQggLvkPLjqh00ZgFDBacMJYFkuwFlH1mshdkZ5JPJERA9JpI6xNCBESvibQ+IURA9JpI6xNCBESvibQ+IURA9DTsuHTOrVFFxixgB/eUFlU8uKJ0eDBFOu/9EvoeKnlJS2/08Tc8NOwQ8sIfMeYFjqKDjdU2sp4AAAAASUVORK5CYII='; diff --git a/system/Encryption/Handlers/OpenSSLHandler.php b/system/Encryption/Handlers/OpenSSLHandler.php index fbed105a9617..8a80332021c7 100644 --- a/system/Encryption/Handlers/OpenSSLHandler.php +++ b/system/Encryption/Handlers/OpenSSLHandler.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Encryption\Handlers; use CodeIgniter\Encryption\Exceptions\EncryptionException; +use Override; use SensitiveParameter; /** @@ -81,6 +82,7 @@ class OpenSSLHandler extends BaseHandler /** * {@inheritDoc} */ + #[Override] public function encrypt(#[SensitiveParameter] $data, #[SensitiveParameter] $params = null) { // Allow key override @@ -117,6 +119,7 @@ public function encrypt(#[SensitiveParameter] $data, #[SensitiveParameter] $para /** * {@inheritDoc} */ + #[Override] public function decrypt($data, #[SensitiveParameter] $params = null) { // Allow key override diff --git a/system/Encryption/Handlers/SodiumHandler.php b/system/Encryption/Handlers/SodiumHandler.php index b518a322c152..2f660f21d7b4 100644 --- a/system/Encryption/Handlers/SodiumHandler.php +++ b/system/Encryption/Handlers/SodiumHandler.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Encryption\Handlers; use CodeIgniter\Encryption\Exceptions\EncryptionException; +use Override; use SensitiveParameter; use SodiumException; @@ -44,6 +45,7 @@ class SodiumHandler extends BaseHandler /** * {@inheritDoc} */ + #[Override] public function encrypt(#[SensitiveParameter] $data, #[SensitiveParameter] $params = null) { $key = $this->key; @@ -80,6 +82,7 @@ public function encrypt(#[SensitiveParameter] $data, #[SensitiveParameter] $para /** * {@inheritDoc} */ + #[Override] public function decrypt($data, #[SensitiveParameter] $params = null) { $key = $this->key; diff --git a/system/Encryption/KeyRotationDecorator.php b/system/Encryption/KeyRotationDecorator.php index 46846dead1bb..3dc689b7e227 100644 --- a/system/Encryption/KeyRotationDecorator.php +++ b/system/Encryption/KeyRotationDecorator.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Encryption; use CodeIgniter\Encryption\Exceptions\EncryptionException; +use Override; use SensitiveParameter; /** @@ -43,6 +44,7 @@ public function __construct( * * Encryption always uses the inner handler's current key. */ + #[Override] public function encrypt(#[SensitiveParameter] $data, #[SensitiveParameter] $params = null) { return $this->innerHandler->encrypt($data, $params); @@ -56,6 +58,7 @@ public function encrypt(#[SensitiveParameter] $data, #[SensitiveParameter] $para * * @throws EncryptionException */ + #[Override] public function decrypt($data, #[SensitiveParameter] $params = null) { try { diff --git a/system/Entity/Cast/ArrayCast.php b/system/Entity/Cast/ArrayCast.php index dc1d5d7e20d2..37e0d2a4b606 100644 --- a/system/Entity/Cast/ArrayCast.php +++ b/system/Entity/Cast/ArrayCast.php @@ -13,11 +13,14 @@ namespace CodeIgniter\Entity\Cast; +use Override; + /** * @extends BaseCast, string> */ class ArrayCast extends BaseCast { + #[Override] public static function get($value, array $params = []): array { if (is_string($value) && (str_starts_with($value, 'a:') || str_starts_with($value, 's:'))) { @@ -27,6 +30,7 @@ public static function get($value, array $params = []): array return (array) $value; } + #[Override] public static function set($value, array $params = []): string { return serialize($value); diff --git a/system/Entity/Cast/BaseCast.php b/system/Entity/Cast/BaseCast.php index 68bd544a071f..9d24ec6e2edf 100644 --- a/system/Entity/Cast/BaseCast.php +++ b/system/Entity/Cast/BaseCast.php @@ -13,6 +13,8 @@ namespace CodeIgniter\Entity\Cast; +use Override; + /** * @template TPhpNativeValue * @template TEntityStoredValue @@ -21,11 +23,13 @@ */ abstract class BaseCast implements CastInterface { + #[Override] public static function get($value, array $params = []) { return $value; } + #[Override] public static function set($value, array $params = []) { return $value; diff --git a/system/Entity/Cast/BooleanCast.php b/system/Entity/Cast/BooleanCast.php index a8bdb8ac1e7d..8e9363d6952e 100644 --- a/system/Entity/Cast/BooleanCast.php +++ b/system/Entity/Cast/BooleanCast.php @@ -13,11 +13,14 @@ namespace CodeIgniter\Entity\Cast; +use Override; + /** * @extends BaseCast */ class BooleanCast extends BaseCast { + #[Override] public static function get($value, array $params = []): bool { return (bool) $value; diff --git a/system/Entity/Cast/CSVCast.php b/system/Entity/Cast/CSVCast.php index 6c4a65f816ab..a1fe0825ee65 100644 --- a/system/Entity/Cast/CSVCast.php +++ b/system/Entity/Cast/CSVCast.php @@ -13,16 +13,20 @@ namespace CodeIgniter\Entity\Cast; +use Override; + /** * @extends BaseCast, string> */ class CSVCast extends BaseCast { + #[Override] public static function get($value, array $params = []): array { return explode(',', $value); } + #[Override] public static function set($value, array $params = []): string { return implode(',', $value); diff --git a/system/Entity/Cast/DatetimeCast.php b/system/Entity/Cast/DatetimeCast.php index 332de01a99cf..efc3aca06bad 100644 --- a/system/Entity/Cast/DatetimeCast.php +++ b/system/Entity/Cast/DatetimeCast.php @@ -15,12 +15,14 @@ use CodeIgniter\I18n\Time; use DateTimeInterface; +use Override; /** * @extends BaseCast */ class DatetimeCast extends BaseCast { + #[Override] public static function get($value, array $params = []) { if ($value instanceof Time) { diff --git a/system/Entity/Cast/EnumCast.php b/system/Entity/Cast/EnumCast.php index caf6b1289294..994f74c5ba33 100644 --- a/system/Entity/Cast/EnumCast.php +++ b/system/Entity/Cast/EnumCast.php @@ -15,6 +15,7 @@ use BackedEnum; use CodeIgniter\Entity\Exceptions\CastException; +use Override; use ReflectionEnum; use UnitEnum; @@ -23,6 +24,7 @@ */ class EnumCast extends BaseCast { + #[Override] public static function get($value, array $params = []): BackedEnum|UnitEnum { $enumClass = $params[0] ?? null; @@ -67,6 +69,7 @@ public static function get($value, array $params = []): BackedEnum|UnitEnum /** * @param mixed $value */ + #[Override] public static function set($value, array $params = []): int|string { $enumClass = $params[0] ?? null; diff --git a/system/Entity/Cast/FloatCast.php b/system/Entity/Cast/FloatCast.php index 78d08292c101..3877c77738c5 100644 --- a/system/Entity/Cast/FloatCast.php +++ b/system/Entity/Cast/FloatCast.php @@ -14,12 +14,14 @@ namespace CodeIgniter\Entity\Cast; use CodeIgniter\Entity\Exceptions\CastException; +use Override; /** * @extends BaseCast */ class FloatCast extends BaseCast { + #[Override] public static function get($value, array $params = []): float { $precision = isset($params[0]) ? (int) $params[0] : null; diff --git a/system/Entity/Cast/IntBoolCast.php b/system/Entity/Cast/IntBoolCast.php index 21e03c04a98a..d9e0dd1a674a 100644 --- a/system/Entity/Cast/IntBoolCast.php +++ b/system/Entity/Cast/IntBoolCast.php @@ -13,6 +13,8 @@ namespace CodeIgniter\Entity\Cast; +use Override; + /** * DB column: int (0/1) <--> Class property: bool * @@ -20,11 +22,13 @@ */ final class IntBoolCast extends BaseCast { + #[Override] public static function get($value, array $params = []): bool { return (bool) $value; } + #[Override] public static function set($value, array $params = []): int { return (int) $value; diff --git a/system/Entity/Cast/IntegerCast.php b/system/Entity/Cast/IntegerCast.php index dad299ef74c1..d1b42a89cbf0 100644 --- a/system/Entity/Cast/IntegerCast.php +++ b/system/Entity/Cast/IntegerCast.php @@ -13,11 +13,14 @@ namespace CodeIgniter\Entity\Cast; +use Override; + /** * @extends BaseCast */ class IntegerCast extends BaseCast { + #[Override] public static function get($value, array $params = []): int { return (int) $value; diff --git a/system/Entity/Cast/JsonCast.php b/system/Entity/Cast/JsonCast.php index c94e4d6f34a8..456428544d24 100644 --- a/system/Entity/Cast/JsonCast.php +++ b/system/Entity/Cast/JsonCast.php @@ -15,6 +15,7 @@ use CodeIgniter\Entity\Exceptions\CastException; use JsonException; +use Override; use stdClass; /** @@ -22,6 +23,7 @@ */ class JsonCast extends BaseCast { + #[Override] public static function get($value, array $params = []) { $associative = in_array('array', $params, true); @@ -46,6 +48,7 @@ public static function get($value, array $params = []) return $tmp; } + #[Override] public static function set($value, array $params = []): string { if (function_exists('json_encode')) { diff --git a/system/Entity/Cast/ObjectCast.php b/system/Entity/Cast/ObjectCast.php index c2c1499a3af0..300da44c2b07 100644 --- a/system/Entity/Cast/ObjectCast.php +++ b/system/Entity/Cast/ObjectCast.php @@ -13,11 +13,14 @@ namespace CodeIgniter\Entity\Cast; +use Override; + /** * @extends BaseCast */ class ObjectCast extends BaseCast { + #[Override] public static function get($value, array $params = []): object { return (object) $value; diff --git a/system/Entity/Cast/StringCast.php b/system/Entity/Cast/StringCast.php index 7c01c2c4a617..1ec2a39cec51 100644 --- a/system/Entity/Cast/StringCast.php +++ b/system/Entity/Cast/StringCast.php @@ -13,11 +13,14 @@ namespace CodeIgniter\Entity\Cast; +use Override; + /** * @extends BaseCast */ class StringCast extends BaseCast { + #[Override] public static function get($value, array $params = []): string { return (string) $value; diff --git a/system/Entity/Cast/TimestampCast.php b/system/Entity/Cast/TimestampCast.php index b48211f221df..2d62bcfa7de8 100644 --- a/system/Entity/Cast/TimestampCast.php +++ b/system/Entity/Cast/TimestampCast.php @@ -14,12 +14,14 @@ namespace CodeIgniter\Entity\Cast; use CodeIgniter\Entity\Exceptions\CastException; +use Override; /** * @extends BaseCast */ class TimestampCast extends BaseCast { + #[Override] public static function get($value, array $params = []) { $value = strtotime($value); diff --git a/system/Entity/Cast/URICast.php b/system/Entity/Cast/URICast.php index ef4346d1a5eb..326b863d8a89 100644 --- a/system/Entity/Cast/URICast.php +++ b/system/Entity/Cast/URICast.php @@ -14,12 +14,14 @@ namespace CodeIgniter\Entity\Cast; use CodeIgniter\HTTP\URI; +use Override; /** * @extends BaseCast */ class URICast extends BaseCast { + #[Override] public static function get($value, array $params = []): URI { return $value instanceof URI ? $value : new URI($value); diff --git a/system/Entity/Entity.php b/system/Entity/Entity.php index a396c28aab8d..243b5b74eb93 100644 --- a/system/Entity/Entity.php +++ b/system/Entity/Entity.php @@ -33,6 +33,7 @@ use DateTimeInterface; use Exception; use JsonSerializable; +use Override; use Traversable; use UnitEnum; @@ -608,6 +609,7 @@ protected function dataCaster(): ?DataCaster * * @return array */ + #[Override] public function jsonSerialize(): array { return $this->toArray(); diff --git a/system/Entity/Exceptions/CastException.php b/system/Entity/Exceptions/CastException.php index db82ca40bb3f..927329f5ae60 100644 --- a/system/Entity/Exceptions/CastException.php +++ b/system/Entity/Exceptions/CastException.php @@ -15,12 +15,14 @@ use CodeIgniter\Exceptions\FrameworkException; use CodeIgniter\Exceptions\HasExitCodeInterface; +use Override; /** * CastException is thrown for invalid cast initialization and management. */ class CastException extends FrameworkException implements HasExitCodeInterface { + #[Override] public function getExitCode(): int { return EXIT_CONFIG; diff --git a/system/Exceptions/ConfigException.php b/system/Exceptions/ConfigException.php index b30818124901..24b5d02682e5 100644 --- a/system/Exceptions/ConfigException.php +++ b/system/Exceptions/ConfigException.php @@ -13,6 +13,8 @@ namespace CodeIgniter\Exceptions; +use Override; + /** * Exception thrown if the value of the Config class is invalid or the type is * incorrect. @@ -21,6 +23,7 @@ class ConfigException extends RuntimeException implements HasExitCodeInterface { use DebugTraceableTrait; + #[Override] public function getExitCode(): int { return EXIT_CONFIG; diff --git a/system/Files/File.php b/system/Files/File.php index dda73875a997..960e8be7b2b6 100644 --- a/system/Files/File.php +++ b/system/Files/File.php @@ -17,6 +17,7 @@ use CodeIgniter\Files\Exceptions\FileNotFoundException; use CodeIgniter\I18n\Time; use Config\Mimes; +use Override; use RuntimeException; use SplFileInfo; @@ -61,6 +62,7 @@ public function __construct(string $path, bool $checkFile = false) * * @throws RuntimeException if the file does not exist or an error occurs */ + #[Override] public function getSize(): false|int { return $this->size ??= parent::getSize(); diff --git a/system/Files/FileCollection.php b/system/Files/FileCollection.php index ea6632d9be1f..81e214e792b9 100644 --- a/system/Files/FileCollection.php +++ b/system/Files/FileCollection.php @@ -18,6 +18,7 @@ use CodeIgniter\Files\Exceptions\FileNotFoundException; use Countable; use IteratorAggregate; +use Override; use Traversable; /** @@ -385,6 +386,7 @@ public function retainMultiplePatterns(array $patterns, ?string $scope = null) * Returns the current number of files in the collection. * Fulfills Countable. */ + #[Override] public function count(): int { return count($this->files); @@ -397,6 +399,7 @@ public function count(): int * * @throws FileNotFoundException */ + #[Override] public function getIterator(): Traversable { foreach ($this->get() as $file) { diff --git a/system/Filters/CSRF.php b/system/Filters/CSRF.php index eb9017c3dac3..d29fc7d33046 100644 --- a/system/Filters/CSRF.php +++ b/system/Filters/CSRF.php @@ -20,6 +20,7 @@ use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\Security\Exceptions\SecurityException; use CodeIgniter\Security\Security; +use Override; /** * CSRF filter. @@ -39,6 +40,7 @@ class CSRF implements FilterInterface * * @throws SecurityException */ + #[Override] public function before(RequestInterface $request, $arguments = null) { if (! $request instanceof IncomingRequest) { @@ -73,6 +75,7 @@ public function before(RequestInterface $request, $arguments = null) * * @param list|null $arguments */ + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { return null; diff --git a/system/Filters/Cors.php b/system/Filters/Cors.php index 34e40c482daa..a822b0959936 100644 --- a/system/Filters/Cors.php +++ b/system/Filters/Cors.php @@ -17,6 +17,7 @@ use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; class Cors implements FilterInterface { @@ -47,6 +48,7 @@ public function __construct(array $config = []) * * @return ResponseInterface|null */ + #[Override] public function before(RequestInterface $request, $arguments = null) { if (! $request instanceof IncomingRequest) { @@ -95,6 +97,7 @@ private function createCorsService(?array $arguments): void /** * @param list|null $arguments */ + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { if (! $request instanceof IncomingRequest) { diff --git a/system/Filters/DebugToolbar.php b/system/Filters/DebugToolbar.php index 5f5ba05ab14e..6edea872c75e 100644 --- a/system/Filters/DebugToolbar.php +++ b/system/Filters/DebugToolbar.php @@ -15,6 +15,7 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; /** * Debug toolbar filter @@ -26,6 +27,7 @@ class DebugToolbar implements FilterInterface * * @param list|null $arguments */ + #[Override] public function before(RequestInterface $request, $arguments = null) { return null; @@ -37,6 +39,7 @@ public function before(RequestInterface $request, $arguments = null) * * @param list|null $arguments */ + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { service('toolbar')->prepare($request, $response); diff --git a/system/Filters/ForceHTTPS.php b/system/Filters/ForceHTTPS.php index 6f59338d948f..d59d65cc71bd 100644 --- a/system/Filters/ForceHTTPS.php +++ b/system/Filters/ForceHTTPS.php @@ -17,6 +17,7 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Config\App; +use Override; /** * Force HTTPS filter @@ -34,6 +35,7 @@ class ForceHTTPS implements FilterInterface * * @return ResponseInterface|null */ + #[Override] public function before(RequestInterface $request, $arguments = null) { $config = config(App::class); @@ -58,6 +60,7 @@ public function before(RequestInterface $request, $arguments = null) * * @param list|null $arguments */ + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { return null; diff --git a/system/Filters/Honeypot.php b/system/Filters/Honeypot.php index fe6491d7f6ab..107887042a03 100644 --- a/system/Filters/Honeypot.php +++ b/system/Filters/Honeypot.php @@ -17,6 +17,7 @@ use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; /** * Honeypot filter @@ -31,6 +32,7 @@ class Honeypot implements FilterInterface * * @throws HoneypotException */ + #[Override] public function before(RequestInterface $request, $arguments = null) { if (! $request instanceof IncomingRequest) { @@ -49,6 +51,7 @@ public function before(RequestInterface $request, $arguments = null) * * @param list|null $arguments */ + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { service('honeypot')->attachHoneypot($response); diff --git a/system/Filters/InvalidChars.php b/system/Filters/InvalidChars.php index 6d8a3a2a5cee..caf82a36dae0 100644 --- a/system/Filters/InvalidChars.php +++ b/system/Filters/InvalidChars.php @@ -17,6 +17,7 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\Security\Exceptions\SecurityException; +use Override; /** * InvalidChars filter. @@ -47,6 +48,7 @@ class InvalidChars implements FilterInterface * * @param list|null $arguments */ + #[Override] public function before(RequestInterface $request, $arguments = null) { if (! $request instanceof IncomingRequest) { @@ -74,6 +76,7 @@ public function before(RequestInterface $request, $arguments = null) * * @param list|null $arguments */ + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { return null; diff --git a/system/Filters/PageCache.php b/system/Filters/PageCache.php index 785af8c054fb..4088c432ca5f 100644 --- a/system/Filters/PageCache.php +++ b/system/Filters/PageCache.php @@ -22,6 +22,7 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Config\Cache; +use Override; /** * Page Cache filter @@ -50,6 +51,7 @@ public function __construct(?Cache $config = null) * * @return ResponseInterface|null */ + #[Override] public function before(RequestInterface $request, $arguments = null) { assert($request instanceof CLIRequest || $request instanceof IncomingRequest); @@ -68,6 +70,7 @@ public function before(RequestInterface $request, $arguments = null) * * @param list|null $arguments */ + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { assert($request instanceof CLIRequest || $request instanceof IncomingRequest); diff --git a/system/Filters/PerformanceMetrics.php b/system/Filters/PerformanceMetrics.php index 259f7d46e298..57fcdb2661ac 100644 --- a/system/Filters/PerformanceMetrics.php +++ b/system/Filters/PerformanceMetrics.php @@ -15,6 +15,7 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; /** * Performance Metrics filter @@ -26,6 +27,7 @@ class PerformanceMetrics implements FilterInterface * * @param list|null $arguments */ + #[Override] public function before(RequestInterface $request, $arguments = null) { return null; @@ -36,6 +38,7 @@ public function before(RequestInterface $request, $arguments = null) * * @param list|null $arguments */ + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { $body = $response->getBody(); diff --git a/system/Filters/RequestId.php b/system/Filters/RequestId.php index f2db86376525..a3bcbfdecd8b 100644 --- a/system/Filters/RequestId.php +++ b/system/Filters/RequestId.php @@ -15,6 +15,7 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; class RequestId implements FilterInterface { @@ -24,6 +25,7 @@ class RequestId implements FilterInterface * * {@inheritDoc} */ + #[Override] public function before(RequestInterface $request, $arguments = null): ?ResponseInterface { $requestId = trim($request->getHeaderLine('X-Request-ID')); @@ -42,6 +44,7 @@ public function before(RequestInterface $request, $arguments = null): ?ResponseI /** * {@inheritDoc} */ + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null): ?ResponseInterface { if (context()->has('request_id')) { diff --git a/system/Filters/SecureHeaders.php b/system/Filters/SecureHeaders.php index 15a69313bb53..daf28a0b1b5d 100644 --- a/system/Filters/SecureHeaders.php +++ b/system/Filters/SecureHeaders.php @@ -15,6 +15,7 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; /** * Add Common Security Headers @@ -51,6 +52,7 @@ class SecureHeaders implements FilterInterface * * @param list|null $arguments */ + #[Override] public function before(RequestInterface $request, $arguments = null) { return null; @@ -61,6 +63,7 @@ public function before(RequestInterface $request, $arguments = null) * * @param list|null $arguments */ + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { foreach ($this->headers as $header => $value) { diff --git a/system/Format/JSONFormatter.php b/system/Format/JSONFormatter.php index 4689e5f73a84..2e36dfc4c006 100644 --- a/system/Format/JSONFormatter.php +++ b/system/Format/JSONFormatter.php @@ -15,6 +15,7 @@ use CodeIgniter\Format\Exceptions\FormatException; use Config\Format; +use Override; /** * JSON data formatter @@ -28,6 +29,7 @@ class JSONFormatter implements FormatterInterface * * @return false|non-empty-string */ + #[Override] public function format($data) { $config = new Format(); diff --git a/system/Format/XMLFormatter.php b/system/Format/XMLFormatter.php index 3a2e8a6f20a9..8744fe59aee7 100644 --- a/system/Format/XMLFormatter.php +++ b/system/Format/XMLFormatter.php @@ -15,6 +15,7 @@ use CodeIgniter\Format\Exceptions\FormatException; use Config\Format; +use Override; use SimpleXMLElement; use Stringable; @@ -30,6 +31,7 @@ class XMLFormatter implements FormatterInterface * * @return false|non-empty-string */ + #[Override] public function format($data) { $config = new Format(); diff --git a/system/HTTP/DownloadResponse.php b/system/HTTP/DownloadResponse.php index d03b9fe8a4ad..c719acd3d81c 100644 --- a/system/HTTP/DownloadResponse.php +++ b/system/HTTP/DownloadResponse.php @@ -16,6 +16,7 @@ use CodeIgniter\Exceptions\DownloadException; use CodeIgniter\Files\File; use Config\Mimes; +use Override; /** * HTTP response when a download is requested. @@ -201,6 +202,7 @@ private function getContentDisposition(bool $inline = false): string * * @throws DownloadException */ + #[Override] public function setStatusCode(int $code, string $reason = '') { throw DownloadException::forCannotSetStatusCode($code, $reason); @@ -212,6 +214,7 @@ public function setStatusCode(int $code, string $reason = '') * * @return $this */ + #[Override] public function setContentType(string $mime, string $charset = 'UTF-8') { parent::setContentType($mime, $charset); @@ -227,6 +230,7 @@ public function setContentType(string $mime, string $charset = 'UTF-8') * Sets the appropriate headers to ensure this response * is not cached by the browsers. */ + #[Override] public function noCache(): self { $this->removeHeader('Cache-Control'); @@ -242,6 +246,7 @@ public function noCache(): self * * @todo Do downloads need CSP or Cookies? Compare with ResponseTrait::send() */ + #[Override] public function send() { // Turn off output buffering completely, even if php.ini output_buffering is not off @@ -284,6 +289,7 @@ public function buildHeaders() * * @throws DownloadException */ + #[Override] public function sendBody() { if ($this->binary !== null) { diff --git a/system/HTTP/Exceptions/FormRequestException.php b/system/HTTP/Exceptions/FormRequestException.php index 5daae9a48d1d..5ebfe0666609 100644 --- a/system/HTTP/Exceptions/FormRequestException.php +++ b/system/HTTP/Exceptions/FormRequestException.php @@ -16,6 +16,7 @@ use CodeIgniter\Exceptions\RuntimeException; use CodeIgniter\HTTP\ResponsableInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; /** * @internal @@ -27,6 +28,7 @@ public function __construct(private readonly ResponseInterface $response) parent::__construct('FormRequest authorization or validation failed.'); } + #[Override] public function getResponse(): ResponseInterface { return $this->response; diff --git a/system/HTTP/Exceptions/HTTPException.php b/system/HTTP/Exceptions/HTTPException.php index 80f91b233ee9..5acf52986b00 100644 --- a/system/HTTP/Exceptions/HTTPException.php +++ b/system/HTTP/Exceptions/HTTPException.php @@ -14,6 +14,7 @@ namespace CodeIgniter\HTTP\Exceptions; use CodeIgniter\Exceptions\FrameworkException; +use Override; /** * Things that can go wrong with HTTP @@ -202,6 +203,7 @@ public static function forAlreadyMoved() * * @return static */ + #[Override] public static function forInvalidFile(?string $path = null) { return new static(lang('HTTP.invalidFile')); diff --git a/system/HTTP/Exceptions/RedirectException.php b/system/HTTP/Exceptions/RedirectException.php index 2f26013876b2..8648d199da95 100644 --- a/system/HTTP/Exceptions/RedirectException.php +++ b/system/HTTP/Exceptions/RedirectException.php @@ -19,6 +19,7 @@ use CodeIgniter\Exceptions\RuntimeException; use CodeIgniter\HTTP\ResponsableInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; use Throwable; /** @@ -68,6 +69,7 @@ public function __construct($message = '', int $code = self::DEFAULT_STATUS_CODE parent::__construct($message, $code, $previous); } + #[Override] public function getResponse(): ResponseInterface { if (! $this->response instanceof ResponseInterface) { diff --git a/system/HTTP/Files/UploadedFile.php b/system/HTTP/Files/UploadedFile.php index 03b0185cb350..50331867dfb0 100644 --- a/system/HTTP/Files/UploadedFile.php +++ b/system/HTTP/Files/UploadedFile.php @@ -17,6 +17,7 @@ use CodeIgniter\HTTP\Exceptions\HTTPException; use Config\Mimes; use Exception; +use Override; /** * Value object representing a single file uploaded through an @@ -80,6 +81,7 @@ class UploadedFile extends File implements UploadedFileInterface * @param int|null $error The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants) * @param string|null $clientPath The webkit relative path of the uploaded file. */ + #[Override] public function __construct(string $path, string $originalName, ?string $mimeType = null, ?int $size = null, ?int $error = null, ?string $clientPath = null) { $this->path = $path; @@ -126,6 +128,7 @@ public function __construct(string $path, string $originalName, ?string $mimeTyp * * @return static */ + #[Override] public function move(string $targetPath, ?string $name = null, bool $overwrite = false) { $targetPath = rtrim($targetPath, '/') . '/'; @@ -206,6 +209,7 @@ protected function setPath(string $path): string * the move() method will not work and certain properties, like * the tempName, will no longer be available. */ + #[Override] public function hasMoved(): bool { return $this->hasMoved; @@ -226,6 +230,7 @@ public function hasMoved(): bool * * @return int One of PHP's UPLOAD_ERR_XXX constants. */ + #[Override] public function getError(): int { return $this->error ?? UPLOAD_ERR_OK; @@ -259,6 +264,7 @@ public function getErrorString(): string * * @return string The media type sent by the client or null if none was provided. */ + #[Override] public function getClientMimeType(): string { return $this->originalMimeType; @@ -271,6 +277,7 @@ public function getClientMimeType(): string * * @return string The filename sent by the client or null if none was provided. */ + #[Override] public function getName(): string { return $this->name; @@ -288,6 +295,7 @@ public function getClientName(): string * (PHP 8.1+) * Returns the webkit relative path of the uploaded file on directory uploads. */ + #[Override] public function getClientPath(): ?string { return $this->clientPath; @@ -296,6 +304,7 @@ public function getClientPath(): ?string /** * Gets the temporary filename where the file was uploaded to. */ + #[Override] public function getTempName(): string { return $this->path; @@ -312,6 +321,7 @@ public function getTempName(): string * but might be insecure if the mime type is not matched. Consider * using guessExtension for a more safe version. */ + #[Override] public function getExtension(): string { $guessExtension = $this->guessExtension(); @@ -325,6 +335,7 @@ public function getExtension(): string * an empty string if it fails to determine an extension instead of * falling back to the unsecure clientExtension. */ + #[Override] public function guessExtension(): string { return Mimes::guessExtensionFromType($this->getMimeType(), $this->getClientExtension()) ?? ''; @@ -335,6 +346,7 @@ public function guessExtension(): string * was uploaded. This is NOT a trusted source. * For a trusted version, use guessExtension() instead. */ + #[Override] public function getClientExtension(): string { return pathinfo($this->originalName, PATHINFO_EXTENSION); @@ -344,6 +356,7 @@ public function getClientExtension(): string * Returns whether the file was uploaded successfully, based on whether * it was uploaded via HTTP and has no errors. */ + #[Override] public function isValid(): bool { return is_uploaded_file($this->path) && $this->error === UPLOAD_ERR_OK; diff --git a/system/HTTP/Header.php b/system/HTTP/Header.php index 845307c84bca..344e519172f3 100644 --- a/system/HTTP/Header.php +++ b/system/HTTP/Header.php @@ -14,6 +14,7 @@ namespace CodeIgniter\HTTP; use InvalidArgumentException; +use Override; use Stringable; /** @@ -205,6 +206,7 @@ public function getValueLine(): string * Returns a representation of the entire header string, including * the header name and all values converted to the proper format. */ + #[Override] public function __toString(): string { return $this->name . ': ' . $this->getValueLine(); diff --git a/system/HTTP/Message.php b/system/HTTP/Message.php index 9ff7aa76231b..e192608f0ec1 100644 --- a/system/HTTP/Message.php +++ b/system/HTTP/Message.php @@ -14,6 +14,7 @@ namespace CodeIgniter\HTTP; use CodeIgniter\Exceptions\InvalidArgumentException; +use Override; /** * An HTTP message @@ -53,6 +54,7 @@ class Message implements MessageInterface * * @return string|null */ + #[Override] public function getBody() { return $this->body; @@ -61,6 +63,7 @@ public function getBody() /** * Determines whether a header exists. */ + #[Override] public function hasHeader(string $name): bool { $origName = $this->getHeaderName($name); @@ -79,6 +82,7 @@ public function hasHeader(string $name): bool * comma concatenation. For such headers, use getHeader() instead * and supply your own delimiter when concatenating. */ + #[Override] public function getHeaderLine(string $name): string { if ($this->hasMultipleHeaders($name)) { @@ -100,6 +104,7 @@ public function getHeaderLine(string $name): string /** * Returns the HTTP Protocol Version. */ + #[Override] public function getProtocolVersion(): string { return $this->protocolVersion ?? '1.1'; diff --git a/system/HTTP/OutgoingRequest.php b/system/HTTP/OutgoingRequest.php index 0c033de2592c..98d7ffa8bf74 100644 --- a/system/HTTP/OutgoingRequest.php +++ b/system/HTTP/OutgoingRequest.php @@ -13,6 +13,8 @@ namespace CodeIgniter\HTTP; +use Override; + /** * Representation of an outgoing, client-side request. */ @@ -71,6 +73,7 @@ private function getHostFromUri(URI $uri): string * * @return string Returns the request method (always uppercase) */ + #[Override] public function getMethod(): string { return $this->method; @@ -97,6 +100,7 @@ public function setMethod(string $method) * * @return static */ + #[Override] public function withMethod($method) { $request = clone $this; @@ -110,6 +114,7 @@ public function withMethod($method) * * @return URI */ + #[Override] public function getUri() { return $this->uri; @@ -123,6 +128,7 @@ public function getUri() * * @return static */ + #[Override] public function withUri(URI $uri, $preserveHost = false) { $request = clone $this; diff --git a/system/HTTP/Request.php b/system/HTTP/Request.php index 73859dd843ae..cf3308be42b0 100644 --- a/system/HTTP/Request.php +++ b/system/HTTP/Request.php @@ -14,6 +14,7 @@ namespace CodeIgniter\HTTP; use Config\App; +use Override; /** * Representation of an incoming, server-side HTTP request. @@ -49,6 +50,7 @@ public function __construct($config = null) * * @codeCoverageIgnore */ + #[Override] public function setMethod(string $method) { $this->method = $method; @@ -63,6 +65,7 @@ public function setMethod(string $method) * * @return static */ + #[Override] public function withMethod($method) { $request = clone $this; @@ -77,6 +80,7 @@ public function withMethod($method) * * @return URI */ + #[Override] public function getUri() { return $this->uri; diff --git a/system/HTTP/Response.php b/system/HTTP/Response.php index 4ca3db28d596..6adca77453ba 100644 --- a/system/HTTP/Response.php +++ b/system/HTTP/Response.php @@ -15,6 +15,7 @@ use CodeIgniter\Cookie\Cookie; use CodeIgniter\HTTP\Exceptions\HTTPException; +use Override; /** * Representation of an outgoing, server-side response. @@ -171,6 +172,7 @@ public function pretend(bool $pretend = true) * * @return int Status code. */ + #[Override] public function getStatusCode(): int { if ($this->statusCode === 0) { @@ -194,6 +196,7 @@ public function getStatusCode(): int * * @return string Reason phrase; must return an empty string if none present. */ + #[Override] public function getReasonPhrase() { if ($this->reason === '') { diff --git a/system/HTTP/SSEResponse.php b/system/HTTP/SSEResponse.php index 8dc35278ddb4..9e8ff49976d4 100644 --- a/system/HTTP/SSEResponse.php +++ b/system/HTTP/SSEResponse.php @@ -14,6 +14,7 @@ namespace CodeIgniter\HTTP; use JsonException; +use Override; /** * HTTP response for Server-Sent Events (SSE) streaming. @@ -117,6 +118,7 @@ private function formatMultiline(string $prefix, string $value): string * SSE headers are fixed by the protocol, so they override * anything set on the response. */ + #[Override] protected function prepareStreamHeaders(): void { $this->setContentType('text/event-stream', 'UTF-8'); @@ -136,6 +138,7 @@ protected function prepareStreamHeaders(): void * CSP is not finalized for SSE responses, as Content Security * Policy does not apply to event streams. */ + #[Override] protected function shouldFinalizeCsp(): bool { return false; diff --git a/system/HTTP/SiteURI.php b/system/HTTP/SiteURI.php index 782972e24a1e..80fb10ab4fdb 100644 --- a/system/HTTP/SiteURI.php +++ b/system/HTTP/SiteURI.php @@ -16,6 +16,7 @@ use CodeIgniter\Exceptions\ConfigException; use CodeIgniter\HTTP\Exceptions\HTTPException; use Config\App; +use Override; /** * URI for the application site @@ -226,6 +227,7 @@ public function getRoutePath(): string /** * Formats the URI as a string. */ + #[Override] public function __toString(): string { return static::createURIString( @@ -242,6 +244,7 @@ public function __toString(): string * * @return $this */ + #[Override] public function setPath(string $path) { $this->setRoutePath($path); @@ -278,6 +281,7 @@ private function convertToSegments(string $path): array /** * Sets the path portion of the URI based on segments. */ + #[Override] protected function refreshPath(): self { $allSegments = array_merge($this->baseSegments, $this->segments); @@ -306,6 +310,7 @@ protected function refreshPath(): self * pass?: string, * } $parts */ + #[Override] protected function applyParts(array $parts): void { if (isset($parts['host']) && $parts['host'] !== '') { diff --git a/system/HTTP/StreamResponse.php b/system/HTTP/StreamResponse.php index 6983449533f9..cde23e7f7b94 100644 --- a/system/HTTP/StreamResponse.php +++ b/system/HTTP/StreamResponse.php @@ -14,6 +14,7 @@ namespace CodeIgniter\HTTP; use Closure; +use Override; /** * HTTP response that streams its body to the client as it is generated, @@ -102,6 +103,7 @@ public function isClientConnected(): bool * * @return $this */ + #[Override] public function send() { // Turn off output buffering completely, even if php.ini output_buffering is not off @@ -154,6 +156,7 @@ protected function prepareStreamHeaders(): void * * @return $this */ + #[Override] public function sendBody() { return $this; diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php index 9fd1c8a758ba..9abfbd471558 100644 --- a/system/HTTP/URI.php +++ b/system/HTTP/URI.php @@ -16,6 +16,7 @@ use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\HTTP\Exceptions\HTTPException; use Config\App; +use Override; use SensitiveParameter; use Stringable; @@ -613,6 +614,7 @@ public function getTotalSegments(): int * be relative to the project's configuration. * This aspect of __toString() is deprecated and should be avoided. */ + #[Override] public function __toString(): string { $path = $this->getPath(); diff --git a/system/HTTP/UserAgent.php b/system/HTTP/UserAgent.php index b89fb63b70f0..a3080eb6665c 100644 --- a/system/HTTP/UserAgent.php +++ b/system/HTTP/UserAgent.php @@ -14,6 +14,7 @@ namespace CodeIgniter\HTTP; use Config\UserAgents; +use Override; use Stringable; /** @@ -377,6 +378,7 @@ protected function setMobile(): bool /** * Outputs the original Agent String when cast as a string. */ + #[Override] public function __toString(): string { return $this->getAgentString(); diff --git a/system/HotReloader/IteratorFilter.php b/system/HotReloader/IteratorFilter.php index 1134f77665f1..826705fc64d8 100644 --- a/system/HotReloader/IteratorFilter.php +++ b/system/HotReloader/IteratorFilter.php @@ -14,6 +14,7 @@ namespace CodeIgniter\HotReloader; use Config\Toolbar; +use Override; use RecursiveFilterIterator; use RecursiveIterator; @@ -39,6 +40,7 @@ public function __construct(RecursiveIterator $iterator) /** * Apply filters to the files in the iterator. */ + #[Override] public function accept(): bool { if (! $this->current()->isFile()) { diff --git a/system/I18n/TimeLegacy.php b/system/I18n/TimeLegacy.php index f927f36a0d9a..563cee7f8f8a 100644 --- a/system/I18n/TimeLegacy.php +++ b/system/I18n/TimeLegacy.php @@ -15,6 +15,7 @@ use DateTime; use Exception; +use Override; /** * Legacy Time class. @@ -56,6 +57,7 @@ class TimeLegacy extends DateTime * * @throws Exception */ + #[Override] public function setTimestamp($timestamp): static { $time = date('Y-m-d H:i:s', $timestamp); diff --git a/system/Images/Handlers/BaseHandler.php b/system/Images/Handlers/BaseHandler.php index 692af5096e0b..8f6ede6fe440 100644 --- a/system/Images/Handlers/BaseHandler.php +++ b/system/Images/Handlers/BaseHandler.php @@ -18,6 +18,7 @@ use CodeIgniter\Images\Image; use CodeIgniter\Images\ImageHandlerInterface; use Config\Images; +use Override; /** * Base image handling implementation. @@ -247,6 +248,7 @@ public function withResource() * * @return $this */ + #[Override] public function resize(int $width, int $height, bool $maintainRatio = false, string $masterDim = 'auto') { if ($this->image()->origWidth === $width && $this->image()->origHeight === $height) { @@ -274,6 +276,7 @@ public function resize(int $width, int $height, bool $maintainRatio = false, str * * @return $this */ + #[Override] public function crop(?int $width = null, ?int $height = null, ?int $x = null, ?int $y = null, bool $maintainRatio = false, string $masterDim = 'auto') { $this->width = $width; @@ -302,6 +305,7 @@ public function crop(?int $width = null, ?int $height = null, ?int $x = null, ?i * * @return $this */ + #[Override] public function convert(int $imageType) { $this->ensureResource(); @@ -316,6 +320,7 @@ public function convert(int $imageType) * * @return $this */ + #[Override] public function rotate(float $angle) { $degs = [90.0, 180.0, 270.0]; @@ -342,6 +347,7 @@ public function rotate(float $angle) * * @return $this */ + #[Override] public function flatten(int $red = 255, int $green = 255, int $blue = 255) { $this->width = $this->image()->origWidth; @@ -373,6 +379,7 @@ abstract protected function _rotate(int $angle); * * @return $this */ + #[Override] public function flip(string $dir = 'vertical') { $dir = strtolower($dir); @@ -392,6 +399,7 @@ public function flip(string $dir = 'vertical') */ abstract protected function _flip(string $direction); + #[Override] public function text(string $text, array $options = []) { $options = array_merge($this->textDefaults, $options); @@ -463,6 +471,7 @@ abstract public function _getHeight(); * * @return $this */ + #[Override] public function reorient(bool $silent = false) { $orientation = $this->getEXIF('Orientation', $silent); @@ -492,6 +501,7 @@ public function reorient(bool $silent = false) * * @throws ImageException */ + #[Override] public function getEXIF(?string $key = null, bool $silent = false) { if (! function_exists('exif_read_data')) { @@ -532,6 +542,7 @@ public function getEXIF(?string $key = null, bool $silent = false) * * @return $this */ + #[Override] public function fit(int $width, ?int $height = null, string $position = 'center') { $origWidth = $this->image()->origWidth; @@ -676,6 +687,7 @@ abstract public function getVersion(); * * @return bool */ + #[Override] abstract public function save(?string $target = null, int $quality = 90); /** @@ -770,6 +782,7 @@ public function getHeight() * * This method should be implemented to remove or reset metadata as needed. */ + #[Override] public function clearMetadata(): static { return $this; diff --git a/system/Images/Handlers/GDHandler.php b/system/Images/Handlers/GDHandler.php index e1c6c15f5cdd..705d1b5d4156 100644 --- a/system/Images/Handlers/GDHandler.php +++ b/system/Images/Handlers/GDHandler.php @@ -16,6 +16,7 @@ use CodeIgniter\Images\Exceptions\ImageException; use Config\Images; use GdImage; +use Override; /** * Image handler for GD package @@ -42,6 +43,7 @@ public function __construct($config = null) * Handles the rotation of an image resource. * Doesn't save the image, but replaces the current resource. */ + #[Override] protected function _rotate(int $angle): bool { $srcImg = $this->createImage(); @@ -63,6 +65,7 @@ protected function _rotate(int $angle): bool * * @return $this */ + #[Override] protected function _flatten(int $red = 255, int $green = 255, int $blue = 255) { $srcImg = $this->createImage(); @@ -91,6 +94,7 @@ protected function _flatten(int $red = 255, int $green = 255, int $blue = 255) * * @return $this */ + #[Override] protected function _flip(string $direction) { $srcImg = $this->createImage(); @@ -109,6 +113,7 @@ protected function _flip(string $direction) * * @return string */ + #[Override] public function getVersion() { if (! function_exists('gd_info')) { @@ -125,6 +130,7 @@ public function getVersion() * * @return $this */ + #[Override] public function _resize(bool $maintainRatio = false) { return $this->process('resize'); @@ -135,6 +141,7 @@ public function _resize(bool $maintainRatio = false) * * @return $this */ + #[Override] public function _crop() { return $this->process('crop'); @@ -145,6 +152,7 @@ public function _crop() * * @return $this */ + #[Override] protected function process(string $action) { $origWidth = $this->image()->origWidth; @@ -196,6 +204,7 @@ protected function process(string $action) * * @param non-empty-string|null $target */ + #[Override] public function save(?string $target = null, int $quality = 90): bool { $original = $target; @@ -309,6 +318,7 @@ protected function createImage(string $path = '', string $imageType = '') /** * Make the image resource object if needed */ + #[Override] protected function ensureResource() { $this->resource ??= $this->getImageResource( @@ -383,6 +393,7 @@ protected function getImageResource(string $path, int $imageType) /** * Add text overlay to an image. */ + #[Override] protected function _text(string $text, array $options = []) { // Reverse the vertical offset @@ -493,6 +504,7 @@ protected function textOverlay(string $text, array $options = [], bool $isShadow * * @return int */ + #[Override] public function _getWidth() { return imagesx($this->resource); @@ -503,6 +515,7 @@ public function _getWidth() * * @return int */ + #[Override] public function _getHeight() { return imagesy($this->resource); diff --git a/system/Images/Handlers/ImageMagickHandler.php b/system/Images/Handlers/ImageMagickHandler.php index 9679e69c2bf0..5dc24fe358f0 100644 --- a/system/Images/Handlers/ImageMagickHandler.php +++ b/system/Images/Handlers/ImageMagickHandler.php @@ -21,6 +21,7 @@ use ImagickException; use ImagickPixel; use ImagickPixelException; +use Override; use RuntimeException; /** @@ -56,6 +57,7 @@ public function __construct($config = null) * * @throws ImageException */ + #[Override] protected function ensureResource() { if (! $this->resource instanceof Imagick) { @@ -86,6 +88,7 @@ protected function ensureResource() * * @throws ImageException */ + #[Override] protected function process(string $action, int $quality = 100) { $this->image(); @@ -138,6 +141,7 @@ protected function process(string $action, int $quality = 100) * * @throws ImagickException */ + #[Override] public function _resize(bool $maintainRatio = false) { if ($maintainRatio) { @@ -159,6 +163,7 @@ public function _resize(bool $maintainRatio = false) * * @throws ImagickException */ + #[Override] public function _crop() { $result = $this->process('crop'); @@ -190,6 +195,7 @@ public function _crop() * * @throws ImagickException */ + #[Override] protected function _rotate(int $angle) { $this->ensureResource(); @@ -209,6 +215,7 @@ protected function _rotate(int $angle) * * @throws ImagickException|ImagickPixelException */ + #[Override] protected function _flatten(int $red = 255, int $green = 255, int $blue = 255) { $this->ensureResource(); @@ -243,6 +250,7 @@ protected function _flatten(int $red = 255, int $green = 255, int $blue = 255) * * @throws ImagickException */ + #[Override] protected function _flip(string $direction) { $this->ensureResource(); @@ -261,6 +269,7 @@ protected function _flip(string $direction) * * @return string */ + #[Override] public function getVersion() { $version = Imagick::getVersion(); @@ -333,6 +342,7 @@ protected function supportedFormatCheck() * * @throws ImagickException */ + #[Override] public function save(?string $target = null, int $quality = 90): bool { $original = $target; @@ -387,6 +397,7 @@ public function save(?string $target = null, int $quality = 90): bool * * @throws ImagickDrawException|ImagickException|ImagickPixelException */ + #[Override] protected function _text(string $text, array $options = []) { $this->ensureResource(); @@ -505,6 +516,7 @@ protected function _text(string $text, array $options = []) * * @throws ImagickException */ + #[Override] public function _getWidth() { $this->ensureResource(); @@ -519,6 +531,7 @@ public function _getWidth() * * @throws ImagickException */ + #[Override] public function _getHeight() { $this->ensureResource(); @@ -536,6 +549,7 @@ public function _getHeight() * * @return $this */ + #[Override] public function reorient(bool $silent = false) { $orientation = $this->getEXIF('Orientation', $silent); @@ -557,6 +571,7 @@ public function reorient(bool $silent = false) * * @throws ImagickException */ + #[Override] public function clearMetadata(): static { $this->ensureResource(); diff --git a/system/Input/ValidatedInput.php b/system/Input/ValidatedInput.php index ee59bd05aacb..d1fa4ac83d9f 100644 --- a/system/Input/ValidatedInput.php +++ b/system/Input/ValidatedInput.php @@ -17,6 +17,7 @@ use CodeIgniter\I18n\Time; use DateTimeZone; use Exception; +use Override; use ReflectionEnum; use UnitEnum; @@ -150,6 +151,7 @@ private function backedEnum(string $key, string $enumClass, ReflectionEnum $refl return $enum; } + #[Override] protected function invalidValue(string $key, string $type, mixed $default): never { throw new InvalidArgumentException( diff --git a/system/Lock/Lock.php b/system/Lock/Lock.php index d6d7e764bccf..13d60617de05 100644 --- a/system/Lock/Lock.php +++ b/system/Lock/Lock.php @@ -16,6 +16,7 @@ use Closure; use CodeIgniter\Cache\LockStoreInterface; use CodeIgniter\Exceptions\InvalidArgumentException; +use Override; final readonly class Lock implements LockInterface { @@ -36,11 +37,13 @@ public function __construct( } } + #[Override] public function acquire(): bool { return $this->store->acquireLock($this->key, $this->owner, $this->ttl); } + #[Override] public function block(int $seconds): bool { if ($seconds < 1) { @@ -63,6 +66,7 @@ public function block(int $seconds): bool /** * @param Closure(): mixed $callback */ + #[Override] public function run(Closure $callback, int $waitSeconds = 0): mixed { $acquired = $waitSeconds > 0 ? $this->block($waitSeconds) : $this->acquire(); @@ -78,16 +82,19 @@ public function run(Closure $callback, int $waitSeconds = 0): mixed } } + #[Override] public function release(): bool { return $this->store->releaseLock($this->key, $this->owner); } + #[Override] public function forceRelease(): bool { return $this->store->forceReleaseLock($this->key); } + #[Override] public function refresh(?int $ttl = null): bool { $ttl ??= $this->ttl; @@ -99,11 +106,13 @@ public function refresh(?int $ttl = null): bool return $this->store->refreshLock($this->key, $this->owner, $ttl); } + #[Override] public function isAcquired(): bool { return $this->store->getLockOwner($this->key) === $this->owner; } + #[Override] public function owner(): string { return $this->owner; diff --git a/system/Log/Handlers/BaseHandler.php b/system/Log/Handlers/BaseHandler.php index 3abc951ac218..a69f45b09ee8 100644 --- a/system/Log/Handlers/BaseHandler.php +++ b/system/Log/Handlers/BaseHandler.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Log\Handlers; use JsonException; +use Override; /** * Base class for logging @@ -52,6 +53,7 @@ public function __construct(array $config) * Checks whether the Handler will handle logging items of this * log Level. */ + #[Override] public function canHandle(string $level): bool { return in_array($level, $this->handles, true); @@ -60,6 +62,7 @@ public function canHandle(string $level): bool /** * Stores the date format to use while logging messages. */ + #[Override] public function setDateFormat(string $format): HandlerInterface { $this->dateFormat = $format; diff --git a/system/Log/Handlers/ChromeLoggerHandler.php b/system/Log/Handlers/ChromeLoggerHandler.php index 531756a34faf..c945a4598228 100644 --- a/system/Log/Handlers/ChromeLoggerHandler.php +++ b/system/Log/Handlers/ChromeLoggerHandler.php @@ -15,6 +15,7 @@ use CodeIgniter\HTTP\ResponseInterface; use JsonException; +use Override; /** * Allows for logging items to the Chrome console for debugging. @@ -103,6 +104,7 @@ public function __construct(array $config = []) * @param object|string $message * @param array $context */ + #[Override] public function handle($level, $message, array $context = []): bool { $message = $this->format($message); diff --git a/system/Log/Handlers/ErrorlogHandler.php b/system/Log/Handlers/ErrorlogHandler.php index 635058720284..1df8002eb386 100644 --- a/system/Log/Handlers/ErrorlogHandler.php +++ b/system/Log/Handlers/ErrorlogHandler.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Log\Handlers; use CodeIgniter\Log\Exceptions\LogException; +use Override; /** * Log handler that writes to PHP's `error_log()` @@ -71,6 +72,7 @@ public function __construct(array $config = []) * @param string $message * @param array $context */ + #[Override] public function handle($level, $message, array $context = []): bool { if ($context !== []) { diff --git a/system/Log/Handlers/FileHandler.php b/system/Log/Handlers/FileHandler.php index d88b85b3a455..a7379d2d768e 100644 --- a/system/Log/Handlers/FileHandler.php +++ b/system/Log/Handlers/FileHandler.php @@ -15,6 +15,7 @@ use DateTime; use Exception; +use Override; /** * Log error messages to file system @@ -78,6 +79,7 @@ public function __construct(array $config = []) * * @throws Exception */ + #[Override] public function handle($level, $message, array $context = []): bool { $filepath = $this->path . 'log-' . date('Y-m-d') . '.' . $this->fileExtension; diff --git a/system/Log/Logger.php b/system/Log/Logger.php index d17c9305c9da..817338908762 100644 --- a/system/Log/Logger.php +++ b/system/Log/Logger.php @@ -17,6 +17,7 @@ use CodeIgniter\Exceptions\RuntimeException; use CodeIgniter\Log\Exceptions\LogException; use CodeIgniter\Log\Handlers\HandlerInterface; +use Override; use Psr\Log\LoggerInterface; use Stringable; use Throwable; @@ -189,6 +190,7 @@ public function __construct($config, bool $debug = CI_DEBUG) /** * System is unusable. */ + #[Override] public function emergency(string|Stringable $message, array $context = []): void { $this->log('emergency', $message, $context); @@ -200,6 +202,7 @@ public function emergency(string|Stringable $message, array $context = []): void * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. */ + #[Override] public function alert(string|Stringable $message, array $context = []): void { $this->log('alert', $message, $context); @@ -210,6 +213,7 @@ public function alert(string|Stringable $message, array $context = []): void * * Example: Application component unavailable, unexpected exception. */ + #[Override] public function critical(string|Stringable $message, array $context = []): void { $this->log('critical', $message, $context); @@ -219,6 +223,7 @@ public function critical(string|Stringable $message, array $context = []): void * Runtime errors that do not require immediate action but should typically * be logged and monitored. */ + #[Override] public function error(string|Stringable $message, array $context = []): void { $this->log('error', $message, $context); @@ -230,6 +235,7 @@ public function error(string|Stringable $message, array $context = []): void * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. */ + #[Override] public function warning(string|Stringable $message, array $context = []): void { $this->log('warning', $message, $context); @@ -238,6 +244,7 @@ public function warning(string|Stringable $message, array $context = []): void /** * Normal but significant events. */ + #[Override] public function notice(string|Stringable $message, array $context = []): void { $this->log('notice', $message, $context); @@ -248,6 +255,7 @@ public function notice(string|Stringable $message, array $context = []): void * * Example: User logs in, SQL logs. */ + #[Override] public function info(string|Stringable $message, array $context = []): void { $this->log('info', $message, $context); @@ -256,6 +264,7 @@ public function info(string|Stringable $message, array $context = []): void /** * Detailed debug information. */ + #[Override] public function debug(string|Stringable $message, array $context = []): void { $this->log('debug', $message, $context); @@ -266,6 +275,7 @@ public function debug(string|Stringable $message, array $context = []): void * * @param mixed $level */ + #[Override] public function log($level, string|Stringable $message, array $context = []): void { if (is_numeric($level)) { diff --git a/system/Model.php b/system/Model.php index 21c518f5b3e1..bc03ee1971c9 100644 --- a/system/Model.php +++ b/system/Model.php @@ -31,6 +31,7 @@ use Config\Database; use Config\Feature; use Generator; +use Override; use stdClass; use Throwable; @@ -192,6 +193,7 @@ public function setTable(string $table) return $this; } + #[Override] protected function doFind(bool $singleton, $id = null) { $builder = $this->builder(); @@ -246,6 +248,7 @@ protected function doFind(bool $singleton, $id = null) return $rows; } + #[Override] protected function doFindColumn(string $columnName) { return $this->select($columnName)->asArray()->find(); @@ -256,6 +259,7 @@ protected function doFindColumn(string $columnName) * * Works with the current Query Builder instance. */ + #[Override] protected function doFindAll(?int $limit = null, int $offset = 0) { $limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true; // @phpstan-ignore nullCoalesce.property @@ -296,6 +300,7 @@ protected function doFindAll(?int $limit = null, int $offset = 0) * Will take any previous Query Builder calls into account * when determining the result set. */ + #[Override] protected function doFirst() { $builder = $this->builder(); @@ -329,6 +334,7 @@ protected function doFirst() return $row; } + #[Override] protected function doInsert(array $row) { $escape = $this->escape; @@ -389,6 +395,7 @@ protected function doInsert(array $row) return $result; } + #[Override] protected function doInsertBatch(?array $set = null, ?bool $escape = null, int $batchSize = 100, bool $testing = false) { if (is_array($set) && ! $this->useAutoIncrement) { @@ -407,6 +414,7 @@ protected function doInsertBatch(?array $set = null, ?bool $escape = null, int $ return $this->builder()->testMode($testing)->insertBatch($set, $escape, $batchSize); } + #[Override] protected function doUpdate($id = null, $row = null): bool { $escape = $this->escape; @@ -432,11 +440,13 @@ protected function doUpdate($id = null, $row = null): bool return $builder->update(); } + #[Override] protected function doUpdateBatch(?array $set = null, ?string $index = null, int $batchSize = 100, bool $returnSQL = false) { return $this->builder()->testMode($returnSQL)->updateBatch($set, $index, $batchSize); } + #[Override] protected function doDelete($id = null, bool $purge = false) { $set = []; @@ -467,6 +477,7 @@ protected function doDelete($id = null, bool $purge = false) return $builder->delete(); } + #[Override] protected function doPurgeDeleted() { return $this->builder() @@ -474,11 +485,13 @@ protected function doPurgeDeleted() ->delete(); } + #[Override] protected function doOnlyDeleted() { $this->builder()->where($this->table . '.' . $this->deletedField . ' IS NOT NULL'); } + #[Override] protected function doReplace(?array $row = null, bool $returnSQL = false) { return $this->builder()->testMode($returnSQL)->replace($row); @@ -491,6 +504,7 @@ protected function doReplace(?array $row = null, bool $returnSQL = false) * `['source' => 'message']`. * This method works only with dbCalls. */ + #[Override] protected function doErrors() { // $error is always ['code' => string|int, 'message' => string] @@ -503,6 +517,7 @@ protected function doErrors() return [$this->db::class => $error['message']]; } + #[Override] public function getIdValue($row) { if (is_object($row)) { @@ -533,6 +548,7 @@ public function getIdValue($row) return null; } + #[Override] public function countAllResults(bool $reset = true, bool $test = false) { $this->prepareSoftDeleteQuery($reset); @@ -759,6 +775,7 @@ private function assertValidChunkSize(int $size): void /** * {@inheritDoc} */ + #[Override] public function chunk(int $size, Closure $userFunc) { foreach ($this->iterateChunks($size) as $rows) { @@ -773,6 +790,7 @@ public function chunk(int $size, Closure $userFunc) /** * {@inheritDoc} */ + #[Override] public function chunkById(int $size, Closure $userFunc) { foreach ($this->iterateChunksById($size) as $rows) { @@ -787,6 +805,7 @@ public function chunkById(int $size, Closure $userFunc) /** * {@inheritDoc} */ + #[Override] public function chunkRows(int $size, Closure $userFunc): void { foreach ($this->iterateChunks($size) as $rows) { @@ -799,6 +818,7 @@ public function chunkRows(int $size, Closure $userFunc): void /** * {@inheritDoc} */ + #[Override] public function chunkRowsById(int $size, Closure $userFunc): void { foreach ($this->iterateChunksById($size) as $rows) { @@ -881,6 +901,7 @@ public function set($key, $value = '', ?bool $escape = null) return $this; } + #[Override] protected function shouldUpdate($row): bool { if (parent::shouldUpdate($row) === false) { @@ -896,6 +917,7 @@ protected function shouldUpdate($row): bool return $this->where($this->primaryKey, $this->getIdValue($row))->countAllResults() === 1; } + #[Override] public function insert($row = null, bool $returnID = true) { if (isset($this->tempData['data'])) { @@ -913,6 +935,7 @@ public function insert($row = null, bool $returnID = true) return parent::insert($row, $returnID); } + #[Override] protected function doProtectFieldsForInsert(array $row): array { if (! $this->protectFields) { @@ -939,6 +962,7 @@ protected function doProtectFieldsForInsert(array $row): array return $row; } + #[Override] protected function doProtectFieldsForUpdate(array $row): array { $row = $this->doProtectInsertOnlyFieldsForUpdate($row, [$this->primaryKey]); @@ -995,6 +1019,7 @@ public function firstOrInsert(array|object $attributes, array|object $values = [ return $this->where($this->primaryKey, $id)->first() ?? false; } + #[Override] protected function doProtectFieldsForReplace(array $row): array { $primaryKey = array_intersect_key($row, [$this->primaryKey => true]); @@ -1011,6 +1036,7 @@ protected function doProtectFieldsForReplace(array $row): array return array_replace(array_intersect_key($row, $protectedRow), $protectedRow); } + #[Override] public function update($id = null, $row = null): bool { if (isset($this->tempData['data'])) { @@ -1033,6 +1059,7 @@ public function update($id = null, $row = null): bool * * @return mixed */ + #[Override] public function __get(string $name) { if (parent::__isset($name)) { @@ -1045,6 +1072,7 @@ public function __get(string $name) /** * Checks for the existence of properties across this model, builder, and db connection. */ + #[Override] public function __isset(string $name): bool { if (parent::__isset($name)) { @@ -1060,6 +1088,7 @@ public function __isset(string $name): bool * * @return mixed */ + #[Override] public function __call(string $name, array $params) { $builder = $this->builder(); diff --git a/system/Pager/Pager.php b/system/Pager/Pager.php index 06ed57070883..c59e6c2ffd74 100644 --- a/system/Pager/Pager.php +++ b/system/Pager/Pager.php @@ -18,6 +18,7 @@ use CodeIgniter\Pager\Exceptions\PagerException; use CodeIgniter\View\RendererInterface; use Config\Pager as PagerConfig; +use Override; /** * Class Pager @@ -87,6 +88,7 @@ public function __construct(PagerConfig $config, RendererInterface $view) * * @param string $template The output template alias to render. */ + #[Override] public function links(string $group = 'default', string $template = 'default_full'): string { $this->ensureGroup($group); @@ -97,6 +99,7 @@ public function links(string $group = 'default', string $template = 'default_ful /** * Creates simple Next/Previous links, instead of full pagination. */ + #[Override] public function simpleLinks(string $group = 'default', string $template = 'default_simple'): string { $this->ensureGroup($group); @@ -112,6 +115,7 @@ public function simpleLinks(string $group = 'default', string $template = 'defau * @param int $segment (whether page number is provided by URI segment) * @param string|null $group optional group (i.e. if we'd like to define custom path) */ + #[Override] public function makeLinks(int $page, ?int $perPage, int $total, string $template = 'default_full', int $segment = 0, ?string $group = 'default'): string { $group = $group === '' ? 'default' : $group; @@ -143,6 +147,7 @@ protected function displayLinks(string $group, string $template): string * * @return $this */ + #[Override] public function store(string $group, int $page, ?int $perPage, int $total, int $segment = 0) { if ($segment !== 0) { @@ -187,6 +192,7 @@ public function setSegment(int $number, string $group = 'default') * * @return $this */ + #[Override] public function setPath(string $path, string $group = 'default') { $this->ensureGroup($group); @@ -209,6 +215,7 @@ public function getTotal(string $group = 'default'): int /** * Returns the total number of pages. */ + #[Override] public function getPageCount(string $group = 'default'): int { $this->ensureGroup($group); @@ -219,6 +226,7 @@ public function getPageCount(string $group = 'default'): int /** * Returns the number of the current page of results. */ + #[Override] public function getCurrentPage(string $group = 'default'): int { $this->ensureGroup($group); @@ -231,6 +239,7 @@ public function getCurrentPage(string $group = 'default'): int /** * Tells whether this group of results has any more pages of results. */ + #[Override] public function hasMore(string $group = 'default'): bool { $this->ensureGroup($group); @@ -243,6 +252,7 @@ public function hasMore(string $group = 'default'): bool * * @return int|null */ + #[Override] public function getLastPage(string $group = 'default') { $this->ensureGroup($group); @@ -257,6 +267,7 @@ public function getLastPage(string $group = 'default') /** * Determines the first page # that should be shown. */ + #[Override] public function getFirstPage(string $group = 'default'): int { $this->ensureGroup($group); @@ -270,6 +281,7 @@ public function getFirstPage(string $group = 'default'): int * * @return string|URI */ + #[Override] public function getPageURI(?int $page = null, string $group = 'default', bool $returnObject = false) { $this->ensureGroup($group); @@ -311,6 +323,7 @@ public function getPageURI(?int $page = null, string $group = 'default', bool $r * * @return string|null */ + #[Override] public function getNextPageURI(string $group = 'default', bool $returnObject = false) { $this->ensureGroup($group); @@ -335,6 +348,7 @@ public function getNextPageURI(string $group = 'default', bool $returnObject = f * * @return string|null */ + #[Override] public function getPreviousPageURI(string $group = 'default', bool $returnObject = false) { $this->ensureGroup($group); @@ -357,6 +371,7 @@ public function getPreviousPageURI(string $group = 'default', bool $returnObject /** * Returns the number of results per page that should be shown. */ + #[Override] public function getPerPage(string $group = 'default'): int { $this->ensureGroup($group); @@ -364,6 +379,7 @@ public function getPerPage(string $group = 'default'): int return (int) $this->groups[$group]['perPage']; } + #[Override] public function getDetails(string $group = 'default'): array { if (! array_key_exists($group, $this->groups)) { diff --git a/system/RESTful/BaseResource.php b/system/RESTful/BaseResource.php index e5ff13e1abdb..8dc7e85efe46 100644 --- a/system/RESTful/BaseResource.php +++ b/system/RESTful/BaseResource.php @@ -18,6 +18,7 @@ use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; use Psr\Log\LoggerInterface; abstract class BaseResource extends Controller @@ -46,6 +47,7 @@ abstract class BaseResource extends Controller * * @return void */ + #[Override] public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); diff --git a/system/Router/Attributes/Cache.php b/system/Router/Attributes/Cache.php index 447f9e48c260..bad42eb3e066 100644 --- a/system/Router/Attributes/Cache.php +++ b/system/Router/Attributes/Cache.php @@ -17,6 +17,7 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\I18n\Time; +use Override; /** * Cache Attribute @@ -52,6 +53,7 @@ public function __construct( ) { } + #[Override] public function before(RequestInterface $request): RequestInterface|ResponseInterface|null { // Only cache GET requests @@ -84,6 +86,7 @@ public function before(RequestInterface $request): RequestInterface|ResponseInte return null; // Continue to controller } + #[Override] public function after(RequestInterface $request, ResponseInterface $response): ?ResponseInterface { // Don't re-cache if response was already served from cache diff --git a/system/Router/Attributes/Filter.php b/system/Router/Attributes/Filter.php index edba9452619e..70c035b7582b 100644 --- a/system/Router/Attributes/Filter.php +++ b/system/Router/Attributes/Filter.php @@ -16,6 +16,7 @@ use Attribute; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; /** * Filter Attribute @@ -47,6 +48,7 @@ public function __construct( ) { } + #[Override] public function before(RequestInterface $request): RequestInterface|ResponseInterface|null { // Filters are handled by the filter system via getFilters() @@ -54,6 +56,7 @@ public function before(RequestInterface $request): RequestInterface|ResponseInte return null; } + #[Override] public function after(RequestInterface $request, ResponseInterface $response): ?ResponseInterface { return null; diff --git a/system/Router/Attributes/Restrict.php b/system/Router/Attributes/Restrict.php index ca50eb1b3999..21a182136cdf 100644 --- a/system/Router/Attributes/Restrict.php +++ b/system/Router/Attributes/Restrict.php @@ -17,6 +17,7 @@ use CodeIgniter\Exceptions\PageNotFoundException; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; /** * Restrict Attribute @@ -54,6 +55,7 @@ public function __construct( ) { } + #[Override] public function before(RequestInterface $request): RequestInterface|ResponseInterface|null { $this->checkEnvironment(); @@ -63,6 +65,7 @@ public function before(RequestInterface $request): RequestInterface|ResponseInte return null; // Continue normal execution } + #[Override] public function after(RequestInterface $request, ResponseInterface $response): ?ResponseInterface { return null; // No post-processing needed diff --git a/system/Router/AutoRouter.php b/system/Router/AutoRouter.php index 18bb9f25e58a..9e4f7c405a99 100644 --- a/system/Router/AutoRouter.php +++ b/system/Router/AutoRouter.php @@ -16,6 +16,7 @@ use Closure; use CodeIgniter\Exceptions\PageNotFoundException; use CodeIgniter\HTTP\ResponseInterface; +use Override; /** * Router for Auto-Routing @@ -55,6 +56,7 @@ public function __construct( ) { } + #[Override] public function getRoute(string $uri, string $httpVerb): array { $segments = explode('/', $uri); diff --git a/system/Router/AutoRouterImproved.php b/system/Router/AutoRouterImproved.php index 75bdf82233b6..32bf2433df4a 100644 --- a/system/Router/AutoRouterImproved.php +++ b/system/Router/AutoRouterImproved.php @@ -16,6 +16,7 @@ use CodeIgniter\Exceptions\PageNotFoundException; use CodeIgniter\Router\Exceptions\MethodNotFoundException; use Config\Routing; +use Override; use ReflectionClass; use ReflectionException; @@ -250,6 +251,7 @@ private function searchLastDefaultController(): bool return false; } + #[Override] public function getRoute(string $uri, string $httpVerb): array { $this->uri = $uri; diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 4e10be41e11c..f577be2c762e 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -22,6 +22,7 @@ use Config\App; use Config\Modules; use Config\Routing; +use Override; /** * @todo Implement nested resource routing (See CakePHP) @@ -383,6 +384,7 @@ protected function discoverRoutes() $this->didDiscover = true; } + #[Override] public function addPlaceholder($placeholder, ?string $pattern = null): RouteCollectionInterface { if (! is_array($placeholder)) { @@ -406,6 +408,7 @@ public function getPlaceholders(): array return $this->placeholders; } + #[Override] public function setDefaultNamespace(string $value): RouteCollectionInterface { $this->defaultNamespace = rtrim($value, '\\') . '\\'; @@ -413,6 +416,7 @@ public function setDefaultNamespace(string $value): RouteCollectionInterface return $this; } + #[Override] public function setDefaultController(string $value): RouteCollectionInterface { $this->defaultController = $value; @@ -420,6 +424,7 @@ public function setDefaultController(string $value): RouteCollectionInterface return $this; } + #[Override] public function setDefaultMethod(string $value): RouteCollectionInterface { $this->defaultMethod = $value; @@ -427,6 +432,7 @@ public function setDefaultMethod(string $value): RouteCollectionInterface return $this; } + #[Override] public function setTranslateURIDashes(bool $value): RouteCollectionInterface { $this->translateURIDashes = $value; @@ -434,6 +440,7 @@ public function setTranslateURIDashes(bool $value): RouteCollectionInterface return $this; } + #[Override] public function setAutoRoute(bool $value): RouteCollectionInterface { $this->autoRoute = $value; @@ -441,6 +448,7 @@ public function setAutoRoute(bool $value): RouteCollectionInterface return $this; } + #[Override] public function set404Override($callable = null): RouteCollectionInterface { $this->override404 = $callable; @@ -448,6 +456,7 @@ public function set404Override($callable = null): RouteCollectionInterface return $this; } + #[Override] public function get404Override() { return $this->override404; @@ -466,31 +475,37 @@ public function setDefaultConstraint(string $placeholder): RouteCollectionInterf return $this; } + #[Override] public function getDefaultController(): string { return $this->defaultController; } + #[Override] public function getDefaultMethod(): string { return $this->defaultMethod; } + #[Override] public function getDefaultNamespace(): string { return $this->defaultNamespace; } + #[Override] public function shouldTranslateURIDashes(): bool { return $this->translateURIDashes; } + #[Override] public function shouldAutoRoute(): bool { return $this->autoRoute; } + #[Override] public function getRoutes(?string $verb = null, bool $includeWildcard = true): array { if ((string) $verb === '') { @@ -531,6 +546,7 @@ public function getRoutes(?string $verb = null, bool $includeWildcard = true): a return $routes; } + #[Override] public function getRoutesOptions(?string $from = null, ?string $verb = null): array { $options = $this->loadRoutesOptions($verb); @@ -538,11 +554,13 @@ public function getRoutesOptions(?string $from = null, ?string $verb = null): ar return ((string) $from !== '') ? $options[$from] ?? [] : $options; } + #[Override] public function getHTTPVerb(): string { return $this->HTTPVerb; } + #[Override] public function setHTTPVerb(string $verb) { if ($verb !== '*' && $verb === strtolower($verb)) { @@ -579,6 +597,7 @@ public function map(array $routes = [], ?array $options = null): RouteCollection return $this; } + #[Override] public function add(string $from, $to, ?array $options = null): RouteCollectionInterface { $this->create('*', $from, $to, $options); @@ -618,6 +637,7 @@ public function addRedirect(string $from, string $to, int $status = 302) return $this; } + #[Override] public function isRedirect(string $routeKey): bool { if (isset($this->routes['*'][$routeKey]['redirect'])) { @@ -635,6 +655,7 @@ public function isRedirect(string $routeKey): bool return false; } + #[Override] public function getRedirectCode(string $routeKey): int { if (isset($this->routes['*'][$routeKey]['redirect'])) { @@ -1095,6 +1116,7 @@ public function environment(string $env, Closure $callback): RouteCollectionInte return $this; } + #[Override] public function reverseRoute(string $search, ...$params) { if ($search === '') { @@ -1168,6 +1190,7 @@ protected function localizeRoute(string $route): string return strtr($route, ['{locale}' => service('request')->getLocale()]); } + #[Override] public function isFiltered(string $search, ?string $verb = null): bool { $options = $this->loadRoutesOptions($verb); @@ -1175,6 +1198,7 @@ public function isFiltered(string $search, ?string $verb = null): bool return isset($options[$search]['filter']); } + #[Override] public function getFiltersForRoute(string $search, ?string $verb = null): array { $options = $this->loadRoutesOptions($verb); @@ -1696,6 +1720,7 @@ public function useSupportedLocalesOnly(bool $useOnly): self return $this; } + #[Override] public function shouldUseSupportedLocalesOnly(): bool { return $this->useSupportedLocalesOnly; diff --git a/system/Router/Router.php b/system/Router/Router.php index aa6526b56061..434addb6852e 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -27,6 +27,7 @@ use Config\App; use Config\Feature; use Config\Routing; +use Override; use ReflectionClass; use Throwable; @@ -152,6 +153,7 @@ class Router implements RouterInterface /** * Stores a reference to the RouteCollection object. */ + #[Override] public function __construct(RouteCollectionInterface $routes, ?Request $request = null) { $config = config(App::class); @@ -203,6 +205,7 @@ public function __construct(RouteCollectionInterface $routes, ?Request $request * @throws PageNotFoundException * @throws RedirectException */ + #[Override] public function handle(?string $uri = null) { // If we cannot find a URI to match against, then set it to root (`/`). @@ -272,6 +275,7 @@ public function getFilters(): array * * @return Closure|string Controller classname or Closure */ + #[Override] public function controllerName() { return $this->translateURIDashes && ! $this->controller instanceof Closure @@ -283,6 +287,7 @@ public function controllerName() * Returns the name of the method to run in the * chosen controller. */ + #[Override] public function methodName(): string { return $this->translateURIDashes @@ -321,6 +326,7 @@ public function get404Override() * during the parsing process as an array, ready to send to * instance->method(...$params). */ + #[Override] public function params(): array { return $this->params; @@ -370,6 +376,7 @@ public function getMatchedRouteOptions() * * @param string $page */ + #[Override] public function setIndexPage($page): self { $this->indexPage = $page; diff --git a/system/Security/Security.php b/system/Security/Security.php index 444da3a2b5ca..b9be078b5dd1 100644 --- a/system/Security/Security.php +++ b/system/Security/Security.php @@ -25,6 +25,7 @@ use Config\Cookie as CookieConfig; use Config\Security as SecurityConfig; use JsonException; +use Override; use SensitiveParameter; /** @@ -109,6 +110,7 @@ public function __construct(protected SecurityConfig $config) } } + #[Override] public function verify(RequestInterface $request): static { $method = $request->getMethod(); @@ -164,6 +166,7 @@ private function verifyToken(IncomingRequest $request): void log_message('info', 'CSRF token verified.'); } + #[Override] public function getHash(): ?string { return $this->config->tokenRandomize && isset($this->hash) @@ -171,21 +174,25 @@ public function getHash(): ?string : $this->hash; } + #[Override] public function getTokenName(): string { return $this->config->tokenName; } + #[Override] public function getHeaderName(): string { return $this->config->headerName; } + #[Override] public function getCookieName(): string { return $this->config->cookieName; } + #[Override] public function shouldRedirect(): bool { return $this->config->redirect; diff --git a/system/Session/Handlers/ArrayHandler.php b/system/Session/Handlers/ArrayHandler.php index 5d8bf6188567..61d3ab4aedc4 100644 --- a/system/Session/Handlers/ArrayHandler.php +++ b/system/Session/Handlers/ArrayHandler.php @@ -13,6 +13,8 @@ namespace CodeIgniter\Session\Handlers; +use Override; + /** * Session handler using static array for storage. * Intended only for use during testing. @@ -30,6 +32,7 @@ class ArrayHandler extends BaseHandler * @param string $path The path where to store/retrieve the session. * @param string $name The session name. */ + #[Override] public function open($path, $name): bool { return true; @@ -40,6 +43,7 @@ public function open($path, $name): bool * * @param string $id The session ID. */ + #[Override] public function read($id): string { return ''; @@ -51,6 +55,7 @@ public function read($id): string * @param string $id The session ID. * @param string $data The encoded session data. */ + #[Override] public function write($id, $data): bool { return true; @@ -59,6 +64,7 @@ public function write($id, $data): bool /** * Closes the current session. */ + #[Override] public function close(): bool { return true; @@ -69,6 +75,7 @@ public function close(): bool * * @param string $id The session ID being destroyed. */ + #[Override] public function destroy($id): bool { return true; @@ -80,6 +87,7 @@ public function destroy($id): bool * @param int $max_lifetime Sessions that have not updated * for the last max_lifetime seconds will be removed. */ + #[Override] public function gc(int $max_lifetime): int { return 1; diff --git a/system/Session/Handlers/Database/MySQLiHandler.php b/system/Session/Handlers/Database/MySQLiHandler.php index 453ebb1f3cc9..f99b340b9394 100644 --- a/system/Session/Handlers/Database/MySQLiHandler.php +++ b/system/Session/Handlers/Database/MySQLiHandler.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Session\Handlers\Database; use CodeIgniter\Session\Handlers\DatabaseHandler; +use Override; /** * Session handler for MySQLi @@ -23,6 +24,7 @@ class MySQLiHandler extends DatabaseHandler /** * Lock the session. */ + #[Override] protected function lockSession(string $sessionID): bool { $arg = md5($sessionID . ($this->matchIP ? '_' . $this->ipAddress : '')); @@ -38,6 +40,7 @@ protected function lockSession(string $sessionID): bool /** * Releases the lock, if any. */ + #[Override] protected function releaseLock(): bool { if (! $this->lock) { diff --git a/system/Session/Handlers/Database/PostgreHandler.php b/system/Session/Handlers/Database/PostgreHandler.php index de7732b1b2d5..01df1188004f 100644 --- a/system/Session/Handlers/Database/PostgreHandler.php +++ b/system/Session/Handlers/Database/PostgreHandler.php @@ -15,6 +15,7 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Session\Handlers\DatabaseHandler; +use Override; /** * Session handler for Postgre @@ -26,6 +27,7 @@ class PostgreHandler extends DatabaseHandler * * @return void */ + #[Override] protected function setSelect(BaseBuilder $builder) { $builder->select("encode(data, 'base64') AS data"); @@ -38,6 +40,7 @@ protected function setSelect(BaseBuilder $builder) * * @return false|string */ + #[Override] protected function decodeData($data) { return base64_decode(rtrim($data), true); @@ -46,6 +49,7 @@ protected function decodeData($data) /** * Prepare data to insert/update */ + #[Override] protected function prepareData(string $data): string { return '\x' . bin2hex($data); @@ -57,6 +61,7 @@ protected function prepareData(string $data): string * @param int $max_lifetime Sessions that have not updated * for the last max_lifetime seconds will be removed. */ + #[Override] public function gc(int $max_lifetime): false|int { $separator = '\''; @@ -68,6 +73,7 @@ public function gc(int $max_lifetime): false|int /** * Lock the session. */ + #[Override] protected function lockSession(string $sessionID): bool { $arg = 'hashtext(' . $this->db->escape($sessionID) . ')' @@ -85,6 +91,7 @@ protected function lockSession(string $sessionID): bool /** * Releases the lock, if any. */ + #[Override] protected function releaseLock(): bool { if (! $this->lock) { diff --git a/system/Session/Handlers/DatabaseHandler.php b/system/Session/Handlers/DatabaseHandler.php index a432a3f67b7e..bb796b9adba4 100644 --- a/system/Session/Handlers/DatabaseHandler.php +++ b/system/Session/Handlers/DatabaseHandler.php @@ -18,6 +18,7 @@ use CodeIgniter\Session\Exceptions\SessionException; use Config\Database; use Config\Session as SessionConfig; +use Override; /** * Base database session handler. @@ -93,6 +94,7 @@ public function __construct(SessionConfig $config, string $ipAddress) * @param string $path The path where to store/retrieve the session * @param string $name The session name */ + #[Override] public function open($path, $name): bool { if ($this->db->connID === false) { @@ -107,6 +109,7 @@ public function open($path, $name): bool * * @param string $id The session ID */ + #[Override] public function read($id): false|string { if ($this->lockSession($id) === false) { @@ -173,6 +176,7 @@ protected function decodeData($data) * @param string $id The session ID. * @param string $data The encoded session data. */ + #[Override] public function write($id, $data): bool { if ($this->lock === false) { @@ -233,6 +237,7 @@ protected function prepareData(string $data): string /** * Closes the current session. */ + #[Override] public function close(): bool { return ($this->lock && ! $this->releaseLock()) ? $this->fail() : true; @@ -243,6 +248,7 @@ public function close(): bool * * @param string $id The session ID being destroyed. */ + #[Override] public function destroy($id): bool { if ($this->lock) { @@ -274,6 +280,7 @@ public function destroy($id): bool * * @return false|int Returns the number of deleted sessions on success, or false on failure. */ + #[Override] public function gc(int $max_lifetime): false|int { return $this->db->table($this->table)->where( @@ -286,6 +293,7 @@ public function gc(int $max_lifetime): false|int /** * Releases the lock, if any. */ + #[Override] protected function releaseLock(): bool { if (! $this->lock) { diff --git a/system/Session/Handlers/FileHandler.php b/system/Session/Handlers/FileHandler.php index e49cbbf749db..e731c7c9e186 100644 --- a/system/Session/Handlers/FileHandler.php +++ b/system/Session/Handlers/FileHandler.php @@ -16,6 +16,7 @@ use CodeIgniter\I18n\Time; use CodeIgniter\Session\Exceptions\SessionException; use Config\Session as SessionConfig; +use Override; /** * Session handler using file system for storage. @@ -90,6 +91,7 @@ public function __construct(SessionConfig $config, string $ipAddress) * * @throws SessionException */ + #[Override] public function open($path, $name): bool { if (! is_dir($path) && ! mkdir($path, 0700, true)) { @@ -113,6 +115,7 @@ public function open($path, $name): bool * * @param string $id The session ID. */ + #[Override] public function read($id): false|string { // This might seem weird, but PHP 5.6 introduced session_reset(), @@ -169,6 +172,7 @@ public function read($id): false|string * @param string $id The session ID. * @param string $data The encoded session data. */ + #[Override] public function write($id, $data): bool { // If the two IDs don't match, we have a session_regenerate_id() call @@ -216,6 +220,7 @@ public function write($id, $data): bool /** * Closes the current session. */ + #[Override] public function close(): bool { if (is_resource($this->fileHandle)) { @@ -234,6 +239,7 @@ public function close(): bool * * @param string $id The session ID being destroyed. */ + #[Override] public function destroy($id): bool { if ($this->close()) { @@ -259,6 +265,7 @@ public function destroy($id): bool * @param int $max_lifetime Sessions that have not updated * for the last max_lifetime seconds will be removed. */ + #[Override] public function gc(int $max_lifetime): false|int { if (! is_dir($this->savePath) || ($directory = opendir($this->savePath)) === false) { diff --git a/system/Session/Handlers/MemcachedHandler.php b/system/Session/Handlers/MemcachedHandler.php index c22f03c786c8..b4723de3b12d 100644 --- a/system/Session/Handlers/MemcachedHandler.php +++ b/system/Session/Handlers/MemcachedHandler.php @@ -18,6 +18,7 @@ use CodeIgniter\Session\PersistsConnection; use Config\Session as SessionConfig; use Memcached; +use Override; /** * Session handler using Memcached for persistence. @@ -83,6 +84,7 @@ public function __construct(SessionConfig $config, string $ipAddress) * @param string $path The path where to store/retrieve the session. * @param string $name The session name. */ + #[Override] public function open($path, $name): bool { if ($this->hasPersistentConnection()) { @@ -160,6 +162,7 @@ public function open($path, $name): bool * * @param string $id The session ID. */ + #[Override] public function read($id): false|string { if (isset($this->memcached) && $this->lockSession($id)) { @@ -181,6 +184,7 @@ public function read($id): false|string * @param string $id The session ID. * @param string $data The encoded session data. */ + #[Override] public function write($id, $data): bool { if (! isset($this->memcached)) { @@ -218,6 +222,7 @@ public function write($id, $data): bool /** * Closes the current session. */ + #[Override] public function close(): bool { if (isset($this->memcached)) { @@ -236,6 +241,7 @@ public function close(): bool * * @param string $id The session ID being destroyed. */ + #[Override] public function destroy($id): bool { if (isset($this->memcached, $this->lockKey)) { @@ -253,6 +259,7 @@ public function destroy($id): bool * @param int $max_lifetime Sessions that have not updated * for the last max_lifetime seconds will be removed. */ + #[Override] public function gc(int $max_lifetime): int { return 1; @@ -263,6 +270,7 @@ public function gc(int $max_lifetime): int * * @param string $sessionID Session ID. */ + #[Override] protected function lockSession(string $sessionID): bool { if (isset($this->lockKey)) { @@ -307,6 +315,7 @@ protected function lockSession(string $sessionID): bool /** * Releases a previously acquired lock. */ + #[Override] protected function releaseLock(): bool { if (isset($this->memcached, $this->lockKey) && $this->lock) { diff --git a/system/Session/Handlers/RedisHandler.php b/system/Session/Handlers/RedisHandler.php index c3c1ee909b8c..d46417e21e6c 100644 --- a/system/Session/Handlers/RedisHandler.php +++ b/system/Session/Handlers/RedisHandler.php @@ -17,6 +17,7 @@ use CodeIgniter\Session\Exceptions\SessionException; use CodeIgniter\Session\PersistsConnection; use Config\Session as SessionConfig; +use Override; use Redis; use RedisException; @@ -172,6 +173,7 @@ protected function setSavePath(): void * * @throws RedisException */ + #[Override] public function open($path, $name): bool { if ($this->savePath === [] || $this->savePath === '') { @@ -225,6 +227,7 @@ public function open($path, $name): bool * * @throws RedisException */ + #[Override] public function read($id): false|string { if (isset($this->redis) && $this->lockSession($id)) { @@ -254,6 +257,7 @@ public function read($id): false|string * * @throws RedisException */ + #[Override] public function write($id, $data): bool { if (! isset($this->redis)) { @@ -292,6 +296,7 @@ public function write($id, $data): bool /** * Closes the current session. */ + #[Override] public function close(): bool { if (isset($this->redis)) { @@ -318,6 +323,7 @@ public function close(): bool * * @throws RedisException */ + #[Override] public function destroy($id): bool { if (isset($this->redis, $this->lockKey)) { @@ -339,6 +345,7 @@ public function destroy($id): bool * @param int $max_lifetime Sessions that have not updated * for the last max_lifetime seconds will be removed. */ + #[Override] public function gc(int $max_lifetime): int { return 1; @@ -351,6 +358,7 @@ public function gc(int $max_lifetime): int * * @throws RedisException */ + #[Override] protected function lockSession(string $sessionID): bool { $lockKey = $this->keyPrefix . $sessionID . ':lock'; @@ -403,6 +411,7 @@ protected function lockSession(string $sessionID): bool * * @throws RedisException */ + #[Override] protected function releaseLock(): bool { if (isset($this->redis, $this->lockKey) && $this->lock) { diff --git a/system/Session/Session.php b/system/Session/Session.php index 1f38b4699e9e..97945773286b 100644 --- a/system/Session/Session.php +++ b/system/Session/Session.php @@ -17,6 +17,7 @@ use CodeIgniter\I18n\Time; use Config\Cookie as CookieConfig; use Config\Session as SessionConfig; +use Override; use Psr\Log\LoggerAwareTrait; use SessionHandlerInterface; @@ -234,6 +235,7 @@ protected function initVars() } } + #[Override] public function regenerate(bool $destroy = false) { $_SESSION['__ci_last_regenerate'] = Time::now()->getTimestamp(); @@ -262,6 +264,7 @@ private function removeOldSessionCookie(): void } } + #[Override] public function destroy() { if (service('environment')->isTesting()) { @@ -285,6 +288,7 @@ public function close() session_write_close(); } + #[Override] public function set($data, $value = null) { $data = is_array($data) ? $data : [$data => $value]; @@ -298,6 +302,7 @@ public function set($data, $value = null) } } + #[Override] public function get(?string $key = null) { if (! isset($_SESSION) || $_SESSION === []) { @@ -322,6 +327,7 @@ public function get(?string $key = null) return $userdata; } + #[Override] public function has(string $key): bool { return isset($_SESSION[$key]); @@ -342,6 +348,7 @@ public function push(string $key, array $data) } } + #[Override] public function remove($key) { $key = is_array($key) ? $key : [$key]; @@ -396,12 +403,14 @@ public function __isset(string $key): bool return isset($_SESSION[$key]) || $key === 'session_id'; } + #[Override] public function setFlashdata($data, $value = null) { $this->set($data, $value); $this->markAsFlashdata(is_array($data) ? array_keys($data) : $data); } + #[Override] public function getFlashdata(?string $key = null) { $_SESSION['__ci_vars'] ??= []; @@ -425,11 +434,13 @@ public function getFlashdata(?string $key = null) return $flashdata; } + #[Override] public function keepFlashdata($key) { $this->markAsFlashdata($key); } + #[Override] public function markAsFlashdata($key): bool { $keys = is_array($key) ? $key : [$key]; @@ -446,6 +457,7 @@ public function markAsFlashdata($key): bool return true; } + #[Override] public function unmarkFlashdata($key) { if (! isset($_SESSION['__ci_vars'])) { @@ -467,6 +479,7 @@ public function unmarkFlashdata($key) } } + #[Override] public function getFlashKeys(): array { if (! isset($_SESSION['__ci_vars'])) { @@ -484,12 +497,14 @@ public function getFlashKeys(): array return $keys; } + #[Override] public function setTempdata($data, $value = null, int $ttl = 300) { $this->set($data, $value); $this->markAsTempdata($data, $ttl); } + #[Override] public function getTempdata(?string $key = null) { $_SESSION['__ci_vars'] ??= []; @@ -513,12 +528,14 @@ public function getTempdata(?string $key = null) return $tempdata; } + #[Override] public function removeTempdata(string $key) { $this->unmarkTempdata($key); unset($_SESSION[$key]); } + #[Override] public function markAsTempdata($key, int $ttl = 300): bool { $time = Time::now()->getTimestamp(); @@ -550,6 +567,7 @@ public function markAsTempdata($key, int $ttl = 300): bool return true; } + #[Override] public function unmarkTempdata($key) { if (! isset($_SESSION['__ci_vars'])) { @@ -571,6 +589,7 @@ public function unmarkTempdata($key) } } + #[Override] public function getTempKeys(): array { if (! isset($_SESSION['__ci_vars'])) { diff --git a/system/Test/CIUnitTestCase.php b/system/Test/CIUnitTestCase.php index e2367780b2b4..b61d5832cdfa 100644 --- a/system/Test/CIUnitTestCase.php +++ b/system/Test/CIUnitTestCase.php @@ -33,6 +33,7 @@ use Config\Services; use Config\Session; use Exception; +use Override; use PHPUnit\Framework\TestCase; /** @@ -230,6 +231,7 @@ abstract class CIUnitTestCase extends TestCase /** * Load the helpers. */ + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -237,6 +239,7 @@ public static function setUpBeforeClass(): void helper(['url', 'test']); } + #[Override] protected function setUp(): void { parent::setUp(); @@ -258,6 +261,7 @@ protected function setUp(): void $this->callTraitMethods('setUp'); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/system/Test/Constraints/SeeInDatabase.php b/system/Test/Constraints/SeeInDatabase.php index ef795274ed5d..12f53d65ed83 100644 --- a/system/Test/Constraints/SeeInDatabase.php +++ b/system/Test/Constraints/SeeInDatabase.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Test\Constraints; use CodeIgniter\Database\ConnectionInterface; +use Override; use PHPUnit\Framework\Constraint\Constraint; class SeeInDatabase extends Constraint @@ -54,6 +55,7 @@ public function __construct(ConnectionInterface $db, array $data) * * @param mixed $table */ + #[Override] protected function matches($table): bool { return $this->db->table($table)->where($this->data)->countAllResults() > 0; @@ -64,6 +66,7 @@ protected function matches($table): bool * * @param mixed $table */ + #[Override] protected function failureDescription($table): string { return sprintf( @@ -115,6 +118,7 @@ protected function getAdditionalInfo(string $table): string * * @param int $options */ + #[Override] public function toString(bool $exportObjects = false, $options = 0): string { return json_encode($this->data, $options); diff --git a/system/Test/Filters/CITestStreamFilter.php b/system/Test/Filters/CITestStreamFilter.php index fa91aa69ef55..1f2b8bafa6c6 100644 --- a/system/Test/Filters/CITestStreamFilter.php +++ b/system/Test/Filters/CITestStreamFilter.php @@ -13,6 +13,7 @@ namespace CodeIgniter\Test\Filters; +use Override; use php_user_filter; /** @@ -51,6 +52,7 @@ class CITestStreamFilter extends php_user_filter * * @param-out int $consumed */ + #[Override] public function filter($in, $out, &$consumed, $closing): int { while ($bucket = stream_bucket_make_writeable($in)) { diff --git a/system/Test/Mock/MockCURLRequest.php b/system/Test/Mock/MockCURLRequest.php index c525db589649..c991f84dda3b 100644 --- a/system/Test/Mock/MockCURLRequest.php +++ b/system/Test/Mock/MockCURLRequest.php @@ -16,6 +16,7 @@ use CodeIgniter\HTTP\CURLRequest; use CodeIgniter\HTTP\Exceptions\HTTPException; use CodeIgniter\HTTP\URI; +use Override; /** * Simply allows us to not actually call cURL during the @@ -88,6 +89,7 @@ public function setCurlErrors(array $curlErrors) /** * @param array $curlOptions */ + #[Override] protected function sendRequest(array $curlOptions = []): string { $this->response = clone $this->responseOrig; @@ -103,6 +105,7 @@ protected function sendRequest(array $curlOptions = []): string return $this->outputs !== [] ? array_shift($this->outputs) : $this->output; } + #[Override] protected function sleep(float $seconds): void { $this->sleeps[] = $seconds; diff --git a/system/Test/Mock/MockCache.php b/system/Test/Mock/MockCache.php index 93caf0fdad20..0445a4af9137 100644 --- a/system/Test/Mock/MockCache.php +++ b/system/Test/Mock/MockCache.php @@ -19,6 +19,7 @@ use CodeIgniter\Cache\LockStoreInterface; use CodeIgniter\Cache\LockStoreProviderInterface; use CodeIgniter\I18n\Time; +use Override; use PHPUnit\Framework\Assert; class MockCache extends BaseHandler implements CacheInterface, LockStoreProviderInterface @@ -49,6 +50,7 @@ class MockCache extends BaseHandler implements CacheInterface, LockStoreProvider /** * Takes care of any handler-specific setup that must be done. */ + #[Override] public function initialize(): void { } @@ -60,6 +62,7 @@ public function initialize(): void * * @return bool|null */ + #[Override] public function get(string $key): mixed { $key = static::validateKey($key, $this->prefix); @@ -72,6 +75,7 @@ public function get(string $key): mixed * * @return bool|null */ + #[Override] public function remember(string $key, callable|int $ttl, Closure $callback): mixed { $value = $this->get($key); @@ -101,6 +105,7 @@ public function remember(string $key, callable|int $ttl, Closure $callback): mix * @param mixed $value the data to save * @param int $ttl Time To Live, in seconds (default 60) */ + #[Override] public function save(string $key, $value, int $ttl = 60): bool { if ($this->bypass) { @@ -118,6 +123,7 @@ public function save(string $key, $value, int $ttl = 60): bool /** * Deletes a specific item from the cache store. */ + #[Override] public function delete(string $key): bool { $key = static::validateKey($key, $this->prefix); @@ -134,6 +140,7 @@ public function delete(string $key): bool /** * Deletes items from the cache store matching a given pattern. */ + #[Override] public function deleteMatching(string $pattern): int { $count = 0; @@ -151,6 +158,7 @@ public function deleteMatching(string $pattern): int /** * Performs atomic incrementation of a raw stored value. */ + #[Override] public function increment(string $key, int $offset = 1): bool { $key = static::validateKey($key, $this->prefix); @@ -168,6 +176,7 @@ public function increment(string $key, int $offset = 1): bool /** * Performs atomic decrementation of a raw stored value. */ + #[Override] public function decrement(string $key, int $offset = 1): bool { $key = static::validateKey($key, $this->prefix); @@ -186,6 +195,7 @@ public function decrement(string $key, int $offset = 1): bool /** * Will delete all items in the entire cache. */ + #[Override] public function clean(): true { $this->cache = []; @@ -203,6 +213,7 @@ public function clean(): true * * @return list Keys currently present in the store */ + #[Override] public function getCacheInfo(): array { return array_keys($this->cache); @@ -215,6 +226,7 @@ public function getCacheInfo(): array * otherwise, array with the 'expire' key for * absolute epoch expiry (or null). */ + #[Override] public function getMetaData(string $key): ?array { // Misses return null @@ -233,11 +245,13 @@ public function getMetaData(string $key): ?array /** * Determine if the driver is supported on this system. */ + #[Override] public function isSupported(): bool { return true; } + #[Override] public function lockStore(): LockStoreInterface { return $this->lockStore ??= new MockLockStore(); diff --git a/system/Test/Mock/MockConnection.php b/system/Test/Mock/MockConnection.php index 18a3eda45d63..7320cfd9e9d7 100644 --- a/system/Test/Mock/MockConnection.php +++ b/system/Test/Mock/MockConnection.php @@ -18,6 +18,7 @@ use CodeIgniter\Database\BaseResult; use CodeIgniter\Database\Query; use CodeIgniter\Database\TableName; +use Override; use stdClass; /** @@ -76,6 +77,7 @@ public function shouldReturn(string $method, $return) * * @todo BC set $queryClass default as null in 4.1 */ + #[Override] public function query(string $sql, $binds = null, bool $setEscapeFlags = true, string $queryClass = '') { /** @var class-string $queryClass */ @@ -121,6 +123,7 @@ public function query(string $sql, $binds = null, bool $setEscapeFlags = true, s * * @return false|object|resource */ + #[Override] public function connect(bool $persistent = false) { $return = $this->returnValues['connect'] ?? true; @@ -138,6 +141,7 @@ public function connect(bool $persistent = false) * Keep or establish the connection if no queries have been sent for * a length of time exceeding the server's idle timeout. */ + #[Override] public function reconnect(): bool { return true; @@ -148,6 +152,7 @@ public function reconnect(): bool * * @return bool */ + #[Override] public function setDatabase(string $databaseName) { $this->database = $databaseName; @@ -158,6 +163,7 @@ public function setDatabase(string $databaseName) /** * Returns a string containing the version of the database being used. */ + #[Override] public function getVersion(): string { return CodeIgniter::CI_VERSION; @@ -168,6 +174,7 @@ public function getVersion(): string * * @return false|object|resource */ + #[Override] protected function execute(string $sql) { return $this->returnValues['execute']; @@ -176,6 +183,7 @@ protected function execute(string $sql) /** * Returns the total number of rows affected by this query. */ + #[Override] public function affectedRows(): int { return 1; @@ -186,6 +194,7 @@ public function affectedRows(): int * * @return array{code: int, message: string} */ + #[Override] public function error(): array { return [ @@ -194,6 +203,7 @@ public function error(): array ]; } + #[Override] public function insertID(): int { return 0; @@ -204,6 +214,7 @@ public function insertID(): int * * @param string|null $tableName If $tableName is provided will return only this table if exists. */ + #[Override] protected function _listTables(bool $constrainByPrefix = false, ?string $tableName = null): string { return ''; @@ -214,6 +225,7 @@ protected function _listTables(bool $constrainByPrefix = false, ?string $tableNa * * @param string|TableName $table */ + #[Override] protected function _listColumns($table = ''): string { return ''; @@ -222,6 +234,7 @@ protected function _listColumns($table = ''): string /** * @return list */ + #[Override] protected function _fieldData(string $table): array { return []; @@ -230,6 +243,7 @@ protected function _fieldData(string $table): array /** * @return array */ + #[Override] protected function _indexData(string $table): array { return []; @@ -238,6 +252,7 @@ protected function _indexData(string $table): array /** * @return array */ + #[Override] protected function _foreignKeyData(string $table): array { return []; @@ -248,6 +263,7 @@ protected function _foreignKeyData(string $table): array * * @return void */ + #[Override] protected function _close() { } @@ -255,6 +271,7 @@ protected function _close() /** * Begin Transaction */ + #[Override] protected function _transBegin(): bool { return true; @@ -263,6 +280,7 @@ protected function _transBegin(): bool /** * Commit Transaction */ + #[Override] protected function _transCommit(): bool { return true; @@ -271,6 +289,7 @@ protected function _transCommit(): bool /** * Rollback Transaction */ + #[Override] protected function _transRollback(): bool { return true; diff --git a/system/Test/Mock/MockEmail.php b/system/Test/Mock/MockEmail.php index 222e77007c22..09de42702e30 100644 --- a/system/Test/Mock/MockEmail.php +++ b/system/Test/Mock/MockEmail.php @@ -15,6 +15,7 @@ use CodeIgniter\Email\Email; use CodeIgniter\Events\Events; +use Override; class MockEmail extends Email { @@ -25,6 +26,7 @@ class MockEmail extends Email */ public $returnValue = true; + #[Override] public function send($autoClear = true) { if ($this->returnValue) { diff --git a/system/Test/Mock/MockInputOutput.php b/system/Test/Mock/MockInputOutput.php index 6f6b49674d5e..d3fefe5f7984 100644 --- a/system/Test/Mock/MockInputOutput.php +++ b/system/Test/Mock/MockInputOutput.php @@ -18,6 +18,7 @@ use CodeIgniter\Exceptions\LogicException; use CodeIgniter\Test\Filters\CITestStreamFilter; use CodeIgniter\Test\PhpStreamWrapper; +use Override; final class MockInputOutput extends InputOutput { @@ -131,6 +132,7 @@ private function removeStreamFilters(): void $this->priorFilterState = null; } + #[Override] public function input(?string $prefix = null): string { if ($this->inputs === []) { @@ -163,11 +165,13 @@ public function input(?string $prefix = null): string /** * Whether the scripted answers have run out, so that a scripted empty answer before the last stays an empty line. */ + #[Override] public function isAtEnd(): bool { return $this->inputs === []; } + #[Override] public function fwrite($handle, string $string): void { $this->addStreamFilters(); diff --git a/system/Test/Mock/MockLanguage.php b/system/Test/Mock/MockLanguage.php index 3102bb91755b..5102e9ab4a56 100644 --- a/system/Test/Mock/MockLanguage.php +++ b/system/Test/Mock/MockLanguage.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Test\Mock; use CodeIgniter\Language\Language; +use Override; /** * @phpstan-import-type LoadedStrings from Language @@ -52,6 +53,7 @@ public function setData(string $file, array $data, ?string $locale = null) * * @return LoadedStrings */ + #[Override] protected function requireFile(string $path): array { return $this->data ?? []; diff --git a/system/Test/Mock/MockLockStore.php b/system/Test/Mock/MockLockStore.php index a59042db806c..db1cff0c31a5 100644 --- a/system/Test/Mock/MockLockStore.php +++ b/system/Test/Mock/MockLockStore.php @@ -15,6 +15,7 @@ use CodeIgniter\Cache\LockStoreInterface; use CodeIgniter\I18n\Time; +use Override; class MockLockStore implements LockStoreInterface { @@ -23,6 +24,7 @@ class MockLockStore implements LockStoreInterface */ private array $locks = []; + #[Override] public function acquireLock(string $key, string $owner, int $ttl): bool { if ($this->getLockOwner($key) !== null) { @@ -37,6 +39,7 @@ public function acquireLock(string $key, string $owner, int $ttl): bool return true; } + #[Override] public function releaseLock(string $key, string $owner): bool { if ($this->getLockOwner($key) !== $owner) { @@ -48,6 +51,7 @@ public function releaseLock(string $key, string $owner): bool return true; } + #[Override] public function forceReleaseLock(string $key): bool { unset($this->locks[$key]); @@ -55,6 +59,7 @@ public function forceReleaseLock(string $key): bool return true; } + #[Override] public function refreshLock(string $key, string $owner, int $ttl): bool { if ($this->getLockOwner($key) !== $owner) { @@ -66,6 +71,7 @@ public function refreshLock(string $key, string $owner, int $ttl): bool return true; } + #[Override] public function getLockOwner(string $key): ?string { if (! isset($this->locks[$key])) { diff --git a/system/Test/Mock/MockResult.php b/system/Test/Mock/MockResult.php index 28147af9cd9e..2ae102c5a3df 100644 --- a/system/Test/Mock/MockResult.php +++ b/system/Test/Mock/MockResult.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Test\Mock; use CodeIgniter\Database\BaseResult; +use Override; use stdClass; /** @@ -21,6 +22,7 @@ */ class MockResult extends BaseResult { + #[Override] public function getFieldCount(): int { return 0; @@ -29,6 +31,7 @@ public function getFieldCount(): int /** * @return array{} */ + #[Override] public function getFieldNames(): array { return []; @@ -37,11 +40,13 @@ public function getFieldNames(): array /** * @return array{} */ + #[Override] public function getFieldData(): array { return []; } + #[Override] public function freeResult() { } @@ -49,6 +54,7 @@ public function freeResult() /** * @return true */ + #[Override] public function dataSeek(int $n = 0) { return true; @@ -57,6 +63,7 @@ public function dataSeek(int $n = 0) /** * @return array{} */ + #[Override] protected function fetchAssoc() { return []; @@ -65,11 +72,13 @@ protected function fetchAssoc() /** * @return object */ + #[Override] protected function fetchObject(string $className = stdClass::class) { return new $className(); } + #[Override] public function getNumRows(): int { return 0; diff --git a/system/Test/Mock/MockSecurity.php b/system/Test/Mock/MockSecurity.php index 072dc548dbe6..3d5e338c253d 100644 --- a/system/Test/Mock/MockSecurity.php +++ b/system/Test/Mock/MockSecurity.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Test\Mock; use CodeIgniter\Security\Security; +use Override; class MockSecurity extends Security { @@ -22,6 +23,7 @@ protected function doSendCookie(): void service('superglobals')->setCookie('csrf_cookie_name', $this->hash); } + #[Override] protected function randomize(string $hash): string { $keyBinary = hex2bin('005513c290126d34d41bf41c5265e0f1'); diff --git a/system/Test/Mock/MockServices.php b/system/Test/Mock/MockServices.php index c71bb612c6a7..cb6e55234fad 100644 --- a/system/Test/Mock/MockServices.php +++ b/system/Test/Mock/MockServices.php @@ -15,6 +15,7 @@ use CodeIgniter\Autoloader\FileLocator; use CodeIgniter\Config\BaseService; +use Override; class MockServices extends BaseService { @@ -36,6 +37,7 @@ public function __construct() // parent::__construct(); } + #[Override] public static function locator(bool $getShared = true) { return new FileLocator(static::autoloader()); diff --git a/system/Test/Mock/MockSession.php b/system/Test/Mock/MockSession.php index b581f81dfafb..6b9130d1975f 100644 --- a/system/Test/Mock/MockSession.php +++ b/system/Test/Mock/MockSession.php @@ -16,6 +16,7 @@ use CodeIgniter\Cookie\Cookie; use CodeIgniter\I18n\Time; use CodeIgniter\Session\Session; +use Override; /** * Class MockSession @@ -40,6 +41,7 @@ class MockSession extends Session * * @return void */ + #[Override] protected function setSaveHandler() { // session_set_save_handler($this->driver, true); @@ -51,6 +53,7 @@ protected function setSaveHandler() * * @return void */ + #[Override] protected function startSession() { // session_start(); @@ -63,6 +66,7 @@ protected function startSession() * * @return void */ + #[Override] protected function setCookie() { $expiration = $this->config->expiration === 0 ? 0 : Time::now()->getTimestamp() + $this->config->expiration; @@ -76,6 +80,7 @@ protected function setCookie() * * @return void */ + #[Override] public function regenerate(bool $destroy = false) { $this->didRegenerate = true; diff --git a/system/Test/Mock/MockUploadedFile.php b/system/Test/Mock/MockUploadedFile.php index dfff9bcc97f9..627c292ec37b 100644 --- a/system/Test/Mock/MockUploadedFile.php +++ b/system/Test/Mock/MockUploadedFile.php @@ -14,12 +14,14 @@ namespace CodeIgniter\Test\Mock; use CodeIgniter\HTTP\Files\UploadedFile; +use Override; /** * An uploaded file for feature tests, using a regular local file as its source. */ class MockUploadedFile extends UploadedFile { + #[Override] public function __construct( string $path, string $originalName, @@ -31,11 +33,13 @@ public function __construct( parent::__construct($path, $originalName, $mimeType ?? '', $size, $error, $clientPath); } + #[Override] public function isValid(): bool { return is_file($this->path) && $this->error === UPLOAD_ERR_OK; } + #[Override] protected function moveFile(string $destination): bool { return rename($this->path, $destination); diff --git a/system/Test/TestLogger.php b/system/Test/TestLogger.php index a13657748e53..5dc5d1a4a867 100644 --- a/system/Test/TestLogger.php +++ b/system/Test/TestLogger.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Test; use CodeIgniter\Log\Logger; +use Override; use Stringable; class TestLogger extends Logger @@ -30,6 +31,7 @@ class TestLogger extends Logger * @param mixed $level * @param string $message */ + #[Override] public function log($level, string|Stringable $message, array $context = []): void { // While this requires duplicate work, we want to ensure diff --git a/system/Throttle/Throttler.php b/system/Throttle/Throttler.php index ce9d673b6f6a..261ca373530b 100644 --- a/system/Throttle/Throttler.php +++ b/system/Throttle/Throttler.php @@ -15,6 +15,7 @@ use CodeIgniter\Cache\CacheInterface; use CodeIgniter\I18n\Time; +use Override; /** * Class Throttler @@ -71,6 +72,7 @@ public function __construct(CacheInterface $cache) * Returns the number of seconds until the next available token will * be released for usage. */ + #[Override] public function getTokenTime(): int { return $this->tokenTime; @@ -91,6 +93,7 @@ public function getTokenTime(): int * @param int $seconds The time it takes the "bucket" to completely refill * @param int $cost The number of tokens this action uses. */ + #[Override] public function check(string $key, int $capacity, int $seconds, int $cost = 1): bool { $tokenName = $this->prefix . $key; diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index 7bdb1228a158..2ff3e684e5b6 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -23,6 +23,7 @@ use CodeIgniter\Input\ValidatedInput; use CodeIgniter\Validation\Exceptions\ValidationException; use CodeIgniter\View\RendererInterface; +use Override; /** * Validator @@ -121,6 +122,7 @@ public function __construct($config, RendererInterface $view) $this->loadRuleSets(); } + #[Override] public function run(?array $data = null, ?string $group = null, $dbGroup = null): bool { if ($data === null) { @@ -225,6 +227,7 @@ private static function getRegex(string $field): string . '\z/'; } + #[Override] public function check($value, $rules, array $errors = [], $dbGroup = null): bool { $this->reset(); @@ -241,6 +244,7 @@ public function check($value, $rules, array $errors = [], $dbGroup = null): bool ); } + #[Override] public function getValidated(): array { return $this->validated; @@ -249,6 +253,7 @@ public function getValidated(): array /** * Returns the actual validated data as a typed input object. */ + #[Override] public function getValidatedInput(): ValidatedInput { return service('inputdatafactory')->createValidated($this->validated); @@ -500,6 +505,7 @@ private function isStringList(array $array): bool * Takes a Request object and grabs the input data to use from its * array values. */ + #[Override] public function withRequest(RequestInterface $request): ValidationInterface { /** @var IncomingRequest $request */ @@ -524,6 +530,7 @@ public function withRequest(RequestInterface $request): ValidationInterface return $this; } + #[Override] public function setRule(string $field, ?string $label, $rules, array $errors = []) { if (! is_array($rules) && ! is_string($rules)) { @@ -546,6 +553,7 @@ public function setRule(string $field, ?string $label, $rules, array $errors = [ return $this; } + #[Override] public function setRules(array $rules, array $errors = []): ValidationInterface { $this->customErrors = $errors; @@ -578,6 +586,7 @@ public function setRules(array $rules, array $errors = []): ValidationInterface return $this; } + #[Override] public function getRules(): array { return $this->rules; @@ -586,6 +595,7 @@ public function getRules(): array /** * Checks to see if the rule for key $field has been set or not. */ + #[Override] public function hasRule(string $field): bool { return array_key_exists($field, $this->rules); @@ -600,6 +610,7 @@ public function hasRule(string $field): bool * * @throws ValidationException If group not found. */ + #[Override] public function getRuleGroup(string $group): array { if (! isset($this->config->{$group})) { @@ -622,6 +633,7 @@ public function getRuleGroup(string $group): array * * @throws ValidationException If group not found. */ + #[Override] public function setRuleGroup(string $group) { $rules = $this->getRuleGroup($group); @@ -638,6 +650,7 @@ public function setRuleGroup(string $group) * * You can also use validation_list_errors() in Form helper. */ + #[Override] public function listErrors(string $template = 'list'): string { if (! array_key_exists($template, $this->config->templates)) { @@ -654,6 +667,7 @@ public function listErrors(string $template = 'list'): string * * You can also use validation_show_error() in Form helper. */ + #[Override] public function showError(string $field, string $template = 'single'): string { if (! array_key_exists($field, $this->getErrors())) { @@ -686,6 +700,7 @@ protected function loadRuleSets() } } + #[Override] public function loadRuleGroup(?string $group = null) { if ($group === null || $group === '') { @@ -812,6 +827,7 @@ private function retrievePlaceholders(string $rule, array $data): array /** * Checks to see if an error exists for the given field. */ + #[Override] public function hasError(string $field): bool { return (bool) preg_grep(self::getRegex($field), array_keys($this->getErrors())); @@ -821,6 +837,7 @@ public function hasError(string $field): bool * Returns the error(s) for a specified $field (or empty string if not * set). */ + #[Override] public function getError(?string $field = null): string { if ($field === null && count($this->rules) === 1) { @@ -849,6 +866,7 @@ public function getError(?string $field = null): string * * @codeCoverageIgnore */ + #[Override] public function getErrors(): array { return $this->errors; @@ -857,6 +875,7 @@ public function getErrors(): array /** * Sets the error for a specific field. Used by custom validation methods. */ + #[Override] public function setError(string $field, string $error): ValidationInterface { $this->errors[$field] = $error; @@ -1063,6 +1082,7 @@ private function collectMissingPaths( * Resets the class to a blank slate. Should be called whenever * you need to process more than one array. */ + #[Override] public function reset(): ValidationInterface { $this->data = []; diff --git a/system/View/Cells/Cell.php b/system/View/Cells/Cell.php index 3c61214bf95f..8ed4d96560a5 100644 --- a/system/View/Cells/Cell.php +++ b/system/View/Cells/Cell.php @@ -15,6 +15,7 @@ use CodeIgniter\Exceptions\LogicException; use CodeIgniter\Traits\PropertiesTrait; +use Override; use ReflectionClass; use Stringable; @@ -126,6 +127,7 @@ final protected function view(?string $view, array $data = []): string /** * Provides capability to render on string casting. */ + #[Override] public function __toString(): string { return $this->render(); diff --git a/system/View/Parser.php b/system/View/Parser.php index 21b3fe47b6e3..0b00e848a5f7 100644 --- a/system/View/Parser.php +++ b/system/View/Parser.php @@ -14,6 +14,7 @@ use CodeIgniter\Autoloader\FileLocatorInterface; use CodeIgniter\View\Exceptions\ViewException; use Config\View as ViewConfig; +use Override; use ParseError; use PhpToken; use Psr\Log\LoggerInterface; @@ -120,6 +121,7 @@ public function __construct( * it might be needed to pass additional info * to other template engines. */ + #[Override] public function render(string $view, ?array $options = null, ?bool $saveData = null): string { $start = microtime(true); @@ -184,6 +186,7 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n * it might be needed to pass additional info * to other template engines. */ + #[Override] public function renderString(string $template, ?array $options = null, ?bool $saveData = null): string { $start = microtime(true); @@ -214,6 +217,7 @@ public function renderString(string $template, ?array $options = null, ?bool $sa * @param 'attr'|'css'|'html'|'js'|'raw'|'url'|null $context The context to escape it for. * If 'raw', no escaping will happen. */ + #[Override] public function setData(array $data = [], ?string $context = null): RendererInterface { if ($context !== null && $context !== '') { diff --git a/system/View/View.php b/system/View/View.php index 6cdef5689c4a..1bfb3d18f3bd 100644 --- a/system/View/View.php +++ b/system/View/View.php @@ -20,6 +20,7 @@ use CodeIgniter\View\Exceptions\ViewException; use Config\Toolbar; use Config\View as ViewConfig; +use Override; use Psr\Log\LoggerInterface; /** @@ -161,6 +162,7 @@ public function __construct( * if false, cleans the data after displaying, * if null, uses the config setting. */ + #[Override] public function render(string $view, ?array $options = null, ?bool $saveData = null): string { $this->renderVars['start'] = microtime(true); @@ -318,6 +320,7 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n * if false, cleans the data after displaying, * if null, uses the config setting. */ + #[Override] public function renderString(string $view, ?array $options = null, ?bool $saveData = null): string { $start = microtime(true); @@ -355,6 +358,7 @@ public function excerpt(string $string, int $length = 20): string * @param 'attr'|'css'|'html'|'js'|'raw'|'url'|null $context The context to escape it for. * If 'raw', no escaping will happen. */ + #[Override] public function setData(array $data = [], ?string $context = null): RendererInterface { if ($context !== null) { @@ -374,6 +378,7 @@ public function setData(array $data = [], ?string $context = null): RendererInte * @param 'attr'|'css'|'html'|'js'|'raw'|'url'|null $context The context to escape it for. * If 'raw', no escaping will happen. */ + #[Override] public function setVar(string $name, $value = null, ?string $context = null): RendererInterface { if ($context !== null) { @@ -389,6 +394,7 @@ public function setVar(string $name, $value = null, ?string $context = null): Re /** * Removes all of the view data from the system. */ + #[Override] public function resetData(): RendererInterface { $this->data = []; diff --git a/tests/system/API/ResponseTraitTest.php b/tests/system/API/ResponseTraitTest.php index 6da0f1d21078..a87e416f9cb8 100644 --- a/tests/system/API/ResponseTraitTest.php +++ b/tests/system/API/ResponseTraitTest.php @@ -34,6 +34,7 @@ use Config\Cookie; use Config\Services; use Exception; +use Override; use PHPUnit\Framework\Attributes\Group; use stdClass; use Tests\Support\API\InvalidTransformer; @@ -49,6 +50,7 @@ final class ResponseTraitTest extends CIUnitTestCase private ?MockResponse $response = null; private ?FormatterInterface $formatter = null; + #[Override] protected function setUp(): void { parent::setUp(); @@ -57,6 +59,7 @@ protected function setUp(): void $this->formatter = new JSONFormatter(); } + #[Override] protected function tearDown(): void { Services::superglobals()->setGetArray([]); diff --git a/tests/system/API/TransformerTest.php b/tests/system/API/TransformerTest.php index 52793c4c00cd..1b76fdf2f639 100644 --- a/tests/system/API/TransformerTest.php +++ b/tests/system/API/TransformerTest.php @@ -20,6 +20,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockAppConfig; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\Group; use stdClass; use Tests\Support\API\ChildTransformer; @@ -31,6 +32,7 @@ #[Group('Others')] final class TransformerTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); @@ -39,6 +41,7 @@ protected function setUp(): void Services::superglobals()->setGetArray([]); } + #[Override] protected function tearDown(): void { Services::superglobals()->setGetArray([]); @@ -73,6 +76,7 @@ private function createMockRequest(string $query = ''): IncomingRequest public function testConstructorWithNoRequest(): void { $transformer = new class () extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return ['id' => 1, 'name' => 'Test']; @@ -89,6 +93,7 @@ public function testConstructorWithRequest(): void $request = $this->createMockRequest(); $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return ['id' => 1, 'name' => 'Test']; @@ -105,6 +110,7 @@ public function testTransformWithNull(): void $request = $this->createMockRequest(); $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return ['id' => 1, 'name' => 'Test']; @@ -127,6 +133,7 @@ public function testTransformWithEntity(): void }; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -144,6 +151,7 @@ public function testTransformWithArray(): void $data = ['id' => 1, 'name' => 'Test Array']; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -163,6 +171,7 @@ public function testTransformWithObject(): void $object->name = 'Test Object'; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -184,6 +193,7 @@ public function testTransformMany(): void ]; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -203,6 +213,7 @@ public function testTransformManyWithEmptyArray(): void $request = $this->createMockRequest(); $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource ?? []; @@ -220,6 +231,7 @@ public function testLimitFieldsWithNoFieldsParam(): void $data = ['id' => 1, 'name' => 'Test', 'email' => 'test@example.com']; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -237,6 +249,7 @@ public function testLimitFieldsWithFieldsParam(): void $data = ['id' => 1, 'name' => 'Test', 'email' => 'test@example.com']; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -254,6 +267,7 @@ public function testLimitFieldsWithSingleField(): void $data = ['id' => 1, 'name' => 'Test', 'email' => 'test@example.com']; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -271,6 +285,7 @@ public function testLimitFieldsWithSpaces(): void $data = ['id' => 1, 'name' => 'Test', 'email' => 'test@example.com', 'bio' => 'Bio']; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -288,11 +303,13 @@ public function testLimitFieldsWithAllowedFieldsValidation(): void $data = ['id' => 1, 'name' => 'Test', 'email' => 'test@example.com']; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; } + #[Override] protected function getAllowedFields(): array { return ['id', 'name', 'email']; @@ -312,11 +329,13 @@ public function testLimitFieldsThrowsExceptionForInvalidField(): void $data = ['id' => 1, 'name' => 'Test', 'email' => 'test@example.com']; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; } + #[Override] protected function getAllowedFields(): array { return ['id', 'name', 'email']; @@ -332,6 +351,7 @@ public function testInsertIncludesWithNoIncludeParam(): void $data = ['id' => 1, 'name' => 'Test']; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -358,6 +378,7 @@ public function testInsertIncludesWithIncludeParam(): void $data = ['id' => 1, 'name' => 'Test']; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -387,6 +408,7 @@ public function testInsertIncludesWithMultipleIncludes(): void $data = ['id' => 1, 'name' => 'Test']; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -425,6 +447,7 @@ public function testInsertIncludesThrowsExceptionForNonExistentMethod(): void $data = ['id' => 1, 'name' => 'Test']; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -451,11 +474,13 @@ public function testInsertIncludesWithEmptyAllowedIncludes(): void $data = ['id' => 1, 'name' => 'Test']; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; } + #[Override] protected function getAllowedIncludes(): array { return []; @@ -482,6 +507,7 @@ public function testCombinedFieldsAndIncludes(): void $data = ['id' => 1, 'name' => 'Test', 'email' => 'test@example.com']; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -515,6 +541,7 @@ public function testTransformManyWithFieldsFilter(): void ]; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -537,6 +564,7 @@ public function testTransformManyWithIncludes(): void ]; $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -563,6 +591,7 @@ public function testTransformThrowsExceptionForInvalidInclude(): void $request = $this->createMockRequest('include=nonexistent'); $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return ['id' => $resource['id'], 'name' => $resource['name']]; @@ -581,6 +610,7 @@ public function testTransformThrowsExceptionForMissingIncludeMethod(): void $request = $this->createMockRequest('include=invalid'); $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return ['id' => $resource['id'], 'name' => $resource['name']]; @@ -599,6 +629,7 @@ public function testTransformWithMultipleIncludesValidatesAll(): void $request = $this->createMockRequest('include=posts,invalid'); $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return ['id' => $resource['id'], 'name' => $resource['name']]; @@ -625,6 +656,7 @@ public function testTransformWithValidIncludeDoesNotThrowException(): void $request = $this->createMockRequest('include=posts'); $transformer = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return ['id' => $resource['id'], 'name' => $resource['name']]; @@ -758,6 +790,7 @@ public function testDepthIsRestoredAfterIncludeThrows(): void Services::injectMock('request', $request); $throwingRoot = new class ($request) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -777,6 +810,7 @@ public function toArray(mixed $resource): array Services::injectMock('request', $fieldsRequest); $nextRoot = new class ($fieldsRequest) extends BaseTransformer { + #[Override] public function toArray(mixed $resource): array { return $resource; @@ -909,11 +943,13 @@ public function testSparseFieldsetRespectsAllowedFieldsWhitelist(): void $transformer = new class ($request) extends BaseTransformer { protected ?string $resourceType = 'widget'; + #[Override] public function toArray(mixed $resource): array { return $resource; } + #[Override] protected function getAllowedFields(): array { return ['id', 'name']; diff --git a/tests/system/AutoReview/ComposerJsonTest.php b/tests/system/AutoReview/ComposerJsonTest.php index 55f22adb892b..7e100accff89 100644 --- a/tests/system/AutoReview/ComposerJsonTest.php +++ b/tests/system/AutoReview/ComposerJsonTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Exceptions\InvalidArgumentException; use JsonException; +use Override; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; @@ -41,6 +42,7 @@ final class ComposerJsonTest extends TestCase */ private array $starterComposer; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/AutoReview/CreateNewChangelogTest.php b/tests/system/AutoReview/CreateNewChangelogTest.php index 44e386f1858f..69b42e8fe9ea 100644 --- a/tests/system/AutoReview/CreateNewChangelogTest.php +++ b/tests/system/AutoReview/CreateNewChangelogTest.php @@ -13,6 +13,7 @@ namespace CodeIgniter\AutoReview; +use Override; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -27,6 +28,7 @@ final class CreateNewChangelogTest extends TestCase { private string $currentVersion; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/AutoReview/RunRandomTestsTest.php b/tests/system/AutoReview/RunRandomTestsTest.php index 7e979ba93361..93c6584c73c1 100644 --- a/tests/system/AutoReview/RunRandomTestsTest.php +++ b/tests/system/AutoReview/RunRandomTestsTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\AutoReview; use FilesystemIterator; +use Override; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -31,6 +32,7 @@ final class RunRandomTestsTest extends TestCase private string $project; private string $timeoutCommand; + #[Override] protected function setUp(): void { parent::setUp(); @@ -63,6 +65,7 @@ protected function setUp(): void chmod($this->project . '/vendor/bin/phpunit', 0755); } + #[Override] protected function tearDown(): void { if (isset($this->project)) { diff --git a/tests/system/AutoReview/UpdateDocsNavTest.php b/tests/system/AutoReview/UpdateDocsNavTest.php index 837604ee8193..4ae0bf00d720 100644 --- a/tests/system/AutoReview/UpdateDocsNavTest.php +++ b/tests/system/AutoReview/UpdateDocsNavTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\AutoReview; use FilesystemIterator; +use Override; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; @@ -43,6 +44,7 @@ final class UpdateDocsNavTest extends TestCase private string $docs; + #[Override] protected function setUp(): void { parent::setUp(); @@ -60,6 +62,7 @@ protected function setUp(): void } } + #[Override] protected function tearDown(): void { $files = new RecursiveIteratorIterator( diff --git a/tests/system/AutoReview/UpdateUpgradeGuideTest.php b/tests/system/AutoReview/UpdateUpgradeGuideTest.php index 97fb711bc648..cd9ec17d2356 100644 --- a/tests/system/AutoReview/UpdateUpgradeGuideTest.php +++ b/tests/system/AutoReview/UpdateUpgradeGuideTest.php @@ -13,6 +13,7 @@ namespace CodeIgniter\AutoReview; +use Override; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; @@ -27,6 +28,7 @@ final class UpdateUpgradeGuideTest extends TestCase private string $nextVersion; private string $upgradePath; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Autoloader/AutoloaderTest.php b/tests/system/Autoloader/AutoloaderTest.php index 9548dec15cda..9b67540dada8 100644 --- a/tests/system/Autoloader/AutoloaderTest.php +++ b/tests/system/Autoloader/AutoloaderTest.php @@ -20,6 +20,7 @@ use CodeIgniter\Test\ReflectionHelper; use Config\Autoload; use Config\Modules; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; use PHPUnit\Framework\Attributes\RunInSeparateProcess; @@ -41,6 +42,7 @@ final class AutoloaderTest extends CIUnitTestCase */ private Closure $classLoader; + #[Override] protected function setUp(): void { parent::setUp(); @@ -65,6 +67,7 @@ protected function setUp(): void $this->classLoader = self::getPrivateMethodInvoker($this->loader, 'loadInNamespace'); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Autoloader/FileLocatorCachedTest.php b/tests/system/Autoloader/FileLocatorCachedTest.php index 0a5f3a3c586d..5cf6085bebcb 100644 --- a/tests/system/Autoloader/FileLocatorCachedTest.php +++ b/tests/system/Autoloader/FileLocatorCachedTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Cache\FactoriesCache\FileVarExportHandler; use Config\Autoload; use Config\Modules; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Cache\IsolatedCacheTrait; @@ -29,6 +30,7 @@ final class FileLocatorCachedTest extends FileLocatorTest private FileVarExportHandler $handler; + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -36,6 +38,7 @@ public static function setUpBeforeClass(): void self::setUpBeforeClassIsolatedCache(); } + #[Override] public static function tearDownAfterClass(): void { self::tearDownAfterClassIsolatedCache(); @@ -43,6 +46,7 @@ public static function tearDownAfterClass(): void parent::tearDownAfterClass(); } + #[Override] protected function setUp(): void { parent::setUp(); @@ -71,6 +75,7 @@ protected function setUp(): void $this->locator = new FileLocatorCached($fileLocator, $this->handler); } + #[Override] protected function tearDown(): void { $this->locator->__destruct(); diff --git a/tests/system/Autoloader/FileLocatorTest.php b/tests/system/Autoloader/FileLocatorTest.php index 07bca58683fb..1d73478ef7c1 100644 --- a/tests/system/Autoloader/FileLocatorTest.php +++ b/tests/system/Autoloader/FileLocatorTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Autoload; use Config\Modules; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -32,6 +33,7 @@ class FileLocatorTest extends CIUnitTestCase */ protected FileLocatorInterface $locator; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/CLI/AbstractCommandTest.php b/tests/system/CLI/AbstractCommandTest.php index 08e125c8e26b..43fa7e253b79 100644 --- a/tests/system/CLI/AbstractCommandTest.php +++ b/tests/system/CLI/AbstractCommandTest.php @@ -31,6 +31,7 @@ use CodeIgniter\Test\StreamFilterTrait; use Config\App; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\After; use PHPUnit\Framework\Attributes\Before; use PHPUnit\Framework\Attributes\CoversClass; @@ -110,6 +111,7 @@ public function testCommandRequiresCommandAttribute(): void $this->expectExceptionMessageMatches('/^Command class ".*" is missing the CodeIgniter\\\\CLI\\\\Attributes\\\\Command attribute\.$/'); new class (new Commands()) extends AbstractCommand { + #[Override] protected function execute(array $arguments, array $options): int { return EXIT_SUCCESS; diff --git a/tests/system/CLI/AbstractGeneratorCommandTest.php b/tests/system/CLI/AbstractGeneratorCommandTest.php index df8b81a974bc..1c76f745f471 100644 --- a/tests/system/CLI/AbstractGeneratorCommandTest.php +++ b/tests/system/CLI/AbstractGeneratorCommandTest.php @@ -20,6 +20,7 @@ use CodeIgniter\Test\Mock\MockInputOutput; use CodeIgniter\Test\StreamFilterTrait; use Config\Generators; +use Override; use PHPUnit\Framework\Attributes\After; use PHPUnit\Framework\Attributes\Before; use PHPUnit\Framework\Attributes\CoversClass; @@ -495,6 +496,7 @@ private function createClassAndViewGenerator(): AbstractGeneratorCommand return new #[Command(name: 'make:classandview', description: 'Generates a class and a view.', group: 'Fixtures')] #[GeneratorCommand(component: 'Widget', template: 'config.tpl.php')] class (new Commands()) extends AbstractGeneratorCommand { + #[Override] protected function execute(array $arguments, array $options): int { return $this->generateClass() | $this->generateView(Commands::class); diff --git a/tests/system/CLI/BaseCommandTest.php b/tests/system/CLI/BaseCommandTest.php index 6546ea909376..577521f73240 100644 --- a/tests/system/CLI/BaseCommandTest.php +++ b/tests/system/CLI/BaseCommandTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Filters\CITestStreamFilter; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\After; use PHPUnit\Framework\Attributes\Before; use PHPUnit\Framework\Attributes\CoversClass; @@ -42,6 +43,7 @@ protected function resetCli(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); @@ -76,6 +78,7 @@ public function testCallingModernCommand(): void protected $group = 'Fixtures'; protected $name = 'legacy:bridge'; + #[Override] public function run(array $params) { return $this->call('app:about', ['hello', 'foo' => 'provided', 'quux' => null]); diff --git a/tests/system/CLI/CLITest.php b/tests/system/CLI/CLITest.php index 739dd631cb90..003dd1e4b91d 100644 --- a/tests/system/CLI/CLITest.php +++ b/tests/system/CLI/CLITest.php @@ -22,6 +22,7 @@ use CodeIgniter\Test\PhpStreamWrapper; use CodeIgniter\Test\StreamFilterTrait; use ErrorException; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; @@ -35,6 +36,7 @@ final class CLITest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function setUp(): void { parent::setUp(); @@ -45,6 +47,7 @@ protected function setUp(): void CLI::init(); } + #[Override] protected function tearDown(): void { CLI::reset(); diff --git a/tests/system/CLI/ConsoleTest.php b/tests/system/CLI/ConsoleTest.php index 0a99a7daf753..5245338f2780 100644 --- a/tests/system/CLI/ConsoleTest.php +++ b/tests/system/CLI/ConsoleTest.php @@ -25,6 +25,7 @@ use CodeIgniter\Test\Mock\MockCodeIgniter; use CodeIgniter\Test\Mock\MockInputOutput; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -40,6 +41,7 @@ final class ConsoleTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function setUp(): void { parent::setUp(); @@ -55,6 +57,7 @@ protected function setUp(): void $this->app->initialize(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/CLI/ProgressBarTest.php b/tests/system/CLI/ProgressBarTest.php index 84eb49250849..fd6b400c89f0 100644 --- a/tests/system/CLI/ProgressBarTest.php +++ b/tests/system/CLI/ProgressBarTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockInputOutput; +use Override; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; @@ -29,6 +30,7 @@ final class ProgressBarTest extends CIUnitTestCase private MockInputOutput $io; private ProgressBar $bar; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/CLI/PromptTest.php b/tests/system/CLI/PromptTest.php index 0804aac43186..92d9eb2102d8 100644 --- a/tests/system/CLI/PromptTest.php +++ b/tests/system/CLI/PromptTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockInputOutput; use CodeIgniter\Validation\ValidationInterface; +use Override; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -32,6 +33,7 @@ final class PromptTest extends CIUnitTestCase { private MockInputOutput $io; + #[Override] protected function setUp(): void { parent::setUp(); @@ -41,6 +43,7 @@ protected function setUp(): void $this->io = new MockInputOutput(); } + #[Override] protected function tearDown(): void { CLI::reset(); diff --git a/tests/system/CLI/SignalTest.php b/tests/system/CLI/SignalTest.php index ab92a135ebb5..e9046c24809f 100644 --- a/tests/system/CLI/SignalTest.php +++ b/tests/system/CLI/SignalTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Log\Logger; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Commands\Legacy\SignalCommand; use Tests\Support\Commands\Legacy\SignalCommandNoPcntl; @@ -32,6 +33,7 @@ final class SignalTest extends CIUnitTestCase private SignalCommand $command; private Logger $logger; + #[Override] protected function setUp(): void { if (is_windows()) { @@ -53,6 +55,7 @@ protected function setUp(): void $this->command = new SignalCommand($this->logger, service('commands')); } + #[Override] protected function tearDown(): void { CLI::reset(); diff --git a/tests/system/CLI/SignalWindowsTest.php b/tests/system/CLI/SignalWindowsTest.php index f16c782f5475..efc2d51d8bac 100644 --- a/tests/system/CLI/SignalWindowsTest.php +++ b/tests/system/CLI/SignalWindowsTest.php @@ -16,6 +16,7 @@ use Closure; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; use Tests\Support\Commands\Legacy\SignalCommandNoPcntl; @@ -38,6 +39,7 @@ final class SignalWindowsTest extends CIUnitTestCase private SignalCommandWindows $command; + #[Override] protected function setUp(): void { $this->resetServices(); @@ -46,6 +48,7 @@ protected function setUp(): void $this->command = new SignalCommandWindows(service('logger'), service('commands')); } + #[Override] protected function tearDown(): void { CLI::reset(); diff --git a/tests/system/CLI/TerminalTest.php b/tests/system/CLI/TerminalTest.php index 809de47c594b..cebe29d7b2b3 100644 --- a/tests/system/CLI/TerminalTest.php +++ b/tests/system/CLI/TerminalTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\CLI; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -41,6 +42,7 @@ final class TerminalTest extends CIUnitTestCase */ private array $savedHints = []; + #[Override] protected function setUp(): void { parent::setUp(); @@ -56,6 +58,7 @@ protected function setUp(): void } } + #[Override] protected function tearDown(): void { $superglobals = service('superglobals'); diff --git a/tests/system/Cache/CacheFactoryTest.php b/tests/system/Cache/CacheFactoryTest.php index c51dce6830c3..75c80d544cf3 100644 --- a/tests/system/Cache/CacheFactoryTest.php +++ b/tests/system/Cache/CacheFactoryTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Cache\Handlers\DummyHandler; use CodeIgniter\Test\CIUnitTestCase; use Config\Cache; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -28,6 +29,7 @@ final class CacheFactoryTest extends CIUnitTestCase private static string $directory = 'CacheFactory'; private Cache $config; + #[Override] protected function setUp(): void { parent::setUp(); @@ -37,6 +39,7 @@ protected function setUp(): void $this->config->file['storePath'] .= self::$directory; } + #[Override] protected function tearDown(): void { if (is_dir($this->config->file['storePath'])) { diff --git a/tests/system/Cache/FactoriesCacheFileHandlerTest.php b/tests/system/Cache/FactoriesCacheFileHandlerTest.php index 660c476cc799..404fdc66c7b8 100644 --- a/tests/system/Cache/FactoriesCacheFileHandlerTest.php +++ b/tests/system/Cache/FactoriesCacheFileHandlerTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Cache; use Config\Cache; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -22,6 +23,7 @@ #[Group('Others')] final class FactoriesCacheFileHandlerTest extends AbstractFactoriesCacheHandlerTestCase { + #[Override] protected function createFactoriesCache(): void { $this->handler = CacheFactory::getHandler(new Cache(), 'file'); diff --git a/tests/system/Cache/FactoriesCacheFileVarExportHandlerTest.php b/tests/system/Cache/FactoriesCacheFileVarExportHandlerTest.php index c7a9f14e9d94..19578ce09a38 100644 --- a/tests/system/Cache/FactoriesCacheFileVarExportHandlerTest.php +++ b/tests/system/Cache/FactoriesCacheFileVarExportHandlerTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Cache; use CodeIgniter\Cache\FactoriesCache\FileVarExportHandler; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Cache\IsolatedCacheTrait; @@ -25,6 +26,7 @@ final class FactoriesCacheFileVarExportHandlerTest extends AbstractFactoriesCach { use IsolatedCacheTrait; + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -32,6 +34,7 @@ public static function setUpBeforeClass(): void self::setUpBeforeClassIsolatedCache(); } + #[Override] public static function tearDownAfterClass(): void { self::tearDownAfterClassIsolatedCache(); @@ -39,6 +42,7 @@ public static function tearDownAfterClass(): void parent::tearDownAfterClass(); } + #[Override] protected function createFactoriesCache(): void { $this->handler = $this->getIsolatedCacheHandler(); diff --git a/tests/system/Cache/Handlers/ApcuHandlerTest.php b/tests/system/Cache/Handlers/ApcuHandlerTest.php index b08235e7c20f..39480f59352e 100644 --- a/tests/system/Cache/Handlers/ApcuHandlerTest.php +++ b/tests/system/Cache/Handlers/ApcuHandlerTest.php @@ -18,6 +18,7 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\I18n\Time; use Config\Cache; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpExtension; @@ -28,6 +29,7 @@ #[RequiresPhpExtension('apcu')] final class ApcuHandlerTest extends AbstractHandlerTestCase { + #[Override] protected function setUp(): void { parent::setUp(); @@ -39,6 +41,7 @@ protected function setUp(): void $this->handler = CacheFactory::getHandler(new Cache(), 'apcu'); } + #[Override] protected function tearDown(): void { if (isset($this->handler)) { diff --git a/tests/system/Cache/Handlers/DummyHandlerTest.php b/tests/system/Cache/Handlers/DummyHandlerTest.php index 2bdc42b5bd5d..ebeb40717094 100644 --- a/tests/system/Cache/Handlers/DummyHandlerTest.php +++ b/tests/system/Cache/Handlers/DummyHandlerTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Cache\CacheFactory; use CodeIgniter\Test\CIUnitTestCase; use Config\Cache; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class DummyHandlerTest extends CIUnitTestCase { private DummyHandler $handler; + #[Override] protected function setUp(): void { $this->handler = CacheFactory::getHandler(new Cache(), 'dummy'); diff --git a/tests/system/Cache/Handlers/FileHandlerTest.php b/tests/system/Cache/Handlers/FileHandlerTest.php index 54199b1307e1..952b96a920ec 100644 --- a/tests/system/Cache/Handlers/FileHandlerTest.php +++ b/tests/system/Cache/Handlers/FileHandlerTest.php @@ -19,6 +19,7 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\I18n\Time; use Config\Cache; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; @@ -32,6 +33,7 @@ final class FileHandlerTest extends AbstractHandlerTestCase private static string $directory = 'FileHandler'; private Cache $config; + #[Override] protected function setUp(): void { parent::setUp(); @@ -51,6 +53,7 @@ protected function setUp(): void $this->handler = CacheFactory::getHandler($this->config, 'file'); } + #[Override] protected function tearDown(): void { parent::tearDown(); @@ -509,6 +512,7 @@ public function testFileHandler(): void $this->assertArrayHasKey('fileperms', $actual); } + #[Override] public function testGetMetaDataMiss(): void { $this->assertNull($this->handler->getMetaData(self::$dummy)); diff --git a/tests/system/Cache/Handlers/MemcachedHandlerTest.php b/tests/system/Cache/Handlers/MemcachedHandlerTest.php index e81c8c9056fe..2f44d012ecf5 100644 --- a/tests/system/Cache/Handlers/MemcachedHandlerTest.php +++ b/tests/system/Cache/Handlers/MemcachedHandlerTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Exceptions\BadMethodCallException; use CodeIgniter\I18n\Time; use Config\Cache; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ #[Group('CacheLive')] final class MemcachedHandlerTest extends AbstractHandlerTestCase { + #[Override] protected function setUp(): void { parent::setUp(); @@ -37,6 +39,7 @@ protected function setUp(): void $this->handler = CacheFactory::getHandler(new Cache(), 'memcached'); } + #[Override] protected function tearDown(): void { if (isset($this->handler)) { @@ -179,6 +182,7 @@ public function testIsSupported(): void $this->assertTrue($this->handler->isSupported()); } + #[Override] public function testGetMetaDataMiss(): void { $this->assertNull($this->handler->getMetaData(self::$dummy)); diff --git a/tests/system/Cache/Handlers/PredisHandlerTest.php b/tests/system/Cache/Handlers/PredisHandlerTest.php index 9f5b63b13309..3e5470af37c3 100644 --- a/tests/system/Cache/Handlers/PredisHandlerTest.php +++ b/tests/system/Cache/Handlers/PredisHandlerTest.php @@ -17,6 +17,7 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\I18n\Time; use Config\Cache; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -27,6 +28,7 @@ final class PredisHandlerTest extends AbstractHandlerTestCase { private Cache $config; + #[Override] protected function setUp(): void { parent::setUp(); @@ -35,6 +37,7 @@ protected function setUp(): void $this->handler = CacheFactory::getHandler($this->config, 'predis'); } + #[Override] protected function tearDown(): void { if (isset($this->handler)) { diff --git a/tests/system/Cache/Handlers/RedisHandlerTest.php b/tests/system/Cache/Handlers/RedisHandlerTest.php index 1f85ecc28349..73fa3ae63d34 100644 --- a/tests/system/Cache/Handlers/RedisHandlerTest.php +++ b/tests/system/Cache/Handlers/RedisHandlerTest.php @@ -17,6 +17,7 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\I18n\Time; use Config\Cache; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -28,6 +29,7 @@ final class RedisHandlerTest extends AbstractHandlerTestCase { private Cache $config; + #[Override] protected function setUp(): void { parent::setUp(); @@ -40,6 +42,7 @@ protected function setUp(): void $this->handler = CacheFactory::getHandler($this->config, 'redis'); } + #[Override] protected function tearDown(): void { if (isset($this->handler)) { diff --git a/tests/system/Cache/ResponseCacheTest.php b/tests/system/Cache/ResponseCacheTest.php index 73cc3e5a7a78..44662a50f46e 100644 --- a/tests/system/Cache/ResponseCacheTest.php +++ b/tests/system/Cache/ResponseCacheTest.php @@ -27,6 +27,7 @@ use Config\App; use Config\Cache; use ErrorException; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; @@ -37,6 +38,7 @@ #[Group('Others')] final class ResponseCacheTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/CodeIgniterTest.php b/tests/system/CodeIgniterTest.php index 67fd9d88d4e2..5dc422f79ff6 100644 --- a/tests/system/CodeIgniterTest.php +++ b/tests/system/CodeIgniterTest.php @@ -32,6 +32,7 @@ use Config\Modules; use Config\Routing; use Kint\Renderer\RichRenderer; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -51,6 +52,7 @@ final class CodeIgniterTest extends CIUnitTestCase { private CodeIgniter $codeigniter; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { @@ -68,6 +70,7 @@ protected function setUp(): void $response->pretend(); } + #[Override] protected function tearDown(): void { parent::tearDown(); @@ -1363,6 +1366,7 @@ public function testGatherOutputCalledOnceWhenControllerReturnsResponse(): void $codeigniter = new class ($config) extends MockCodeIgniter { public int $gatherOutputCalls = 0; + #[Override] protected function gatherOutput($returned = null): void { $this->gatherOutputCalls++; diff --git a/tests/system/Commands/Cache/ClearCacheTest.php b/tests/system/Commands/Cache/ClearCacheTest.php index 9323c3c4737a..0e4fc4fc8f8c 100644 --- a/tests/system/Commands/Cache/ClearCacheTest.php +++ b/tests/system/Commands/Cache/ClearCacheTest.php @@ -23,6 +23,7 @@ use CodeIgniter\Test\StreamFilterTrait; use Config\Cache; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Cache\IsolatedCacheTrait; @@ -37,6 +38,7 @@ final class ClearCacheTest extends CIUnitTestCase private Cache $config; + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -44,6 +46,7 @@ public static function setUpBeforeClass(): void self::setUpBeforeClassIsolatedCache(); } + #[Override] public static function tearDownAfterClass(): void { self::tearDownAfterClassIsolatedCache(); @@ -51,6 +54,7 @@ public static function tearDownAfterClass(): void parent::tearDownAfterClass(); } + #[Override] protected function setUp(): void { parent::setUp(); @@ -74,6 +78,7 @@ protected function setUp(): void Services::injectMock('cache', $handler); } + #[Override] protected function tearDown(): void { $this->config->handler = 'file'; diff --git a/tests/system/Commands/Cache/InfoCacheTest.php b/tests/system/Commands/Cache/InfoCacheTest.php index 0898df6f5ffd..f365989b5dcb 100644 --- a/tests/system/Commands/Cache/InfoCacheTest.php +++ b/tests/system/Commands/Cache/InfoCacheTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Test\StreamFilterTrait; use Config\Cache; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -31,6 +32,7 @@ final class InfoCacheTest extends CIUnitTestCase private Cache $config; + #[Override] protected function setUp(): void { parent::setUp(); @@ -51,6 +53,7 @@ protected function setUp(): void Services::injectMock('cache', $handler); } + #[Override] protected function tearDown(): void { $this->config->handler = 'file'; diff --git a/tests/system/Commands/ConfigurableSortImportsTest.php b/tests/system/Commands/ConfigurableSortImportsTest.php index ac68028a3279..b3bdd0e93f8e 100644 --- a/tests/system/Commands/ConfigurableSortImportsTest.php +++ b/tests/system/Commands/ConfigurableSortImportsTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -25,6 +26,7 @@ final class ConfigurableSortImportsTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -32,6 +34,7 @@ public static function setUpBeforeClass(): void service('superglobals')->unsetServer('CODEIGNITER_SCREAM_DEPRECATIONS'); } + #[Override] public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); diff --git a/tests/system/Commands/CreateDatabaseTest.php b/tests/system/Commands/CreateDatabaseTest.php index 88c978c94316..e68ba4fd6e7b 100644 --- a/tests/system/Commands/CreateDatabaseTest.php +++ b/tests/system/Commands/CreateDatabaseTest.php @@ -21,6 +21,7 @@ use CodeIgniter\Test\Mock\MockInputOutput; use CodeIgniter\Test\StreamFilterTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -35,6 +36,7 @@ final class CreateDatabaseTest extends CIUnitTestCase private BaseConnection $connection; + #[Override] protected function setUp(): void { $this->connection = Database::connect(null, false); @@ -45,6 +47,7 @@ protected function setUp(): void $this->dropDatabase(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Database/MigrateStatusTest.php b/tests/system/Commands/Database/MigrateStatusTest.php index c32d2a58b706..cdd0495fba8c 100644 --- a/tests/system/Commands/Database/MigrateStatusTest.php +++ b/tests/system/Commands/Database/MigrateStatusTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\DatabaseTestTrait; use CodeIgniter\Test\StreamFilterTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -32,6 +33,7 @@ final class MigrateStatusTest extends CIUnitTestCase private string $migrationNamespace = 'Tests\\Support\\MigrationTestMigrations'; private string $migrationNamespacePath = SUPPORTPATH . 'MigrationTestMigrations/'; + #[Override] protected function setUp(): void { $this->resetServices(); @@ -47,6 +49,7 @@ protected function setUp(): void CLI::init(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Database/ShowTableInfoMockIOTest.php b/tests/system/Commands/Database/ShowTableInfoMockIOTest.php index 82b213450b5a..234c76a2fc71 100644 --- a/tests/system/Commands/Database/ShowTableInfoMockIOTest.php +++ b/tests/system/Commands/Database/ShowTableInfoMockIOTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\DatabaseTestTrait; use CodeIgniter\Test\Mock\MockInputOutput; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -30,6 +31,7 @@ final class ShowTableInfoMockIOTest extends CIUnitTestCase protected $migrateOnce = true; + #[Override] protected function setUp(): void { parent::setUp(); @@ -42,6 +44,7 @@ protected function setUp(): void CLI::init(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Database/ShowTableInfoTest.php b/tests/system/Commands/Database/ShowTableInfoTest.php index 7ca76014c33b..e1b61b8df06d 100644 --- a/tests/system/Commands/Database/ShowTableInfoTest.php +++ b/tests/system/Commands/Database/ShowTableInfoTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\DatabaseTestTrait; use CodeIgniter\Test\StreamFilterTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; @@ -32,6 +33,7 @@ final class ShowTableInfoTest extends CIUnitTestCase protected $seed = CITestSeeder::class; + #[Override] protected function setUp(): void { parent::setUp(); @@ -42,6 +44,7 @@ protected function setUp(): void CLI::init(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/DatabaseCommandsTest.php b/tests/system/Commands/DatabaseCommandsTest.php index 577b6abb9604..b42979bc75dd 100644 --- a/tests/system/Commands/DatabaseCommandsTest.php +++ b/tests/system/Commands/DatabaseCommandsTest.php @@ -22,6 +22,7 @@ use CodeIgniter\Test\Mock\MockInputOutput; use CodeIgniter\Test\StreamFilterTrait; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; @@ -36,6 +37,7 @@ final class DatabaseCommandsTest extends CIUnitTestCase use DatabaseTestTrait; use StreamFilterTrait; + #[Override] protected function tearDown(): void { command('migrate:rollback'); diff --git a/tests/system/Commands/Encryption/GenerateKeyTest.php b/tests/system/Commands/Encryption/GenerateKeyTest.php index 8dc655b3b419..e33ff4026b39 100644 --- a/tests/system/Commands/Encryption/GenerateKeyTest.php +++ b/tests/system/Commands/Encryption/GenerateKeyTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockInputOutput; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; @@ -36,6 +37,7 @@ final class GenerateKeyTest extends CIUnitTestCase private string $envPath; private string $backupEnvPath; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { @@ -54,6 +56,7 @@ protected function setUp(): void $this->resetEnvironment(); } + #[Override] protected function tearDown(): void { if (is_file($this->envPath)) { diff --git a/tests/system/Commands/Encryption/RotateKeyTest.php b/tests/system/Commands/Encryption/RotateKeyTest.php index d575c8785d40..262627ca7906 100644 --- a/tests/system/Commands/Encryption/RotateKeyTest.php +++ b/tests/system/Commands/Encryption/RotateKeyTest.php @@ -20,6 +20,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockInputOutput; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; @@ -39,6 +40,7 @@ final class RotateKeyTest extends CIUnitTestCase private string $envPath; private string $backupEnvPath; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { @@ -57,6 +59,7 @@ protected function setUp(): void $this->resetEnvironment(); } + #[Override] protected function tearDown(): void { if (is_file($this->envPath)) { diff --git a/tests/system/Commands/Generators/CellGeneratorTest.php b/tests/system/Commands/Generators/CellGeneratorTest.php index fa562e6de947..5bdcca97e950 100644 --- a/tests/system/Commands/Generators/CellGeneratorTest.php +++ b/tests/system/Commands/Generators/CellGeneratorTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockInputOutput; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -28,6 +29,7 @@ final class CellGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function setUp(): void { parent::setUp(); @@ -35,6 +37,7 @@ protected function setUp(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Generators/CommandGeneratorTest.php b/tests/system/Commands/Generators/CommandGeneratorTest.php index be679c3c701d..bd7068384069 100644 --- a/tests/system/Commands/Generators/CommandGeneratorTest.php +++ b/tests/system/Commands/Generators/CommandGeneratorTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockInputOutput; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -28,6 +29,7 @@ final class CommandGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function setUp(): void { parent::setUp(); @@ -35,6 +37,7 @@ protected function setUp(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Generators/ConfigGeneratorTest.php b/tests/system/Commands/Generators/ConfigGeneratorTest.php index 4418f7cf5870..1bbe17d887db 100644 --- a/tests/system/Commands/Generators/ConfigGeneratorTest.php +++ b/tests/system/Commands/Generators/ConfigGeneratorTest.php @@ -16,6 +16,7 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class ConfigGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function setUp(): void { parent::setUp(); @@ -33,6 +35,7 @@ protected function setUp(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Generators/ControllerGeneratorTest.php b/tests/system/Commands/Generators/ControllerGeneratorTest.php index 83777b5ae1b0..3ad954bd1ae5 100644 --- a/tests/system/Commands/Generators/ControllerGeneratorTest.php +++ b/tests/system/Commands/Generators/ControllerGeneratorTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockInputOutput; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -28,6 +29,7 @@ final class ControllerGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function setUp(): void { parent::setUp(); @@ -35,6 +37,7 @@ protected function setUp(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Generators/EntityGeneratorTest.php b/tests/system/Commands/Generators/EntityGeneratorTest.php index 9ed096919e9c..6688524ae3e0 100644 --- a/tests/system/Commands/Generators/EntityGeneratorTest.php +++ b/tests/system/Commands/Generators/EntityGeneratorTest.php @@ -16,6 +16,7 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -31,6 +32,7 @@ private function getUndecoratedBuffer(): string return preg_replace('/\e\[[^m]+m/', '', $this->getStreamFilterBuffer()) ?? ''; } + #[Override] protected function setUp(): void { parent::setUp(); @@ -38,6 +40,7 @@ protected function setUp(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Generators/FilterGeneratorTest.php b/tests/system/Commands/Generators/FilterGeneratorTest.php index 508762247bb4..b86546b61cfc 100644 --- a/tests/system/Commands/Generators/FilterGeneratorTest.php +++ b/tests/system/Commands/Generators/FilterGeneratorTest.php @@ -16,6 +16,7 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -31,6 +32,7 @@ private function getUndecoratedBuffer(): string return preg_replace('/\e\[[^m]+m/', '', $this->getStreamFilterBuffer()) ?? ''; } + #[Override] protected function setUp(): void { parent::setUp(); @@ -38,6 +40,7 @@ protected function setUp(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Generators/FormRequestGeneratorTest.php b/tests/system/Commands/Generators/FormRequestGeneratorTest.php index f82561dc19dc..5fdf22d26520 100644 --- a/tests/system/Commands/Generators/FormRequestGeneratorTest.php +++ b/tests/system/Commands/Generators/FormRequestGeneratorTest.php @@ -16,6 +16,7 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -31,6 +32,7 @@ private function getUndecoratedBuffer(): string return preg_replace('/\e\[[^m]+m/', '', $this->getStreamFilterBuffer()) ?? ''; } + #[Override] protected function setUp(): void { parent::setUp(); @@ -38,6 +40,7 @@ protected function setUp(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Generators/GeneratorsTest.php b/tests/system/Commands/Generators/GeneratorsTest.php index b55864b23f11..06f993ad895c 100644 --- a/tests/system/Commands/Generators/GeneratorsTest.php +++ b/tests/system/Commands/Generators/GeneratorsTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -25,6 +26,7 @@ final class GeneratorsTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Generators/MigrationGeneratorTest.php b/tests/system/Commands/Generators/MigrationGeneratorTest.php index 95b4bda8883f..a03a665fef4c 100644 --- a/tests/system/Commands/Generators/MigrationGeneratorTest.php +++ b/tests/system/Commands/Generators/MigrationGeneratorTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -28,6 +29,7 @@ final class MigrationGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function setUp(): void { parent::setUp(); @@ -35,6 +37,7 @@ protected function setUp(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Generators/ModelGeneratorTest.php b/tests/system/Commands/Generators/ModelGeneratorTest.php index a955438857ff..f5859c11efef 100644 --- a/tests/system/Commands/Generators/ModelGeneratorTest.php +++ b/tests/system/Commands/Generators/ModelGeneratorTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockInputOutput; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -28,6 +29,7 @@ final class ModelGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function setUp(): void { parent::setUp(); @@ -35,6 +37,7 @@ protected function setUp(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Generators/ScaffoldGeneratorTest.php b/tests/system/Commands/Generators/ScaffoldGeneratorTest.php index 1ad83ae859b2..bdad9a944179 100644 --- a/tests/system/Commands/Generators/ScaffoldGeneratorTest.php +++ b/tests/system/Commands/Generators/ScaffoldGeneratorTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockInputOutput; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -29,6 +30,7 @@ final class ScaffoldGeneratorTest extends CIUnitTestCase private const TIMESTAMP = '\d{4}-\d{2}-\d{2}-\d{6}'; + #[Override] protected function setUp(): void { parent::setUp(); @@ -36,6 +38,7 @@ protected function setUp(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Generators/SeederGeneratorTest.php b/tests/system/Commands/Generators/SeederGeneratorTest.php index 43aa6911982e..69b6a139cade 100644 --- a/tests/system/Commands/Generators/SeederGeneratorTest.php +++ b/tests/system/Commands/Generators/SeederGeneratorTest.php @@ -16,6 +16,7 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -31,6 +32,7 @@ private function getUndecoratedBuffer(): string return preg_replace('/\e\[[^m]+m/', '', $this->getStreamFilterBuffer()) ?? ''; } + #[Override] protected function setUp(): void { parent::setUp(); @@ -38,6 +40,7 @@ protected function setUp(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Generators/TestGeneratorTest.php b/tests/system/Commands/Generators/TestGeneratorTest.php index fbb5b2778c1f..d8899eba86ce 100644 --- a/tests/system/Commands/Generators/TestGeneratorTest.php +++ b/tests/system/Commands/Generators/TestGeneratorTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockInputOutput; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -28,6 +29,7 @@ final class TestGeneratorTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function setUp(): void { parent::setUp(); @@ -35,6 +37,7 @@ protected function setUp(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Generators/TransformerGeneratorTest.php b/tests/system/Commands/Generators/TransformerGeneratorTest.php index d1f5eef2cc89..d06de6d4df2e 100644 --- a/tests/system/Commands/Generators/TransformerGeneratorTest.php +++ b/tests/system/Commands/Generators/TransformerGeneratorTest.php @@ -16,6 +16,7 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -31,6 +32,7 @@ private function getUndecoratedBuffer(): string return preg_replace('/\e\[[^m]+m/', '', $this->getStreamFilterBuffer()) ?? ''; } + #[Override] protected function setUp(): void { parent::setUp(); @@ -38,6 +40,7 @@ protected function setUp(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Generators/ValidationGeneratorTest.php b/tests/system/Commands/Generators/ValidationGeneratorTest.php index c5a7f7eb0d5f..8656a9305e52 100644 --- a/tests/system/Commands/Generators/ValidationGeneratorTest.php +++ b/tests/system/Commands/Generators/ValidationGeneratorTest.php @@ -16,6 +16,7 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -31,6 +32,7 @@ private function getUndecoratedBuffer(): string return preg_replace('/\e\[[^m]+m/', '', $this->getStreamFilterBuffer()) ?? ''; } + #[Override] protected function setUp(): void { parent::setUp(); @@ -38,6 +40,7 @@ protected function setUp(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Housekeeping/ClearDebugbarTest.php b/tests/system/Commands/Housekeeping/ClearDebugbarTest.php index 19be1f23fb81..b8680a0b4e19 100644 --- a/tests/system/Commands/Housekeeping/ClearDebugbarTest.php +++ b/tests/system/Commands/Housekeeping/ClearDebugbarTest.php @@ -16,6 +16,7 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; @@ -29,6 +30,7 @@ final class ClearDebugbarTest extends CIUnitTestCase private int $time; + #[Override] protected function setUp(): void { parent::setUp(); @@ -42,6 +44,7 @@ protected function setUp(): void $this->createDummyDebugbarJson(); } + #[Override] protected function tearDown(): void { command('debugbar:clear'); diff --git a/tests/system/Commands/Housekeeping/ClearLogsTest.php b/tests/system/Commands/Housekeeping/ClearLogsTest.php index 95ddbc9213f7..964504ff9b70 100644 --- a/tests/system/Commands/Housekeeping/ClearLogsTest.php +++ b/tests/system/Commands/Housekeeping/ClearLogsTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockInputOutput; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; @@ -31,6 +32,7 @@ final class ClearLogsTest extends CIUnitTestCase private string $date; + #[Override] protected function setUp(): void { parent::setUp(); @@ -47,6 +49,7 @@ protected function setUp(): void $this->createDummyLogFiles(); } + #[Override] protected function tearDown(): void { command('logs:clear --force'); diff --git a/tests/system/Commands/MigrationIntegrationTest.php b/tests/system/Commands/MigrationIntegrationTest.php index 07a477624db0..5677b6981cb0 100644 --- a/tests/system/Commands/MigrationIntegrationTest.php +++ b/tests/system/Commands/MigrationIntegrationTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -28,6 +29,7 @@ final class MigrationIntegrationTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function setUp(): void { $this->resetServices(); @@ -38,6 +40,7 @@ protected function setUp(): void $this->dropTestTables(); } + #[Override] protected function tearDown(): void { service('migrations')->clearHistory(); diff --git a/tests/system/Commands/Translation/LocalizationFinderTest.php b/tests/system/Commands/Translation/LocalizationFinderTest.php index 324c344d0ffe..393c537575f5 100644 --- a/tests/system/Commands/Translation/LocalizationFinderTest.php +++ b/tests/system/Commands/Translation/LocalizationFinderTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\StreamFilterTrait; use Config\App; use Locale; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -37,6 +38,7 @@ final class LocalizationFinderTest extends CIUnitTestCase */ private array $originalSupportedLocales; + #[Override] protected function setUp(): void { parent::setUp(); @@ -53,6 +55,7 @@ protected function setUp(): void $this->clearGeneratedFiles(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Translation/LocalizationSyncTest.php b/tests/system/Commands/Translation/LocalizationSyncTest.php index b0f7080464b8..61613d57da31 100644 --- a/tests/system/Commands/Translation/LocalizationSyncTest.php +++ b/tests/system/Commands/Translation/LocalizationSyncTest.php @@ -20,6 +20,7 @@ use CodeIgniter\Test\StreamFilterTrait; use Config\App; use Locale; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -59,6 +60,7 @@ final class LocalizationSyncTest extends CIUnitTestCase ], ]; + #[Override] protected function setUp(): void { parent::setUp(); @@ -76,6 +78,7 @@ protected function setUp(): void $this->makeLanguageFiles(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Utilities/ConfigCheckTest.php b/tests/system/Commands/Utilities/ConfigCheckTest.php index 81a27cb69021..ebf837bd295c 100644 --- a/tests/system/Commands/Utilities/ConfigCheckTest.php +++ b/tests/system/Commands/Utilities/ConfigCheckTest.php @@ -19,6 +19,7 @@ use Config\App; use Kint\Kint; use Kint\Renderer\CliRenderer; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -29,6 +30,7 @@ final class ConfigCheckTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -39,6 +41,7 @@ public static function setUpBeforeClass(): void CliRenderer::$cli_colors = false; } + #[Override] public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); @@ -49,6 +52,7 @@ public static function tearDownAfterClass(): void CliRenderer::$cli_colors = true; } + #[Override] protected function setUp(): void { parent::setUp(); @@ -57,6 +61,7 @@ protected function setUp(): void CLI::reset(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Utilities/EnvironmentCommandTest.php b/tests/system/Commands/Utilities/EnvironmentCommandTest.php index ca5236f5ff5b..71224691611a 100644 --- a/tests/system/Commands/Utilities/EnvironmentCommandTest.php +++ b/tests/system/Commands/Utilities/EnvironmentCommandTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -30,6 +31,7 @@ final class EnvironmentCommandTest extends CIUnitTestCase private string $envPath = ROOTPATH . '.env'; private string $backupEnvPath = ROOTPATH . '.env.backup'; + #[Override] protected function setUp(): void { parent::setUp(); @@ -41,6 +43,7 @@ protected function setUp(): void Services::injectMock('superglobals', new Superglobals()); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Utilities/FilterCheckTest.php b/tests/system/Commands/Utilities/FilterCheckTest.php index bb6c7759cbd5..995c64cb8cbc 100644 --- a/tests/system/Commands/Utilities/FilterCheckTest.php +++ b/tests/system/Commands/Utilities/FilterCheckTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -25,12 +26,14 @@ final class FilterCheckTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function setUp(): void { $this->resetServices(); parent::setUp(); } + #[Override] protected function tearDown(): void { $this->resetServices(); diff --git a/tests/system/Commands/Utilities/NamespacesTest.php b/tests/system/Commands/Utilities/NamespacesTest.php index 5f9c69182af2..18decd3bb080 100644 --- a/tests/system/Commands/Utilities/NamespacesTest.php +++ b/tests/system/Commands/Utilities/NamespacesTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\ReflectionHelper; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -27,6 +28,7 @@ final class NamespacesTest extends CIUnitTestCase use StreamFilterTrait; use ReflectionHelper; + #[Override] protected function setUp(): void { $this->resetServices(); @@ -34,6 +36,7 @@ protected function setUp(): void parent::setUp(); } + #[Override] protected function tearDown(): void { $this->resetServices(); diff --git a/tests/system/Commands/Utilities/OptimizeTest.php b/tests/system/Commands/Utilities/OptimizeTest.php index 72fb93b07e09..a0f2d2cb0290 100644 --- a/tests/system/Commands/Utilities/OptimizeTest.php +++ b/tests/system/Commands/Utilities/OptimizeTest.php @@ -22,6 +22,7 @@ use CodeIgniter\Test\ReflectionHelper; use CodeIgniter\Test\StreamFilterTrait; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Cache\IsolatedCacheTrait; @@ -38,6 +39,7 @@ final class OptimizeTest extends CIUnitTestCase private string $file = WRITEPATH . 'cache/OptimizeTest_config'; private FileVarExportHandler $handler; + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -45,6 +47,7 @@ public static function setUpBeforeClass(): void self::setUpBeforeClassIsolatedCache(); } + #[Override] public static function tearDownAfterClass(): void { self::tearDownAfterClassIsolatedCache(); @@ -52,6 +55,7 @@ public static function tearDownAfterClass(): void parent::tearDownAfterClass(); } + #[Override] protected function setUp(): void { parent::setUp(); @@ -60,6 +64,7 @@ protected function setUp(): void $this->handler->delete('FileLocatorCache'); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Utilities/PhpIniCheckTest.php b/tests/system/Commands/Utilities/PhpIniCheckTest.php index 63afb42ff872..43f28d7ce87e 100644 --- a/tests/system/Commands/Utilities/PhpIniCheckTest.php +++ b/tests/system/Commands/Utilities/PhpIniCheckTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -25,12 +26,14 @@ final class PhpIniCheckTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function setUp(): void { $this->resetServices(); parent::setUp(); } + #[Override] protected function tearDown(): void { $this->resetServices(); diff --git a/tests/system/Commands/Utilities/PublishCommandTest.php b/tests/system/Commands/Utilities/PublishCommandTest.php index 737b55f7ef0c..967374516f5d 100644 --- a/tests/system/Commands/Utilities/PublishCommandTest.php +++ b/tests/system/Commands/Utilities/PublishCommandTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Publishers\TestPublisher; @@ -26,6 +27,7 @@ final class PublishCommandTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php b/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php index e3e7369ad131..edb86d8ac0e4 100644 --- a/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php +++ b/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php @@ -16,6 +16,7 @@ use CodeIgniter\HTTP\Method; use CodeIgniter\Test\CIUnitTestCase; use Config\Filters; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -24,6 +25,7 @@ #[Group('Others')] final class AutoRouteCollectorTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Commands/Utilities/Routes/FilterFinderTest.php b/tests/system/Commands/Utilities/Routes/FilterFinderTest.php index 80f566feab75..ee98c037235c 100644 --- a/tests/system/Commands/Utilities/Routes/FilterFinderTest.php +++ b/tests/system/Commands/Utilities/Routes/FilterFinderTest.php @@ -29,6 +29,7 @@ use Config\Filters as FiltersConfig; use Config\Modules; use Config\Routing; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -43,6 +44,7 @@ final class FilterFinderTest extends CIUnitTestCase private Response $response; private Modules $moduleConfig; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php b/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php index 06f11f77c495..5a4a658e1687 100644 --- a/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php +++ b/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Routing; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -24,6 +25,7 @@ #[Group('Others')] final class SampleURIGeneratorTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Commands/Utilities/RoutesTest.php b/tests/system/Commands/Utilities/RoutesTest.php index 20bceadc947a..3126cb1d68e0 100644 --- a/tests/system/Commands/Utilities/RoutesTest.php +++ b/tests/system/Commands/Utilities/RoutesTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\StreamFilterTrait; use Config\Feature; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -28,6 +29,7 @@ final class RoutesTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function setUp(): void { $this->resetServices(); @@ -38,6 +40,7 @@ protected function setUp(): void ->setServer('SERVER_NAME', 'example.com'); } + #[Override] protected function tearDown(): void { $this->resetServices(); diff --git a/tests/system/Commands/Worker/WorkerCommandsTest.php b/tests/system/Commands/Worker/WorkerCommandsTest.php index 7e5a494039b4..cb4b994bfcc6 100644 --- a/tests/system/Commands/Worker/WorkerCommandsTest.php +++ b/tests/system/Commands/Worker/WorkerCommandsTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockInputOutput; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -36,6 +37,7 @@ final class WorkerCommandsTest extends CIUnitTestCase 'Caddyfile', ]; + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/CommonFunctionsSendTest.php b/tests/system/CommonFunctionsSendTest.php index 1cf2b7917459..e3cd959b21a8 100644 --- a/tests/system/CommonFunctionsSendTest.php +++ b/tests/system/CommonFunctionsSendTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; use PHPUnit\Framework\Attributes\RunInSeparateProcess; @@ -25,6 +26,7 @@ #[Group('SeparateProcess')] final class CommonFunctionsSendTest extends CIUnitTestCase { + #[Override] #[WithoutErrorHandler] protected function setUp(): void { diff --git a/tests/system/CommonFunctionsTest.php b/tests/system/CommonFunctionsTest.php index 8f80282482da..28bad7a6bab5 100644 --- a/tests/system/CommonFunctionsTest.php +++ b/tests/system/CommonFunctionsTest.php @@ -44,6 +44,7 @@ use Exception; use InvalidArgumentException; use Kint; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -63,6 +64,7 @@ final class CommonFunctionsTest extends CIUnitTestCase private ?App $config = null; private IncomingRequest $request; + #[Override] protected function setUp(): void { unset($_ENV['foo']); diff --git a/tests/system/CommonHelperTest.php b/tests/system/CommonHelperTest.php index 641f56dc8ec4..c3e2410e5cb8 100644 --- a/tests/system/CommonHelperTest.php +++ b/tests/system/CommonHelperTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Files\Exceptions\FileNotFoundException; use CodeIgniter\Test\CIUnitTestCase; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\CoversFunction; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; @@ -39,6 +40,7 @@ final class CommonHelperTest extends CIUnitTestCase SYSTEMPATH . 'Helpers' . DIRECTORY_SEPARATOR . 'foobarbaz_helper.php', ]; + #[Override] protected function setUp(): void { $this->resetServices(); @@ -46,6 +48,7 @@ protected function setUp(): void $this->cleanUpDummyHelpers(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Config/BaseConfigTest.php b/tests/system/Config/BaseConfigTest.php index 31dc1e0c1687..bd3754aadd93 100644 --- a/tests/system/Config/BaseConfigTest.php +++ b/tests/system/Config/BaseConfigTest.php @@ -23,6 +23,7 @@ use EnvIndexConfig; use GrowingEnvConfig; use MergeRegistrarConfig; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; @@ -48,6 +49,7 @@ final class BaseConfigTest extends CIUnitTestCase { private string $fixturesFolder; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { @@ -83,6 +85,7 @@ protected function setUp(): void Services::injectMock('superglobals', new Superglobals()); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Config/DotEnvTest.php b/tests/system/Config/DotEnvTest.php index 732fbeac1cdc..ca0a40ed32dc 100644 --- a/tests/system/Config/DotEnvTest.php +++ b/tests/system/Config/DotEnvTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -34,6 +35,7 @@ final class DotEnvTest extends CIUnitTestCase private ?vfsStreamDirectory $root; private string $fixturesFolder; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { @@ -51,6 +53,7 @@ protected function setUp(): void Services::injectMock('superglobals', new Superglobals()); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Config/FactoriesTest.php b/tests/system/Config/FactoriesTest.php index abaef3997a88..4316b0c0584a 100644 --- a/tests/system/Config/FactoriesTest.php +++ b/tests/system/Config/FactoriesTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\App; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\Attributes\Group; use ReflectionClass; @@ -34,6 +35,7 @@ #[Group('Others')] final class FactoriesTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Config/MergeTest.php b/tests/system/Config/MergeTest.php index 2b3ccf75685a..3630995e4b91 100644 --- a/tests/system/Config/MergeTest.php +++ b/tests/system/Config/MergeTest.php @@ -16,6 +16,7 @@ use Closure; use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\Group; use ReflectionClass; @@ -33,6 +34,7 @@ final class MergeTest extends CIUnitTestCase */ private Closure $applyMerge; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Config/ServicesTest.php b/tests/system/Config/ServicesTest.php index dde873de492b..1691ced3e2d2 100644 --- a/tests/system/Config/ServicesTest.php +++ b/tests/system/Config/ServicesTest.php @@ -55,6 +55,7 @@ use Config\Session as ConfigSession; use Config\WorkerMode; use InvalidArgumentException; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; @@ -73,6 +74,7 @@ final class ServicesTest extends CIUnitTestCase */ private array $original; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { @@ -81,6 +83,7 @@ protected function setUp(): void $this->original = $_SERVER; } + #[Override] protected function tearDown(): void { service('superglobals')->setServerArray($this->original); diff --git a/tests/system/Config/fixtures/CustomEnvHookConfig.php b/tests/system/Config/fixtures/CustomEnvHookConfig.php index a8fee8ae0301..9af698b0fc98 100644 --- a/tests/system/Config/fixtures/CustomEnvHookConfig.php +++ b/tests/system/Config/fixtures/CustomEnvHookConfig.php @@ -18,6 +18,7 @@ class CustomEnvHookConfig extends BaseConfig public string $name = 'default'; public string $hooked = 'default'; + #[Override] protected function getEnvValue(string $property, string $prefix, string $shortPrefix) { if ($property === 'hooked') { diff --git a/tests/system/ControllerTest.php b/tests/system/ControllerTest.php index 5fc137d80df3..6aa86f181068 100644 --- a/tests/system/ControllerTest.php +++ b/tests/system/ControllerTest.php @@ -23,6 +23,7 @@ use CodeIgniter\Validation\Exceptions\ValidationException; use Config\App; use Config\Validation as ValidationConfig; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; use Psr\Log\LoggerInterface; @@ -52,6 +53,7 @@ final class ControllerTest extends CIUnitTestCase private LoggerInterface $logger; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Cookie/CookieStoreTest.php b/tests/system/Cookie/CookieStoreTest.php index 2b8fb9c5032c..5559a9806405 100644 --- a/tests/system/Cookie/CookieStoreTest.php +++ b/tests/system/Cookie/CookieStoreTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Cookie\Exceptions\CookieException; use CodeIgniter\Test\CIUnitTestCase; use DateTimeImmutable; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -38,12 +39,14 @@ final class CookieStoreTest extends CIUnitTestCase */ private array $defaults; + #[Override] protected function setUp(): void { parent::setUp(); $this->defaults = Cookie::setDefaults(); } + #[Override] protected function tearDown(): void { Cookie::setDefaults($this->defaults); diff --git a/tests/system/Cookie/CookieTest.php b/tests/system/Cookie/CookieTest.php index 694c9cde6392..8478f7b2b1ed 100644 --- a/tests/system/Cookie/CookieTest.php +++ b/tests/system/Cookie/CookieTest.php @@ -19,6 +19,7 @@ use Config\Cookie as CookieConfig; use DateTimeImmutable; use DateTimeZone; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -42,12 +43,14 @@ final class CookieTest extends CIUnitTestCase */ private array $defaults; + #[Override] protected function setUp(): void { parent::setUp(); $this->defaults = Cookie::setDefaults(); } + #[Override] protected function tearDown(): void { Cookie::setDefaults($this->defaults); diff --git a/tests/system/DataCaster/EncryptedCastTest.php b/tests/system/DataCaster/EncryptedCastTest.php index c40305579e72..35232a29342b 100644 --- a/tests/system/DataCaster/EncryptedCastTest.php +++ b/tests/system/DataCaster/EncryptedCastTest.php @@ -21,6 +21,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Encryption as EncryptionConfig; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpExtension; use stdClass; @@ -35,6 +36,7 @@ final class EncryptedCastTest extends CIUnitTestCase private const CURRENT_KEY = 'current-encrypted-cast-key'; private const OLD_KEY = 'old-encrypted-cast-key'; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/BaseConnectionTest.php b/tests/system/Database/BaseConnectionTest.php index f16b6dd0a009..695d8413c516 100644 --- a/tests/system/Database/BaseConnectionTest.php +++ b/tests/system/Database/BaseConnectionTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; use ErrorException; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Mock\MockPreparedQuery; @@ -670,6 +671,7 @@ public function testAfterCommitCallbacksRemainQueuedWhenDriverCommitFails(): voi $db = new class ($this->options) extends MockConnection { public int $commitAttempts = 0; + #[Override] protected function _transCommit(): bool { $this->commitAttempts++; @@ -705,6 +707,7 @@ public function testAfterRollbackCallbacksRemainQueuedWhenDriverRollbackFails(): $db = new class ($this->options) extends MockConnection { public int $rollbackAttempts = 0; + #[Override] protected function _transRollback(): bool { $this->rollbackAttempts++; @@ -738,6 +741,7 @@ public function testTransactionReturnsFalseWhenTransactionCannotBegin(): void $callbackRan = false; $db = new class ($this->options) extends MockConnection { + #[Override] protected function _transBegin(): bool { return false; @@ -767,6 +771,7 @@ public function testTransactionRetriesSuppressedRetryableQueryFailure(): void $db = new class ($this->options) extends MockConnection { public int $queries = 0; + #[Override] public function query(string $sql, $binds = null, bool $setEscapeFlags = true, string $queryClass = ''): bool { $this->queries++; @@ -783,6 +788,7 @@ public function query(string $sql, $binds = null, bool $setEscapeFlags = true, s return true; } + #[Override] protected function isRetryableTransactionErrorCode(int|string $code): bool { return $code === 1213; @@ -809,11 +815,13 @@ public function testTransactionRetriesRetryableQueryFailureWhenTransExceptionRol $db = new class ($this->options) extends MockConnection { public int $queries = 0; + #[Override] public function query(string $sql, $binds = null, bool $setEscapeFlags = true, string $queryClass = '') { return BaseConnection::query($sql, $binds, $setEscapeFlags, $queryClass); } + #[Override] protected function execute(string $sql): object { $this->queries++; @@ -825,6 +833,7 @@ protected function execute(string $sql): object return (object) []; } + #[Override] protected function isRetryableTransactionErrorCode(int|string $code): bool { return $code === 1213; @@ -852,6 +861,7 @@ public function testTransactionDoesNotRetrySuppressedNonRetryableQueryFailure(): $db = new class ($this->options) extends MockConnection { public int $queries = 0; + #[Override] public function query(string $sql, $binds = null, bool $setEscapeFlags = true, string $queryClass = ''): bool { $this->queries++; @@ -878,6 +888,7 @@ public function query(string $sql, $binds = null, bool $setEscapeFlags = true, s public function testTransactionRetriesSuppressedRetryablePreparedQueryFailure(): void { $db = new class (array_merge($this->options, ['DBDebug' => false])) extends MockConnection { + #[Override] protected function isRetryableTransactionErrorCode(int|string $code): bool { return $code === 1213; @@ -904,11 +915,13 @@ protected function isRetryableTransactionErrorCode(int|string $code): bool public function testTransactionDoesNotRetryCallbackExceptionWhenRollbackFails(): void { $db = new class ($this->options) extends MockConnection { + #[Override] protected function _transRollback(): bool { return false; } + #[Override] protected function isRetryableTransactionErrorCode(int|string $code): bool { return $code === 1213; @@ -937,6 +950,7 @@ public function testTransactionDoesNotRetrySuppressedQueryFailureWhenRollbackFai $db = new class ($this->options) extends MockConnection { public int $queries = 0; + #[Override] public function query(string $sql, $binds = null, bool $setEscapeFlags = true, string $queryClass = ''): bool { $this->queries++; @@ -945,11 +959,13 @@ public function query(string $sql, $binds = null, bool $setEscapeFlags = true, s return false; } + #[Override] protected function _transRollback(): bool { return false; } + #[Override] protected function isRetryableTransactionErrorCode(int|string $code): bool { return $code === 1213; @@ -988,6 +1004,7 @@ public function testTransactionRunsCallbackWhenTransactionsAreDisabled(): void public function testCallFunctionDoesNotDoublePrefixAlreadyPrefixedName(): void { $db = new class ($this->options) extends MockConnection { + #[Override] protected function getDriverFunctionPrefix(): string { return 'str_'; @@ -1000,6 +1017,7 @@ protected function getDriverFunctionPrefix(): string public function testCallFunctionPrefixesUnprefixedName(): void { $db = new class ($this->options) extends MockConnection { + #[Override] protected function getDriverFunctionPrefix(): string { return 'str_'; diff --git a/tests/system/Database/BaseQueryTest.php b/tests/system/Database/BaseQueryTest.php index 71a7161c5aaa..bf4bb7d737d0 100644 --- a/tests/system/Database/BaseQueryTest.php +++ b/tests/system/Database/BaseQueryTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Database\SQLSRV\Connection as SQLSRVConnection; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Enum\RoleEnum; @@ -32,6 +33,7 @@ final class BaseQueryTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); @@ -381,6 +383,7 @@ public function testNamedBindsAreNotReplacedAfterEscapedValueEndingWithBackslash public function testNamedBindsAreNotReplacedInsideBackslashEscapedValues(): void { $db = new class ([]) extends MockConnection { + #[Override] protected function _escapeString(string $str): string { return addslashes($str); @@ -404,6 +407,7 @@ public function testNamedBindsAreNotReplacedInsidePostgreEscapeStrings(): void // Emulates standard_conforming_strings = on, where only E'...' // strings use backslash escapes. $db = new class ([]) extends PostgreConnection { + #[Override] protected function _escapeString(string $str): string { return $str; @@ -460,6 +464,7 @@ public function testNamedBindsWithPostgreQuotedIdentifierEndingWithBackslash(): // Emulates standard_conforming_strings = off, where a backslash // escapes inside '...' strings but never inside "..." identifiers. $db = new class ([]) extends PostgreConnection { + #[Override] protected function _escapeString(string $str): string { return addcslashes($str, "\\'"); @@ -663,6 +668,7 @@ public function testNamedBindsWithMySQLUtf8DoesNotSkipMultibyteSequences(): void public function testNamedBindsWithPostgreMultibyteCharsets(string $charset, string $char, string $suffix): void { $db = new class (['charset' => $charset]) extends PostgreConnection { + #[Override] protected function _escapeString(string $str): string { return $str; @@ -995,6 +1001,7 @@ public static function provideHighlightQueryKeywords(): iterable private function createBackslashEscapingMySQLiConnection(string $charset): MySQLiConnection { return new class (['charset' => $charset]) extends MySQLiConnection { + #[Override] protected function _escapeString(string $str): string { return addcslashes($str, "\\'"); diff --git a/tests/system/Database/BaseResultTest.php b/tests/system/Database/BaseResultTest.php index aa14f54ec8fb..6873528e8c25 100644 --- a/tests/system/Database/BaseResultTest.php +++ b/tests/system/Database/BaseResultTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Database; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\Group; use stdClass; @@ -53,6 +54,7 @@ public function __construct(array $resultArray, array $resultObject) parent::__construct($connId, $resultId); } + #[Override] public function getFieldCount(): int { return 0; @@ -61,6 +63,7 @@ public function getFieldCount(): int /** * @return list */ + #[Override] public function getFieldNames(): array { return []; @@ -69,15 +72,18 @@ public function getFieldNames(): array /** * @return list */ + #[Override] public function getFieldData(): array { return []; } + #[Override] public function freeResult(): void { } + #[Override] public function dataSeek(int $n = 0): bool { return true; @@ -86,11 +92,13 @@ public function dataSeek(int $n = 0): bool /** * @return array|false|null */ + #[Override] protected function fetchAssoc(): array|bool|null { return false; } + #[Override] protected function fetchObject(string $className = stdClass::class) { return false; diff --git a/tests/system/Database/Builder/AliasTest.php b/tests/system/Database/Builder/AliasTest.php index 571aa1df042a..75c04d01735b 100644 --- a/tests/system/Database/Builder/AliasTest.php +++ b/tests/system/Database/Builder/AliasTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\TableName; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class AliasTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/BaseTest.php b/tests/system/Database/Builder/BaseTest.php index 49f74da2762d..f1e26b4b38ef 100644 --- a/tests/system/Database/Builder/BaseTest.php +++ b/tests/system/Database/Builder/BaseTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class BaseTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/CountTest.php b/tests/system/Database/Builder/CountTest.php index 3331d64802a2..f5312f5454c8 100644 --- a/tests/system/Database/Builder/CountTest.php +++ b/tests/system/Database/Builder/CountTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Database\SQLSRV\Builder as SQLSRVBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -28,6 +29,7 @@ final class CountTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/DeleteTest.php b/tests/system/Database/Builder/DeleteTest.php index 5fb9acb592cf..14300306ef85 100644 --- a/tests/system/Database/Builder/DeleteTest.php +++ b/tests/system/Database/Builder/DeleteTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; use CodeIgniter\Test\Mock\MockQuery; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -29,6 +30,7 @@ final class DeleteTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); @@ -206,6 +208,7 @@ public function testDeleteBatchDoesNotReplaceNamedBindsInsideBatchData(): void public function testDeleteBatchPostgreDoesNotReplaceTablePlaceholderInsideWhereBind(): void { $db = new class (['DBDriver' => 'Postgre']) extends MockConnection { + #[Override] protected function _fieldData(string $table): array { return [ @@ -278,6 +281,7 @@ public function testDeleteBatchEscapesWhereInBinds(): void public function testDeleteBatchPostgreCastsPositionalAndMappedConstraints(): void { $db = new class (['DBDriver' => 'Postgre']) extends MockConnection { + #[Override] protected function _fieldData(string $table): array { return [ diff --git a/tests/system/Database/Builder/DistinctTest.php b/tests/system/Database/Builder/DistinctTest.php index 8d8bc03130ac..7c47f737d4ee 100644 --- a/tests/system/Database/Builder/DistinctTest.php +++ b/tests/system/Database/Builder/DistinctTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class DistinctTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/EmptyTest.php b/tests/system/Database/Builder/EmptyTest.php index c5526a0730a6..5fda8805254f 100644 --- a/tests/system/Database/Builder/EmptyTest.php +++ b/tests/system/Database/Builder/EmptyTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class EmptyTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/ExistsTest.php b/tests/system/Database/Builder/ExistsTest.php index d03f3c2407a4..56ca6107235c 100644 --- a/tests/system/Database/Builder/ExistsTest.php +++ b/tests/system/Database/Builder/ExistsTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; use Config\Feature; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -27,6 +28,7 @@ #[Group('Others')] final class ExistsTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/ExplainTest.php b/tests/system/Database/Builder/ExplainTest.php index 350797a2f3ba..d38941afa00f 100644 --- a/tests/system/Database/Builder/ExplainTest.php +++ b/tests/system/Database/Builder/ExplainTest.php @@ -20,6 +20,7 @@ use CodeIgniter\Database\SQLSRV\Builder as SQLSRVBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -30,6 +31,7 @@ final class ExplainTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/FromTest.php b/tests/system/Database/Builder/FromTest.php index 32308fbce277..9b0d63b19df5 100644 --- a/tests/system/Database/Builder/FromTest.php +++ b/tests/system/Database/Builder/FromTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Database\SQLSRV\Builder as SQLSRVBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -27,6 +28,7 @@ final class FromTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/GetTest.php b/tests/system/Database/Builder/GetTest.php index 11b57525e30c..a3c013361a4c 100644 --- a/tests/system/Database/Builder/GetTest.php +++ b/tests/system/Database/Builder/GetTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; use Config\Feature; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class GetTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/GroupTest.php b/tests/system/Database/Builder/GroupTest.php index e80021ae0411..35050f9f68b9 100644 --- a/tests/system/Database/Builder/GroupTest.php +++ b/tests/system/Database/Builder/GroupTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -28,6 +29,7 @@ final class GroupTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/InsertTest.php b/tests/system/Database/Builder/InsertTest.php index 534a14482fca..2c8e7b0a175b 100644 --- a/tests/system/Database/Builder/InsertTest.php +++ b/tests/system/Database/Builder/InsertTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Enum\StatusEnum; @@ -28,6 +29,7 @@ #[Group('Others')] final class InsertTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/JoinTest.php b/tests/system/Database/Builder/JoinTest.php index 909387cc5a6f..a2a092545f24 100644 --- a/tests/system/Database/Builder/JoinTest.php +++ b/tests/system/Database/Builder/JoinTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Database\SQLSRV\Builder as SQLSRVBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -29,6 +30,7 @@ final class JoinTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/LikeTest.php b/tests/system/Database/Builder/LikeTest.php index c456dbe3da83..a60d3d36b581 100644 --- a/tests/system/Database/Builder/LikeTest.php +++ b/tests/system/Database/Builder/LikeTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -29,6 +30,7 @@ final class LikeTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/LimitTest.php b/tests/system/Database/Builder/LimitTest.php index fbd23d116490..f8b82153fb88 100644 --- a/tests/system/Database/Builder/LimitTest.php +++ b/tests/system/Database/Builder/LimitTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class LimitTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/OrderTest.php b/tests/system/Database/Builder/OrderTest.php index 36cbac106fda..1019bdda74a1 100644 --- a/tests/system/Database/Builder/OrderTest.php +++ b/tests/system/Database/Builder/OrderTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class OrderTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/PrefixTest.php b/tests/system/Database/Builder/PrefixTest.php index ae712eae2d50..38a6cd03df4a 100644 --- a/tests/system/Database/Builder/PrefixTest.php +++ b/tests/system/Database/Builder/PrefixTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class PrefixTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/ReplaceTest.php b/tests/system/Database/Builder/ReplaceTest.php index c0aa754ac9e5..3cee84b19658 100644 --- a/tests/system/Database/Builder/ReplaceTest.php +++ b/tests/system/Database/Builder/ReplaceTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class ReplaceTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/SelectTest.php b/tests/system/Database/Builder/SelectTest.php index 2e8c35b32786..968fe6412cb2 100644 --- a/tests/system/Database/Builder/SelectTest.php +++ b/tests/system/Database/Builder/SelectTest.php @@ -24,6 +24,7 @@ use CodeIgniter\Database\SQLSRV\Builder as SQLSRVBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -35,6 +36,7 @@ final class SelectTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/TruncateTest.php b/tests/system/Database/Builder/TruncateTest.php index 1b9d4199ade0..a688d2b9f428 100644 --- a/tests/system/Database/Builder/TruncateTest.php +++ b/tests/system/Database/Builder/TruncateTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class TruncateTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/UnionTest.php b/tests/system/Database/Builder/UnionTest.php index 9c1cf2f5741f..8c3a2e42ab99 100644 --- a/tests/system/Database/Builder/UnionTest.php +++ b/tests/system/Database/Builder/UnionTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Database\SQLSRV\Connection as SQLSRVConnection; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -25,6 +26,7 @@ #[Group('Others')] final class UnionTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/UpdateTest.php b/tests/system/Database/Builder/UpdateTest.php index 191d7080222b..f06c840968c4 100644 --- a/tests/system/Database/Builder/UpdateTest.php +++ b/tests/system/Database/Builder/UpdateTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; use CodeIgniter\Test\Mock\MockQuery; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -27,6 +28,7 @@ #[Group('Others')] final class UpdateTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); @@ -472,6 +474,7 @@ public function testSetWithAndWithoutEscape(): void public function testUpdateBatchPostgreDoesNotCastEnumAndArrayColumns(): void { $db = new class (['DBDriver' => 'Postgre']) extends MockConnection { + #[Override] protected function _fieldData(string $table): array { return [ @@ -506,6 +509,7 @@ protected function _fieldData(string $table): array public function testUpdateBatchPostgreDoesNotCastSourceSharedByColumnsOfDifferentTypes(): void { $db = new class (['DBDriver' => 'Postgre']) extends MockConnection { + #[Override] protected function _fieldData(string $table): array { return [ diff --git a/tests/system/Database/Builder/WhenTest.php b/tests/system/Database/Builder/WhenTest.php index 5db1d790d381..2a857ecc61e3 100644 --- a/tests/system/Database/Builder/WhenTest.php +++ b/tests/system/Database/Builder/WhenTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use stdClass; @@ -25,6 +26,7 @@ #[Group('Others')] final class WhenTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Builder/WhereTest.php b/tests/system/Database/Builder/WhereTest.php index 249beaed2a81..b58a25f03b69 100644 --- a/tests/system/Database/Builder/WhereTest.php +++ b/tests/system/Database/Builder/WhereTest.php @@ -22,6 +22,7 @@ use DateTime; use Error; use ErrorException; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use stdClass; @@ -34,6 +35,7 @@ #[Group('Others')] final class WhereTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/ConfigTest.php b/tests/system/Database/ConfigTest.php index aae24c18a44b..8e3450130145 100644 --- a/tests/system/Database/ConfigTest.php +++ b/tests/system/Database/ConfigTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\Postgre\Connection as PostgreConnection; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\ReflectionHelper; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -117,6 +118,7 @@ final class ConfigTest extends CIUnitTestCase 'port' => 5432, ]; + #[Override] protected function tearDown(): void { $this->setPrivateProperty(Config::class, 'instances', []); diff --git a/tests/system/Database/ConstraintViolationExceptionTest.php b/tests/system/Database/ConstraintViolationExceptionTest.php index 84efcc253f90..fc0d005978e0 100644 --- a/tests/system/Database/ConstraintViolationExceptionTest.php +++ b/tests/system/Database/ConstraintViolationExceptionTest.php @@ -26,6 +26,7 @@ use CodeIgniter\Database\SQLSRV\Connection as SQLSRVConnection; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -353,6 +354,7 @@ public function __construct(array $params, private readonly string $version) parent::__construct($params); } + #[Override] public function getVersion(): string { return $this->version; diff --git a/tests/system/Database/DatabaseSeederTest.php b/tests/system/Database/DatabaseSeederTest.php index a34f19eda88d..2eb17c3176ab 100644 --- a/tests/system/Database/DatabaseSeederTest.php +++ b/tests/system/Database/DatabaseSeederTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\SeederWithDBGroup; use Tests\Support\Database\Seeds\SeederWithoutDBGroup; @@ -25,6 +26,7 @@ #[Group('DatabaseLive')] final class DatabaseSeederTest extends CIUnitTestCase { + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce1Test.php b/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce1Test.php index 86889e859fff..60ee45a9782e 100644 --- a/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce1Test.php +++ b/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce1Test.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -35,6 +36,7 @@ final class DatabaseTestCaseMigrationOnce1Test extends CIUnitTestCase 'Tests\Support\MigrationTestMigrations', ]; + #[Override] protected function setUp(): void { $forge = Database::forge(); @@ -53,6 +55,7 @@ protected function setUpAddNamespace(): void ); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce2Test.php b/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce2Test.php index 12df06ca89cd..de82a4946d52 100644 --- a/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce2Test.php +++ b/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce2Test.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -35,6 +36,7 @@ final class DatabaseTestCaseMigrationOnce2Test extends CIUnitTestCase 'Tests\Support\MigrationTestMigrations', ]; + #[Override] protected function setUp(): void { $forge = Database::forge(); @@ -53,6 +55,7 @@ protected function setUpAddNamespace(): void ); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Database/DatabaseTestCaseTest.php b/tests/system/Database/DatabaseTestCaseTest.php index 0827f82c1d1f..1643805de599 100644 --- a/tests/system/Database/DatabaseTestCaseTest.php +++ b/tests/system/Database/DatabaseTestCaseTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\AnotherSeeder; use Tests\Support\Database\Seeds\CITestSeeder; @@ -38,6 +39,7 @@ final class DatabaseTestCaseTest extends CIUnitTestCase 'Tests\Support\MigrationTestMigrations', ]; + #[Override] protected function setUp(): void { $forge = Database::forge(); @@ -56,6 +58,7 @@ protected function setUpAddNamespace(): void ); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Database/Forge/DropForeignKeyTest.php b/tests/system/Database/Forge/DropForeignKeyTest.php index 8c2b37e10b2b..1a7ca19b44ce 100644 --- a/tests/system/Database/Forge/DropForeignKeyTest.php +++ b/tests/system/Database/Forge/DropForeignKeyTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Database\Forge; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -27,6 +28,7 @@ final class DropForeignKeyTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Forge/DropKeyAsConstraintTest.php b/tests/system/Database/Forge/DropKeyAsConstraintTest.php index 43e146854b6c..101dbec0de16 100644 --- a/tests/system/Database/Forge/DropKeyAsConstraintTest.php +++ b/tests/system/Database/Forge/DropKeyAsConstraintTest.php @@ -21,6 +21,7 @@ use CodeIgniter\Database\SQLSRV\Forge as SQLSRVForge; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -31,6 +32,7 @@ final class DropKeyAsConstraintTest extends CIUnitTestCase { protected $db; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Forge/SQLSRVForgeTest.php b/tests/system/Database/Forge/SQLSRVForgeTest.php index 3621a3ce024f..86d1ab6ecfc9 100644 --- a/tests/system/Database/Forge/SQLSRVForgeTest.php +++ b/tests/system/Database/Forge/SQLSRVForgeTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Database\SQLSRV\Forge; use CodeIgniter\Database\SQLSRV\Result; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -43,6 +44,7 @@ public function __construct() $this->pretend = true; } + #[Override] public function initialize(): void { } @@ -50,11 +52,13 @@ public function initialize(): void /** * @param array|string|null $binds */ + #[Override] public function query(string $sql, $binds = null, bool $setEscapeFlags = true, string $queryClass = ''): ResultInterface { $this->queries[] = $sql; return new class ($this->connID, $this->resultID) extends Result { + #[Override] public function getRowArray(int $n = 0): array { return ['constraint_name' => 'df_test']; @@ -96,6 +100,7 @@ public function __construct() $this->pretend = true; } + #[Override] public function initialize(): void { } @@ -103,11 +108,13 @@ public function initialize(): void /** * @param array|string|null $binds */ + #[Override] public function query(string $sql, $binds = null, bool $setEscapeFlags = true, string $queryClass = ''): ResultInterface { $this->queries[] = $sql; return new class ($this->connID, $this->resultID) extends Result { + #[Override] public function getResultArray(): array { return []; diff --git a/tests/system/Database/Live/AbstractGetFieldDataTestCase.php b/tests/system/Database/Live/AbstractGetFieldDataTestCase.php index 533e1089c3d6..71debffe69f3 100644 --- a/tests/system/Database/Live/AbstractGetFieldDataTestCase.php +++ b/tests/system/Database/Live/AbstractGetFieldDataTestCase.php @@ -17,6 +17,7 @@ use CodeIgniter\Database\Forge; use CodeIgniter\Test\CIUnitTestCase; use Config\Database; +use Override; use stdClass; abstract class AbstractGetFieldDataTestCase extends CIUnitTestCase @@ -29,6 +30,7 @@ abstract class AbstractGetFieldDataTestCase extends CIUnitTestCase protected Forge $forge; protected string $table = 'test1'; + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -36,6 +38,7 @@ public static function setUpBeforeClass(): void helper('array'); } + #[Override] protected function setUp(): void { parent::setUp(); @@ -50,6 +53,7 @@ protected function setUp(): void */ abstract protected function createForge(): void; + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Database/Live/ConnectTest.php b/tests/system/Database/Live/ConnectTest.php index cf11183d068b..33f60f1bbcf0 100644 --- a/tests/system/Database/Live/ConnectTest.php +++ b/tests/system/Database/Live/ConnectTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -44,6 +45,7 @@ final class ConnectTest extends CIUnitTestCase */ private array $tests = []; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/ConstraintViolationExceptionTest.php b/tests/system/Database/Live/ConstraintViolationExceptionTest.php index e88849c0bf98..53e128ae5207 100644 --- a/tests/system/Database/Live/ConstraintViolationExceptionTest.php +++ b/tests/system/Database/Live/ConstraintViolationExceptionTest.php @@ -21,6 +21,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; @@ -36,6 +37,7 @@ final class ConstraintViolationExceptionTest extends CIUnitTestCase protected $refresh = true; protected $seed = CITestSeeder::class; + #[Override] protected function tearDown(): void { $this->enableDBDebug(); diff --git a/tests/system/Database/Live/DbDebugTest.php b/tests/system/Database/Live/DbDebugTest.php index 8155e9e42db2..e0c73a498672 100644 --- a/tests/system/Database/Live/DbDebugTest.php +++ b/tests/system/Database/Live/DbDebugTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -47,6 +48,7 @@ public function testDBDebugFalse(): void $this->assertFalse($result); } + #[Override] protected function tearDown(): void { $this->enableDBDebug(); diff --git a/tests/system/Database/Live/EscapeTest.php b/tests/system/Database/Live/EscapeTest.php index bf000fbcea66..a610dc016117 100644 --- a/tests/system/Database/Live/EscapeTest.php +++ b/tests/system/Database/Live/EscapeTest.php @@ -18,6 +18,7 @@ use CodeIgniter\I18n\Time; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Enum\RoleEnum; use Tests\Support\Enum\StatusEnum; @@ -33,6 +34,7 @@ final class EscapeTest extends CIUnitTestCase protected $refresh = false; private string $char; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/ExecuteLogMessageFormatTest.php b/tests/system/Database/Live/ExecuteLogMessageFormatTest.php index 0698206c341e..265ca976e1fa 100644 --- a/tests/system/Database/Live/ExecuteLogMessageFormatTest.php +++ b/tests/system/Database/Live/ExecuteLogMessageFormatTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\TestLogger; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -24,6 +25,7 @@ #[Group('DatabaseLive')] final class ExecuteLogMessageFormatTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); @@ -31,6 +33,7 @@ protected function setUp(): void self::setPrivateProperty(TestLogger::class, 'op_logs', []); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Database/Live/ForgeTest.php b/tests/system/Database/Live/ForgeTest.php index 3d599478d34c..abde04be42f5 100644 --- a/tests/system/Database/Live/ForgeTest.php +++ b/tests/system/Database/Live/ForgeTest.php @@ -20,6 +20,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; use stdClass; use Tests\Support\Database\Seeds\CITestSeeder; @@ -36,6 +37,7 @@ final class ForgeTest extends CIUnitTestCase protected $seed = CITestSeeder::class; private Forge $forge; + #[Override] protected function setUp(): void { $this->forge = Database::forge($this->DBGroup); diff --git a/tests/system/Database/Live/MetadataTest.php b/tests/system/Database/Live/MetadataTest.php index 62f96f443acc..9b6cf47388b5 100644 --- a/tests/system/Database/Live/MetadataTest.php +++ b/tests/system/Database/Live/MetadataTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; @@ -34,6 +35,7 @@ final class MetadataTest extends CIUnitTestCase */ private array $expectedTables = []; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/MySQLi/DeadlockTransactionTest.php b/tests/system/Database/Live/MySQLi/DeadlockTransactionTest.php index 433c982a6403..21c67d7a7970 100644 --- a/tests/system/Database/Live/MySQLi/DeadlockTransactionTest.php +++ b/tests/system/Database/Live/MySQLi/DeadlockTransactionTest.php @@ -19,6 +19,7 @@ use Config\Database; use mysqli; use mysqli_driver; +use Override; use PHPUnit\Framework\Attributes\Group; use Throwable; @@ -40,6 +41,7 @@ final class DeadlockTransactionTest extends CIUnitTestCase private ?mysqli $held = null; private ?string $probeTable = null; + #[Override] protected function setUp(): void { $config = config('Database'); @@ -53,6 +55,7 @@ protected function setUp(): void parent::setUp(); } + #[Override] protected function tearDown(): void { $this->releaseDeadlock(); diff --git a/tests/system/Database/Live/MySQLi/FoundRowsTest.php b/tests/system/Database/Live/MySQLi/FoundRowsTest.php index 122af23b24cd..2e67e50fbb2d 100644 --- a/tests/system/Database/Live/MySQLi/FoundRowsTest.php +++ b/tests/system/Database/Live/MySQLi/FoundRowsTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; @@ -38,6 +39,7 @@ final class FoundRowsTest extends CIUnitTestCase protected $refresh = true; protected $seed = CITestSeeder::class; + #[Override] protected function setUp(): void { $config = config('Database'); diff --git a/tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php b/tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php index 98403c46e8a8..2a532c21d438 100644 --- a/tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php +++ b/tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php @@ -15,6 +15,7 @@ use CodeIgniter\Database\Live\AbstractGetFieldDataTestCase; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -23,6 +24,7 @@ #[Group('DatabaseLive')] final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase { + #[Override] protected function createForge(): void { if ($this->db->DBDriver !== 'MySQLi') { @@ -46,6 +48,7 @@ private function isOldMySQL(): bool ); } + #[Override] public function testGetFieldDataDefault(): void { $this->createTableForDefault(); diff --git a/tests/system/Database/Live/MySQLi/NumberNativeTest.php b/tests/system/Database/Live/MySQLi/NumberNativeTest.php index c419cd6e8e01..2f636ea2d2ba 100644 --- a/tests/system/Database/Live/MySQLi/NumberNativeTest.php +++ b/tests/system/Database/Live/MySQLi/NumberNativeTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; @@ -36,6 +37,7 @@ final class NumberNativeTest extends CIUnitTestCase protected $refresh = true; protected $seed = CITestSeeder::class; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/MySQLi/RawSqlTest.php b/tests/system/Database/Live/MySQLi/RawSqlTest.php index a5a2bb9eb614..d7fb74c2d16d 100644 --- a/tests/system/Database/Live/MySQLi/RawSqlTest.php +++ b/tests/system/Database/Live/MySQLi/RawSqlTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\RawSql; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; @@ -29,6 +30,7 @@ final class RawSqlTest extends CIUnitTestCase protected $seed = CITestSeeder::class; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/OCI8/CallStoredProcedureTest.php b/tests/system/Database/Live/OCI8/CallStoredProcedureTest.php index 50a034e36dc2..ed8801d7c115 100644 --- a/tests/system/Database/Live/OCI8/CallStoredProcedureTest.php +++ b/tests/system/Database/Live/OCI8/CallStoredProcedureTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\OCI8\Connection as OCI8Connection; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -28,6 +29,7 @@ final class CallStoredProcedureTest extends CIUnitTestCase protected $refresh = true; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/OCI8/ConnectionTest.php b/tests/system/Database/Live/OCI8/ConnectionTest.php index 2124bc2c7e32..1a30d73d4963 100644 --- a/tests/system/Database/Live/OCI8/ConnectionTest.php +++ b/tests/system/Database/Live/OCI8/ConnectionTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\OCI8\Connection; use CodeIgniter\Test\CIUnitTestCase; use Config\Database as DbConfig; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -30,6 +31,7 @@ final class ConnectionTest extends CIUnitTestCase */ private array $settings = []; + #[Override] protected function setUp(): void { $dbConfig = config(DbConfig::class); diff --git a/tests/system/Database/Live/OCI8/GetFieldDataTestCase.php b/tests/system/Database/Live/OCI8/GetFieldDataTestCase.php index 477bebe50113..6c02b48f0864 100644 --- a/tests/system/Database/Live/OCI8/GetFieldDataTestCase.php +++ b/tests/system/Database/Live/OCI8/GetFieldDataTestCase.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\Live\AbstractGetFieldDataTestCase; use Config\Database; use LogicException; +use Override; use PHPUnit\Framework\Attributes\Group; use stdClass; @@ -25,6 +26,7 @@ #[Group('DatabaseLive')] final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase { + #[Override] protected function createForge(): void { if ($this->db->DBDriver !== 'OCI8') { @@ -51,6 +53,7 @@ private function getFieldMetaData(string $column, string $table): stdClass return $fields[$name]; } + #[Override] public function testGetFieldDataDefault(): void { $this->createTableForDefault(); diff --git a/tests/system/Database/Live/OCI8/LastInsertIDTest.php b/tests/system/Database/Live/OCI8/LastInsertIDTest.php index 0a041fbcd073..628b4dedfc5a 100644 --- a/tests/system/Database/Live/OCI8/LastInsertIDTest.php +++ b/tests/system/Database/Live/OCI8/LastInsertIDTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Database\Query; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; @@ -31,6 +32,7 @@ final class LastInsertIDTest extends CIUnitTestCase protected $refresh = true; protected $seed = CITestSeeder::class; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/Postgre/ConnectTest.php b/tests/system/Database/Live/Postgre/ConnectTest.php index d616a60b968c..d111fc65413d 100644 --- a/tests/system/Database/Live/Postgre/ConnectTest.php +++ b/tests/system/Database/Live/Postgre/ConnectTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Test\CIUnitTestCase; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -24,6 +25,7 @@ #[Group('DatabaseLive')] final class ConnectTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/Postgre/GetFieldDataTestCase.php b/tests/system/Database/Live/Postgre/GetFieldDataTestCase.php index 0adfc036c4c3..03f9c8a75a93 100644 --- a/tests/system/Database/Live/Postgre/GetFieldDataTestCase.php +++ b/tests/system/Database/Live/Postgre/GetFieldDataTestCase.php @@ -15,6 +15,7 @@ use CodeIgniter\Database\Live\AbstractGetFieldDataTestCase; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -23,6 +24,7 @@ #[Group('DatabaseLive')] final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase { + #[Override] protected function createForge(): void { if ($this->db->DBDriver !== 'Postgre') { @@ -32,6 +34,7 @@ protected function createForge(): void $this->forge = Database::forge($this->db); } + #[Override] public function testGetFieldDataDefault(): void { $this->createTableForDefault(); diff --git a/tests/system/Database/Live/Postgre/InsertIDTest.php b/tests/system/Database/Live/Postgre/InsertIDTest.php index 97f749c64804..6cf0f800293a 100644 --- a/tests/system/Database/Live/Postgre/InsertIDTest.php +++ b/tests/system/Database/Live/Postgre/InsertIDTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\Postgre\Connection; use CodeIgniter\Test\CIUnitTestCase; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -24,6 +25,7 @@ #[Group('DatabaseLive')] final class InsertIDTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/PreparedQueryTest.php b/tests/system/Database/Live/PreparedQueryTest.php index 929e43b82573..47eb2fbced8f 100644 --- a/tests/system/Database/Live/PreparedQueryTest.php +++ b/tests/system/Database/Live/PreparedQueryTest.php @@ -22,6 +22,7 @@ use CodeIgniter\Exceptions\BadMethodCallException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; use Tests\Support\Enum\StatusEnum; @@ -37,6 +38,7 @@ final class PreparedQueryTest extends CIUnitTestCase protected $seed = CITestSeeder::class; private ?BasePreparedQuery $query = null; + #[Override] protected function setUp(): void { parent::setUp(); @@ -44,6 +46,7 @@ protected function setUp(): void $this->query = null; } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Database/Live/PretendTest.php b/tests/system/Database/Live/PretendTest.php index b3e6506c1be6..ef8c35027dd3 100644 --- a/tests/system/Database/Live/PretendTest.php +++ b/tests/system/Database/Live/PretendTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\Query; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class PretendTest extends CIUnitTestCase { use DatabaseTestTrait; + #[Override] protected function tearDown(): void { // We share `$this->db` in testing, so we need to restore the state. diff --git a/tests/system/Database/Live/ReconnectDuringTransactionTest.php b/tests/system/Database/Live/ReconnectDuringTransactionTest.php index 280d68d6f034..b8624828cefe 100644 --- a/tests/system/Database/Live/ReconnectDuringTransactionTest.php +++ b/tests/system/Database/Live/ReconnectDuringTransactionTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -28,6 +29,7 @@ final class ReconnectDuringTransactionTest extends CIUnitTestCase protected $migrate = false; + #[Override] protected function setUp(): void { // Dedicated connection so a forced wait_timeout cannot drop the shared one. diff --git a/tests/system/Database/Live/SQLSRV/GetFieldDataTestCase.php b/tests/system/Database/Live/SQLSRV/GetFieldDataTestCase.php index c07566e187df..8d278243b907 100644 --- a/tests/system/Database/Live/SQLSRV/GetFieldDataTestCase.php +++ b/tests/system/Database/Live/SQLSRV/GetFieldDataTestCase.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\Live\AbstractGetFieldDataTestCase; use CodeIgniter\Database\SQLSRV\Connection; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -25,6 +26,7 @@ #[Group('DatabaseLive')] final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase { + #[Override] protected function createForge(): void { if ($this->db->DBDriver !== 'SQLSRV') { @@ -34,6 +36,7 @@ protected function createForge(): void $this->forge = Database::forge($this->db); } + #[Override] public function testGetFieldDataDefault(): void { $this->createTableForDefault(); diff --git a/tests/system/Database/Live/SQLSRV/IncrementTest.php b/tests/system/Database/Live/SQLSRV/IncrementTest.php index c5ea28cd2692..6997758b1cb2 100644 --- a/tests/system/Database/Live/SQLSRV/IncrementTest.php +++ b/tests/system/Database/Live/SQLSRV/IncrementTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\SQLSRV\Builder; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; @@ -30,6 +31,7 @@ final class IncrementTest extends CIUnitTestCase protected $refresh = true; protected $seed = CITestSeeder::class; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/SQLSRV/SelectLockTest.php b/tests/system/Database/Live/SQLSRV/SelectLockTest.php index f2cd5cd0fca5..f60da300be38 100644 --- a/tests/system/Database/Live/SQLSRV/SelectLockTest.php +++ b/tests/system/Database/Live/SQLSRV/SelectLockTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; @@ -29,6 +30,7 @@ final class SelectLockTest extends CIUnitTestCase protected $refresh = true; protected $seed = CITestSeeder::class; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/SQLite3/AlterTableTest.php b/tests/system/Database/Live/SQLite3/AlterTableTest.php index b752399f445a..135cb6b8b136 100644 --- a/tests/system/Database/Live/SQLite3/AlterTableTest.php +++ b/tests/system/Database/Live/SQLite3/AlterTableTest.php @@ -20,6 +20,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpExtension; @@ -42,6 +43,7 @@ final class AlterTableTest extends CIUnitTestCase private Table $table; private Forge $forge; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/SQLite3/ConnectTest.php b/tests/system/Database/Live/SQLite3/ConnectTest.php index 17871de81bf1..33b387d5cfa6 100644 --- a/tests/system/Database/Live/SQLite3/ConnectTest.php +++ b/tests/system/Database/Live/SQLite3/ConnectTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\Test\CIUnitTestCase; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -24,6 +25,7 @@ #[Group('DatabaseLive')] final class ConnectTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/SQLite3/ForgeModifyColumnTest.php b/tests/system/Database/Live/SQLite3/ForgeModifyColumnTest.php index c628b01aea21..87996751e87c 100644 --- a/tests/system/Database/Live/SQLite3/ForgeModifyColumnTest.php +++ b/tests/system/Database/Live/SQLite3/ForgeModifyColumnTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\Forge; use CodeIgniter\Test\CIUnitTestCase; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class ForgeModifyColumnTest extends CIUnitTestCase { private Forge $forge; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/SQLite3/GetFieldDataTestCase.php b/tests/system/Database/Live/SQLite3/GetFieldDataTestCase.php index 9fb6d881f019..e793fd8c3afa 100644 --- a/tests/system/Database/Live/SQLite3/GetFieldDataTestCase.php +++ b/tests/system/Database/Live/SQLite3/GetFieldDataTestCase.php @@ -15,6 +15,7 @@ use CodeIgniter\Database\Live\AbstractGetFieldDataTestCase; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -23,6 +24,7 @@ #[Group('DatabaseLive')] final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase { + #[Override] protected function createForge(): void { if ($this->db->DBDriver !== 'SQLite3') { @@ -38,6 +40,7 @@ protected function createForge(): void $this->forge = Database::forge($config); } + #[Override] public function testGetFieldDataDefault(): void { $this->createTableForDefault(); diff --git a/tests/system/Database/Live/SQLite3/GetForeignKeyDataTest.php b/tests/system/Database/Live/SQLite3/GetForeignKeyDataTest.php index d86c806b37d0..1ff43756b418 100644 --- a/tests/system/Database/Live/SQLite3/GetForeignKeyDataTest.php +++ b/tests/system/Database/Live/SQLite3/GetForeignKeyDataTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -23,6 +24,7 @@ #[Group('DatabaseLive')] final class GetForeignKeyDataTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/SQLite3/GetIndexDataTest.php b/tests/system/Database/Live/SQLite3/GetIndexDataTest.php index 854d247daf22..445c163311af 100644 --- a/tests/system/Database/Live/SQLite3/GetIndexDataTest.php +++ b/tests/system/Database/Live/SQLite3/GetIndexDataTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\SQLite3\Forge; use CodeIgniter\Test\CIUnitTestCase; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; use stdClass; @@ -27,6 +28,7 @@ final class GetIndexDataTest extends CIUnitTestCase { private Forge $forge; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Database/Live/TransactionCallbacksTest.php b/tests/system/Database/Live/TransactionCallbacksTest.php index 2d7a6f0d3f31..a6f270bcc867 100644 --- a/tests/system/Database/Live/TransactionCallbacksTest.php +++ b/tests/system/Database/Live/TransactionCallbacksTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; use RuntimeException; use Tests\Support\Database\Seeds\CITestSeeder; @@ -32,6 +33,7 @@ final class TransactionCallbacksTest extends CIUnitTestCase protected $refresh = true; protected $seed = CITestSeeder::class; + #[Override] protected function setUp(): void { // Reset connection instance. diff --git a/tests/system/Database/Live/TransactionClosureTest.php b/tests/system/Database/Live/TransactionClosureTest.php index a78b2fb429d6..f617340e4452 100644 --- a/tests/system/Database/Live/TransactionClosureTest.php +++ b/tests/system/Database/Live/TransactionClosureTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; use RuntimeException; use Tests\Support\Database\Seeds\CITestSeeder; @@ -34,6 +35,7 @@ final class TransactionClosureTest extends CIUnitTestCase protected $refresh = true; protected $seed = CITestSeeder::class; + #[Override] protected function setUp(): void { // Reset connection instance. diff --git a/tests/system/Database/Live/TransactionDBDebugFalseTest.php b/tests/system/Database/Live/TransactionDBDebugFalseTest.php index 8be00575abed..e7972051b2b2 100644 --- a/tests/system/Database/Live/TransactionDBDebugFalseTest.php +++ b/tests/system/Database/Live/TransactionDBDebugFalseTest.php @@ -13,6 +13,7 @@ namespace CodeIgniter\Database\Live; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -21,6 +22,7 @@ #[Group('DatabaseLive')] final class TransactionDBDebugFalseTest extends TransactionDBDebugTrueTest { + #[Override] protected function setUp(): void { parent::setUp(); @@ -28,6 +30,7 @@ protected function setUp(): void $this->disableDBDebug(); } + #[Override] protected function tearDown(): void { parent::tearDown(); @@ -35,6 +38,7 @@ protected function tearDown(): void $this->enableDBDebug(); } + #[Override] public function testTransStartTransException(): void { $builder = $this->db->table('job'); diff --git a/tests/system/Database/Live/TransactionDBDebugTrueTest.php b/tests/system/Database/Live/TransactionDBDebugTrueTest.php index cbfa6a1ff289..c0fa96fa092d 100644 --- a/tests/system/Database/Live/TransactionDBDebugTrueTest.php +++ b/tests/system/Database/Live/TransactionDBDebugTrueTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; @@ -33,6 +34,7 @@ class TransactionDBDebugTrueTest extends CIUnitTestCase protected $refresh = true; protected $seed = CITestSeeder::class; + #[Override] protected function setUp(): void { // Reset connection instance. diff --git a/tests/system/Database/Live/TransactionTest.php b/tests/system/Database/Live/TransactionTest.php index d36cbf35d677..5d1ff5135a91 100644 --- a/tests/system/Database/Live/TransactionTest.php +++ b/tests/system/Database/Live/TransactionTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; @@ -31,6 +32,7 @@ final class TransactionTest extends CIUnitTestCase protected $refresh = true; protected $seed = CITestSeeder::class; + #[Override] protected function setUp(): void { // Reset connection instance. diff --git a/tests/system/Database/Live/UniqueConstraintViolationTest.php b/tests/system/Database/Live/UniqueConstraintViolationTest.php index 0a436f079b88..f5f84e4a6f2d 100644 --- a/tests/system/Database/Live/UniqueConstraintViolationTest.php +++ b/tests/system/Database/Live/UniqueConstraintViolationTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\Exceptions\UniqueConstraintViolationException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Database\Seeds\CITestSeeder; @@ -30,6 +31,7 @@ final class UniqueConstraintViolationTest extends CIUnitTestCase protected $refresh = true; protected $seed = CITestSeeder::class; + #[Override] protected function tearDown(): void { $this->enableDBDebug(); diff --git a/tests/system/Database/Live/WorkerModeTest.php b/tests/system/Database/Live/WorkerModeTest.php index 276f432758ab..876291ff2110 100644 --- a/tests/system/Database/Live/WorkerModeTest.php +++ b/tests/system/Database/Live/WorkerModeTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Database\Config; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use Override; use PHPUnit\Framework\Attributes\Group; use RuntimeException; @@ -28,6 +29,7 @@ final class WorkerModeTest extends CIUnitTestCase { use DatabaseTestTrait; + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Database/Migrations/MigrationRunnerTest.php b/tests/system/Database/Migrations/MigrationRunnerTest.php index fdf5a56d2037..6091a45f4ec6 100644 --- a/tests/system/Database/Migrations/MigrationRunnerTest.php +++ b/tests/system/Database/Migrations/MigrationRunnerTest.php @@ -25,6 +25,7 @@ use Config\Migrations; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\MigrationTestMigrations\Database\Migrations\Migration_another_migration; use Tests\Support\MigrationTestMigrations\Database\Migrations\Migration_some_migration; @@ -47,6 +48,7 @@ final class MigrationRunnerTest extends CIUnitTestCase private vfsStreamDirectory $root; private Migrations $config; + #[Override] protected function setUp(): void { $this->setUpMethods[] = 'setUpAddNamespace'; @@ -67,6 +69,7 @@ protected function setUpAddNamespace(): void ); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Database/Migrations/MigrationTest.php b/tests/system/Database/Migrations/MigrationTest.php index 90d71db35c15..22d54dccac5c 100644 --- a/tests/system/Database/Migrations/MigrationTest.php +++ b/tests/system/Database/Migrations/MigrationTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\Migration; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -31,10 +32,12 @@ public function testDBGroup(): void $migration = new class () extends Migration { protected $DBGroup = 'tests'; + #[Override] public function up(): void { } + #[Override] public function down(): void { } diff --git a/tests/system/Database/ReconnectLostTransactionTest.php b/tests/system/Database/ReconnectLostTransactionTest.php index eca053ef5b41..ce241d1a7fdc 100644 --- a/tests/system/Database/ReconnectLostTransactionTest.php +++ b/tests/system/Database/ReconnectLostTransactionTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Database\MySQLi\Connection as MySQLiConnection; use CodeIgniter\Database\OCI8\Connection as OCI8Connection; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -28,6 +29,7 @@ final class ReconnectLostTransactionTest extends CIUnitTestCase public function testReconnectClearsTransactionStateWhenInitializeFails(): void { $db = new class (['DBDriver' => 'MySQLi']) extends MySQLiConnection { + #[Override] public function initialize(): never { throw new DatabaseException('database unavailable'); @@ -58,6 +60,7 @@ public function testReconnectRestoresOci8CommitModeWhenTransactionIsLost(): void } $db = new class (['DBDriver' => 'OCI8']) extends OCI8Connection { + #[Override] public function initialize(): void { } diff --git a/tests/system/Database/TableNameTest.php b/tests/system/Database/TableNameTest.php index 99f447879f5d..b87193ef9edb 100644 --- a/tests/system/Database/TableNameTest.php +++ b/tests/system/Database/TableNameTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -23,6 +24,7 @@ #[Group('Others')] final class TableNameTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Debug/ExceptionHandlerTest.php b/tests/system/Debug/ExceptionHandlerTest.php index f7284d54f01c..13db117abdc7 100644 --- a/tests/system/Debug/ExceptionHandlerTest.php +++ b/tests/system/Debug/ExceptionHandlerTest.php @@ -27,6 +27,7 @@ use Config\App; use Config\Exceptions as ExceptionsConfig; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use stdClass; @@ -42,6 +43,7 @@ final class ExceptionHandlerTest extends CIUnitTestCase private ExceptionHandler $handler; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Debug/ExceptionsTest.php b/tests/system/Debug/ExceptionsTest.php index 84f77c5721b4..515cd49879ea 100644 --- a/tests/system/Debug/ExceptionsTest.php +++ b/tests/system/Debug/ExceptionsTest.php @@ -20,6 +20,7 @@ use CodeIgniter\Test\ReflectionHelper; use Config\Exceptions as ExceptionsConfig; use ErrorException; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -32,6 +33,7 @@ final class ExceptionsTest extends CIUnitTestCase private Exceptions $exception; + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -39,6 +41,7 @@ public static function setUpBeforeClass(): void service('superglobals')->unsetServer('CODEIGNITER_SCREAM_DEPRECATIONS'); } + #[Override] public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); @@ -46,6 +49,7 @@ public static function tearDownAfterClass(): void service('superglobals')->setServer('CODEIGNITER_SCREAM_DEPRECATIONS', '1'); } + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Debug/Toolbar/Collectors/HistoryTest.php b/tests/system/Debug/Toolbar/Collectors/HistoryTest.php index dffa30ce67dc..aacec53bb413 100644 --- a/tests/system/Debug/Toolbar/Collectors/HistoryTest.php +++ b/tests/system/Debug/Toolbar/Collectors/HistoryTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; use DateTime; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -30,6 +31,7 @@ final class HistoryTest extends CIUnitTestCase private float $time; + #[Override] protected function setUp(): void { parent::setUp(); @@ -37,6 +39,7 @@ protected function setUp(): void $this->time = (float) sprintf('%.6F', microtime(true)); } + #[Override] protected function tearDown(): void { command('debugbar:clear'); diff --git a/tests/system/Debug/Toolbar/Collectors/LogsTest.php b/tests/system/Debug/Toolbar/Collectors/LogsTest.php index a89fc878260c..319158bdb4bd 100644 --- a/tests/system/Debug/Toolbar/Collectors/LogsTest.php +++ b/tests/system/Debug/Toolbar/Collectors/LogsTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Logger as LoggerConfig; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\Group; use Psr\Log\AbstractLogger; use Stringable; @@ -29,6 +30,7 @@ final class LogsTest extends CIUnitTestCase { private Logger $logger; + #[Override] protected function setUp(): void { parent::setUp(); @@ -74,6 +76,7 @@ public function testNotEmpty(): void public function testEmptyWithThirdPartyLogger(): void { Services::injectMock('logger', new class () extends AbstractLogger { + #[Override] public function log($level, string|Stringable $message, array $context = []): void { } diff --git a/tests/system/Debug/ToolbarTest.php b/tests/system/Debug/ToolbarTest.php index d701e7753ff7..8df62b00296f 100644 --- a/tests/system/Debug/ToolbarTest.php +++ b/tests/system/Debug/ToolbarTest.php @@ -21,6 +21,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Utilities\NativeHeadersStack; use Config\Toolbar as ToolbarConfig; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; @@ -35,6 +36,7 @@ final class ToolbarTest extends CIUnitTestCase private ?IncomingRequest $request = null; private ?ResponseInterface $response = null; + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -43,6 +45,7 @@ public static function setUpBeforeClass(): void require_once SUPPORTPATH . 'Mock/MockNativeHeaders.php'; } + #[Override] protected function setUp(): void { parent::setUp(); @@ -64,6 +67,7 @@ protected function setUp(): void Services::injectMock('codeigniter', $app); } + #[Override] protected function tearDown(): void { // Restore is_cli state diff --git a/tests/system/Encryption/EncryptionTest.php b/tests/system/Encryption/EncryptionTest.php index 81c4554336e0..9c72b082d769 100644 --- a/tests/system/Encryption/EncryptionTest.php +++ b/tests/system/Encryption/EncryptionTest.php @@ -20,6 +20,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Encryption as EncryptionConfig; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -30,6 +31,7 @@ final class EncryptionTest extends CIUnitTestCase { private Encryption $encryption; + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -45,6 +47,7 @@ public static function setUpBeforeClass(): void } } + #[Override] protected function setUp(): void { parent::setUp(); @@ -52,6 +55,7 @@ protected function setUp(): void $this->encryption = new Encryption(); } + #[Override] public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); diff --git a/tests/system/Encryption/Handlers/OpenSSLHandlerTest.php b/tests/system/Encryption/Handlers/OpenSSLHandlerTest.php index 01254f31b810..1b01706a9f9b 100644 --- a/tests/system/Encryption/Handlers/OpenSSLHandlerTest.php +++ b/tests/system/Encryption/Handlers/OpenSSLHandlerTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Encryption\Exceptions\EncryptionException; use CodeIgniter\Test\CIUnitTestCase; use Config\Encryption as EncryptionConfig; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -27,6 +28,7 @@ final class OpenSSLHandlerTest extends CIUnitTestCase { private Encryption $encryption; + #[Override] protected function setUp(): void { if (! extension_loaded('openssl')) { diff --git a/tests/system/Encryption/Handlers/SodiumHandlerTest.php b/tests/system/Encryption/Handlers/SodiumHandlerTest.php index fe63cec36fb9..3a0fab388e01 100644 --- a/tests/system/Encryption/Handlers/SodiumHandlerTest.php +++ b/tests/system/Encryption/Handlers/SodiumHandlerTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Encryption\Exceptions\EncryptionException; use CodeIgniter\Test\CIUnitTestCase; use Config\Encryption as EncryptionConfig; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -28,6 +29,7 @@ final class SodiumHandlerTest extends CIUnitTestCase private Encryption $encryption; private EncryptionConfig $config; + #[Override] protected function setUp(): void { if (! extension_loaded('sodium')) { diff --git a/tests/system/Encryption/KeyRotationDecoratorTest.php b/tests/system/Encryption/KeyRotationDecoratorTest.php index 1f86220739db..fcdcacb4900c 100644 --- a/tests/system/Encryption/KeyRotationDecoratorTest.php +++ b/tests/system/Encryption/KeyRotationDecoratorTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Encryption\Exceptions\EncryptionException; use CodeIgniter\Test\CIUnitTestCase; use Config\Encryption as EncryptionConfig; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpExtension; @@ -27,6 +28,7 @@ final class KeyRotationDecoratorTest extends CIUnitTestCase { private Encryption $encryption; + #[Override] protected function setUp(): void { $this->encryption = new Encryption(); diff --git a/tests/system/Entity/EntityTest.php b/tests/system/Entity/EntityTest.php index 84604e2e77f8..bbda2729d928 100644 --- a/tests/system/Entity/EntityTest.php +++ b/tests/system/Entity/EntityTest.php @@ -26,6 +26,7 @@ use DateTimeInterface; use DateTimeZone; use JsonSerializable; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use ReflectionException; @@ -2180,6 +2181,7 @@ public function testHasChangedWithJsonSerializable(): void }; $obj1 = new class () implements JsonSerializable { + #[Override] public function jsonSerialize(): mixed { return ['value' => 'original']; @@ -2192,6 +2194,7 @@ public function jsonSerialize(): mixed $this->assertFalse($entity->hasChanged('data')); $obj2 = new class () implements JsonSerializable { + #[Override] public function jsonSerialize(): mixed { return ['value' => 'modified']; @@ -2216,6 +2219,7 @@ public function __construct(private string $value) { } + #[Override] public function jsonSerialize(): mixed { return ['json' => $this->value]; @@ -2817,6 +2821,7 @@ public function __construct(private string $email) { } + #[Override] public function __toString(): string { return $this->email; diff --git a/tests/system/Events/EventsTest.php b/tests/system/Events/EventsTest.php index 39be06b1235b..d19a345838fa 100644 --- a/tests/system/Events/EventsTest.php +++ b/tests/system/Events/EventsTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockEvents; use Config\Modules; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; use PHPUnit\Framework\Attributes\RunInSeparateProcess; @@ -35,6 +36,7 @@ final class EventsTest extends CIUnitTestCase */ private Events $manager; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { @@ -45,6 +47,7 @@ protected function setUp(): void Events::removeAllListeners(); } + #[Override] protected function tearDown(): void { Events::simulate(false); diff --git a/tests/system/Files/FileCollectionTest.php b/tests/system/Files/FileCollectionTest.php index 7bb402eaa4af..0c3b9783beb9 100644 --- a/tests/system/Files/FileCollectionTest.php +++ b/tests/system/Files/FileCollectionTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Files\Exceptions\FileException; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -38,6 +39,7 @@ final class FileCollectionTest extends CIUnitTestCase * tests call static methods before * the constructor would load it. */ + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -124,6 +126,7 @@ public function testConstructorAddsFiles(): void public function testConstructorCallsDefine(): void { $collection = new class () extends FileCollection { + #[Override] protected function define(): void { $this->add(SUPPORTPATH . 'Files/baker/banana.php'); diff --git a/tests/system/Files/FileWithVfsTest.php b/tests/system/Files/FileWithVfsTest.php index e0065591963d..f511e1f1a5b8 100644 --- a/tests/system/Files/FileWithVfsTest.php +++ b/tests/system/Files/FileWithVfsTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -29,6 +30,7 @@ final class FileWithVfsTest extends CIUnitTestCase private string $start; private File $file; + #[Override] protected function setUp(): void { parent::setUp(); @@ -40,6 +42,7 @@ protected function setUp(): void $this->file = new File($this->start . 'able/apple.php'); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Filters/CSRFTest.php b/tests/system/Filters/CSRFTest.php index 454ec6ce1847..e8376f237c3f 100644 --- a/tests/system/Filters/CSRFTest.php +++ b/tests/system/Filters/CSRFTest.php @@ -23,6 +23,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockSecurity; use Config\Security as SecurityConfig; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; @@ -37,6 +38,7 @@ final class CSRFTest extends CIUnitTestCase private CLIRequest|IncomingRequest $request; private ?Response $response = null; + #[Override] protected function setUp(): void { parent::setUp(); @@ -46,6 +48,7 @@ protected function setUp(): void $this->config = new \Config\Filters(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Filters/CorsTest.php b/tests/system/Filters/CorsTest.php index 38389f25c213..b6c1a371c18c 100644 --- a/tests/system/Filters/CorsTest.php +++ b/tests/system/Filters/CorsTest.php @@ -23,6 +23,7 @@ use CodeIgniter\HTTP\UserAgent; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockAppConfig; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -38,6 +39,7 @@ final class CorsTest extends CIUnitTestCase private Cors $cors; private ResponseInterface $response; + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Filters/DebugToolbarTest.php b/tests/system/Filters/DebugToolbarTest.php index fc9f8f179776..c5a5a23f87d8 100644 --- a/tests/system/Filters/DebugToolbarTest.php +++ b/tests/system/Filters/DebugToolbarTest.php @@ -22,6 +22,7 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use Config\Filters as FilterConfig; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; @@ -39,6 +40,7 @@ final class DebugToolbarTest extends CIUnitTestCase private Response $response; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Filters/FiltersTest.php b/tests/system/Filters/FiltersTest.php index d696498efaa2..e27466d164e6 100644 --- a/tests/system/Filters/FiltersTest.php +++ b/tests/system/Filters/FiltersTest.php @@ -32,6 +32,7 @@ use CodeIgniter\Test\ConfigFromArrayTrait; use CodeIgniter\Test\Mock\MockAppConfig; use Config\Filters as FiltersConfig; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -56,6 +57,7 @@ final class FiltersTest extends CIUnitTestCase private Response $response; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Filters/HoneypotTest.php b/tests/system/Filters/HoneypotTest.php index 8ad3106f1a9f..789508234761 100644 --- a/tests/system/Filters/HoneypotTest.php +++ b/tests/system/Filters/HoneypotTest.php @@ -22,6 +22,7 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use Config\Honeypot; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; @@ -45,6 +46,7 @@ final class HoneypotTest extends CIUnitTestCase private ?Response $response = null; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { diff --git a/tests/system/Filters/InvalidCharsTest.php b/tests/system/Filters/InvalidCharsTest.php index 66588b5b1a35..8e23af798002 100644 --- a/tests/system/Filters/InvalidCharsTest.php +++ b/tests/system/Filters/InvalidCharsTest.php @@ -22,6 +22,7 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockAppConfig; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use PHPUnit\Framework\Attributes\Group; @@ -35,6 +36,7 @@ final class InvalidCharsTest extends CIUnitTestCase private InvalidChars $invalidChars; private IncomingRequest $request; + #[Override] protected function setUp(): void { parent::setUp(); @@ -45,6 +47,7 @@ protected function setUp(): void $this->invalidChars = new InvalidChars(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Filters/RequestIdTest.php b/tests/system/Filters/RequestIdTest.php index 03804d27a88f..f8b9e579c7d1 100644 --- a/tests/system/Filters/RequestIdTest.php +++ b/tests/system/Filters/RequestIdTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Filters; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -22,6 +23,7 @@ #[Group('Others')] final class RequestIdTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Filters/fixtures/GoogleCurious.php b/tests/system/Filters/fixtures/GoogleCurious.php index 6a6871fcc8d4..57255691453e 100644 --- a/tests/system/Filters/fixtures/GoogleCurious.php +++ b/tests/system/Filters/fixtures/GoogleCurious.php @@ -16,14 +16,17 @@ use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; class GoogleCurious implements FilterInterface { + #[Override] public function before(RequestInterface $request, $arguments = null) { return 'This is curious'; } + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { return null; diff --git a/tests/system/Filters/fixtures/GoogleEmpty.php b/tests/system/Filters/fixtures/GoogleEmpty.php index 9de00d28f514..414d3ea7881a 100644 --- a/tests/system/Filters/fixtures/GoogleEmpty.php +++ b/tests/system/Filters/fixtures/GoogleEmpty.php @@ -16,14 +16,17 @@ use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; class GoogleEmpty implements FilterInterface { + #[Override] public function before(RequestInterface $request, $arguments = null) { return ''; } + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { return null; diff --git a/tests/system/Filters/fixtures/GoogleMe.php b/tests/system/Filters/fixtures/GoogleMe.php index 504044c0fb82..35ec047c02b2 100644 --- a/tests/system/Filters/fixtures/GoogleMe.php +++ b/tests/system/Filters/fixtures/GoogleMe.php @@ -16,9 +16,11 @@ use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; class GoogleMe implements FilterInterface { + #[Override] public function before(RequestInterface $request, $arguments = null) { $request->setBody('http://google.com'); @@ -26,6 +28,7 @@ public function before(RequestInterface $request, $arguments = null) return $request; } + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { $response->setBody('http://google.com'); diff --git a/tests/system/Filters/fixtures/GoogleYou.php b/tests/system/Filters/fixtures/GoogleYou.php index 5911940b2954..28cedbfb0ce1 100644 --- a/tests/system/Filters/fixtures/GoogleYou.php +++ b/tests/system/Filters/fixtures/GoogleYou.php @@ -16,9 +16,11 @@ use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; class GoogleYou implements FilterInterface { + #[Override] public function before(RequestInterface $request, $arguments = null) { $response = service('response'); @@ -27,6 +29,7 @@ public function before(RequestInterface $request, $arguments = null) return $response; } + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { return null; diff --git a/tests/system/Filters/fixtures/Multiple1.php b/tests/system/Filters/fixtures/Multiple1.php index 6d2cee231808..bb8a562a181a 100644 --- a/tests/system/Filters/fixtures/Multiple1.php +++ b/tests/system/Filters/fixtures/Multiple1.php @@ -16,9 +16,11 @@ use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; class Multiple1 implements FilterInterface { + #[Override] public function before(RequestInterface $request, $arguments = null) { $request->setHeader('x-csp', 'http://exampleMultipleCSP.com'); @@ -26,6 +28,7 @@ public function before(RequestInterface $request, $arguments = null) return $request; } + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { return null; diff --git a/tests/system/Filters/fixtures/Multiple2.php b/tests/system/Filters/fixtures/Multiple2.php index d86f8fa79399..b9f66cecca60 100644 --- a/tests/system/Filters/fixtures/Multiple2.php +++ b/tests/system/Filters/fixtures/Multiple2.php @@ -16,9 +16,11 @@ use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; class Multiple2 implements FilterInterface { + #[Override] public function before(RequestInterface $request, $arguments = null) { $request->setHeader('x-url', 'http://exampleMultipleURL.com'); @@ -26,6 +28,7 @@ public function before(RequestInterface $request, $arguments = null) return $request; } + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { return null; diff --git a/tests/system/Filters/fixtures/Role.php b/tests/system/Filters/fixtures/Role.php index 8d634d3ad138..a687bc8bd861 100644 --- a/tests/system/Filters/fixtures/Role.php +++ b/tests/system/Filters/fixtures/Role.php @@ -16,9 +16,11 @@ use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use Override; class Role implements FilterInterface { + #[Override] public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { if (is_array($arguments)) { @@ -32,6 +34,7 @@ public function after(RequestInterface $request, ResponseInterface $response, $a return $response; } + #[Override] public function before(RequestInterface $request, $arguments = null) { if (is_array($arguments)) { diff --git a/tests/system/Format/FormatTest.php b/tests/system/Format/FormatTest.php index 91fb618209d7..6288563824d4 100644 --- a/tests/system/Format/FormatTest.php +++ b/tests/system/Format/FormatTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Format\Exceptions\FormatException; use CodeIgniter\HTTP\URI; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class FormatTest extends CIUnitTestCase { private Format $format; + #[Override] protected function setUp(): void { $this->format = new Format(new \Config\Format()); diff --git a/tests/system/Format/JSONFormatterTest.php b/tests/system/Format/JSONFormatterTest.php index 7581a6022a9a..f4a50c83a442 100644 --- a/tests/system/Format/JSONFormatterTest.php +++ b/tests/system/Format/JSONFormatterTest.php @@ -17,6 +17,7 @@ use CodeIgniter\EnvironmentDetector; use CodeIgniter\Format\Exceptions\FormatException; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -28,12 +29,14 @@ final class JSONFormatterTest extends CIUnitTestCase { private JSONFormatter $jsonFormatter; + #[Override] protected function setUp(): void { parent::setUp(); $this->jsonFormatter = new JSONFormatter(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Format/XMLFormatterTest.php b/tests/system/Format/XMLFormatterTest.php index f86aa95d1feb..c04a1eb04c82 100644 --- a/tests/system/Format/XMLFormatterTest.php +++ b/tests/system/Format/XMLFormatterTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Format\Exceptions\FormatException; use CodeIgniter\Test\CIUnitTestCase; use DOMDocument; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use stdClass; @@ -29,6 +30,7 @@ final class XMLFormatterTest extends CIUnitTestCase { private XMLFormatter $xmlFormatter; + #[Override] protected function setUp(): void { parent::setUp(); @@ -173,6 +175,7 @@ public function testEmptyTagNameAfterSanitization(): void public function testStringableObjectValue(): void { $value = new class () implements Stringable { + #[Override] public function __toString(): string { return 'bar'; diff --git a/tests/system/HTTP/CLIRequestTest.php b/tests/system/HTTP/CLIRequestTest.php index 20b2b2732f99..8a72a5f21521 100644 --- a/tests/system/HTTP/CLIRequestTest.php +++ b/tests/system/HTTP/CLIRequestTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -33,6 +34,7 @@ final class CLIRequestTest extends CIUnitTestCase { private CLIRequest $request; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/HTTP/CURLRequestExceptionTest.php b/tests/system/HTTP/CURLRequestExceptionTest.php index e8e290f2c8c8..1afbe43e52c3 100644 --- a/tests/system/HTTP/CURLRequestExceptionTest.php +++ b/tests/system/HTTP/CURLRequestExceptionTest.php @@ -20,6 +20,7 @@ use Config\App; use Config\CURLRequest as ConfigCURLRequest; use InvalidArgumentException; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use Throwable; @@ -286,6 +287,7 @@ private function failingRequest(array $options = [], ?URI $uri = null): MockCURL return new class ($app, $uri ?? new URI(), new Response(), $options) extends MockCURLRequest { private bool $failNextRequest = true; + #[Override] protected function sendRequest(array $curlOptions = []): string { if ($this->failNextRequest) { diff --git a/tests/system/HTTP/CURLRequestRetryTest.php b/tests/system/HTTP/CURLRequestRetryTest.php index a8e36e3b7f3a..016bd3807e06 100644 --- a/tests/system/HTTP/CURLRequestRetryTest.php +++ b/tests/system/HTTP/CURLRequestRetryTest.php @@ -21,6 +21,7 @@ use CodeIgniter\Test\Mock\MockCURLRequest; use Config\App; use Config\CURLRequest as ConfigCURLRequest; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -31,6 +32,7 @@ final class CURLRequestRetryTest extends CIUnitTestCase { private MockCURLRequest $request; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/HTTP/CURLRequestShareOptionsTest.php b/tests/system/HTTP/CURLRequestShareOptionsTest.php index 9716351f486e..dc6a0b181674 100644 --- a/tests/system/HTTP/CURLRequestShareOptionsTest.php +++ b/tests/system/HTTP/CURLRequestShareOptionsTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\Mock\MockCURLRequest; use Config\App; use Config\CURLRequest as ConfigCURLRequest; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -32,6 +33,7 @@ final class CURLRequestShareOptionsTest extends CURLRequestTest * @param array $options * @param array|null $shareConnectionOptions */ + #[Override] protected function getRequest(array $options = [], ?array $shareConnectionOptions = null): MockCURLRequest { $uri = new URI($options['baseURI'] ?? null); @@ -48,6 +50,7 @@ protected function getRequest(array $options = [], ?array $shareConnectionOption return new MockCURLRequest(new App(), $uri, new Response(), $options); } + #[Override] public function testHeaderContentLengthNotSharedBetweenRequests(): void { $options = [ @@ -66,6 +69,7 @@ public function testHeaderContentLengthNotSharedBetweenRequests(): void $this->assertSame('9', $request->header('Content-Length')->getValue()); } + #[Override] public function testBodyIsResetOnSecondRequest(): void { $request = $this->getRequest([ diff --git a/tests/system/HTTP/CURLRequestTest.php b/tests/system/HTTP/CURLRequestTest.php index 408e94353307..0d30669e19dc 100644 --- a/tests/system/HTTP/CURLRequestTest.php +++ b/tests/system/HTTP/CURLRequestTest.php @@ -23,6 +23,7 @@ use Config\CURLRequest as ConfigCURLRequest; use CURLFile; use CurlShareHandle; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -37,6 +38,7 @@ class CURLRequestTest extends CIUnitTestCase { protected MockCURLRequest $request; + #[Override] protected function setUp(): void { $this->resetServices(); diff --git a/tests/system/HTTP/ContentSecurityPolicyTest.php b/tests/system/HTTP/ContentSecurityPolicyTest.php index a6b70f7f27e0..5d3fffa2226c 100644 --- a/tests/system/HTTP/ContentSecurityPolicyTest.php +++ b/tests/system/HTTP/ContentSecurityPolicyTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Test\TestResponse; use Config\App; use Config\ContentSecurityPolicy as CSPConfig; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; use PHPUnit\Framework\Attributes\RunInSeparateProcess; @@ -38,6 +39,7 @@ final class ContentSecurityPolicyTest extends CIUnitTestCase private ?Response $response = null; private ?ContentSecurityPolicy $csp = null; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { diff --git a/tests/system/HTTP/CorsTest.php b/tests/system/HTTP/CorsTest.php index 71d2c84a44b7..b2d4be69adfe 100644 --- a/tests/system/HTTP/CorsTest.php +++ b/tests/system/HTTP/CorsTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\HTTP; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; @@ -24,6 +25,7 @@ #[Group('Others')] final class CorsTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { $this->resetServices(); diff --git a/tests/system/HTTP/DownloadResponseTest.php b/tests/system/HTTP/DownloadResponseTest.php index d5fea35e380c..6b8a4686969a 100644 --- a/tests/system/HTTP/DownloadResponseTest.php +++ b/tests/system/HTTP/DownloadResponseTest.php @@ -20,6 +20,7 @@ use CodeIgniter\Test\CIUnitTestCase; use DateTime; use DateTimeZone; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; @@ -33,6 +34,7 @@ #[Group('SeparateProcess')] final class DownloadResponseTest extends CIUnitTestCase { + #[Override] #[WithoutErrorHandler] protected function setUp(): void { @@ -41,6 +43,7 @@ protected function setUp(): void Services::injectMock('superglobals', new Superglobals()); } + #[Override] protected function tearDown(): void { if (service('superglobals')->server('HTTP_USER_AGENT') !== null) { diff --git a/tests/system/HTTP/Files/FileCollectionTest.php b/tests/system/HTTP/Files/FileCollectionTest.php index 636285256d7b..12f767ca3e54 100644 --- a/tests/system/HTTP/Files/FileCollectionTest.php +++ b/tests/system/HTTP/Files/FileCollectionTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Mimes; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -23,6 +24,7 @@ #[Group('Others')] final class FileCollectionTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/HTTP/Files/FileMovingTest.php b/tests/system/HTTP/Files/FileMovingTest.php index bf9eeb997675..5a7add86fd7d 100644 --- a/tests/system/HTTP/Files/FileMovingTest.php +++ b/tests/system/HTTP/Files/FileMovingTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -29,6 +30,7 @@ final class FileMovingTest extends CIUnitTestCase private ?vfsStreamDirectory $root; private string $destination; + #[Override] protected function setUp(): void { parent::setUp(); @@ -49,6 +51,7 @@ protected function setUp(): void move_uploaded_file('', '', true); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/HTTP/FormRequestTest.php b/tests/system/HTTP/FormRequestTest.php index d10c2433d663..7cfcb36a9597 100644 --- a/tests/system/HTTP/FormRequestTest.php +++ b/tests/system/HTTP/FormRequestTest.php @@ -20,6 +20,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockCodeIgniter; use Config\App; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RunInSeparateProcess; @@ -35,6 +36,7 @@ final class FormRequestTest extends CIUnitTestCase { private MockCodeIgniter $codeigniter; + #[Override] protected function setUp(): void { parent::setUp(); @@ -51,6 +53,7 @@ protected function setUp(): void $this->codeigniter = new MockCodeIgniter(new App()); } + #[Override] protected function tearDown(): void { parent::tearDown(); @@ -80,6 +83,7 @@ private function makeRequest(?string $body = null): IncomingRequest private function makeFormRequest(IncomingRequest $request): FormRequest { return new class ($request) extends FormRequest { + #[Override] public function rules(): array { return [ @@ -139,6 +143,7 @@ public function testConstructorThrowsWhenFallbackRequestIsNotIncomingRequest(): $this->expectExceptionMessage('requires an IncomingRequest instance, got CodeIgniter\HTTP\CLIRequest.'); new class () extends FormRequest { + #[Override] public function rules(): array { return []; @@ -197,6 +202,7 @@ public function testGetValidatedReturnsNestedValidatedData(): void ]); $formRequest = new class ($this->makeRequest()) extends FormRequest { + #[Override] public function rules(): array { return [ @@ -226,6 +232,7 @@ public function testGetValidatedReturnsNullValidatedField(): void service('superglobals')->setServer('CONTENT_TYPE', 'application/json'); $formRequest = new class ($this->makeRequest('{"note":null}')) extends FormRequest { + #[Override] public function rules(): array { return ['note' => 'permit_empty']; @@ -263,11 +270,13 @@ public function testPrepareForValidationIsCalledBeforeValidation(): void $formRequest = new class ($this->makeRequest()) extends FormRequest { public static bool $prepareCalled = false; + #[Override] public function rules(): array { return ['title' => 'required|min_length[3]']; } + #[Override] protected function prepareForValidation(array $data): array { self::$prepareCalled = true; @@ -319,6 +328,7 @@ public function testFailedValidationResponseContainsErrors(): void service('superglobals')->setServer('CONTENT_TYPE', 'application/json'); $formRequest = new class ($this->makeRequest('{}')) extends FormRequest { + #[Override] public function rules(): array { return ['title' => 'required']; @@ -424,6 +434,7 @@ public function testPreparedValidationDataIsPassedToFailedValidationWithoutPrepa */ public array $preparedData = []; + #[Override] public function rules(): array { return [ @@ -432,6 +443,7 @@ public function rules(): array ]; } + #[Override] protected function prepareForValidation(array $data): array { $this->prepareCount++; @@ -440,6 +452,7 @@ protected function prepareForValidation(array $data): array return $data; } + #[Override] protected function failedValidation(array $errors, array $preparedData): ResponseInterface { $this->preparedData = $preparedData; @@ -463,6 +476,7 @@ public function testDefaultFailedValidationFlashesPreparedValidationDataAsOldInp service('superglobals')->setPost('title', ' Hello World '); $formRequest = new class ($this->makeRequest()) extends FormRequest { + #[Override] public function rules(): array { return [ @@ -471,6 +485,7 @@ public function rules(): array ]; } + #[Override] protected function prepareForValidation(array $data): array { $data['title'] = trim($data['title'] ?? ''); @@ -494,6 +509,7 @@ public function testDefaultFailedValidationFlashesPreparedGetDataAsOldInput(): v service('superglobals')->setGet('title', ' Hello World '); $formRequest = new class ($this->makeRequest()) extends FormRequest { + #[Override] public function rules(): array { return [ @@ -502,6 +518,7 @@ public function rules(): array ]; } + #[Override] protected function prepareForValidation(array $data): array { $data['title'] = trim($data['title'] ?? ''); @@ -526,6 +543,7 @@ public function testDefaultFailedValidationPreservesGetDataWhenPostDataIsPrepare service('superglobals')->setPost('title', ' Hello World '); $formRequest = new class ($this->makeRequest()) extends FormRequest { + #[Override] public function rules(): array { return [ @@ -534,6 +552,7 @@ public function rules(): array ]; } + #[Override] protected function prepareForValidation(array $data): array { $data['title'] = trim($data['title'] ?? ''); @@ -555,11 +574,13 @@ protected function prepareForValidation(array $data): array public function testResolveRequestReturns403WhenUnauthorized(): void { $formRequest = new class ($this->makeRequest()) extends FormRequest { + #[Override] public function rules(): array { return []; } + #[Override] public function isAuthorized(): bool { return false; @@ -581,11 +602,13 @@ public function testAuthorizationIsCheckedBeforeValidation(): void */ public static array $order = []; + #[Override] public function rules(): array { return ['title' => 'required']; } + #[Override] public function isAuthorized(): bool { self::$order[] = 'authorize'; @@ -593,6 +616,7 @@ public function isAuthorized(): bool return false; } + #[Override] protected function prepareForValidation(array $data): array { self::$order[] = 'prepare'; @@ -615,11 +639,13 @@ public function testValidationDataOverrideIsUsed(): void { // No POST data at all - but validationData() supplies its own. $formRequest = new class ($this->makeRequest()) extends FormRequest { + #[Override] public function rules(): array { return ['title' => 'required|min_length[3]']; } + #[Override] protected function validationData(): array { return ['title' => 'Injected Title']; @@ -636,11 +662,13 @@ public function testCustomFailedValidationIsRespected(): void $formRequest = new class ($this->makeRequest()) extends FormRequest { public static bool $called = false; + #[Override] public function rules(): array { return ['title' => 'required']; } + #[Override] protected function failedValidation(array $errors, array $preparedData): ResponseInterface { self::$called = true; @@ -660,16 +688,19 @@ public function testCustomFailedAuthorizationIsRespected(): void $formRequest = new class ($this->makeRequest()) extends FormRequest { public static bool $called = false; + #[Override] public function rules(): array { return []; } + #[Override] public function isAuthorized(): bool { return false; } + #[Override] protected function failedAuthorization(): ResponseInterface { self::$called = true; diff --git a/tests/system/HTTP/IncomingRequestTest.php b/tests/system/HTTP/IncomingRequestTest.php index 55700af2d8ba..19b3413e3c29 100644 --- a/tests/system/HTTP/IncomingRequestTest.php +++ b/tests/system/HTTP/IncomingRequestTest.php @@ -23,6 +23,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\App; use JsonException; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -39,6 +40,7 @@ final class IncomingRequestTest extends CIUnitTestCase { private IncomingRequest $request; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { diff --git a/tests/system/HTTP/MessageTest.php b/tests/system/HTTP/MessageTest.php index f921795c2a48..5de3418eba05 100644 --- a/tests/system/HTTP/MessageTest.php +++ b/tests/system/HTTP/MessageTest.php @@ -18,6 +18,7 @@ use CodeIgniter\HTTP\Exceptions\HTTPException; use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -31,6 +32,7 @@ final class MessageTest extends CIUnitTestCase { private Message $message; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/HTTP/NegotiateTest.php b/tests/system/HTTP/NegotiateTest.php index dea9169d7960..a8645d5d9d67 100644 --- a/tests/system/HTTP/NegotiateTest.php +++ b/tests/system/HTTP/NegotiateTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\App; use Config\Feature; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; @@ -30,6 +31,7 @@ final class NegotiateTest extends CIUnitTestCase private IncomingRequest $request; private Negotiate $negotiate; + #[Override] protected function setUp(): void { $this->resetServices(); diff --git a/tests/system/HTTP/RedirectExceptionTest.php b/tests/system/HTTP/RedirectExceptionTest.php index 4a787830c1f4..3655a58da50c 100644 --- a/tests/system/HTTP/RedirectExceptionTest.php +++ b/tests/system/HTTP/RedirectExceptionTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Log\Logger; use CodeIgniter\Test\Mock\MockLogger as LoggerConfig; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Tests\Support\Log\Handlers\TestHandler; @@ -29,12 +30,14 @@ #[Group('Others')] final class RedirectExceptionTest extends TestCase { + #[Override] protected function setUp(): void { Services::reset(); Services::injectMock('logger', new Logger(new LoggerConfig())); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/HTTP/RedirectResponseTest.php b/tests/system/HTTP/RedirectResponseTest.php index c191d00d6751..65a08f92ef99 100644 --- a/tests/system/HTTP/RedirectResponseTest.php +++ b/tests/system/HTTP/RedirectResponseTest.php @@ -24,6 +24,7 @@ use Config\Modules; use Config\Routing; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; @@ -40,6 +41,7 @@ final class RedirectResponseTest extends CIUnitTestCase private MockIncomingRequest $request; private App $config; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { diff --git a/tests/system/HTTP/RequestInputTest.php b/tests/system/HTTP/RequestInputTest.php index 44d094b0ada1..417aa7812e7e 100644 --- a/tests/system/HTTP/RequestInputTest.php +++ b/tests/system/HTTP/RequestInputTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; @@ -29,6 +30,7 @@ #[Group('SeparateProcess')] final class RequestInputTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/HTTP/RequestTest.php b/tests/system/HTTP/RequestTest.php index 2dafdc4fd792..6c5e579f67f7 100644 --- a/tests/system/HTTP/RequestTest.php +++ b/tests/system/HTTP/RequestTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -31,6 +32,7 @@ final class RequestTest extends CIUnitTestCase { private Request $request; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/HTTP/ResponseCookieTest.php b/tests/system/HTTP/ResponseCookieTest.php index cf3f8eccd9b5..41677af5c3ee 100644 --- a/tests/system/HTTP/ResponseCookieTest.php +++ b/tests/system/HTTP/ResponseCookieTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Cookie\Exceptions\CookieException; use CodeIgniter\Test\CIUnitTestCase; use Config\Cookie as CookieConfig; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -32,12 +33,14 @@ final class ResponseCookieTest extends CIUnitTestCase */ private array $defaults; + #[Override] protected function setUp(): void { parent::setUp(); $this->defaults = Cookie::setDefaults(); } + #[Override] protected function tearDown(): void { Cookie::setDefaults($this->defaults); diff --git a/tests/system/HTTP/ResponseTest.php b/tests/system/HTTP/ResponseTest.php index b4bd5bc394e0..65f1cb10fd08 100644 --- a/tests/system/HTTP/ResponseTest.php +++ b/tests/system/HTTP/ResponseTest.php @@ -24,6 +24,7 @@ use Config\App; use DateTime; use DateTimeZone; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -41,6 +42,7 @@ final class ResponseTest extends CIUnitTestCase */ private array $server; + #[Override] protected function setUp(): void { $this->resetServices(); @@ -50,6 +52,7 @@ protected function setUp(): void $this->server = service('superglobals')->getServerArray(); } + #[Override] protected function tearDown(): void { Factories::reset('config'); diff --git a/tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php b/tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php index 43a80e58d1e1..5332339660fc 100644 --- a/tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php +++ b/tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -28,6 +29,7 @@ #[Group('Others')] final class SiteURIFactoryDetectRoutePathTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/HTTP/SiteURIFactoryTest.php b/tests/system/HTTP/SiteURIFactoryTest.php index 5c062371a3ad..21d4bf81aeea 100644 --- a/tests/system/HTTP/SiteURIFactoryTest.php +++ b/tests/system/HTTP/SiteURIFactoryTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -28,6 +29,7 @@ #[Group('Others')] final class SiteURIFactoryTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/HTTP/StreamResponseTest.php b/tests/system/HTTP/StreamResponseTest.php index 2135259202b6..cd434d196fa8 100644 --- a/tests/system/HTTP/StreamResponseTest.php +++ b/tests/system/HTTP/StreamResponseTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Generator; use IteratorAggregate; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -95,6 +96,7 @@ public function __invoke(StreamResponse $stream): void /** * @return Generator */ + #[Override] public function getIterator(): Generator { yield 'iterable chunk'; diff --git a/tests/system/HTTP/UserAgentTest.php b/tests/system/HTTP/UserAgentTest.php index cc6947d1dd50..863a1a39e3b0 100644 --- a/tests/system/HTTP/UserAgentTest.php +++ b/tests/system/HTTP/UserAgentTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\HTTP; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; @@ -28,6 +29,7 @@ final class UserAgentTest extends CIUnitTestCase private string $_mobile_ua = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7'; private UserAgent $agent; + #[Override] protected function setUp(): void { $this->resetServices(); diff --git a/tests/system/Helpers/Array/ArrayHelperRecursiveDiffTest.php b/tests/system/Helpers/Array/ArrayHelperRecursiveDiffTest.php index 9c3e6f943604..8ef7d8f141aa 100644 --- a/tests/system/Helpers/Array/ArrayHelperRecursiveDiffTest.php +++ b/tests/system/Helpers/Array/ArrayHelperRecursiveDiffTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Helpers\Array; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -27,6 +28,7 @@ final class ArrayHelperRecursiveDiffTest extends CIUnitTestCase */ private array $compareWith; + #[Override] protected function setUp(): void { $this->compareWith = [ diff --git a/tests/system/Helpers/ArrayHelperTest.php b/tests/system/Helpers/ArrayHelperTest.php index 546a57fed920..f6de67d80870 100644 --- a/tests/system/Helpers/ArrayHelperTest.php +++ b/tests/system/Helpers/ArrayHelperTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\Test\CIUnitTestCase; use DateTimeImmutable; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use stdClass; @@ -29,6 +30,7 @@ #[Group('Others')] final class ArrayHelperTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Helpers/CookieHelperTest.php b/tests/system/Helpers/CookieHelperTest.php index aebd38239303..c589a22b3fa3 100644 --- a/tests/system/Helpers/CookieHelperTest.php +++ b/tests/system/Helpers/CookieHelperTest.php @@ -26,6 +26,7 @@ use Config\Cookie; use Config\Cookie as CookieConfig; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -39,6 +40,7 @@ final class CookieHelperTest extends CIUnitTestCase private int $expire; private Response $response; + #[Override] protected function setUp(): void { service('superglobals')->setCookieArray([]); diff --git a/tests/system/Helpers/DateHelperTest.php b/tests/system/Helpers/DateHelperTest.php index fe2b2a73978c..55aa2674bb41 100644 --- a/tests/system/Helpers/DateHelperTest.php +++ b/tests/system/Helpers/DateHelperTest.php @@ -16,6 +16,7 @@ use CodeIgniter\I18n\Time; use CodeIgniter\Test\CIUnitTestCase; use DateTimeZone; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -24,6 +25,7 @@ #[Group('Others')] final class DateHelperTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Helpers/FilesystemHelperTest.php b/tests/system/Helpers/FilesystemHelperTest.php index f264864ebf9a..101ad17e2415 100644 --- a/tests/system/Helpers/FilesystemHelperTest.php +++ b/tests/system/Helpers/FilesystemHelperTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\visitor\vfsStreamStructureVisitor; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -29,6 +30,7 @@ final class FilesystemHelperTest extends CIUnitTestCase */ private array $structure; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Helpers/FormHelperTest.php b/tests/system/Helpers/FormHelperTest.php index bfd3d12e0efe..90a65914f8eb 100644 --- a/tests/system/Helpers/FormHelperTest.php +++ b/tests/system/Helpers/FormHelperTest.php @@ -21,6 +21,7 @@ use Config\DocTypes; use Config\Filters; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -36,6 +37,7 @@ #[Group('SeparateProcess')] final class FormHelperTest extends CIUnitTestCase { + #[Override] #[WithoutErrorHandler] protected function setUp(): void { diff --git a/tests/system/Helpers/HTMLHelperTest.php b/tests/system/Helpers/HTMLHelperTest.php index 787b100bbf2b..0ddcae91f276 100644 --- a/tests/system/Helpers/HTMLHelperTest.php +++ b/tests/system/Helpers/HTMLHelperTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\App; use Config\DocTypes; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -41,6 +42,7 @@ final class HTMLHelperTest extends CIUnitTestCase */ private string $imgData = 'R0lGODlhmwDIAOcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8fHyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZGRkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVVVVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKiouLi4yMjI2NjY6Ojo+Pj5CQkJGRkZKSkpOTk5SUlJWVlZaWlpeXl5iYmJmZmZqampubm5ycnJ2dnZ6enp+fn6CgoKGhoaKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq6ysrK2tra6urq+vr7CwsLGxsbKysrOzs7S0tLW1tba2tre3t7i4uLm5ubq6uru7u7y8vL29vb6+vr+/v8DAwMHBwcLCwsPDw8TExMXFxcbGxsfHx8jIyMnJycrKysvLy8zMzM3Nzc7Ozs/Pz9DQ0NHR0dLS0tPT09TU1NXV1dbW1tfX19jY2NnZ2dra2tvb29zc3N3d3d7e3t/f3+Dg4OHh4eLi4uPj4+Tk5OXl5ebm5ufn5+jo6Onp6erq6uvr6+zs7O3t7e7u7u/v7/Dw8PHx8fLy8vPz8/T09PX19fb29vf39/j4+Pn5+fr6+vv7+/z8/P39/f7+/v///yH5BAEKAP8ALAAAAACbAMgAAAj+AP8JHEiwoMGDCBMqXMiwocOHECNKnEhRIoCKGDNq3MixIYCLHUOKHEkS4UeQJVOqXAnxJEqWMGPCdCmzpk2SLl/e3MnTIs2eQIMuzKlTqNGgRIseXWozqVKmUFc6jUo1ptOnVbNqvPpRq9eOXLF+HeswrFiyaE2aTcvW49q2cA+aPRm37sC5Xe3GxUtXb1u+ef2mBRxY8FfChQ1rRXxWsVHGiR1DhdxYMk/KlS3fxJxZs1XOno9yjhx65+jOpUueJp165mrUrcG+jt30NWzaGG2zxi1S927eHH3/Bp5R+HDiFY3fRs5Q+XLmCZ0/h25Q+nTqd61jz239OvXux7f+ywXvHTn58sTPo+etfj3t9u5bwxdfdj79ofDjh84f/jt//Zb91x9zAg6YXoEAGoZggoItyKBfDt5HkIMP1kWhhAJRWCFcGm7IVoceogViiGONSKJXJp6YVYoqUsVii5O96B+L0L1ooEIwFmfjen0dtiOPPa74441q/VTVkESOl9ORSKJ3VYxNehfWUlEaOdFbQlUZZER8IaXllg8B1tOXS3JJmGlkllkfYpvx949wblFW038ZGhfdaZ/ll12UrulZZ5VSubknoCkJOiihI9E5YZqJGroomb05eqiWsvlZXZpJKmmfpl9uJCCOmG4l6aWhJqcoqKVeeSqqkKq6Kqv+nfr0KqyIhvlpS4ziOmtzua45apyU+rorr7ESe6urfBp7LLJNKjusrcnS+qusQ+IXoahISvsstTZqOy1F2XK6YKTdiotgozKaey66KZLaoWo0FtQuvCO6+26h9co7L773TtovvRf6C2KgAf8ZL8HrGnywStcqvDC/BQpsYp6nNtunoNGydGutCLfn8I8yYcxxx+R9DHLIHr/pJ2hzqmeydipj1mbJMZ8nsZgt05zyyzjn3B3PcD4q88ww26wvy0Q7B7Rt6p6JZtE/N91z0nbWrLTUXV4GtXR3Iv20ckuPZi1kWV7N9diMlV211b4567SXQYdNNrBvw932zV6jnfX+Y3GzvZqZU6utm9CzcTslU337LTazU7k4OOF4cpfUYo9DnndslVs+NHtM23v5e4UfHfmBo3sup3l/F/k56KWLvjnpq+ONV42tm84mgYt7Gzhwues+F3axu3477afTXTfsaUObPO5z6zo86s0rfzzv0Tu/O+fPAz499ttLPzvx11v/PfTha7839eUbjiX64weXfmndm3o+bvFL3j7rvwO8Pubzs3s4/ffTH1cAmL+LDRB/B0TZ/jwTQAM2Dn4L9NmTIJjAMUVQQf+z2wMlc0GtVRCDE4RSCBv0QRFOjoQbFFIK9zJCH53QQiskSwxl+EIWEoVDNwShlUqkJsfUUIUVYOJgDx0XxP0UUXAzQlymGCiaqgQEADs='; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Helpers/InflectorHelperTest.php b/tests/system/Helpers/InflectorHelperTest.php index 3d3079ec0880..59599106f2ee 100644 --- a/tests/system/Helpers/InflectorHelperTest.php +++ b/tests/system/Helpers/InflectorHelperTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Helpers; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -23,6 +24,7 @@ #[Group('Others')] final class InflectorHelperTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Helpers/NumberHelperTest.php b/tests/system/Helpers/NumberHelperTest.php index 7e5fe2a358c4..15668d658e9e 100644 --- a/tests/system/Helpers/NumberHelperTest.php +++ b/tests/system/Helpers/NumberHelperTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Helpers; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -22,6 +23,7 @@ #[Group('Others')] final class NumberHelperTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Helpers/SecurityHelperTest.php b/tests/system/Helpers/SecurityHelperTest.php index 9d5d60a903e4..495f4fe6dcdc 100644 --- a/tests/system/Helpers/SecurityHelperTest.php +++ b/tests/system/Helpers/SecurityHelperTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockSecurity; use Config\Security as SecurityConfig; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Config\Services; @@ -26,6 +27,7 @@ #[Group('Others')] final class SecurityHelperTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Helpers/TextHelperTest.php b/tests/system/Helpers/TextHelperTest.php index 2caf612925e0..0d5adc0c4975 100644 --- a/tests/system/Helpers/TextHelperTest.php +++ b/tests/system/Helpers/TextHelperTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -27,6 +28,7 @@ final class TextHelperTest extends CIUnitTestCase private string $longString = '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.'; private string $mbLongString = 'Давным-давно во фреймворке не было тестов. Это печально. И вот несколько хороших людей начали писать тесты. Чем больше времени проходило, тем счастливее становилось. Все были счастливы.'; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Helpers/URLHelper/CurrentUrlTest.php b/tests/system/Helpers/URLHelper/CurrentUrlTest.php index 6058ba1698d2..00c1fc4c65d0 100644 --- a/tests/system/Helpers/URLHelper/CurrentUrlTest.php +++ b/tests/system/Helpers/URLHelper/CurrentUrlTest.php @@ -22,6 +22,7 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -39,6 +40,7 @@ final class CurrentUrlTest extends CIUnitTestCase { private App $config; + #[Override] protected function setUp(): void { parent::setUp(); @@ -56,6 +58,7 @@ protected function setUp(): void service('superglobals')->setServer('SCRIPT_NAME', '/index.php'); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Helpers/URLHelper/MiscUrlTest.php b/tests/system/Helpers/URLHelper/MiscUrlTest.php index c8cefbda9c8b..4e19f701448e 100644 --- a/tests/system/Helpers/URLHelper/MiscUrlTest.php +++ b/tests/system/Helpers/URLHelper/MiscUrlTest.php @@ -23,6 +23,7 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -39,6 +40,7 @@ final class MiscUrlTest extends CIUnitTestCase { private App $config; + #[Override] protected function setUp(): void { parent::setUp(); @@ -53,6 +55,7 @@ protected function setUp(): void $this->config->indexPage = 'index.php'; } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Helpers/URLHelper/SiteUrlCliTest.php b/tests/system/Helpers/URLHelper/SiteUrlCliTest.php index 0d9d9b114dd8..fad321a50742 100644 --- a/tests/system/Helpers/URLHelper/SiteUrlCliTest.php +++ b/tests/system/Helpers/URLHelper/SiteUrlCliTest.php @@ -18,6 +18,7 @@ use CodeIgniter\HTTP\CLIRequest; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -35,6 +36,7 @@ final class SiteUrlCliTest extends CIUnitTestCase { private App $config; + #[Override] protected function setUp(): void { parent::setUp(); @@ -44,6 +46,7 @@ protected function setUp(): void $this->config = new App(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Helpers/URLHelper/SiteUrlTest.php b/tests/system/Helpers/URLHelper/SiteUrlTest.php index a095cf703a86..464792bb7565 100644 --- a/tests/system/Helpers/URLHelper/SiteUrlTest.php +++ b/tests/system/Helpers/URLHelper/SiteUrlTest.php @@ -21,6 +21,7 @@ use CodeIgniter\Superglobals; use CodeIgniter\Test\CIUnitTestCase; use Config\App; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -38,6 +39,7 @@ final class SiteUrlTest extends CIUnitTestCase { private App $config; + #[Override] protected function setUp(): void { parent::setUp(); @@ -48,6 +50,7 @@ protected function setUp(): void $this->config = new App(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Helpers/XMLHelperTest.php b/tests/system/Helpers/XMLHelperTest.php index f0a52d104d64..9f4a315d1dca 100644 --- a/tests/system/Helpers/XMLHelperTest.php +++ b/tests/system/Helpers/XMLHelperTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Helpers; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -22,6 +23,7 @@ #[Group('Others')] final class XMLHelperTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Honeypot/HoneypotTest.php b/tests/system/Honeypot/HoneypotTest.php index 0f0ba51f9d52..9d18128dcd82 100644 --- a/tests/system/Honeypot/HoneypotTest.php +++ b/tests/system/Honeypot/HoneypotTest.php @@ -26,6 +26,7 @@ use Config\App; use Config\Filters as FiltersConfig; use Config\Honeypot as HoneypotConfig; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; @@ -46,6 +47,7 @@ final class HoneypotTest extends CIUnitTestCase private Response $response; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/HotReloader/DirectoryHasherTest.php b/tests/system/HotReloader/DirectoryHasherTest.php index 8a0428465cea..da02dae4d272 100644 --- a/tests/system/HotReloader/DirectoryHasherTest.php +++ b/tests/system/HotReloader/DirectoryHasherTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Exceptions\FrameworkException; use CodeIgniter\Test\CIUnitTestCase; use Config\Toolbar; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -30,6 +31,7 @@ final class DirectoryHasherTest extends CIUnitTestCase private string $fixturePath; private string $fixturePathAlt; + #[Override] protected function setUp(): void { parent::setUp(); @@ -46,6 +48,7 @@ protected function setUp(): void $this->hasher = new DirectoryHasher(); } + #[Override] protected function tearDown(): void { $this->removeFixtureDirectory($this->fixturePath); diff --git a/tests/system/I18n/TimeDifferenceTest.php b/tests/system/I18n/TimeDifferenceTest.php index 87607af54902..8c6a55ceee30 100644 --- a/tests/system/I18n/TimeDifferenceTest.php +++ b/tests/system/I18n/TimeDifferenceTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Locale; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -25,6 +26,7 @@ final class TimeDifferenceTest extends CIUnitTestCase { private string $currentLocale; + #[Override] protected function setUp(): void { parent::setUp(); @@ -35,6 +37,7 @@ protected function setUp(): void Locale::setDefault('en-US'); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/I18n/TimeLegacyTest.php b/tests/system/I18n/TimeLegacyTest.php index 6e2cb2218e5a..6d8fee2915b5 100644 --- a/tests/system/I18n/TimeLegacyTest.php +++ b/tests/system/I18n/TimeLegacyTest.php @@ -21,6 +21,7 @@ use DateTimeZone; use IntlDateFormatter; use Locale; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -32,6 +33,7 @@ final class TimeLegacyTest extends CIUnitTestCase { private string $currentLocale; + #[Override] protected function setUp(): void { parent::setUp(); @@ -45,6 +47,7 @@ protected function setUp(): void Locale::setDefault('en_US'); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/I18n/TimeTest.php b/tests/system/I18n/TimeTest.php index 8b30a301f2ba..dffac6e2495f 100644 --- a/tests/system/I18n/TimeTest.php +++ b/tests/system/I18n/TimeTest.php @@ -22,6 +22,7 @@ use DateTimeZone; use IntlDateFormatter; use Locale; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -33,6 +34,7 @@ final class TimeTest extends CIUnitTestCase { private string $currentLocale; + #[Override] protected function setUp(): void { parent::setUp(); @@ -46,6 +48,7 @@ protected function setUp(): void Locale::setDefault('en_US'); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Images/BaseHandlerTest.php b/tests/system/Images/BaseHandlerTest.php index 17bc3c00eb70..cea2f132ff47 100644 --- a/tests/system/Images/BaseHandlerTest.php +++ b/tests/system/Images/BaseHandlerTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Images\Handlers\BaseHandler; use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -38,6 +39,7 @@ final class BaseHandlerTest extends CIUnitTestCase private string $start; private string $path; + #[Override] protected function setUp(): void { if (! extension_loaded('gd')) { diff --git a/tests/system/Images/GDHandlerTest.php b/tests/system/Images/GDHandlerTest.php index c9c04e4b5d70..3be342550072 100644 --- a/tests/system/Images/GDHandlerTest.php +++ b/tests/system/Images/GDHandlerTest.php @@ -20,6 +20,7 @@ use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; use org\bovigo\vfs\vfsStreamFile; +use Override; use PHPUnit\Framework\Attributes\Group; use Throwable; @@ -43,6 +44,7 @@ final class GDHandlerTest extends CIUnitTestCase private string $path; private BaseHandler $handler; + #[Override] protected function setUp(): void { if (! extension_loaded('gd')) { diff --git a/tests/system/Images/ImageMagickHandlerTest.php b/tests/system/Images/ImageMagickHandlerTest.php index 24e7ac7a7af9..19034e489d97 100644 --- a/tests/system/Images/ImageMagickHandlerTest.php +++ b/tests/system/Images/ImageMagickHandlerTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Images; use Imagick; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpExtension; @@ -42,6 +43,7 @@ final class ImageMagickHandlerTest extends CIUnitTestCase private string $path; private BaseHandler $handler; + #[Override] protected function setUp(): void { if (! extension_loaded('imagick')) { diff --git a/tests/system/Images/ImageTest.php b/tests/system/Images/ImageTest.php index 622a34ad3cc2..d48a16147fd5 100644 --- a/tests/system/Images/ImageTest.php +++ b/tests/system/Images/ImageTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -29,6 +30,7 @@ final class ImageTest extends CIUnitTestCase private string $start; private Image $image; + #[Override] protected function setUp(): void { // create virtual file system diff --git a/tests/system/Lock/LockTest.php b/tests/system/Lock/LockTest.php index 05d736e1a3cb..8d6c243c19dd 100644 --- a/tests/system/Lock/LockTest.php +++ b/tests/system/Lock/LockTest.php @@ -23,6 +23,7 @@ use CodeIgniter\Lock\Exceptions\LockException; use CodeIgniter\Test\CIUnitTestCase; use Config\Cache; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -34,6 +35,7 @@ final class LockTest extends CIUnitTestCase private Cache $config; private LockManager $locks; + #[Override] protected function setUp(): void { parent::setUp(); @@ -50,6 +52,7 @@ protected function setUp(): void $this->locks = new LockManager(CacheFactory::getHandler($this->config, 'file')); } + #[Override] protected function tearDown(): void { parent::tearDown(); @@ -205,6 +208,7 @@ public function testUnsupportedCacheHandlerThrows(): void public function testUnsupportedLockStoreProviderThrows(): void { $cache = new class () extends DummyHandler implements LockStoreProviderInterface { + #[Override] public function lockStore(): LockStoreInterface { throw CacheException::forUnsupportedLockStore(); diff --git a/tests/system/Log/Handlers/FileHandlerTest.php b/tests/system/Log/Handlers/FileHandlerTest.php index ddd1ca783f7c..9d9c97ab5f99 100644 --- a/tests/system/Log/Handlers/FileHandlerTest.php +++ b/tests/system/Log/Handlers/FileHandlerTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\Mock\MockFileLogger; use CodeIgniter\Test\Mock\MockLogger as LoggerConfig; use org\bovigo\vfs\vfsStream; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Log\Handlers\TestHandler; @@ -28,6 +29,7 @@ final class FileHandlerTest extends CIUnitTestCase { private string $start; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Log/LoggerTest.php b/tests/system/Log/LoggerTest.php index cf9fd2f2475e..46c9b00d29e4 100644 --- a/tests/system/Log/LoggerTest.php +++ b/tests/system/Log/LoggerTest.php @@ -22,6 +22,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockLogger as LoggerConfig; use org\bovigo\vfs\vfsStream; +use Override; use PHPUnit\Framework\Attributes\Group; use ReflectionMethod; use ReflectionNamedType; @@ -35,6 +36,7 @@ #[Group('Others')] final class LoggerTest extends CIUnitTestCase { + #[Override] protected function tearDown(): void { parent::tearDown(); @@ -247,6 +249,7 @@ public function testLogInterpolatesStringableContextValue(): void $logger->log('debug', 'Test message {value}', [ 'value' => new class () implements Stringable { + #[Override] public function __toString(): string { return 'stringable'; diff --git a/tests/system/Models/EventsModelTest.php b/tests/system/Models/EventsModelTest.php index 82e49952c7a2..0e639e10399f 100644 --- a/tests/system/Models/EventsModelTest.php +++ b/tests/system/Models/EventsModelTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Models; use CodeIgniter\Database\Exceptions\DataException; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Models\EventModel; @@ -23,6 +24,7 @@ #[Group('DatabaseLive')] final class EventsModelTest extends LiveModelTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Models/FirstOrInsertModelTest.php b/tests/system/Models/FirstOrInsertModelTest.php index 61a68f2aad22..1e36fd46b87e 100644 --- a/tests/system/Models/FirstOrInsertModelTest.php +++ b/tests/system/Models/FirstOrInsertModelTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Database\Exceptions\UniqueConstraintViolationException; use CodeIgniter\Exceptions\InvalidArgumentException; +use Override; use PHPUnit\Framework\Attributes\Group; use ReflectionProperty; use stdClass; @@ -27,6 +28,7 @@ #[Group('DatabaseLive')] final class FirstOrInsertModelTest extends LiveModelTestCase { + #[Override] protected function tearDown(): void { $this->enableDBDebug(); @@ -170,6 +172,7 @@ public function testHandlesRaceConditionWithDebugEnabled(): void // throws UniqueConstraintViolationException as if our own attempt // also tried to insert the same row. $model = new class ($this->db) extends UserModel { + #[Override] protected function doInsert(array $row): bool { parent::doInsert($row); @@ -197,6 +200,7 @@ public function testHandlesRaceConditionWithDebugDisabled(): void // inserts via a direct DB call, then our own attempt fails with a // unique violation which is stored in lastException (DBDebug=false). $model = new class ($this->db) extends UserModel { + #[Override] protected function doInsert(array $row): bool { // Direct insert – bypasses the model so it won't interfere @@ -231,6 +235,7 @@ public function testReturnsFalseOnNonUniqueErrorWithDebugDisabled(): void // a plain DatabaseException (not UniqueConstraintViolationException) // into lastException and returning false. $model = new class ($this->db) extends UserModel { + #[Override] protected function doInsert(array $row): bool { $prop = new ReflectionProperty($this->db, 'lastException'); diff --git a/tests/system/Models/GeneralModelTest.php b/tests/system/Models/GeneralModelTest.php index eb72f6aec5eb..9222078f66a0 100644 --- a/tests/system/Models/GeneralModelTest.php +++ b/tests/system/Models/GeneralModelTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Model; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Models\JobModel; @@ -38,6 +39,7 @@ final class GeneralModelTest extends CIUnitTestCase */ private ?object $model = null; + #[Override] protected function tearDown(): void { parent::tearDown(); @@ -176,6 +178,7 @@ public function testInitialize(): void /** * Marks the model as initialized. */ + #[Override] protected function initialize(): void { $this->initialized = true; diff --git a/tests/system/Models/LiveModelTestCase.php b/tests/system/Models/LiveModelTestCase.php index 31b2af8edbca..dad13c2f3493 100644 --- a/tests/system/Models/LiveModelTestCase.php +++ b/tests/system/Models/LiveModelTestCase.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use CodeIgniter\Test\ReflectionHelper; +use Override; use Tests\Support\Database\Seeds\CITestSeeder; /** @@ -38,6 +39,7 @@ abstract class LiveModelTestCase extends CIUnitTestCase protected $seed = CITestSeeder::class; + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Models/ReplaceModelTest.php b/tests/system/Models/ReplaceModelTest.php index 6be2fc6e51a9..526d7cb4e46f 100644 --- a/tests/system/Models/ReplaceModelTest.php +++ b/tests/system/Models/ReplaceModelTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Database\Exceptions\DataException; use CodeIgniter\I18n\Time; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Models\JobModel; @@ -27,6 +28,7 @@ #[Group('DatabaseLive')] final class ReplaceModelTest extends LiveModelTestCase { + #[Override] protected function tearDown(): void { parent::tearDown(); @@ -147,6 +149,7 @@ public function testReplacePreservesCustomPrimaryKey(): void public function testReplacePreservesFieldOrder(bool $primaryKeyFirst): void { $model = new class ($this->db) extends UserModel { + #[Override] protected function doReplace(?array $row = null, bool $returnSQL = false): string { return implode(',', array_keys((array) $row)); @@ -177,6 +180,7 @@ public static function provideReplacePreservesFieldOrder(): iterable public function testReplaceUsesCustomFieldProtection(): void { $model = new class ($this->db) extends JobModel { + #[Override] protected function doProtectFields(array $row): array { $row = parent::doProtectFields($row); @@ -270,6 +274,7 @@ public function testReplaceWithEmptyDataCanGenerateTimestamps(): void public function testReplaceRejectsEmptyDataFromCustomProtectionBeforeTimestamps(): void { $model = new class ($this->db) extends JobModel { + #[Override] protected function doProtectFieldsForReplace(array $row): array { return $this->doProtectFields($row); diff --git a/tests/system/Models/TimestampModelTest.php b/tests/system/Models/TimestampModelTest.php index f87f54772831..d281f8d18bf2 100644 --- a/tests/system/Models/TimestampModelTest.php +++ b/tests/system/Models/TimestampModelTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Models; use CodeIgniter\I18n\Time; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Entity\User; use Tests\Support\Models\UserTimestampModel; @@ -30,6 +31,7 @@ final class TimestampModelTest extends LiveModelTestCase protected $refresh = false; protected $seed = ''; + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Models/ValidationModelRuleGroupTest.php b/tests/system/Models/ValidationModelRuleGroupTest.php index 8059e1fee7d2..0bf932076a4c 100644 --- a/tests/system/Models/ValidationModelRuleGroupTest.php +++ b/tests/system/Models/ValidationModelRuleGroupTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Database\BaseConnection; use CodeIgniter\Model; +use Override; use PHPUnit\Framework\Attributes\Group; use stdClass; use Tests\Support\Config\Validation; @@ -29,6 +30,7 @@ #[Group('DatabaseLive')] final class ValidationModelRuleGroupTest extends LiveModelTestCase { + #[Override] protected function setUp(): void { parent::setUp(); @@ -36,6 +38,7 @@ protected function setUp(): void $this->createModel(ValidModelRuleGroup::class); } + #[Override] protected function createModel(string $modelName, ?BaseConnection $db = null): Model { $config = new Validation(); diff --git a/tests/system/Models/ValidationModelTest.php b/tests/system/Models/ValidationModelTest.php index ba03bea98231..e8f69455236b 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 Override; use PHPUnit\Framework\Attributes\Group; use stdClass; use Tests\Support\Models\JobModel; @@ -29,6 +30,7 @@ #[Group('DatabaseLive')] final class ValidationModelTest extends LiveModelTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Models/WithLockedRowModelTest.php b/tests/system/Models/WithLockedRowModelTest.php index 6ea05df4714b..be93eb8500be 100644 --- a/tests/system/Models/WithLockedRowModelTest.php +++ b/tests/system/Models/WithLockedRowModelTest.php @@ -13,6 +13,7 @@ namespace CodeIgniter\Models; +use Override; use PHPUnit\Framework\Attributes\Group; use RuntimeException; use Tests\Support\Models\EventModel; @@ -24,6 +25,7 @@ #[Group('DatabaseLive')] final class WithLockedRowModelTest extends LiveModelTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Pager/PagerRendererTest.php b/tests/system/Pager/PagerRendererTest.php index 6744c2522ab9..99fe51b86d8c 100644 --- a/tests/system/Pager/PagerRendererTest.php +++ b/tests/system/Pager/PagerRendererTest.php @@ -15,6 +15,7 @@ use CodeIgniter\HTTP\URI; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -27,6 +28,7 @@ final class PagerRendererTest extends CIUnitTestCase private string $expect; private URI $uri; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Pager/PagerTest.php b/tests/system/Pager/PagerTest.php index 875f5c25b320..70e6b99dc4d8 100644 --- a/tests/system/Pager/PagerTest.php +++ b/tests/system/Pager/PagerTest.php @@ -24,6 +24,7 @@ use Config\App; use Config\Pager as PagerConfig; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; @@ -37,6 +38,7 @@ final class PagerTest extends CIUnitTestCase private ?Pager $pager = null; private ?PagerConfig $config = null; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Publisher/PublisherContentReplaceTest.php b/tests/system/Publisher/PublisherContentReplaceTest.php index fd948ea70896..10313e38c67c 100644 --- a/tests/system/Publisher/PublisherContentReplaceTest.php +++ b/tests/system/Publisher/PublisherContentReplaceTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Publisher; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -25,6 +26,7 @@ final class PublisherContentReplaceTest extends CIUnitTestCase private string $file; private Publisher $publisher; + #[Override] protected function setUp(): void { parent::setUp(); @@ -35,6 +37,7 @@ protected function setUp(): void $this->publisher = new Publisher(__DIR__, __DIR__); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Publisher/PublisherInputTest.php b/tests/system/Publisher/PublisherInputTest.php index b1046e19cf68..bf2f38237322 100644 --- a/tests/system/Publisher/PublisherInputTest.php +++ b/tests/system/Publisher/PublisherInputTest.php @@ -17,6 +17,7 @@ use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\Test\CIUnitTestCase; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -40,6 +41,7 @@ final class PublisherInputTest extends CIUnitTestCase * tests call static methods before * the constructor would load it. */ + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); diff --git a/tests/system/Publisher/PublisherOutputTest.php b/tests/system/Publisher/PublisherOutputTest.php index 73571cd81a98..1ba89dfcc0be 100644 --- a/tests/system/Publisher/PublisherOutputTest.php +++ b/tests/system/Publisher/PublisherOutputTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -44,6 +45,7 @@ final class PublisherOutputTest extends CIUnitTestCase * tests call static methods before * the constructor would load it. */ + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -51,6 +53,7 @@ public static function setUpBeforeClass(): void helper(['filesystem']); } + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Publisher/PublisherSupportTest.php b/tests/system/Publisher/PublisherSupportTest.php index c63973e63d36..d7af41431512 100644 --- a/tests/system/Publisher/PublisherSupportTest.php +++ b/tests/system/Publisher/PublisherSupportTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Publisher\Exceptions\PublisherException; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Publishers\TestPublisher; @@ -39,6 +40,7 @@ final class PublisherSupportTest extends CIUnitTestCase * tests call static methods before * the constructor would load it. */ + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); diff --git a/tests/system/RESTful/ResourceControllerTest.php b/tests/system/RESTful/ResourceControllerTest.php index 4876de1cd7ad..2befc80963ea 100644 --- a/tests/system/RESTful/ResourceControllerTest.php +++ b/tests/system/RESTful/ResourceControllerTest.php @@ -28,6 +28,7 @@ use CodeIgniter\Test\Mock\MockCodeIgniter; use CodeIgniter\Test\Mock\MockResourceController; use Config\App; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; @@ -51,6 +52,7 @@ final class ResourceControllerTest extends CIUnitTestCase { private CodeIgniter $codeigniter; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { @@ -86,6 +88,7 @@ private function createCodeigniter(): void $response->pretend(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/RESTful/ResourcePresenterTest.php b/tests/system/RESTful/ResourcePresenterTest.php index 8f691c57296b..43744a79a476 100644 --- a/tests/system/RESTful/ResourcePresenterTest.php +++ b/tests/system/RESTful/ResourcePresenterTest.php @@ -22,6 +22,7 @@ use CodeIgniter\Test\Mock\MockCodeIgniter; use CodeIgniter\Test\Mock\MockResourcePresenter; use Config\App; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; @@ -45,6 +46,7 @@ final class ResourcePresenterTest extends CIUnitTestCase { private CodeIgniter $codeigniter; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { @@ -76,6 +78,7 @@ private function createCodeigniter(): void $this->codeigniter = new MockCodeIgniter($config); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Router/Attributes/CacheTest.php b/tests/system/Router/Attributes/CacheTest.php index f31045336973..790c210e0356 100644 --- a/tests/system/Router/Attributes/CacheTest.php +++ b/tests/system/Router/Attributes/CacheTest.php @@ -21,6 +21,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockAppConfig; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; @@ -30,6 +31,7 @@ #[Group('Others')] final class CacheTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); @@ -39,6 +41,7 @@ protected function setUp(): void Time::setTestNow('2026-01-10 12:00:00'); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Router/AutoRouterImprovedTest.php b/tests/system/Router/AutoRouterImprovedTest.php index 7c29f444610d..b79a0a537549 100644 --- a/tests/system/Router/AutoRouterImprovedTest.php +++ b/tests/system/Router/AutoRouterImprovedTest.php @@ -24,6 +24,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Modules; use Config\Routing; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -35,6 +36,7 @@ final class AutoRouterImprovedTest extends CIUnitTestCase { private RouteCollection $collection; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Router/Controllers/Requests/MyFormRequest.php b/tests/system/Router/Controllers/Requests/MyFormRequest.php index c2e4805d7e27..a02863a23090 100644 --- a/tests/system/Router/Controllers/Requests/MyFormRequest.php +++ b/tests/system/Router/Controllers/Requests/MyFormRequest.php @@ -14,9 +14,11 @@ namespace CodeIgniter\Router\Controllers\Requests; use CodeIgniter\HTTP\FormRequest; +use Override; class MyFormRequest extends FormRequest { + #[Override] public function rules(): array { return []; diff --git a/tests/system/Router/RouteCollectionReverseRouteTest.php b/tests/system/Router/RouteCollectionReverseRouteTest.php index 36ead775da06..113b4d75c613 100644 --- a/tests/system/Router/RouteCollectionReverseRouteTest.php +++ b/tests/system/Router/RouteCollectionReverseRouteTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Modules; use Config\Routing; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -27,6 +28,7 @@ #[Group('Others')] final class RouteCollectionReverseRouteTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Router/RouteCollectionTest.php b/tests/system/Router/RouteCollectionTest.php index 01b70c06a750..49da28976d26 100644 --- a/tests/system/Router/RouteCollectionTest.php +++ b/tests/system/Router/RouteCollectionTest.php @@ -24,6 +24,7 @@ use Config\Feature; use Config\Modules; use Config\Routing; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Controllers\Hello; @@ -35,6 +36,7 @@ #[Group('Others')] final class RouteCollectionTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Router/RouterTest.php b/tests/system/Router/RouterTest.php index 6e22c95ed4f9..7548867dbe51 100644 --- a/tests/system/Router/RouterTest.php +++ b/tests/system/Router/RouterTest.php @@ -27,6 +27,7 @@ use Config\Feature; use Config\Modules; use Config\Routing; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Filters\Customfilter; @@ -41,6 +42,7 @@ final class RouterTest extends CIUnitTestCase private RouteCollection $collection; private IncomingRequest $request; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Security/CheckPhpIniTest.php b/tests/system/Security/CheckPhpIniTest.php index 272a06298240..2b599b8e4773 100644 --- a/tests/system/Security/CheckPhpIniTest.php +++ b/tests/system/Security/CheckPhpIniTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -38,6 +39,7 @@ final class CheckPhpIniTest extends CIUnitTestCase */ public static ?array $iniGetAllReturn = null; + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Security/SecurityCSRFCookieRandomizeTokenTest.php b/tests/system/Security/SecurityCSRFCookieRandomizeTokenTest.php index 8edab86902dd..a92a4a3f5efe 100644 --- a/tests/system/Security/SecurityCSRFCookieRandomizeTokenTest.php +++ b/tests/system/Security/SecurityCSRFCookieRandomizeTokenTest.php @@ -23,6 +23,7 @@ use CodeIgniter\Test\Mock\MockAppConfig; use CodeIgniter\Test\Mock\MockSecurity; use Config\Security as SecurityConfig; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -34,6 +35,7 @@ final class SecurityCSRFCookieRandomizeTokenTest extends CIUnitTestCase private const CSRF_PROTECTION_HASH = '8b9218a55906f9dcc1dc263dce7f005a'; private const CSRF_RANDOMIZED_TOKEN = '8bc70b67c91494e815c7d2219c1ae0ab005513c290126d34d41bf41c5265e0f1'; + #[Override] protected function setUp(): void { parent::setUp(); @@ -51,6 +53,7 @@ protected function setUp(): void $this->resetServices(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php b/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php index 1c242e249519..900502d00342 100644 --- a/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php +++ b/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php @@ -33,6 +33,7 @@ use Config\Logger as LoggerConfig; use Config\Security as SecurityConfig; use Config\Session as SessionConfig; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; @@ -58,6 +59,7 @@ final class SecurityCSRFSessionRandomizeTokenTest extends CIUnitTestCase private SecurityConfig $config; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { diff --git a/tests/system/Security/SecurityCSRFSessionTest.php b/tests/system/Security/SecurityCSRFSessionTest.php index fbb28e5baaf1..854fca162e4a 100644 --- a/tests/system/Security/SecurityCSRFSessionTest.php +++ b/tests/system/Security/SecurityCSRFSessionTest.php @@ -32,6 +32,7 @@ use Config\Logger as LoggerConfig; use Config\Security as SecurityConfig; use Config\Session as SessionConfig; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; @@ -52,6 +53,7 @@ final class SecurityCSRFSessionTest extends CIUnitTestCase private SecurityConfig $config; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { diff --git a/tests/system/Security/SecurityTest.php b/tests/system/Security/SecurityTest.php index d7f2e83d8347..ac38be226405 100644 --- a/tests/system/Security/SecurityTest.php +++ b/tests/system/Security/SecurityTest.php @@ -25,6 +25,7 @@ use CodeIgniter\Test\Mock\MockAppConfig; use CodeIgniter\Test\Mock\MockSecurity; use Config\Security as SecurityConfig; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -39,6 +40,7 @@ final class SecurityTest extends CIUnitTestCase private const CORRECT_CSRF_HASH = '8b9218a55906f9dcc1dc263dce7f005a'; private const INVALID_CSRF_HASH = '8b9218a55906f9dcc1dc263dce7f005b'; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Session/Handlers/BaseHandlerTest.php b/tests/system/Session/Handlers/BaseHandlerTest.php index fb9d2a2e9c10..05a838dd9ece 100644 --- a/tests/system/Session/Handlers/BaseHandlerTest.php +++ b/tests/system/Session/Handlers/BaseHandlerTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Cookie as CookieConfig; use Config\Session as SessionConfig; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -59,6 +60,7 @@ final class BaseHandlerTest extends CIUnitTestCase */ public static ?array $lastSetCookieArgs = null; + #[Override] protected function setUp(): void { parent::setUp(); @@ -68,6 +70,7 @@ protected function setUp(): void Factories::reset('config'); } + #[Override] protected function tearDown(): void { // Reset before parent::tearDown() so a failure in the parent does not @@ -90,31 +93,37 @@ private function createHandler(?CookieConfig $cookieConfig = null): BaseHandler $sessionConfig->cookieName = 'ci_session'; return new class ($sessionConfig, '127.0.0.1') extends BaseHandler { + #[Override] public function open(string $path, string $name): bool { return true; } + #[Override] public function close(): bool { return true; } + #[Override] public function read(string $id): string { return ''; } + #[Override] public function write(string $id, string $data): bool { return true; } + #[Override] public function destroy(string $id): bool { return $this->destroyCookie(); } + #[Override] public function gc(int $maxLifetime): int { return 1; diff --git a/tests/system/Session/Handlers/Database/AbstractHandlerTestCase.php b/tests/system/Session/Handlers/Database/AbstractHandlerTestCase.php index 743508d7fe55..2fb2f467ebbe 100644 --- a/tests/system/Session/Handlers/Database/AbstractHandlerTestCase.php +++ b/tests/system/Session/Handlers/Database/AbstractHandlerTestCase.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\DatabaseTestTrait; use CodeIgniter\Test\ReflectionHelper; use Config\Database as DatabaseConfig; +use Override; use Tests\Support\Database\Seeds\CITestSeeder; /** @@ -35,6 +36,7 @@ abstract class AbstractHandlerTestCase extends CIUnitTestCase protected string $sessionName = 'ci_session'; protected string $userIpAddress = '127.0.0.1'; + #[Override] protected function setUp(): void { if (! in_array(config(DatabaseConfig::class)->tests['DBDriver'], ['MySQLi', 'Postgre'], true)) { diff --git a/tests/system/Session/Handlers/Database/MySQLiHandlerTest.php b/tests/system/Session/Handlers/Database/MySQLiHandlerTest.php index 281ac419c5f5..2ef98f017591 100644 --- a/tests/system/Session/Handlers/Database/MySQLiHandlerTest.php +++ b/tests/system/Session/Handlers/Database/MySQLiHandlerTest.php @@ -15,6 +15,7 @@ use Config\Database as DatabaseConfig; use Config\Session as SessionConfig; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -23,6 +24,7 @@ #[Group('DatabaseLive')] final class MySQLiHandlerTest extends AbstractHandlerTestCase { + #[Override] protected function setUp(): void { parent::setUp(); @@ -32,6 +34,7 @@ protected function setUp(): void } } + #[Override] protected function getInstance($options = []): MySQLiHandler { $defaults = [ diff --git a/tests/system/Session/Handlers/Database/PostgreHandlerMockConnection.php b/tests/system/Session/Handlers/Database/PostgreHandlerMockConnection.php index fc45a6414b75..fc08b3244cee 100644 --- a/tests/system/Session/Handlers/Database/PostgreHandlerMockConnection.php +++ b/tests/system/Session/Handlers/Database/PostgreHandlerMockConnection.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\Mock\MockConnection; use CodeIgniter\Test\Mock\MockResult; +use Override; /** * Mock connection that records the raw SQL passed to simpleQuery(). @@ -31,6 +32,7 @@ final class PostgreHandlerMockConnection extends MockConnection */ public array $executed = []; + #[Override] public function simpleQuery(string $sql): MockResult { $this->executed[] = $sql; diff --git a/tests/system/Session/Handlers/Database/PostgreHandlerTest.php b/tests/system/Session/Handlers/Database/PostgreHandlerTest.php index 80ec37fbc240..cc3cc324edcf 100644 --- a/tests/system/Session/Handlers/Database/PostgreHandlerTest.php +++ b/tests/system/Session/Handlers/Database/PostgreHandlerTest.php @@ -15,6 +15,7 @@ use Config\Database as DatabaseConfig; use Config\Session as SessionConfig; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -23,6 +24,7 @@ #[Group('DatabaseLive')] final class PostgreHandlerTest extends AbstractHandlerTestCase { + #[Override] protected function setUp(): void { parent::setUp(); @@ -32,6 +34,7 @@ protected function setUp(): void } } + #[Override] protected function getInstance($options = []): PostgreHandler { $defaults = [ diff --git a/tests/system/Session/Handlers/Database/RedisHandlerTest.php b/tests/system/Session/Handlers/Database/RedisHandlerTest.php index c2f549e31659..7bbae8606c01 100644 --- a/tests/system/Session/Handlers/Database/RedisHandlerTest.php +++ b/tests/system/Session/Handlers/Database/RedisHandlerTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\TestLogger; use Config\Logger as LoggerConfig; use Config\Session as SessionConfig; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpExtension; @@ -62,6 +63,7 @@ protected function getInstance($options = []): RedisHandler return $handler; } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Session/Handlers/FileHandlerTest.php b/tests/system/Session/Handlers/FileHandlerTest.php index 3c94aacad693..9b33afc091fa 100644 --- a/tests/system/Session/Handlers/FileHandlerTest.php +++ b/tests/system/Session/Handlers/FileHandlerTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Test\TestLogger; use Config\Logger as LoggerConfig; use Config\Session as SessionConfig; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; @@ -36,6 +37,7 @@ final class FileHandlerTest extends CIUnitTestCase private string $originalSidBits; private string $originalSidLength; + #[Override] protected function setUp(): void { parent::setUp(); @@ -48,6 +50,7 @@ protected function setUp(): void mkdir($this->tempPath, 0700, true); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Session/Handlers/MemcachedHandlerTest.php b/tests/system/Session/Handlers/MemcachedHandlerTest.php index 8a24a7377722..58bba45abc69 100644 --- a/tests/system/Session/Handlers/MemcachedHandlerTest.php +++ b/tests/system/Session/Handlers/MemcachedHandlerTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\TestLogger; use Config\Logger as LoggerConfig; use Config\Session as SessionConfig; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpExtension; @@ -60,6 +61,7 @@ protected function getInstance($options = []): MemcachedHandler return $handler; } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Session/SessionTest.php b/tests/system/Session/SessionTest.php index 91ed72173097..649a4c92a718 100644 --- a/tests/system/Session/SessionTest.php +++ b/tests/system/Session/SessionTest.php @@ -24,6 +24,7 @@ use Config\Cookie as CookieConfig; use Config\Logger as LoggerConfig; use Config\Session as SessionConfig; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; @@ -37,6 +38,7 @@ #[RunTestsInSeparateProcesses] final class SessionTest extends CIUnitTestCase { + #[Override] #[WithoutErrorHandler] protected function setUp(): void { diff --git a/tests/system/SuperglobalsTest.php b/tests/system/SuperglobalsTest.php index 2aa24f5b64c5..d84522f8dbd2 100644 --- a/tests/system/SuperglobalsTest.php +++ b/tests/system/SuperglobalsTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\Group; @@ -27,6 +28,7 @@ final class SuperglobalsTest extends CIUnitTestCase { private Superglobals $superglobals; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Test/BootstrapFCPATHTest.php b/tests/system/Test/BootstrapFCPATHTest.php index 6b876006c3d1..04109165bc05 100644 --- a/tests/system/Test/BootstrapFCPATHTest.php +++ b/tests/system/Test/BootstrapFCPATHTest.php @@ -13,6 +13,7 @@ namespace CodeIgniter\Test; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -32,6 +33,7 @@ final class BootstrapFCPATHTest extends CIUnitTestCase private string $dir1 = '/tmp/dir1'; private string $file1 = '/tmp/dir1/testFile.php'; + #[Override] protected function setUp(): void { parent::setUp(); @@ -41,6 +43,7 @@ protected function setUp(): void $this->writeFiles(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Test/ControllerTestTraitTest.php b/tests/system/Test/ControllerTestTraitTest.php index 5662c773d4cd..66a5b590ace2 100644 --- a/tests/system/Test/ControllerTestTraitTest.php +++ b/tests/system/Test/ControllerTestTraitTest.php @@ -22,6 +22,7 @@ use CodeIgniter\Log\Logger; use CodeIgniter\Test\Mock\MockLogger as LoggerConfig; use Config\App; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; @@ -41,6 +42,7 @@ final class ControllerTestTraitTest extends CIUnitTestCase { use ControllerTestTrait; + #[Override] #[WithoutErrorHandler] protected function setUp(): void { diff --git a/tests/system/Test/DOMParserTest.php b/tests/system/Test/DOMParserTest.php index 58d4e332ce40..911b36678d46 100644 --- a/tests/system/Test/DOMParserTest.php +++ b/tests/system/Test/DOMParserTest.php @@ -13,6 +13,7 @@ namespace CodeIgniter\Test; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -22,6 +23,7 @@ #[Group('Others')] final class DOMParserTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Test/FabricatorTest.php b/tests/system/Test/FabricatorTest.php index 7eaa81863cfd..2d8ae3f57186 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 Override; use PHPUnit\Framework\Attributes\Group; use stdClass; use Tests\Support\Models\EntityModel; @@ -41,6 +42,7 @@ final class FabricatorTest extends CIUnitTestCase 'deleted_at' => 'date', ]; + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php b/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php index 61218ff64b80..17477be630ec 100644 --- a/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php +++ b/tests/system/Test/FeatureTestAutoRoutingImprovedTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Events\Events; use Config\Feature; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class FeatureTestAutoRoutingImprovedTest extends CIUnitTestCase { use FeatureTestTrait; + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -35,6 +37,7 @@ public static function setUpBeforeClass(): void self::initializeRouter(); } + #[Override] public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); diff --git a/tests/system/Test/FeatureTestTraitTest.php b/tests/system/Test/FeatureTestTraitTest.php index 03bd4c11e468..e27b6589e389 100644 --- a/tests/system/Test/FeatureTestTraitTest.php +++ b/tests/system/Test/FeatureTestTraitTest.php @@ -24,6 +24,7 @@ use Config\App; use Config\Feature; use Config\Routing; +use Override; use PHPUnit\Framework\Attributes\BackupGlobals; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -37,6 +38,7 @@ final class FeatureTestTraitTest extends CIUnitTestCase { use FeatureTestTrait; + #[Override] protected function setUp(): void { parent::setUp(); @@ -44,6 +46,7 @@ protected function setUp(): void $this->skipEvents(); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Test/FilterTestTraitTest.php b/tests/system/Test/FilterTestTraitTest.php index 3343be2e47a1..9b281d38f989 100644 --- a/tests/system/Test/FilterTestTraitTest.php +++ b/tests/system/Test/FilterTestTraitTest.php @@ -15,6 +15,7 @@ use Closure; use CodeIgniter\HTTP\RequestInterface; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Filters\Customfilter; @@ -34,6 +35,7 @@ final class FilterTestTraitTest extends CIUnitTestCase { use FilterTestTrait; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Test/Mock/MockInputOutputTest.php b/tests/system/Test/Mock/MockInputOutputTest.php index 9ac7aefb547a..f5818530b444 100644 --- a/tests/system/Test/Mock/MockInputOutputTest.php +++ b/tests/system/Test/Mock/MockInputOutputTest.php @@ -16,6 +16,7 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\StreamFilterTrait; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -26,6 +27,7 @@ final class MockInputOutputTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Test/Orchestrator/AbstractOrchestratorTest.php b/tests/system/Test/Orchestrator/AbstractOrchestratorTest.php index 06188f4195f0..7c3ee01a65b1 100644 --- a/tests/system/Test/Orchestrator/AbstractOrchestratorTest.php +++ b/tests/system/Test/Orchestrator/AbstractOrchestratorTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Config\DotEnv; use CodeIgniter\Exceptions\RuntimeException; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -33,6 +34,7 @@ final class AbstractOrchestratorTest extends CIUnitTestCase private static string $buildPath; private static OrchestratorStub $orchestrator; + #[Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -48,6 +50,7 @@ public static function setUpBeforeClass(): void self::$orchestrator->build(); } + #[Override] public static function tearDownAfterClass(): void { self::$orchestrator->clean(); diff --git a/tests/system/Test/ReflectionHelperTest.php b/tests/system/Test/ReflectionHelperTest.php index 41eb0d15d9d0..f1c3ee1f368d 100644 --- a/tests/system/Test/ReflectionHelperTest.php +++ b/tests/system/Test/ReflectionHelperTest.php @@ -13,6 +13,7 @@ namespace CodeIgniter\Test; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Test\TestForReflectionHelper; @@ -22,6 +23,7 @@ #[Group('Others')] final class ReflectionHelperTest extends CIUnitTestCase { + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Test/TestCaseTest.php b/tests/system/Test/TestCaseTest.php index 647b657aab40..fbb74670f0e3 100644 --- a/tests/system/Test/TestCaseTest.php +++ b/tests/system/Test/TestCaseTest.php @@ -15,6 +15,7 @@ use CodeIgniter\CLI\CLI; use CodeIgniter\Events\Events; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Test\TestForReflectionHelper; @@ -26,6 +27,7 @@ final class TestCaseTest extends CIUnitTestCase { use StreamFilterTrait; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Throttle/ThrottleTest.php b/tests/system/Throttle/ThrottleTest.php index b16606341ab7..543d8bd866e7 100644 --- a/tests/system/Throttle/ThrottleTest.php +++ b/tests/system/Throttle/ThrottleTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Cache\CacheInterface; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockCache; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; @@ -27,6 +28,7 @@ final class ThrottleTest extends CIUnitTestCase { private CacheInterface $cache; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Typography/TypographyTest.php b/tests/system/Typography/TypographyTest.php index aa46e639e180..53fcd5f0b349 100644 --- a/tests/system/Typography/TypographyTest.php +++ b/tests/system/Typography/TypographyTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Typography; use CodeIgniter\Test\CIUnitTestCase; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -24,6 +25,7 @@ final class TypographyTest extends CIUnitTestCase { private Typography $typography; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Validation/DatabaseRelatedRulesTest.php b/tests/system/Validation/DatabaseRelatedRulesTest.php index 1b6445c47f08..e9373bb7ace1 100644 --- a/tests/system/Validation/DatabaseRelatedRulesTest.php +++ b/tests/system/Validation/DatabaseRelatedRulesTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Validation; use CodeIgniter\Validation\StrictRules\DatabaseRelatedRulesTest as StrictDatabaseRelatedRulesTest; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; @@ -48,6 +49,7 @@ final class DatabaseRelatedRulesTest extends StrictDatabaseRelatedRulesTest ], ]; + #[Override] protected function createRules(): object { return new Rules(); diff --git a/tests/system/Validation/FormatRulesTest.php b/tests/system/Validation/FormatRulesTest.php index c2b6e0ca480c..b6051645182c 100644 --- a/tests/system/Validation/FormatRulesTest.php +++ b/tests/system/Validation/FormatRulesTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Generator; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; @@ -53,6 +54,7 @@ class FormatRulesTest extends CIUnitTestCase ], ]; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Validation/RulesTest.php b/tests/system/Validation/RulesTest.php index d4b71bd0a5f6..01578601f4d4 100644 --- a/tests/system/Validation/RulesTest.php +++ b/tests/system/Validation/RulesTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use ErrorException; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use stdClass; @@ -51,6 +52,7 @@ class RulesTest extends CIUnitTestCase ], ]; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Validation/StrictRules/CreditCardRulesTest.php b/tests/system/Validation/StrictRules/CreditCardRulesTest.php index 55a880839662..650a436fdfe2 100644 --- a/tests/system/Validation/StrictRules/CreditCardRulesTest.php +++ b/tests/system/Validation/StrictRules/CreditCardRulesTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Validation\Validation; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; @@ -50,6 +51,7 @@ class CreditCardRulesTest extends CIUnitTestCase ], ]; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php b/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php index 43e25d8e7a8a..f1874c3a1f0d 100644 --- a/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php +++ b/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Validation\Validation; use Config\Database; use LogicException; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; @@ -59,6 +60,7 @@ class DatabaseRelatedRulesTest extends CIUnitTestCase ], ]; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/Validation/StrictRules/FileRulesTest.php b/tests/system/Validation/StrictRules/FileRulesTest.php index 77b506068728..48edd95e625b 100644 --- a/tests/system/Validation/StrictRules/FileRulesTest.php +++ b/tests/system/Validation/StrictRules/FileRulesTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Validation\Validation; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; @@ -55,6 +56,7 @@ class FileRulesTest extends CIUnitTestCase ], ]; + #[Override] protected function setUp(): void { $this->resetServices(); @@ -154,6 +156,7 @@ protected function setUp(): void ]); } + #[Override] protected function tearDown(): void { parent::tearDown(); diff --git a/tests/system/Validation/StrictRules/FormatRulesTest.php b/tests/system/Validation/StrictRules/FormatRulesTest.php index db7372d8179c..1be4856cf817 100644 --- a/tests/system/Validation/StrictRules/FormatRulesTest.php +++ b/tests/system/Validation/StrictRules/FormatRulesTest.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Validation\StrictRules; use CodeIgniter\Validation\FormatRulesTest as TraditionalFormatRulesTest; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; @@ -44,6 +45,7 @@ final class FormatRulesTest extends TraditionalFormatRulesTest ], ]; + #[Override] public static function provideAlphaSpace(): iterable { yield from [ @@ -74,6 +76,7 @@ public static function provideAlphaSpace(): iterable ]; } + #[Override] public static function provideInvalidIntegerType(): iterable { yield 'array with int' => [ diff --git a/tests/system/Validation/StrictRules/RulesTest.php b/tests/system/Validation/StrictRules/RulesTest.php index 9cb5744a285d..b89f0dd16333 100644 --- a/tests/system/Validation/StrictRules/RulesTest.php +++ b/tests/system/Validation/StrictRules/RulesTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Validation\RulesTest as TraditionalRulesTest; use CodeIgniter\Validation\Validation; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use Tests\Support\Validation\TestRules; @@ -228,6 +229,7 @@ public static function provideLessEqualThanStrict(): iterable * @param array $data */ #[DataProvider('provideMatches')] + #[Override] public function testMatches(array $data, bool $expected): void { $this->validation->setRules(['foo' => 'matches[bar]']); @@ -237,6 +239,7 @@ public function testMatches(array $data, bool $expected): void /** * @return iterable, bool}> */ + #[Override] public static function provideMatches(): iterable { yield from [ @@ -256,6 +259,7 @@ public static function provideMatches(): iterable * @param array $data */ #[DataProvider('provideDiffers')] + #[Override] public function testDiffers(array $data, bool $expected): void { $this->validation->setRules(['foo' => 'differs[bar]']); @@ -265,6 +269,7 @@ public function testDiffers(array $data, bool $expected): void /** * @return iterable, bool}> */ + #[Override] public static function provideDiffers(): iterable { yield from [ @@ -280,6 +285,7 @@ public static function provideDiffers(): iterable ]; } + #[Override] public function testIfExistArray(): void { $rules = ['foo' => 'if_exist|alpha']; diff --git a/tests/system/Validation/ValidationTest.php b/tests/system/Validation/ValidationTest.php index ddcf858e60a8..a8c5b911f4cf 100644 --- a/tests/system/Validation/ValidationTest.php +++ b/tests/system/Validation/ValidationTest.php @@ -24,6 +24,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Validation\Exceptions\ValidationException; use Config\App; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\ExpectationFailedException; @@ -82,6 +83,7 @@ class ValidationTest extends CIUnitTestCase ], ]; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/View/CellTest.php b/tests/system/View/CellTest.php index 85016018fef3..bb1b9fc46d52 100644 --- a/tests/system/View/CellTest.php +++ b/tests/system/View/CellTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockCache; use CodeIgniter\View\Exceptions\ViewException; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -27,6 +28,7 @@ final class CellTest extends CIUnitTestCase { private Cell $cell; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/View/ControlledCellTest.php b/tests/system/View/ControlledCellTest.php index 8215993ca07b..b2099933d9e3 100644 --- a/tests/system/View/ControlledCellTest.php +++ b/tests/system/View/ControlledCellTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\View\Cells\Cell; use CodeIgniter\View\Exceptions\ViewException; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\View\Cells\AdditionCell; use Tests\Support\View\Cells\AwesomeCell; @@ -73,6 +74,7 @@ public function testCellThroughRenderMethodWithExtraData(): void public function testCellDataCannotReplaceIncludedView(): void { $cell = new class () extends Cell { + #[Override] public function render(): string { $directory = __DIR__ . '/../../_support/View/Cells/'; diff --git a/tests/system/View/DBResultDummy.php b/tests/system/View/DBResultDummy.php index 62ebb298b853..b4f88a9f1e9b 100644 --- a/tests/system/View/DBResultDummy.php +++ b/tests/system/View/DBResultDummy.php @@ -14,10 +14,12 @@ namespace CodeIgniter\View; use CodeIgniter\Database\MySQLi\Result; +use Override; // We need this for the _set_from_db_result() test class DBResultDummy extends Result { + #[Override] public function getFieldNames(): array { return [ @@ -29,6 +31,7 @@ public function getFieldNames(): array /** * @return list> */ + #[Override] public function getResultArray(): array { return [ diff --git a/tests/system/View/DecoratorsTest.php b/tests/system/View/DecoratorsTest.php index b9c3f6effdea..51c2e9f8ac1f 100644 --- a/tests/system/View/DecoratorsTest.php +++ b/tests/system/View/DecoratorsTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Config\Factories; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\View\Exceptions\ViewException; +use Override; use PHPUnit\Framework\Attributes\Group; use Tests\Support\View\BadDecorator; use Tests\Support\View\WorldDecorator; @@ -31,6 +32,7 @@ final class DecoratorsTest extends CIUnitTestCase private string $viewsDir; private ?\Config\View $config = null; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/View/ParserFilterTest.php b/tests/system/View/ParserFilterTest.php index 4637b56c23c7..19e5f7505c47 100644 --- a/tests/system/View/ParserFilterTest.php +++ b/tests/system/View/ParserFilterTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Autoloader\FileLocatorInterface; use CodeIgniter\Test\CIUnitTestCase; use Config\View; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -28,6 +29,7 @@ final class ParserFilterTest extends CIUnitTestCase private string $viewsDir; private View $config; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/View/ParserPluginTest.php b/tests/system/View/ParserPluginTest.php index a9312e91168c..72c116b8c3b0 100644 --- a/tests/system/View/ParserPluginTest.php +++ b/tests/system/View/ParserPluginTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Validation\Validation; use Config\Services; +use Override; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\PreserveGlobalState; use PHPUnit\Framework\Attributes\RunInSeparateProcess; @@ -30,6 +31,7 @@ final class ParserPluginTest extends CIUnitTestCase private Parser $parser; private Validation $validator; + #[Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/system/View/ParserTest.php b/tests/system/View/ParserTest.php index 6e8dde918dfd..3ae0d809cfbf 100644 --- a/tests/system/View/ParserTest.php +++ b/tests/system/View/ParserTest.php @@ -19,6 +19,7 @@ use CodeIgniter\View\Exceptions\ViewException; use Config\Services; use Config\View as ViewConfig; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use RuntimeException; @@ -35,6 +36,7 @@ final class ParserTest extends CIUnitTestCase private ViewConfig $config; private Parser $parser; + #[Override] protected function setUp(): void { parent::setUp(); @@ -345,6 +347,7 @@ public function testParseLoopEntityProperties(): void /** * @return array */ + #[Override] public function toArray(bool $onlyChanged = false, bool $cast = true, bool $recursive = false): array { return [ diff --git a/tests/system/View/TableTest.php b/tests/system/View/TableTest.php index e09cb9e6631f..b9bed1eac6bd 100644 --- a/tests/system/View/TableTest.php +++ b/tests/system/View/TableTest.php @@ -15,6 +15,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockTable; +use Override; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\Attributes\Group; @@ -30,6 +31,7 @@ final class TableTest extends CIUnitTestCase private string $styleTableOne = 'background:#F99;text-align:right;width:5em;'; private string $styleTableTwo = 'background:cyan;color:white;text-align:right;width:5em;'; + #[Override] protected function setUp(): void { $this->table = new MockTable(); diff --git a/tests/system/View/ViewTest.php b/tests/system/View/ViewTest.php index 27118e4be6ea..bb28fe7d7eb5 100644 --- a/tests/system/View/ViewTest.php +++ b/tests/system/View/ViewTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\View\Exceptions\ViewException; use Config\View as ViewConfig; +use Override; use PHPUnit\Framework\Attributes\Group; /** @@ -30,6 +31,7 @@ final class ViewTest extends CIUnitTestCase private string $viewsDir; private ViewConfig $config; + #[Override] protected function setUp(): void { parent::setUp();