From 539a76c0c18aeeb286d95b821d6cf5ce2d43a416 Mon Sep 17 00:00:00 2001 From: neznaika0 Date: Thu, 9 Jan 2025 17:48:06 +0300 Subject: [PATCH] refactor: Fix phpstan codeigniter.configArgumentInstanceof --- 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 db975aaa1825..2c7f715c7790 100644 --- a/tests/system/Events/EventsTest.php +++ b/tests/system/Events/EventsTest.php @@ -54,7 +54,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 7301539443d0..773c5855ba03 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -3,7 +3,6 @@ includes: - assign.propertyType.neon - booleanAnd.rightAlwaysTrue.neon - codeigniter.cacheHandlerInstance.neon - - codeigniter.configArgumentInstanceof.neon - codeigniter.frameworkExceptionInstance.neon - codeigniter.getReassignArray.neon - codeigniter.modelArgumentInstanceof.neon