diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index d59ad0d5ff..3cfdd616c5 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -287,10 +287,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 {