From 428b5cc6a838ae6482367d78d6688fe20c426bf5 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Sat, 20 Aug 2016 08:07:04 +0000 Subject: [PATCH] include dynamic services in list of alternatives --- src/Symfony/Component/DependencyInjection/Container.php | 8 ++++---- .../Component/DependencyInjection/Tests/ContainerTest.php | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 3ecf81635a..f6c953f550 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -288,10 +288,10 @@ class Container implements IntrospectableContainerInterface } $alternatives = array(); - foreach ($this->services as $key => $associatedService) { - $lev = levenshtein($id, $key); - if ($lev <= strlen($id) / 3 || false !== strpos($key, $id)) { - $alternatives[] = $key; + foreach ($this->getServiceIds() as $knownId) { + $lev = levenshtein($id, $knownId); + if ($lev <= strlen($id) / 3 || false !== strpos($knownId, $id)) { + $alternatives[] = $knownId; } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index fa556cf8c1..013ee82316 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -219,7 +219,6 @@ class ContainerTest extends \PHPUnit_Framework_TestCase { $sc = new ProjectServiceContainer(); $sc->set('foo', $foo = new \stdClass()); - $sc->set('bar', $foo = new \stdClass()); $sc->set('baz', $foo = new \stdClass()); try {