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
This commit is contained in:
Nicolas Grekas 2016-08-23 09:00:45 +02:00
commit 3596cb26ad
2 changed files with 4 additions and 5 deletions

View File

@ -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;
}
}

View File

@ -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 {