From 155f1c14de69cf144081df008f3aeb36789b724c Mon Sep 17 00:00:00 2001 From: neznaika0 Date: Mon, 13 Jan 2025 05:52:54 +0300 Subject: [PATCH] refactor: Fix phpstan codeigniter.configArgumentInstanceof (#9390) --- system/Config/Services.php | 2 +- system/Events/Events.php | 2 +- system/Filters/Filters.php | 2 +- tests/system/Events/EventsTest.php | 2 +- .../codeigniter.configArgumentInstanceof.neon | 23 ------------------- utils/phpstan-baseline/loader.neon | 1 - 6 files changed, 4 insertions(+), 28 deletions(-) delete mode 100644 utils/phpstan-baseline/codeigniter.configArgumentInstanceof.neon diff --git a/system/Config/Services.php b/system/Config/Services.php index aa8c180a3388..06e8daa9cec9 100644 --- a/system/Config/Services.php +++ b/system/Config/Services.php @@ -619,7 +619,7 @@ public static function routes(bool $getShared = true) return static::getSharedInstance('routes'); } - return new RouteCollection(AppServices::get('locator'), config(Modules::class), config(Routing::class)); + return new RouteCollection(AppServices::get('locator'), new Modules(), config(Routing::class)); } /** diff --git a/system/Events/Events.php b/system/Events/Events.php index ad8efed62f9e..25149729a0d0 100644 --- a/system/Events/Events.php +++ b/system/Events/Events.php @@ -76,7 +76,7 @@ public static function initialize() return; } - $config = config(Modules::class); + $config = new Modules(); $events = APPPATH . 'Config' . DIRECTORY_SEPARATOR . 'Events.php'; $files = []; diff --git a/system/Filters/Filters.php b/system/Filters/Filters.php index fd252fe1fa26..f6dbdf087821 100644 --- a/system/Filters/Filters.php +++ b/system/Filters/Filters.php @@ -116,7 +116,7 @@ public function __construct($config, RequestInterface $request, ResponseInterfac $this->request = &$request; $this->setResponse($response); - $this->modules = $modules ?? config(Modules::class); + $this->modules = $modules instanceof Modules ? $modules : new Modules(); if ($this->modules->shouldDiscover('filters')) { $this->discoverFilters(); diff --git a/tests/system/Events/EventsTest.php b/tests/system/Events/EventsTest.php index f586a91de307..a659c3a3b460 100644 --- a/tests/system/Events/EventsTest.php +++ b/tests/system/Events/EventsTest.php @@ -57,7 +57,7 @@ public function testInitialize(): void /** * @var Modules $config */ - $config = config('Modules'); + $config = new Modules(); $config->aliases = []; // it should start out empty diff --git a/utils/phpstan-baseline/codeigniter.configArgumentInstanceof.neon b/utils/phpstan-baseline/codeigniter.configArgumentInstanceof.neon deleted file mode 100644 index a7e5ee2510ca..000000000000 --- a/utils/phpstan-baseline/codeigniter.configArgumentInstanceof.neon +++ /dev/null @@ -1,23 +0,0 @@ -# total 4 errors - -parameters: - ignoreErrors: - - - message: '#^Argument \#1 \$name \(''Config\\\\Modules''\) passed to function config does not extend CodeIgniter\\\\Config\\\\BaseConfig\.$#' - count: 1 - path: ../../system/Config/Services.php - - - - message: '#^Argument \#1 \$name \(''Config\\\\Modules''\) passed to function config does not extend CodeIgniter\\\\Config\\\\BaseConfig\.$#' - count: 1 - path: ../../system/Events/Events.php - - - - message: '#^Argument \#1 \$name \(''Config\\\\Modules''\) passed to function config does not extend CodeIgniter\\\\Config\\\\BaseConfig\.$#' - count: 1 - path: ../../system/Filters/Filters.php - - - - message: '#^Argument \#1 \$name \(''Modules''\) passed to function config does not extend CodeIgniter\\\\Config\\\\BaseConfig\.$#' - count: 1 - path: ../../tests/system/Events/EventsTest.php diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index e0c0cb703cd7..1cf2cabd4ea7 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -2,7 +2,6 @@ includes: - argument.type.neon - assign.propertyType.neon - codeigniter.cacheHandlerInstance.neon - - codeigniter.configArgumentInstanceof.neon - codeigniter.frameworkExceptionInstance.neon - codeigniter.getReassignArray.neon - codeigniter.modelArgumentInstanceof.neon