Skip to content

Commit

Permalink
Fix Modules does not extend BaseConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan committed Oct 21, 2023
1 parent 11772d4 commit 550a624
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 19 deletions.
10 changes: 0 additions & 10 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion system/Config/BaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions system/Config/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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');

Expand Down
2 changes: 0 additions & 2 deletions tests/system/Cache/FactoriesCacheFileVarExportHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use CodeIgniter\Config\Factories;
use CodeIgniter\Test\CIUnitTestCase;
use Config\App;
use Config\Modules;

/**
* @internal
Expand Down Expand Up @@ -58,7 +57,6 @@ public function testSave()

$this->assertArrayHasKey('aliases', $cachedData);
$this->assertArrayHasKey('instances', $cachedData);
$this->assertArrayHasKey(Modules::class, $cachedData['aliases']);
$this->assertArrayHasKey('App', $cachedData['aliases']);
}

Expand Down

0 comments on commit 550a624

Please sign in to comment.