Skip to content

Commit a663b36

Browse files
authored
Merge pull request #8589 from kenjis/remove-BaseService-discoverServices
refactor: remove deprecated BaseService::discoverServices()
2 parents e72ce8f + 7e00435 commit a663b36

File tree

3 files changed

+5
-63
lines changed

3 files changed

+5
-63
lines changed

phpstan-baseline.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,7 @@
303303
];
304304
$ignoreErrors[] = [
305305
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
306-
'count' => 3,
307-
'path' => __DIR__ . '/system/Config/BaseService.php',
308-
];
309-
$ignoreErrors[] = [
310-
'message' => '#^Only booleans are allowed in a negated boolean, array given\\.$#',
311-
'count' => 1,
306+
'count' => 2,
312307
'path' => __DIR__ . '/system/Config/BaseService.php',
313308
];
314309
$ignoreErrors[] = [

system/Config/BaseService.php

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -318,62 +318,6 @@ public static function injectMock(string $name, $mock)
318318
static::$mocks[strtolower($name)] = $mock;
319319
}
320320

321-
/**
322-
* Will scan all psr4 namespaces registered with system to look
323-
* for new Config\Services files. Caches a copy of each one, then
324-
* looks for the service method in each, returning an instance of
325-
* the service, if available.
326-
*
327-
* @return object|null
328-
*
329-
* @deprecated
330-
*
331-
* @codeCoverageIgnore
332-
*/
333-
protected static function discoverServices(string $name, array $arguments)
334-
{
335-
if (! static::$discovered) {
336-
if ((new Modules())->shouldDiscover('services')) {
337-
$locator = static::locator();
338-
$files = $locator->search('Config/Services');
339-
340-
if (empty($files)) {
341-
// no files at all found - this would be really, really bad
342-
return null;
343-
}
344-
345-
// Get instances of all service classes and cache them locally.
346-
foreach ($files as $file) {
347-
$classname = $locator->findQualifiedNameFromPath($file);
348-
349-
if ($classname === false) {
350-
continue;
351-
}
352-
353-
if ($classname !== Services::class) {
354-
static::$services[] = new $classname();
355-
}
356-
}
357-
}
358-
359-
static::$discovered = true;
360-
}
361-
362-
if (! static::$services) {
363-
// we found stuff, but no services - this would be really bad
364-
return null;
365-
}
366-
367-
// Try to find the desired service method
368-
foreach (static::$services as $class) {
369-
if (method_exists($class, $name)) {
370-
return $class::$name(...$arguments);
371-
}
372-
}
373-
374-
return null;
375-
}
376-
377321
protected static function buildServicesCache(): void
378322
{
379323
if (! static::$discovered) {

user_guide_src/source/changelogs/v4.5.0.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,10 @@ Others
408408
------
409409

410410
- **Cache:** The deprecated ``CodeIgniter\Cache\Exceptions\ExceptionInterface`` has been removed.
411-
- **Config:** The deprecated ``CodeIgniter\Config\Config`` class has been removed.
411+
- **Config:**
412+
- The deprecated ``CodeIgniter\Config\Config`` class has been removed.
413+
- The deprecated ``CodeIgniter\Config\BaseService::discoverServices()`` method
414+
has been removed.
412415
- **Controller:** The deprecated ``Controller::loadHelpers()`` method has been removed.
413416
- **Exceptions:** The deprecated ``CodeIgniter\Exceptions\CastException`` class has been removed.
414417
- **Entity:** The deprecated ``CodeIgniter\Entity`` class has been removed. Use

0 commit comments

Comments
 (0)