Skip to content

Commit ec0eeba

Browse files
committed
refactor: remove deprecations in Services
1 parent cd3013b commit ec0eeba

File tree

6 files changed

+14
-26
lines changed

6 files changed

+14
-26
lines changed

system/Config/BaseService.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,6 @@ class BaseService
175175
*/
176176
protected static $discovered = false;
177177

178-
/**
179-
* A cache of other service classes we've found.
180-
*
181-
* @var array
182-
*
183-
* @deprecated 4.5.0 No longer used.
184-
*/
185-
protected static $services = [];
186-
187178
/**
188179
* A cache of the names of services classes found.
189180
*

system/Config/Services.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -517,17 +517,10 @@ public static function renderer(?string $viewPath = null, ?ViewConfig $config =
517517
* createRequest() injects IncomingRequest or CLIRequest.
518518
*
519519
* @return CLIRequest|IncomingRequest
520-
*
521-
* @deprecated The parameter $config and $getShared are deprecated.
522520
*/
523-
public static function request(?App $config = null, bool $getShared = true)
521+
public static function request()
524522
{
525-
if ($getShared) {
526-
return static::getSharedInstance('request', $config);
527-
}
528-
529-
// @TODO remove the following code for backward compatibility
530-
return AppServices::incomingrequest($config, $getShared);
523+
return static::$instances['request'] ?? static::incomingrequest(getShared: false);
531524
}
532525

533526
/**

tests/system/CommonSingleServiceTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ public function testSingleServiceWithAtLeastOneParamSupplied(string $service): v
6060
$params = [];
6161
$method = new ReflectionMethod(Services::class, $service);
6262

63-
$params[] = $method->getNumberOfParameters() === 1 ? true : $method->getParameters()[0]->getDefaultValue();
63+
$count = $method->getNumberOfParameters();
64+
65+
if ($count === 0) {
66+
$this->markTestSkipped("Service '{$service}' does not have any parameters.");
67+
}
68+
69+
$params[] = $count === 1 ? true : $method->getParameters()[0]->getDefaultValue();
6470

6571
$service1 = single_service($service, ...$params); // @phpstan-ignore codeigniter.unknownServiceMethod
6672
$service2 = single_service($service, ...$params); // @phpstan-ignore codeigniter.unknownServiceMethod

user_guide_src/source/changelogs/v4.8.0.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Method Signature Changes
4343
- The updated method signature is now ``handleRequest(?RouteCollectionInterface $routes, ?Cache $cacheConfig = null)``.
4444
- ``CodeIgniter\CodeIgniter::gatherOutput()`` no longer accepts the deprecated ``$cacheConfig`` parameter.
4545
As this is the first parameter, custom uses of this method will need to be updated to remove the parameter.
46+
- **Config:** ``CodeIgniter\Config\Services::request()`` no longer accepts any parameter.
4647

4748
Removed Deprecated Items
4849
========================
@@ -70,6 +71,8 @@ Removed Deprecated Items
7071
- ``CodeIgniter\CodeIgniter::determinePath()``
7172
- ``CodeIgniter\CodeIgniter::callExit()``
7273
- ``CodeIgniter\Test\MockCodeIgniter::callExit()``
74+
- **Config:** Removed the following property deprecated:
75+
- ``CodeIgniter\Config\BaseService::$services`` (deprecated since v4.5.0)
7376
- **Debug:** Removed the following properties and methods deprecated since v4.4.0:
7477
- ``CodeIgniter\Debug\Exceptions::$ob_level``
7578
- ``CodeIgniter\Debug\Exceptions::$viewPath``

utils/phpstan-baseline/loader.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 2116 errors
1+
# total 2115 errors
22

33
includes:
44
- argument.type.neon

utils/phpstan-baseline/missingType.iterableValue.neon

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 1259 errors
1+
# total 1258 errors
22

33
parameters:
44
ignoreErrors:
@@ -237,11 +237,6 @@ parameters:
237237
count: 1
238238
path: ../../system/Config/BaseService.php
239239

240-
-
241-
message: '#^Property CodeIgniter\\Config\\BaseService\:\:\$services type has no value type specified in iterable type array\.$#'
242-
count: 1
243-
path: ../../system/Config/BaseService.php
244-
245240
-
246241
message: '#^Method CodeIgniter\\Config\\DotEnv\:\:normaliseVariable\(\) return type has no value type specified in iterable type array\.$#'
247242
count: 1

0 commit comments

Comments
 (0)