Skip to content

Commit 3596cb2

Browse files
bug #19685 [DI][2.7] Include dynamic services in alternatives (ro0NL)
This PR was merged into the 2.7 branch. Discussion ---------- [DI][2.7] Include dynamic services in alternatives | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | comma-separated list of tickets fixed by the PR, if any | License | MIT | Doc PR | reference to the documentation PR, if any Commits ------- 428b5cc include dynamic services in list of alternatives
2 parents 589b1d4 + 428b5cc commit 3596cb2

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,10 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
287287
}
288288

289289
$alternatives = array();
290-
foreach ($this->services as $key => $associatedService) {
291-
$lev = levenshtein($id, $key);
292-
if ($lev <= strlen($id) / 3 || false !== strpos($key, $id)) {
293-
$alternatives[] = $key;
290+
foreach ($this->getServiceIds() as $knownId) {
291+
$lev = levenshtein($id, $knownId);
292+
if ($lev <= strlen($id) / 3 || false !== strpos($knownId, $id)) {
293+
$alternatives[] = $knownId;
294294
}
295295
}
296296

src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ public function testGetThrowServiceNotFoundException()
219219
{
220220
$sc = new ProjectServiceContainer();
221221
$sc->set('foo', $foo = new \stdClass());
222-
$sc->set('bar', $foo = new \stdClass());
223222
$sc->set('baz', $foo = new \stdClass());
224223

225224
try {

0 commit comments

Comments
 (0)