minor #21134 [DI] Minor fixes in FactoryReturnTypePass (nicolas-grekas)

This PR was merged into the 3.2 branch.

Discussion
----------

[DI] Minor fixes in FactoryReturnTypePass

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

c231f81 [DI] Minor fixes in FactoryReturnTypePass
This commit is contained in:
Nicolas Grekas 2017-01-02 15:31:02 +01:00
commit e04041fdd5
2 changed files with 6 additions and 6 deletions

View File

@ -58,7 +58,7 @@ class FactoryReturnTypePass implements CompilerPassInterface
if ($factory[0] instanceof Reference) {
$previous[$id] = true;
$factoryDefinition = $container->findDefinition((string) $factory[0]);
$this->updateDefinition($container, (string) $factory[0], $factoryDefinition, $previous);
$this->updateDefinition($container, strtolower($factory[0]), $factoryDefinition, $previous);
$class = $factoryDefinition->getClass();
} else {
$class = $factory[0];
@ -73,12 +73,12 @@ class FactoryReturnTypePass implements CompilerPassInterface
$returnType = $m->getReturnType();
if (null !== $returnType && !$returnType->isBuiltin()) {
$returnType = (string) $returnType;
$returnType = $returnType instanceof \ReflectionNamedType ? $returnType->getName() : $returnType->__toString();
if (null !== $class) {
$declaringClass = $m->getDeclaringClass()->getName();
if ('self' === $returnType) {
if ('self' === strtolower($returnType)) {
$returnType = $declaringClass;
} elseif ('parent' === $returnType) {
} elseif ('parent' === strtolower($returnType)) {
$returnType = get_parent_class($declaringClass) ?: null;
}
}

View File

@ -91,12 +91,12 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
private $usedTags = array();
/**
* @var string[][] A map of env var names to their placeholders
* @var string[][] a map of env var names to their placeholders
*/
private $envPlaceholders = array();
/**
* @var int[] A map of env vars to their resolution counter.
* @var int[] a map of env vars to their resolution counter
*/
private $envCounters = array();