diff --git a/composer.json b/composer.json index cd134a93f9bd..7102ae8f9d9c 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ }, "require-dev": { "codeigniter/coding-standard": "^1.5", - "codeigniter/phpstan-codeigniter": "^v1.1", + "codeigniter/phpstan-codeigniter": "^1.1", "ergebnis/composer-normalize": "^2.28", "fakerphp/faker": "^1.9", "kint-php/kint": "^5.0.4", diff --git a/phpstan-baseline.php b/phpstan-baseline.php index d1c574463f58..3fe8c52e84e8 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -181,6 +181,11 @@ 'count' => 1, 'path' => __DIR__ . '/system/Cache/Handlers/PredisHandler.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Call to function config with Config\\\\Kint\\:\\:class is discouraged\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/system/CodeIgniter.php', +]; $ignoreErrors[] = [ 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', 'count' => 6, @@ -871,16 +876,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, @@ -931,11 +926,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Config/Services.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Argument \\#1 \\$name \\(\'Config\\\\\\\\Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Config/Services.php', -]; $ignoreErrors[] = [ 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', 'count' => 1, @@ -2011,11 +2001,6 @@ 'count' => 4, 'path' => __DIR__ . '/system/Entity/Entity.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Argument \\#1 \\$name \\(\'Config\\\\\\\\Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Events/Events.php', -]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\Events\\\\Events\\:\\:on\\(\\) has parameter \\$callback with no signature specified for callable\\.$#', 'count' => 1, @@ -2056,11 +2041,6 @@ 'count' => 3, 'path' => __DIR__ . '/system/Files/File.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Argument \\#1 \\$name \\(\'Config\\\\\\\\Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Filters/Filters.php', -]; $ignoreErrors[] = [ 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', 'count' => 2, diff --git a/phpstan.neon.dist b/phpstan.neon.dist index eb85c8131723..dac403a7695e 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -32,14 +32,12 @@ parameters: checkGenericClassInNonGenericObjectType: false checkMissingCallableSignature: true treatPhpDocTypesAsCertain: false + codeigniter: + additionalConfigNamespaces: + - CodeIgniter\Config strictRules: allRules: false disallowedLooseComparison: true booleansInConditions: true disallowedConstructs: true matchingInheritedMethodNames: true - ignoreErrors: - - '#^Call to function config with Config\\.+\:\:class is discouraged\.$#' - codeigniter: - additionalConfigNamespaces: - - CodeIgniter\Config\ diff --git a/system/CLI/BaseCommand.php b/system/CLI/BaseCommand.php index c4448d56b01a..ab763fd14135 100644 --- a/system/CLI/BaseCommand.php +++ b/system/CLI/BaseCommand.php @@ -11,7 +11,6 @@ namespace CodeIgniter\CLI; -use Config\Exceptions; use Psr\Log\LoggerInterface; use ReflectionException; use Throwable; @@ -124,7 +123,7 @@ protected function showError(Throwable $e) { $exception = $e; $message = $e->getMessage(); - $config = config(Exceptions::class); + $config = config('Exceptions'); require $config->errorViewPath . '/cli/error_exception.php'; } diff --git a/system/CLI/Console.php b/system/CLI/Console.php index adcf9aaeca8b..2573e7ea840c 100644 --- a/system/CLI/Console.php +++ b/system/CLI/Console.php @@ -12,7 +12,6 @@ namespace CodeIgniter\CLI; use CodeIgniter\CodeIgniter; -use Config\App; use Config\Services; use Exception; @@ -33,7 +32,7 @@ class Console public function run() { // Create CLIRequest - $appConfig = config(App::class); + $appConfig = config('App'); Services::createRequest($appConfig, true); // Load Routes Services::routes()->loadRoutes(); diff --git a/system/CLI/GeneratorTrait.php b/system/CLI/GeneratorTrait.php index 7b6066380739..21ae0c165d8a 100644 --- a/system/CLI/GeneratorTrait.php +++ b/system/CLI/GeneratorTrait.php @@ -11,7 +11,6 @@ namespace CodeIgniter\CLI; -use Config\Generators; use Config\Services; use Throwable; @@ -268,7 +267,7 @@ protected function qualifyClassName(): string protected function renderTemplate(array $data = []): string { try { - return view(config(Generators::class)->views[$this->name], $data, ['debug' => false]); + return view(config('Generators')->views[$this->name], $data, ['debug' => false]); } catch (Throwable $e) { log_message('error', (string) $e); diff --git a/system/Cache/Handlers/BaseHandler.php b/system/Cache/Handlers/BaseHandler.php index c12b330bc469..2a3f463f2851 100644 --- a/system/Cache/Handlers/BaseHandler.php +++ b/system/Cache/Handlers/BaseHandler.php @@ -13,7 +13,6 @@ use Closure; use CodeIgniter\Cache\CacheInterface; -use Config\Cache; use Exception; use InvalidArgumentException; @@ -64,7 +63,7 @@ public static function validateKey($key, $prefix = ''): string throw new InvalidArgumentException('Cache key cannot be empty.'); } - $reserved = config(Cache::class)->reservedCharacters ?? self::RESERVED_CHARACTERS; + $reserved = config('Cache')->reservedCharacters ?? self::RESERVED_CHARACTERS; if ($reserved && strpbrk($key, $reserved) !== false) { throw new InvalidArgumentException('Cache key contains reserved characters ' . $reserved); } diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index 09fc6a1f689f..7708dedd29c5 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -31,11 +31,10 @@ use CodeIgniter\Router\Router; use Config\App; use Config\Cache; -use Config\Feature; use Config\Kint as KintConfig; use Config\Services; use Exception; -use Kint; +use Kint\Kint; use Kint\Renderer\CliRenderer; use Kint\Renderer\RichRenderer; use Locale; @@ -358,7 +357,7 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon $this->spoofRequestMethod(); try { - $this->response = $this->handleRequest($routes, config(Cache::class), $returnResponse); + $this->response = $this->handleRequest($routes, config('Cache'), $returnResponse); } catch (ResponsableInterface|DeprecatedRedirectException $e) { $this->outputBufferingEnd(); if ($e instanceof DeprecatedRedirectException) { @@ -458,7 +457,7 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache // If any filters were specified within the routes file, // we need to ensure it's active for the current request if ($routeFilter !== null) { - $multipleFiltersEnabled = config(Feature::class)->multipleFilters ?? false; + $multipleFiltersEnabled = config('Feature')->multipleFilters ?? false; if ($multipleFiltersEnabled) { $filters->enableFilters($routeFilter, 'before'); $filters->enableFilters($routeFilter, 'after'); @@ -832,7 +831,7 @@ protected function tryToRouteIt(?RouteCollectionInterface $routes = null) $this->benchmark->stop('routing'); // for backward compatibility - $multipleFiltersEnabled = config(Feature::class)->multipleFilters ?? false; + $multipleFiltersEnabled = config('Feature')->multipleFilters ?? false; if (! $multipleFiltersEnabled) { return $this->router->getFilter(); } @@ -973,7 +972,7 @@ protected function display404errors(PageNotFoundException $e) unset($override); - $cacheConfig = config(Cache::class); + $cacheConfig = config('Cache'); $this->gatherOutput($cacheConfig, $returned); return $this->response; diff --git a/system/Commands/Cache/ClearCache.php b/system/Commands/Cache/ClearCache.php index b903425ba795..648d99e42ecc 100644 --- a/system/Commands/Cache/ClearCache.php +++ b/system/Commands/Cache/ClearCache.php @@ -14,7 +14,6 @@ use CodeIgniter\Cache\CacheFactory; use CodeIgniter\CLI\BaseCommand; use CodeIgniter\CLI\CLI; -use Config\Cache; /** * Clears current cache. @@ -63,7 +62,7 @@ class ClearCache extends BaseCommand */ public function run(array $params) { - $config = config(Cache::class); + $config = config('Cache'); $handler = $params[0] ?? $config->handler; if (! array_key_exists($handler, $config->validHandlers)) { diff --git a/system/Commands/Cache/InfoCache.php b/system/Commands/Cache/InfoCache.php index 1dc2504b0fb4..db5a51d76f91 100644 --- a/system/Commands/Cache/InfoCache.php +++ b/system/Commands/Cache/InfoCache.php @@ -15,7 +15,6 @@ use CodeIgniter\CLI\BaseCommand; use CodeIgniter\CLI\CLI; use CodeIgniter\I18n\Time; -use Config\Cache; /** * Shows information on the cache. @@ -55,7 +54,7 @@ class InfoCache extends BaseCommand */ public function run(array $params) { - $config = config(Cache::class); + $config = config('Cache'); helper('number'); if ($config->handler !== 'file') { diff --git a/system/Commands/Database/CreateDatabase.php b/system/Commands/Database/CreateDatabase.php index d103d97f689a..b1e2c5655057 100644 --- a/system/Commands/Database/CreateDatabase.php +++ b/system/Commands/Database/CreateDatabase.php @@ -82,7 +82,7 @@ public function run(array $params) } try { - $config = config(Database::class); + $config = config('Database'); // Set to an empty database to prevent connection errors. $group = ENVIRONMENT === 'testing' ? 'tests' : $config->defaultGroup; diff --git a/system/Commands/Generators/MigrationGenerator.php b/system/Commands/Generators/MigrationGenerator.php index 82428a6948b3..914386a9306a 100644 --- a/system/Commands/Generators/MigrationGenerator.php +++ b/system/Commands/Generators/MigrationGenerator.php @@ -14,9 +14,6 @@ use CodeIgniter\CLI\BaseCommand; use CodeIgniter\CLI\CLI; use CodeIgniter\CLI\GeneratorTrait; -use Config\Database; -use Config\Migrations; -use Config\Session as SessionConfig; /** * Generates a skeleton migration file. @@ -108,10 +105,9 @@ protected function prepare(string $class): string $data['session'] = true; $data['table'] = is_string($table) ? $table : 'ci_sessions'; $data['DBGroup'] = is_string($DBGroup) ? $DBGroup : 'default'; - $data['DBDriver'] = config(Database::class)->{$data['DBGroup']}['DBDriver']; + $data['DBDriver'] = config('Database')->{$data['DBGroup']}['DBDriver']; - /** @var SessionConfig|null $session */ - $session = config(SessionConfig::class); + $session = config('Session'); $data['matchIP'] = $session->matchIP; } @@ -124,6 +120,6 @@ protected function prepare(string $class): string */ protected function basename(string $filename): string { - return gmdate(config(Migrations::class)->timestampFormat) . basename($filename); + return gmdate(config('Migrations')->timestampFormat) . basename($filename); } } diff --git a/system/Commands/Generators/SessionMigrationGenerator.php b/system/Commands/Generators/SessionMigrationGenerator.php index a04527e866d1..fbfb2d3db1ff 100644 --- a/system/Commands/Generators/SessionMigrationGenerator.php +++ b/system/Commands/Generators/SessionMigrationGenerator.php @@ -14,8 +14,6 @@ use CodeIgniter\CLI\BaseCommand; use CodeIgniter\CLI\CLI; use CodeIgniter\CLI\GeneratorTrait; -use Config\App; -use Config\Migrations; /** * Generates a migration file for database sessions. @@ -95,7 +93,7 @@ protected function prepare(string $class): string $data['session'] = true; $data['table'] = $this->getOption('t'); $data['DBGroup'] = $this->getOption('g'); - $data['matchIP'] = config(App::class)->sessionMatchIP ?? false; + $data['matchIP'] = config('App')->sessionMatchIP ?? false; $data['table'] = is_string($data['table']) ? $data['table'] : 'ci_sessions'; $data['DBGroup'] = is_string($data['DBGroup']) ? $data['DBGroup'] : 'default'; @@ -108,6 +106,6 @@ protected function prepare(string $class): string */ protected function basename(string $filename): string { - return gmdate(config(Migrations::class)->timestampFormat) . basename($filename); + return gmdate(config('Migrations')->timestampFormat) . basename($filename); } } diff --git a/system/Commands/Utilities/Routes.php b/system/Commands/Utilities/Routes.php index b3693ec6860e..bff9f8d888ae 100644 --- a/system/Commands/Utilities/Routes.php +++ b/system/Commands/Utilities/Routes.php @@ -18,8 +18,6 @@ use CodeIgniter\Commands\Utilities\Routes\FilterCollector; use CodeIgniter\Commands\Utilities\Routes\SampleURIGenerator; use CodeIgniter\Router\DefinedRouteCollector; -use Config\Feature; -use Config\Routing; use Config\Services; /** @@ -134,7 +132,7 @@ public function run(array $params) } if ($collection->shouldAutoRoute()) { - $autoRoutesImproved = config(Feature::class)->autoRoutesImproved ?? false; + $autoRoutesImproved = config('Feature')->autoRoutesImproved ?? false; if ($autoRoutesImproved) { $autoRouteCollector = new AutoRouteCollectorImproved( @@ -148,7 +146,7 @@ public function run(array $params) $autoRoutes = $autoRouteCollector->get(); // Check for Module Routes. - if ($routingConfig = config(Routing::class)) { + if ($routingConfig = config('Routing')) { foreach ($routingConfig->moduleRoutes as $uri => $namespace) { $autoRouteCollector = new AutoRouteCollectorImproved( $namespace, diff --git a/system/Commands/Utilities/Routes/FilterCollector.php b/system/Commands/Utilities/Routes/FilterCollector.php index 01d228a41704..07f0a7bbaa23 100644 --- a/system/Commands/Utilities/Routes/FilterCollector.php +++ b/system/Commands/Utilities/Routes/FilterCollector.php @@ -15,7 +15,6 @@ use CodeIgniter\Filters\Filters; use CodeIgniter\HTTP\Request; use CodeIgniter\Router\Router; -use Config\Filters as FiltersConfig; /** * Collects filters for a route. @@ -75,7 +74,7 @@ private function createRouter(Request $request): Router private function createFilters(Request $request): Filters { - $config = config(FiltersConfig::class); + $config = config('Filters'); return new Filters($config, $request, Services::response()); } diff --git a/system/Commands/Utilities/Routes/FilterFinder.php b/system/Commands/Utilities/Routes/FilterFinder.php index 2e5da617e795..e09163a5c48c 100644 --- a/system/Commands/Utilities/Routes/FilterFinder.php +++ b/system/Commands/Utilities/Routes/FilterFinder.php @@ -15,7 +15,6 @@ use CodeIgniter\Filters\Filters; use CodeIgniter\HTTP\Exceptions\RedirectException; use CodeIgniter\Router\Router; -use Config\Feature; use Config\Services; /** @@ -38,7 +37,7 @@ private function getRouteFilters(string $uri): array { $this->router->handle($uri); - $multipleFiltersEnabled = config(Feature::class)->multipleFilters ?? false; + $multipleFiltersEnabled = config('Feature')->multipleFilters ?? false; if (! $multipleFiltersEnabled) { $filter = $this->router->getFilter(); diff --git a/system/Common.php b/system/Common.php index ebfd8e2565e8..02996b324ce3 100644 --- a/system/Common.php +++ b/system/Common.php @@ -31,12 +31,10 @@ use CodeIgniter\Model; use CodeIgniter\Session\Session; use CodeIgniter\Test\TestLogger; -use Config\App; use Config\Database; use Config\DocTypes; use Config\Logger; use Config\Services; -use Config\View; use Laminas\Escaper\Escaper; // Services Convenience Functions @@ -50,7 +48,7 @@ */ function app_timezone(): string { - $config = config(App::class); + $config = config('App'); return $config->appTimezone; } @@ -502,7 +500,7 @@ function force_https( Services::session()->regenerate(); // @codeCoverageIgnore } - $baseURL = config(App::class)->baseURL; + $baseURL = config('App')->baseURL; if (strpos($baseURL, 'https://') === 0) { $authority = substr($baseURL, strlen('https://')); @@ -1073,7 +1071,7 @@ function single_service(string $name, ...$params): ?object */ function slash_item(string $item): ?string { - $config = config(App::class); + $config = config('App'); if (! property_exists($config, $item)) { return null; @@ -1084,7 +1082,7 @@ function slash_item(string $item): ?string if (! is_scalar($configItem)) { throw new RuntimeException(sprintf( 'Cannot convert "%s::$%s" of type "%s" to type "string".', - App::class, + 'App', $item, gettype($configItem) )); @@ -1179,7 +1177,7 @@ function view(string $name, array $data = [], array $options = []): string { $renderer = Services::renderer(); - $config = config(View::class); + $config = config('View'); $saveData = $config->saveData; if (array_key_exists('saveData', $options)) { 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..629cb40ebf38 100644 --- a/system/Config/BaseService.php +++ b/system/Config/BaseService.php @@ -330,7 +330,7 @@ public static function injectMock(string $name, $mock) protected static function discoverServices(string $name, array $arguments) { if (! static::$discovered) { - $config = config(Modules::class); + $config = new Modules(); if ($config->shouldDiscover('services')) { $locator = static::locator(); @@ -372,7 +372,7 @@ protected static function discoverServices(string $name, array $arguments) protected static function buildServicesCache(): void { if (! static::$discovered) { - $config = config(Modules::class); + $config = new Modules(); if ($config->shouldDiscover('services')) { $locator = static::locator(); diff --git a/system/Config/Services.php b/system/Config/Services.php index 5ffb9e049c46..85d8c807a399 100644 --- a/system/Config/Services.php +++ b/system/Config/Services.php @@ -64,7 +64,6 @@ use CodeIgniter\View\View; use Config\App; use Config\Cache; -use Config\ContentSecurityPolicy as ContentSecurityPolicyConfig; use Config\ContentSecurityPolicy as CSPConfig; use Config\Database; use Config\Email as EmailConfig; @@ -74,12 +73,10 @@ use Config\Format as FormatConfig; use Config\Honeypot as HoneypotConfig; use Config\Images; -use Config\Logger as LoggerConfig; use Config\Migrations; use Config\Modules; use Config\Pager as PagerConfig; use Config\Paths; -use Config\Routing; use Config\Security as SecurityConfig; use Config\Services as AppServices; use Config\Session as SessionConfig; @@ -120,7 +117,7 @@ public static function cache(?Cache $config = null, bool $getShared = true) return static::getSharedInstance('cache', $config); } - $config ??= config(Cache::class); + $config ??= config('Cache'); return CacheFactory::getHandler($config); } @@ -139,7 +136,7 @@ public static function clirequest(?App $config = null, bool $getShared = true) return static::getSharedInstance('clirequest', $config); } - $config ??= config(App::class); + $config ??= config('App'); return new CLIRequest($config); } @@ -155,7 +152,7 @@ public static function codeigniter(?App $config = null, bool $getShared = true) return static::getSharedInstance('codeigniter', $config); } - $config ??= config(App::class); + $config ??= config('App'); return new CodeIgniter($config); } @@ -185,7 +182,7 @@ public static function csp(?CSPConfig $config = null, bool $getShared = true) return static::getSharedInstance('csp', $config); } - $config ??= config(ContentSecurityPolicyConfig::class); + $config ??= config('ContentSecurityPolicy'); return new ContentSecurityPolicy($config); } @@ -202,7 +199,7 @@ public static function curlrequest(array $options = [], ?ResponseInterface $resp return static::getSharedInstance('curlrequest', $options, $response, $config); } - $config ??= config(App::class); + $config ??= config('App'); $response ??= new Response($config); return new CURLRequest( @@ -227,7 +224,7 @@ public static function email($config = null, bool $getShared = true) } if (empty($config) || ! (is_array($config) || $config instanceof EmailConfig)) { - $config = config(EmailConfig::class); + $config = config('Email'); } return new Email($config); @@ -246,7 +243,7 @@ public static function encrypter(?EncryptionConfig $config = null, $getShared = return static::getSharedInstance('encrypter', $config); } - $config ??= config(EncryptionConfig::class); + $config ??= config('Encryption'); $encryption = new Encryption($config); return $encryption->initialize($config); @@ -269,7 +266,7 @@ public static function exceptions( return static::getSharedInstance('exceptions', $config); } - $config ??= config(ExceptionsConfig::class); + $config ??= config('Exceptions'); return new Exceptions($config); } @@ -288,7 +285,7 @@ public static function filters(?FiltersConfig $config = null, bool $getShared = return static::getSharedInstance('filters', $config); } - $config ??= config(FiltersConfig::class); + $config ??= config('Filters'); return new Filters($config, AppServices::request(), AppServices::response()); } @@ -304,7 +301,7 @@ public static function format(?FormatConfig $config = null, bool $getShared = tr return static::getSharedInstance('format', $config); } - $config ??= config(FormatConfig::class); + $config ??= config('Format'); return new Format($config); } @@ -321,7 +318,7 @@ public static function honeypot(?HoneypotConfig $config = null, bool $getShared return static::getSharedInstance('honeypot', $config); } - $config ??= config(HoneypotConfig::class); + $config ??= config('Honeypot'); return new Honeypot($config); } @@ -338,7 +335,7 @@ public static function image(?string $handler = null, ?Images $config = null, bo return static::getSharedInstance('image', $handler, $config); } - $config ??= config(Images::class); + $config ??= config('Images'); assert($config instanceof Images); $handler = $handler ?: $config->defaultHandler; @@ -398,7 +395,7 @@ public static function logger(bool $getShared = true) return static::getSharedInstance('logger'); } - return new Logger(config(LoggerConfig::class)); + return new Logger(config('Logger')); } /** @@ -412,7 +409,7 @@ public static function migrations(?Migrations $config = null, ?ConnectionInterfa return static::getSharedInstance('migrations', $config, $db); } - $config ??= config(Migrations::class); + $config ??= config('Migrations'); return new MigrationRunner($config, $db); } @@ -446,7 +443,7 @@ public static function responsecache(?Cache $config = null, ?CacheInterface $cac return static::getSharedInstance('responsecache', $config, $cache); } - $config ??= config(Cache::class); + $config ??= config('Cache'); $cache ??= AppServices::cache(); return new ResponseCache($config, $cache); @@ -463,7 +460,7 @@ public static function pager(?PagerConfig $config = null, ?RendererInterface $vi return static::getSharedInstance('pager', $config, $view); } - $config ??= config(PagerConfig::class); + $config ??= config('Pager'); $view ??= AppServices::renderer(null, null, false); return new Pager($config, $view); @@ -481,7 +478,7 @@ public static function parser(?string $viewPath = null, ?ViewConfig $config = nu } $viewPath = $viewPath ?: (new Paths())->viewDirectory; - $config ??= config(ViewConfig::class); + $config ??= config('View'); return new Parser($config, $viewPath, AppServices::locator(), CI_DEBUG, AppServices::logger()); } @@ -500,7 +497,7 @@ public static function renderer(?string $viewPath = null, ?ViewConfig $config = } $viewPath = $viewPath ?: (new Paths())->viewDirectory; - $config ??= config(ViewConfig::class); + $config ??= config('View'); return new View($config, $viewPath, AppServices::locator(), CI_DEBUG, AppServices::logger()); } @@ -559,7 +556,7 @@ public static function incomingrequest(?App $config = null, bool $getShared = tr return static::getSharedInstance('request', $config); } - $config ??= config(App::class); + $config ??= config('App'); return new IncomingRequest( $config, @@ -580,7 +577,7 @@ public static function response(?App $config = null, bool $getShared = true) return static::getSharedInstance('response', $config); } - $config ??= config(App::class); + $config ??= config('App'); return new Response($config); } @@ -596,7 +593,7 @@ public static function redirectresponse(?App $config = null, bool $getShared = t return static::getSharedInstance('redirectresponse', $config); } - $config ??= config(App::class); + $config ??= config('App'); $response = new RedirectResponse($config); $response->setProtocolVersion(AppServices::request()->getProtocolVersion()); @@ -615,7 +612,7 @@ public static function routes(bool $getShared = true) return static::getSharedInstance('routes'); } - return new RouteCollection(AppServices::locator(), config(Modules::class), config(Routing::class)); + return new RouteCollection(AppServices::locator(), new Modules(), config('Routing')); } /** @@ -648,7 +645,7 @@ public static function security(?SecurityConfig $config = null, bool $getShared return static::getSharedInstance('security', $config); } - $config ??= config(SecurityConfig::class); + $config ??= config('Security'); return new Security($config); } @@ -664,14 +661,15 @@ public static function session(?SessionConfig $config = null, bool $getShared = return static::getSharedInstance('session', $config); } - $config ??= config(SessionConfig::class); + /** @var SessionConfig $config */ + $config ??= config('Session'); $logger = AppServices::logger(); $driverName = $config->driver; if ($driverName === DatabaseHandler::class) { - $DBGroup = $config->DBGroup ?? config(Database::class)->defaultGroup; + $DBGroup = $config->DBGroup ?? config('Database')->defaultGroup; $db = Database::connect($DBGroup); $driver = $db->getPlatform(); @@ -774,7 +772,7 @@ public static function toolbar(?ToolbarConfig $config = null, bool $getShared = return static::getSharedInstance('toolbar', $config); } - $config ??= config(ToolbarConfig::class); + $config ??= config('Toolbar'); return new Toolbar($config); } @@ -793,7 +791,7 @@ public static function uri(?string $uri = null, bool $getShared = true) } if ($uri === null) { - $appConfig = config(App::class); + $appConfig = config('App'); $factory = AppServices::siteurifactory($appConfig, AppServices::superglobals()); return $factory->createFromGlobals(); @@ -813,7 +811,7 @@ public static function validation(?ValidationConfig $config = null, bool $getSha return static::getSharedInstance('validation', $config); } - $config ??= config(ValidationConfig::class); + $config ??= config('Validation'); return new Validation($config, AppServices::renderer()); } diff --git a/system/Controller.php b/system/Controller.php index 45fe0e499565..6bc509880b4f 100644 --- a/system/Controller.php +++ b/system/Controller.php @@ -17,7 +17,6 @@ use CodeIgniter\Validation\Exceptions\ValidationException; use CodeIgniter\Validation\ValidationInterface; use Config\Services; -use Config\Validation; use Psr\Log\LoggerInterface; /** @@ -176,7 +175,7 @@ private function setValidator($rules, array $messages): void // If you replace the $rules array with the name of the group if (is_string($rules)) { - $validation = config(Validation::class); + $validation = config('Validation'); // If the rule wasn't found in the \Config\Validation, we // should throw an exception so the developer can find it. diff --git a/system/Database/Config.php b/system/Database/Config.php index 62fa79202d26..4681040f61b4 100644 --- a/system/Database/Config.php +++ b/system/Database/Config.php @@ -12,7 +12,6 @@ namespace CodeIgniter\Database; use CodeIgniter\Config\BaseConfig; -use Config\Database as DbConfig; use InvalidArgumentException; /** @@ -59,7 +58,7 @@ public static function connect($group = null, bool $getShared = true) $config = $group; $group = 'custom-' . md5(json_encode($config)); } else { - $dbConfig = config(DbConfig::class); + $dbConfig = config('Database'); if ($group === null) { $group = (ENVIRONMENT === 'testing') ? 'tests' : $dbConfig->defaultGroup; @@ -133,7 +132,7 @@ public static function utils($group = null) */ public static function seeder(?string $group = null) { - $config = config(DbConfig::class); + $config = config('Database'); return new Seeder($config, static::connect($group)); } diff --git a/system/Database/Migration.php b/system/Database/Migration.php index 1616830f9267..f260679a3cf5 100644 --- a/system/Database/Migration.php +++ b/system/Database/Migration.php @@ -44,7 +44,7 @@ abstract class Migration */ public function __construct(?Forge $forge = null) { - $this->forge = $forge ?? Database::forge($this->DBGroup ?? config(Database::class)->defaultGroup); + $this->forge = $forge ?? Database::forge($this->DBGroup ?? config('Database')->defaultGroup); $this->db = $this->forge->getConnection(); } diff --git a/system/Database/MigrationRunner.php b/system/Database/MigrationRunner.php index 241a9e6da5fa..f556ed82c577 100644 --- a/system/Database/MigrationRunner.php +++ b/system/Database/MigrationRunner.php @@ -142,7 +142,7 @@ public function __construct(MigrationsConfig $config, $db = null) $this->namespace = APP_NAMESPACE; // get default database group - $config = config(Database::class); + $config = config('Database'); $this->group = $config->defaultGroup; unset($config); @@ -840,7 +840,7 @@ protected function migrate($direction, $migration): bool } $instance = new $class(); - $group = $instance->getDBGroup() ?? config(Database::class)->defaultGroup; + $group = $instance->getDBGroup() ?? config('Database')->defaultGroup; if (ENVIRONMENT !== 'testing' && $group === 'tests' && $this->groupFilter !== 'tests') { // @codeCoverageIgnoreStart diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php index 73c777ba7289..5678d889bca2 100644 --- a/system/Debug/Toolbar.php +++ b/system/Debug/Toolbar.php @@ -364,7 +364,7 @@ public function prepare(?RequestInterface $request = null, ?ResponseInterface $r return; } - $toolbar = Services::toolbar(config(ToolbarConfig::class)); + $toolbar = Services::toolbar(config('Toolbar')); $stats = $app->getPerformanceStats(); $data = $toolbar->run( $stats['startTime'], diff --git a/system/Debug/Toolbar/Collectors/Config.php b/system/Debug/Toolbar/Collectors/Config.php index faf7a19b7391..b4600555442d 100644 --- a/system/Debug/Toolbar/Collectors/Config.php +++ b/system/Debug/Toolbar/Collectors/Config.php @@ -12,7 +12,6 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; use CodeIgniter\CodeIgniter; -use Config\App; use Config\Services; /** @@ -25,7 +24,7 @@ class Config */ public static function display(): array { - $config = config(App::class); + $config = config('App'); return [ 'ciVersion' => CodeIgniter::CI_VERSION, diff --git a/system/Debug/Toolbar/Collectors/Database.php b/system/Debug/Toolbar/Collectors/Database.php index 4b2ff96fe8b5..47385174c378 100644 --- a/system/Debug/Toolbar/Collectors/Database.php +++ b/system/Debug/Toolbar/Collectors/Database.php @@ -13,7 +13,6 @@ use CodeIgniter\Database\Query; use CodeIgniter\I18n\Time; -use Config\Toolbar; /** * Collector for the Database tab of the Debug Toolbar. @@ -84,7 +83,7 @@ public function __construct() */ public static function collect(Query $query) { - $config = config(Toolbar::class); + $config = config('Toolbar'); // Provide default in case it's not set $max = $config->maxQueries ?: 100; diff --git a/system/Encryption/Handlers/BaseHandler.php b/system/Encryption/Handlers/BaseHandler.php index 08c0234a5d6d..894cb81d30cf 100644 --- a/system/Encryption/Handlers/BaseHandler.php +++ b/system/Encryption/Handlers/BaseHandler.php @@ -24,7 +24,7 @@ abstract class BaseHandler implements EncrypterInterface */ public function __construct(?Encryption $config = null) { - $config ??= config(Encryption::class); + $config ??= config('Encryption'); // make the parameters conveniently accessible foreach (get_object_vars($config) as $key => $value) { diff --git a/system/Events/Events.php b/system/Events/Events.php index b240dc29e1ca..c958983e733b 100644 --- a/system/Events/Events.php +++ b/system/Events/Events.php @@ -75,7 +75,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 df27e3f6cee3..dc92746ba387 100644 --- a/system/Filters/Filters.php +++ b/system/Filters/Filters.php @@ -111,7 +111,7 @@ public function __construct($config, RequestInterface $request, ResponseInterfac $this->request = &$request; $this->setResponse($response); - $this->modules = $modules ?? config(Modules::class); + $this->modules = $modules ?? new Modules(); if ($this->modules->shouldDiscover('filters')) { $this->discoverFilters(); diff --git a/system/HTTP/CURLRequest.php b/system/HTTP/CURLRequest.php index c8b3b9fe9f92..bcef7e2f450c 100644 --- a/system/HTTP/CURLRequest.php +++ b/system/HTTP/CURLRequest.php @@ -114,12 +114,12 @@ public function __construct(App $config, URI $uri, ?ResponseInterface $response parent::__construct('GET', $uri); - $this->responseOrig = $response ?? new Response(config(App::class)); + $this->responseOrig = $response ?? new Response(config('App')); $this->baseURI = $uri->useRawQueryString(); $this->defaultOptions = $options; /** @var ConfigCURLRequest|null $configCURLRequest */ - $configCURLRequest = config(ConfigCURLRequest::class); + $configCURLRequest = config('CURLRequest'); $this->shareOptions = $configCURLRequest->shareOptions ?? true; $this->config = $this->defaultConfig; diff --git a/system/HTTP/ContentSecurityPolicy.php b/system/HTTP/ContentSecurityPolicy.php index 37b0ce650ff7..d0699acda3ba 100644 --- a/system/HTTP/ContentSecurityPolicy.php +++ b/system/HTTP/ContentSecurityPolicy.php @@ -11,7 +11,6 @@ namespace CodeIgniter\HTTP; -use Config\App; use Config\ContentSecurityPolicy as ContentSecurityPolicyConfig; /** @@ -243,7 +242,7 @@ class ContentSecurityPolicy */ public function __construct(ContentSecurityPolicyConfig $config) { - $appConfig = config(App::class); + $appConfig = config('App'); $this->CSPEnabled = $appConfig->CSPEnabled; foreach (get_object_vars($config) as $setting => $value) { diff --git a/system/HTTP/DownloadResponse.php b/system/HTTP/DownloadResponse.php index 14dc3fec1421..15269854cef1 100644 --- a/system/HTTP/DownloadResponse.php +++ b/system/HTTP/DownloadResponse.php @@ -13,7 +13,6 @@ use CodeIgniter\Exceptions\DownloadException; use CodeIgniter\Files\File; -use Config\App; use Config\Mimes; /** @@ -67,7 +66,7 @@ class DownloadResponse extends Response */ public function __construct(string $filename, bool $setMime) { - parent::__construct(config(App::class)); + parent::__construct(config('App')); $this->filename = $filename; $this->setMime = $setMime; diff --git a/system/HTTP/RequestTrait.php b/system/HTTP/RequestTrait.php index 52ffa812a315..71b3af2e0f8d 100644 --- a/system/HTTP/RequestTrait.php +++ b/system/HTTP/RequestTrait.php @@ -13,7 +13,6 @@ use CodeIgniter\Exceptions\ConfigException; use CodeIgniter\Validation\FormatRules; -use Config\App; /** * Request Trait @@ -60,7 +59,7 @@ public function getIPAddress(): string 'valid_ip', ]; - $proxyIPs = config(App::class)->proxyIPs; + $proxyIPs = config('App')->proxyIPs; if (! empty($proxyIPs) && (! is_array($proxyIPs) || is_int(array_key_first($proxyIPs)))) { throw new ConfigException( diff --git a/system/HTTP/Response.php b/system/HTTP/Response.php index bc37e7418632..2f33976bab0e 100644 --- a/system/HTTP/Response.php +++ b/system/HTTP/Response.php @@ -15,7 +15,6 @@ use CodeIgniter\Cookie\CookieStore; use CodeIgniter\HTTP\Exceptions\HTTPException; use Config\App; -use Config\Cookie as CookieConfig; use Config\Services; /** @@ -160,7 +159,7 @@ public function __construct($config) $this->cookieStore = new CookieStore([]); - $cookie = config(CookieConfig::class); + $cookie = config('Cookie'); Cookie::setDefaults($cookie); diff --git a/system/HTTP/ResponseTrait.php b/system/HTTP/ResponseTrait.php index 7c0741317bc0..7791b222d697 100644 --- a/system/HTTP/ResponseTrait.php +++ b/system/HTTP/ResponseTrait.php @@ -582,7 +582,7 @@ public function setCookie( } /** @var CookieConfig|null $cookieConfig */ - $cookieConfig = config(CookieConfig::class); + $cookieConfig = config('Cookie'); if ($cookieConfig instanceof CookieConfig) { $secure ??= $cookieConfig->secure; diff --git a/system/HTTP/SiteURI.php b/system/HTTP/SiteURI.php index d01f614a1c85..513d272aa7e2 100644 --- a/system/HTTP/SiteURI.php +++ b/system/HTTP/SiteURI.php @@ -376,7 +376,7 @@ public function baseUrl($relativePath = '', ?string $scheme = null): string { $relativePath = $this->stringifyRelativePath($relativePath); - $config = clone config(App::class); + $config = clone config('App'); $config->indexPage = ''; $host = $this->getHost(); @@ -417,7 +417,7 @@ public function siteUrl($relativePath = '', ?string $scheme = null, ?App $config // Check current host. $host = $config === null ? $this->getHost() : null; - $config ??= config(App::class); + $config ??= config('App'); $uri = new self($config, $relativePath, $host, $scheme); diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php index 608f8b75d5ba..7d0f16d39b51 100644 --- a/system/HTTP/URI.php +++ b/system/HTTP/URI.php @@ -13,7 +13,6 @@ use BadMethodCallException; use CodeIgniter\HTTP\Exceptions\HTTPException; -use Config\App; use InvalidArgumentException; /** @@ -648,7 +647,7 @@ public function __toString(): string private function changeSchemeAndPath(string $scheme, string $path): array { // Check if this is an internal URI - $config = config(App::class); + $config = config('App'); $baseUri = new self($config->baseURL); if ( diff --git a/system/HTTP/UserAgent.php b/system/HTTP/UserAgent.php index 77e7cb4392fc..5dff20abe502 100644 --- a/system/HTTP/UserAgent.php +++ b/system/HTTP/UserAgent.php @@ -104,7 +104,7 @@ class UserAgent */ public function __construct(?UserAgents $config = null) { - $this->config = $config ?? config(UserAgents::class); + $this->config = $config ?? config('UserAgents'); if (isset($_SERVER['HTTP_USER_AGENT'])) { $this->agent = trim($_SERVER['HTTP_USER_AGENT']); diff --git a/system/Helpers/cookie_helper.php b/system/Helpers/cookie_helper.php index de8fb6146a63..a647b650f137 100755 --- a/system/Helpers/cookie_helper.php +++ b/system/Helpers/cookie_helper.php @@ -10,7 +10,6 @@ */ use CodeIgniter\Cookie\Cookie; -use Config\Cookie as CookieConfig; use Config\Services; // ============================================================================= @@ -70,7 +69,7 @@ function set_cookie( function get_cookie($index, bool $xssClean = false, ?string $prefix = '') { if ($prefix === '') { - $cookie = config(CookieConfig::class); + $cookie = config('Cookie'); $prefix = $cookie->prefix; } diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php index 7edb05cf1de3..bc0d7cef888e 100644 --- a/system/Helpers/form_helper.php +++ b/system/Helpers/form_helper.php @@ -10,9 +10,7 @@ */ use CodeIgniter\Validation\Exceptions\ValidationException; -use Config\App; use Config\Services; -use Config\Validation; // CodeIgniter Form Helpers @@ -52,7 +50,7 @@ function form_open(string $action = '', $attributes = [], array $hidden = []): s $attributes .= ' method="post"'; } if (stripos($attributes, 'accept-charset=') === false) { - $config = config(App::class); + $config = config('App'); $attributes .= ' accept-charset="' . strtolower($config->charset) . '"'; } @@ -723,7 +721,7 @@ function validation_errors() */ function validation_list_errors(string $template = 'list'): string { - $config = config(Validation::class); + $config = config('Validation'); $view = Services::renderer(); if (! array_key_exists($template, $config->templates)) { @@ -743,7 +741,7 @@ function validation_list_errors(string $template = 'list'): string */ function validation_show_error(string $field, string $template = 'single'): string { - $config = config(Validation::class); + $config = config('Validation'); $view = Services::renderer(); $errors = array_filter(validation_errors(), static fn ($key) => preg_match( diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 27e3ce1d079f..06098e618dd7 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -128,7 +128,7 @@ function uri_string(): string function index_page(?App $altConfig = null): string { // use alternate config if provided, else default one - $config = $altConfig ?? config(App::class); + $config = $altConfig ?? config('App'); return $config->indexPage; } @@ -148,7 +148,7 @@ function index_page(?App $altConfig = null): string function anchor($uri = '', string $title = '', $attributes = '', ?App $altConfig = null): string { // use alternate config if provided, else default one - $config = $altConfig ?? config(App::class); + $config = $altConfig ?? config('App'); $siteUrl = is_array($uri) ? site_url($uri, null, $config) : (preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri, null, $config)); // eliminate trailing slash @@ -181,7 +181,7 @@ function anchor($uri = '', string $title = '', $attributes = '', ?App $altConfig function anchor_popup($uri = '', string $title = '', $attributes = false, ?App $altConfig = null): string { // use alternate config if provided, else default one - $config = $altConfig ?? config(App::class); + $config = $altConfig ?? config('App'); $siteUrl = preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri, null, $config); $siteUrl = rtrim($siteUrl, '/'); diff --git a/system/HotReloader/DirectoryHasher.php b/system/HotReloader/DirectoryHasher.php index ba8d2bfbb891..0dee65ca83f7 100644 --- a/system/HotReloader/DirectoryHasher.php +++ b/system/HotReloader/DirectoryHasher.php @@ -12,7 +12,6 @@ namespace CodeIgniter\HotReloader; use CodeIgniter\Exceptions\FrameworkException; -use Config\Toolbar; use FilesystemIterator; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; @@ -42,7 +41,7 @@ public function hashApp(): array { $hashes = []; - $watchedDirectories = config(Toolbar::class)->watchedDirectories; + $watchedDirectories = config('Toolbar')->watchedDirectories; foreach ($watchedDirectories as $directory) { if (is_dir(ROOTPATH . $directory)) { diff --git a/system/HotReloader/IteratorFilter.php b/system/HotReloader/IteratorFilter.php index db775f90061e..7f40a464d0ac 100644 --- a/system/HotReloader/IteratorFilter.php +++ b/system/HotReloader/IteratorFilter.php @@ -11,7 +11,6 @@ namespace CodeIgniter\HotReloader; -use Config\Toolbar; use RecursiveFilterIterator; use RecursiveIterator; @@ -28,7 +27,7 @@ public function __construct(RecursiveIterator $iterator) { parent::__construct($iterator); - $this->watchedExtensions = config(Toolbar::class)->watchedExtensions; + $this->watchedExtensions = config('Toolbar')->watchedExtensions; } /** diff --git a/system/Publisher/Publisher.php b/system/Publisher/Publisher.php index e40a14c88905..ee670b93e937 100644 --- a/system/Publisher/Publisher.php +++ b/system/Publisher/Publisher.php @@ -15,7 +15,6 @@ use CodeIgniter\Files\FileCollection; use CodeIgniter\HTTP\URI; use CodeIgniter\Publisher\Exceptions\PublisherException; -use Config\Publisher as PublisherConfig; use RuntimeException; use Throwable; @@ -163,7 +162,7 @@ public function __construct(?string $source = null, ?string $destination = null) $this->replacer = new ContentReplacer(); // Restrictions are intentionally not injected to prevent overriding - $this->restrictions = config(PublisherConfig::class)->restrictions; + $this->restrictions = config('Publisher')->restrictions; // Make sure the destination is allowed foreach (array_keys($this->restrictions) as $directory) { diff --git a/system/Router/AutoRouterImproved.php b/system/Router/AutoRouterImproved.php index 0a26fc12f865..c87844cf57c7 100644 --- a/system/Router/AutoRouterImproved.php +++ b/system/Router/AutoRouterImproved.php @@ -13,7 +13,6 @@ use CodeIgniter\Exceptions\PageNotFoundException; use CodeIgniter\Router\Exceptions\MethodNotFoundException; -use Config\Routing; use ReflectionClass; use ReflectionException; @@ -258,7 +257,7 @@ public function getRoute(string $uri, string $httpVerb): array // Check for Module Routes. if ( $this->segments !== [] - && ($routingConfig = config(Routing::class)) + && ($routingConfig = config('Routing')) && array_key_exists($this->segments[0], $routingConfig->moduleRoutes) ) { $uriSegment = array_shift($this->segments); diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index b3bb96e9fa2b..33116ff3aaff 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -14,7 +14,6 @@ use Closure; use CodeIgniter\Autoloader\FileLocator; use CodeIgniter\Router\Exceptions\RouterException; -use Config\App; use Config\Modules; use Config\Routing; use Config\Services; @@ -1400,7 +1399,7 @@ private function replaceLocale(string $route, ?string $locale = null): string // Check invalid locale if ($locale !== null) { - $config = config(App::class); + $config = config('App'); if (! in_array($locale, $config->supportedLocales, true)) { $locale = null; } diff --git a/system/Router/Router.php b/system/Router/Router.php index 0013d7cdf920..0ab124701c18 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -16,8 +16,6 @@ use CodeIgniter\HTTP\Exceptions\RedirectException; use CodeIgniter\HTTP\Request; use CodeIgniter\Router\Exceptions\RouterException; -use Config\App; -use Config\Feature; /** * Request router. @@ -135,7 +133,7 @@ public function __construct(RouteCollectionInterface $routes, ?Request $request $this->translateURIDashes = $this->collection->shouldTranslateURIDashes(); if ($this->collection->shouldAutoRoute()) { - $autoRoutesImproved = config(Feature::class)->autoRoutesImproved ?? false; + $autoRoutesImproved = config('Feature')->autoRoutesImproved ?? false; if ($autoRoutesImproved) { $this->autoRouter = new AutoRouterImproved( $this->collection->getRegisteredControllers('*'), @@ -185,7 +183,7 @@ public function handle(?string $uri = null) // Checks defined routes if ($this->checkRoutes($uri)) { if ($this->collection->isFiltered($this->matchedRoute[0])) { - $multipleFiltersEnabled = config(Feature::class)->multipleFilters ?? false; + $multipleFiltersEnabled = config('Feature')->multipleFilters ?? false; if ($multipleFiltersEnabled) { $this->filtersInfo = $this->collection->getFiltersForRoute($this->matchedRoute[0]); } else { @@ -446,7 +444,7 @@ protected function checkRoutes(string $uri): bool ); if ($this->collection->shouldUseSupportedLocalesOnly() - && ! in_array($matched['locale'], config(App::class)->supportedLocales, true)) { + && ! in_array($matched['locale'], config('App')->supportedLocales, true)) { // Throw exception to prevent the autorouter, if enabled, // from trying to find a route throw PageNotFoundException::forLocaleNotSupported($matched['locale']); diff --git a/system/Security/Security.php b/system/Security/Security.php index 4ba665639f36..19024c55939f 100644 --- a/system/Security/Security.php +++ b/system/Security/Security.php @@ -196,7 +196,7 @@ public function __construct(SecurityConfig $config) $this->rawCookieName = $config->cookieName; if ($this->isCSRFCookie()) { - $cookie = config(CookieConfig::class); + $cookie = config('Cookie'); $this->configureCookie($cookie); } else { diff --git a/system/Session/Handlers/BaseHandler.php b/system/Session/Handlers/BaseHandler.php index 086cdc2f2276..e2a0e863ec0b 100644 --- a/system/Session/Handlers/BaseHandler.php +++ b/system/Session/Handlers/BaseHandler.php @@ -11,7 +11,6 @@ namespace CodeIgniter\Session\Handlers; -use Config\Cookie as CookieConfig; use Config\Session as SessionConfig; use Psr\Log\LoggerAwareTrait; use SessionHandlerInterface; @@ -111,7 +110,7 @@ public function __construct(SessionConfig $config, string $ipAddress) $this->matchIP = $config->matchIP; $this->savePath = $config->savePath; - $cookie = config(CookieConfig::class); + $cookie = config('Cookie'); // Session cookies have no prefix. $this->cookieDomain = $cookie->domain; diff --git a/system/Session/Handlers/DatabaseHandler.php b/system/Session/Handlers/DatabaseHandler.php index edde55ca34c6..ff9e94ad0e8c 100644 --- a/system/Session/Handlers/DatabaseHandler.php +++ b/system/Session/Handlers/DatabaseHandler.php @@ -73,7 +73,7 @@ public function __construct(SessionConfig $config, string $ipAddress) parent::__construct($config, $ipAddress); // Store Session configurations - $this->DBGroup = $config->DBGroup ?? config(Database::class)->defaultGroup; + $this->DBGroup = $config->DBGroup ?? config('Database')->defaultGroup; // Add sessionCookieName for multiple session cookies. $this->idPrefix = $config->cookieName . ':'; diff --git a/system/Session/Session.php b/system/Session/Session.php index 4e4a01581ba2..61f178806b6b 100644 --- a/system/Session/Session.php +++ b/system/Session/Session.php @@ -13,7 +13,6 @@ use CodeIgniter\Cookie\Cookie; use CodeIgniter\I18n\Time; -use Config\Cookie as CookieConfig; use Config\Services; use Config\Session as SessionConfig; use Psr\Log\LoggerAwareTrait; @@ -186,7 +185,7 @@ public function __construct(SessionHandlerInterface $driver, SessionConfig $conf $this->config = $config; - $cookie = config(CookieConfig::class); + $cookie = config('Cookie'); $this->cookie = (new Cookie($this->config->cookieName, '', [ 'expires' => $this->config->expiration === 0 ? 0 : Time::now()->getTimestamp() + $this->config->expiration, diff --git a/system/Test/Fabricator.php b/system/Test/Fabricator.php index 3a28f281d127..27d0c64da6c8 100644 --- a/system/Test/Fabricator.php +++ b/system/Test/Fabricator.php @@ -14,7 +14,6 @@ use CodeIgniter\Exceptions\FrameworkException; use CodeIgniter\I18n\Time; use CodeIgniter\Model; -use Config\App; use Faker\Factory; use Faker\Generator; use InvalidArgumentException; @@ -117,7 +116,7 @@ public function __construct($model, ?array $formatters = null, ?string $locale = // If no locale was specified then use the App default if ($locale === null) { - $locale = config(App::class)->defaultLocale; + $locale = config('App')->defaultLocale; } // There is no easy way to retrieve the locale from Faker so we will store it diff --git a/system/View/View.php b/system/View/View.php index 9d84e969da5b..81982ef93796 100644 --- a/system/View/View.php +++ b/system/View/View.php @@ -16,7 +16,6 @@ use CodeIgniter\Filters\DebugToolbar; use CodeIgniter\View\Exceptions\ViewException; use Config\Services; -use Config\Toolbar; use Config\View as ViewConfig; use Psr\Log\LoggerInterface; use RuntimeException; @@ -259,7 +258,7 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n ($this->debug && (! isset($options['debug']) || $options['debug'] === true)) && in_array(DebugToolbar::class, $afterFilters, true) ) { - $toolbarCollectors = config(Toolbar::class)->collectors; + $toolbarCollectors = config('Toolbar')->collectors; if (in_array(Views::class, $toolbarCollectors, true)) { // Clean up our path names to make them a little cleaner diff --git a/system/View/ViewDecoratorTrait.php b/system/View/ViewDecoratorTrait.php index 97cdbe0a252d..5379b793de79 100644 --- a/system/View/ViewDecoratorTrait.php +++ b/system/View/ViewDecoratorTrait.php @@ -12,7 +12,6 @@ namespace CodeIgniter\View; use CodeIgniter\View\Exceptions\ViewException; -use Config\View as ViewConfig; trait ViewDecoratorTrait { @@ -22,7 +21,7 @@ trait ViewDecoratorTrait */ protected function decorateOutput(string $html): string { - $decorators = \config(ViewConfig::class)->decorators; + $decorators = config('View')->decorators; foreach ($decorators as $decorator) { if (! is_subclass_of($decorator, ViewDecoratorInterface::class)) { 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']); }