From bcfbe299deddd0d5445fbc799314034d6abe3eb1 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Sat, 21 Oct 2023 15:59:29 +0800 Subject: [PATCH] Fix Modules does not extend BaseConfig --- phpstan-baseline.php | 10 ---------- system/Config/BaseConfig.php | 2 +- system/Config/BaseService.php | 8 ++------ .../Cache/FactoriesCacheFileVarExportHandlerTest.php | 1 - 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/phpstan-baseline.php b/phpstan-baseline.php index d1c574463f58..0d372afdb97c 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -871,16 +871,6 @@ 'count' => 4, 'path' => __DIR__ . '/system/Config/BaseConfig.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Argument \\#1 \\$name \\(\'Config\\\\\\\\Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Config/BaseConfig.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Argument \\#1 \\$name \\(\'Config\\\\\\\\Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#', - 'count' => 2, - 'path' => __DIR__ . '/system/Config/BaseService.php', -]; $ignoreErrors[] = [ 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', 'count' => 3, diff --git a/system/Config/BaseConfig.php b/system/Config/BaseConfig.php index 87166737e746..b4b9a4a21349 100644 --- a/system/Config/BaseConfig.php +++ b/system/Config/BaseConfig.php @@ -82,7 +82,7 @@ public static function __set_state(array $array) */ public function __construct() { - static::$moduleConfig = config(Modules::class); + static::$moduleConfig = new Modules(); if (! static::$override) { return; diff --git a/system/Config/BaseService.php b/system/Config/BaseService.php index b66b8c9f535e..22daf7b69e4b 100644 --- a/system/Config/BaseService.php +++ b/system/Config/BaseService.php @@ -330,9 +330,7 @@ public static function injectMock(string $name, $mock) protected static function discoverServices(string $name, array $arguments) { if (! static::$discovered) { - $config = config(Modules::class); - - if ($config->shouldDiscover('services')) { + if ((new Modules())->shouldDiscover('services')) { $locator = static::locator(); $files = $locator->search('Config/Services'); @@ -372,9 +370,7 @@ protected static function discoverServices(string $name, array $arguments) protected static function buildServicesCache(): void { if (! static::$discovered) { - $config = config(Modules::class); - - if ($config->shouldDiscover('services')) { + if ((new Modules())->shouldDiscover('services')) { $locator = static::locator(); $files = $locator->search('Config/Services'); diff --git a/tests/system/Cache/FactoriesCacheFileVarExportHandlerTest.php b/tests/system/Cache/FactoriesCacheFileVarExportHandlerTest.php index a3aff35b000e..412aada9f2ae 100644 --- a/tests/system/Cache/FactoriesCacheFileVarExportHandlerTest.php +++ b/tests/system/Cache/FactoriesCacheFileVarExportHandlerTest.php @@ -58,7 +58,6 @@ public function testSave() $this->assertArrayHasKey('aliases', $cachedData); $this->assertArrayHasKey('instances', $cachedData); - $this->assertArrayHasKey(Modules::class, $cachedData['aliases']); $this->assertArrayHasKey('App', $cachedData['aliases']); }