Skip to content

Commit a420ef9

Browse files
committed
include dynamic services in list of alternatives
1 parent 3014bb2 commit a420ef9

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

Container.php

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

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

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)