Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove deprecated BaseService::discoverServices() #8589

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 3,
'path' => __DIR__ . '/system/Config/BaseService.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in a negated boolean, array given\\.$#',
'count' => 1,
'count' => 2,
'path' => __DIR__ . '/system/Config/BaseService.php',
];
$ignoreErrors[] = [
Expand Down
56 changes: 0 additions & 56 deletions system/Config/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,62 +318,6 @@ public static function injectMock(string $name, $mock)
static::$mocks[strtolower($name)] = $mock;
}

/**
* Will scan all psr4 namespaces registered with system to look
* for new Config\Services files. Caches a copy of each one, then
* looks for the service method in each, returning an instance of
* the service, if available.
*
* @return object|null
*
* @deprecated
*
* @codeCoverageIgnore
*/
protected static function discoverServices(string $name, array $arguments)
{
if (! static::$discovered) {
if ((new Modules())->shouldDiscover('services')) {
$locator = static::locator();
$files = $locator->search('Config/Services');

if (empty($files)) {
// no files at all found - this would be really, really bad
return null;
}

// Get instances of all service classes and cache them locally.
foreach ($files as $file) {
$classname = $locator->findQualifiedNameFromPath($file);

if ($classname === false) {
continue;
}

if ($classname !== Services::class) {
static::$services[] = new $classname();
}
}
}

static::$discovered = true;
}

if (! static::$services) {
// we found stuff, but no services - this would be really bad
return null;
}

// Try to find the desired service method
foreach (static::$services as $class) {
if (method_exists($class, $name)) {
return $class::$name(...$arguments);
}
}

return null;
}

protected static function buildServicesCache(): void
{
if (! static::$discovered) {
Expand Down
5 changes: 4 additions & 1 deletion user_guide_src/source/changelogs/v4.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,10 @@ Others
------

- **Cache:** The deprecated ``CodeIgniter\Cache\Exceptions\ExceptionInterface`` has been removed.
- **Config:** The deprecated ``CodeIgniter\Config\Config`` class has been removed.
- **Config:**
- The deprecated ``CodeIgniter\Config\Config`` class has been removed.
- The deprecated ``CodeIgniter\Config\BaseService::discoverServices()`` method
has been removed.
- **Controller:** The deprecated ``Controller::loadHelpers()`` method has been removed.
- **Exceptions:** The deprecated ``CodeIgniter\Exceptions\CastException`` class has been removed.
- **Entity:** The deprecated ``CodeIgniter\Entity`` class has been removed. Use
Expand Down
Loading