From ec0eeba4efc4febcbf63e4d8cabcc59cca118444 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Sun, 22 Feb 2026 19:10:49 +0800 Subject: [PATCH] refactor: remove deprecations in `Services` --- system/Config/BaseService.php | 9 --------- system/Config/Services.php | 11 ++--------- tests/system/CommonSingleServiceTest.php | 8 +++++++- user_guide_src/source/changelogs/v4.8.0.rst | 3 +++ utils/phpstan-baseline/loader.neon | 2 +- utils/phpstan-baseline/missingType.iterableValue.neon | 7 +------ 6 files changed, 14 insertions(+), 26 deletions(-) diff --git a/system/Config/BaseService.php b/system/Config/BaseService.php index 483da962d5ad..3c3bddb26146 100644 --- a/system/Config/BaseService.php +++ b/system/Config/BaseService.php @@ -175,15 +175,6 @@ class BaseService */ protected static $discovered = false; - /** - * A cache of other service classes we've found. - * - * @var array - * - * @deprecated 4.5.0 No longer used. - */ - protected static $services = []; - /** * A cache of the names of services classes found. * diff --git a/system/Config/Services.php b/system/Config/Services.php index 6e641b4e1d28..3e87b6ab78bd 100644 --- a/system/Config/Services.php +++ b/system/Config/Services.php @@ -517,17 +517,10 @@ public static function renderer(?string $viewPath = null, ?ViewConfig $config = * createRequest() injects IncomingRequest or CLIRequest. * * @return CLIRequest|IncomingRequest - * - * @deprecated The parameter $config and $getShared are deprecated. */ - public static function request(?App $config = null, bool $getShared = true) + public static function request() { - if ($getShared) { - return static::getSharedInstance('request', $config); - } - - // @TODO remove the following code for backward compatibility - return AppServices::incomingrequest($config, $getShared); + return static::$instances['request'] ?? static::incomingrequest(getShared: false); } /** diff --git a/tests/system/CommonSingleServiceTest.php b/tests/system/CommonSingleServiceTest.php index e423d1feaee0..a031dfe7e953 100644 --- a/tests/system/CommonSingleServiceTest.php +++ b/tests/system/CommonSingleServiceTest.php @@ -60,7 +60,13 @@ public function testSingleServiceWithAtLeastOneParamSupplied(string $service): v $params = []; $method = new ReflectionMethod(Services::class, $service); - $params[] = $method->getNumberOfParameters() === 1 ? true : $method->getParameters()[0]->getDefaultValue(); + $count = $method->getNumberOfParameters(); + + if ($count === 0) { + $this->markTestSkipped("Service '{$service}' does not have any parameters."); + } + + $params[] = $count === 1 ? true : $method->getParameters()[0]->getDefaultValue(); $service1 = single_service($service, ...$params); // @phpstan-ignore codeigniter.unknownServiceMethod $service2 = single_service($service, ...$params); // @phpstan-ignore codeigniter.unknownServiceMethod diff --git a/user_guide_src/source/changelogs/v4.8.0.rst b/user_guide_src/source/changelogs/v4.8.0.rst index 95e306063380..2a58ee5c6e19 100644 --- a/user_guide_src/source/changelogs/v4.8.0.rst +++ b/user_guide_src/source/changelogs/v4.8.0.rst @@ -43,6 +43,7 @@ Method Signature Changes - The updated method signature is now ``handleRequest(?RouteCollectionInterface $routes, ?Cache $cacheConfig = null)``. - ``CodeIgniter\CodeIgniter::gatherOutput()`` no longer accepts the deprecated ``$cacheConfig`` parameter. As this is the first parameter, custom uses of this method will need to be updated to remove the parameter. +- **Config:** ``CodeIgniter\Config\Services::request()`` no longer accepts any parameter. Removed Deprecated Items ======================== @@ -70,6 +71,8 @@ Removed Deprecated Items - ``CodeIgniter\CodeIgniter::determinePath()`` - ``CodeIgniter\CodeIgniter::callExit()`` - ``CodeIgniter\Test\MockCodeIgniter::callExit()`` +- **Config:** Removed the following property deprecated: + - ``CodeIgniter\Config\BaseService::$services`` (deprecated since v4.5.0) - **Debug:** Removed the following properties and methods deprecated since v4.4.0: - ``CodeIgniter\Debug\Exceptions::$ob_level`` - ``CodeIgniter\Debug\Exceptions::$viewPath`` diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index b277717823bf..9aafab3d4e1f 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 2116 errors +# total 2115 errors includes: - argument.type.neon diff --git a/utils/phpstan-baseline/missingType.iterableValue.neon b/utils/phpstan-baseline/missingType.iterableValue.neon index d5282359f662..a584450fc456 100644 --- a/utils/phpstan-baseline/missingType.iterableValue.neon +++ b/utils/phpstan-baseline/missingType.iterableValue.neon @@ -1,4 +1,4 @@ -# total 1259 errors +# total 1258 errors parameters: ignoreErrors: @@ -237,11 +237,6 @@ parameters: count: 1 path: ../../system/Config/BaseService.php - - - message: '#^Property CodeIgniter\\Config\\BaseService\:\:\$services type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Config/BaseService.php - - message: '#^Method CodeIgniter\\Config\\DotEnv\:\:normaliseVariable\(\) return type has no value type specified in iterable type array\.$#' count: 1