[DI] There are no initialized-only refs to undeclared services
This commit is contained in:
parent
cf35e0c104
commit
61966df131
@ -1711,12 +1711,12 @@ EOF;
|
||||
return '$this';
|
||||
}
|
||||
|
||||
if (null !== $reference && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $reference->getInvalidBehavior()) {
|
||||
$code = 'null';
|
||||
} elseif ($this->container->hasDefinition($id)) {
|
||||
if ($this->container->hasDefinition($id)) {
|
||||
$definition = $this->container->getDefinition($id);
|
||||
|
||||
if ($this->isTrivialInstance($definition)) {
|
||||
if (null !== $reference && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $reference->getInvalidBehavior()) {
|
||||
$code = 'null';
|
||||
} elseif ($this->isTrivialInstance($definition)) {
|
||||
$code = substr($this->addNewInstance($definition, '', '', $id), 8, -2);
|
||||
if ($definition->isShared()) {
|
||||
$code = sprintf('$this->services[\'%s\'] = %s', $id, $code);
|
||||
@ -1726,6 +1726,8 @@ EOF;
|
||||
} else {
|
||||
$code = sprintf('$this->%s()', $this->generateMethodName($id));
|
||||
}
|
||||
} elseif (null !== $reference && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $reference->getInvalidBehavior()) {
|
||||
return 'null';
|
||||
} elseif (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
|
||||
$code = sprintf('$this->get(\'%s\', ContainerInterface::NULL_ON_INVALID_REFERENCE)', $id);
|
||||
} else {
|
||||
|
@ -76,12 +76,12 @@ class Symfony_DI_PhpDumper_Test_Uninitialized_Reference extends Container
|
||||
$this->services['bar'] = $instance = new \stdClass();
|
||||
|
||||
$instance->foo1 = ${($_ = isset($this->services['foo1']) ? $this->services['foo1'] : null) && false ?: '_'};
|
||||
$instance->foo2 = ${($_ = isset($this->services['foo2']) ? $this->services['foo2'] : null) && false ?: '_'};
|
||||
$instance->foo2 = null;
|
||||
$instance->foo3 = ${($_ = isset($this->services['foo3']) ? $this->services['foo3'] : null) && false ?: '_'};
|
||||
$instance->closures = array(0 => function () {
|
||||
return ${($_ = isset($this->services['foo1']) ? $this->services['foo1'] : null) && false ?: '_'};
|
||||
}, 1 => function () {
|
||||
return ${($_ = isset($this->services['foo2']) ? $this->services['foo2'] : null) && false ?: '_'};
|
||||
return null;
|
||||
}, 2 => function () {
|
||||
return ${($_ = isset($this->services['foo3']) ? $this->services['foo3'] : null) && false ?: '_'};
|
||||
});
|
||||
@ -90,7 +90,7 @@ class Symfony_DI_PhpDumper_Test_Uninitialized_Reference extends Container
|
||||
yield 'foo1' => ${($_ = isset($this->services['foo1']) ? $this->services['foo1'] : null) && false ?: '_'};
|
||||
}
|
||||
if (false) {
|
||||
yield 'foo2' => ${($_ = isset($this->services['foo2']) ? $this->services['foo2'] : null) && false ?: '_'};
|
||||
yield 'foo2' => null;
|
||||
}
|
||||
if (isset($this->services['foo3'])) {
|
||||
yield 'foo3' => ${($_ = isset($this->services['foo3']) ? $this->services['foo3'] : null) && false ?: '_'};
|
||||
|
Reference in New Issue
Block a user