bug #24082 [DI] Minor fix in dumped code (nicolas-grekas)
This PR was merged into the 3.3 branch.
Discussion
----------
[DI] Minor fix in dumped code
| Q | A
| ------------- | ---
| Branch? | 3.3
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
This check is useless, and leads to a potential BC break (a non-shared service overridden by calling `$container->set(...)` - unlikely yes).
Commits
-------
263b95e1d1
[DI] Minor fix in dumped code
This commit is contained in:
commit
2eee9e0073
@ -1579,13 +1579,9 @@ EOF;
|
||||
$code = sprintf('$this->get(\'%s\')', $id);
|
||||
}
|
||||
|
||||
if ($this->container->hasDefinition($id) && $this->container->getDefinition($id)->isShared()) {
|
||||
// The following is PHP 5.5 syntax for what could be written as "(\$this->services['$id'] ?? $code)" on PHP>=7.0
|
||||
// The following is PHP 5.5 syntax for what could be written as "(\$this->services['$id'] ?? $code)" on PHP>=7.0
|
||||
|
||||
$code = "\${(\$_ = isset(\$this->services['$id']) ? \$this->services['$id'] : $code) && false ?: '_'}";
|
||||
}
|
||||
|
||||
return $code;
|
||||
return "\${(\$_ = isset(\$this->services['$id']) ? \$this->services['$id'] : $code) && false ?: '_'}";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -280,7 +280,7 @@ class ProjectServiceContainer extends Container
|
||||
return $this->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () {
|
||||
yield 0 => ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'};
|
||||
if ($this->has('invalid')) {
|
||||
yield 1 => $this->get('invalid', ContainerInterface::NULL_ON_INVALID_REFERENCE);
|
||||
yield 1 => ${($_ = isset($this->services['invalid']) ? $this->services['invalid'] : $this->get('invalid', ContainerInterface::NULL_ON_INVALID_REFERENCE)) && false ?: '_'};
|
||||
}
|
||||
}, function () {
|
||||
return 1 + (int) ($this->has('invalid'));
|
||||
@ -301,12 +301,12 @@ class ProjectServiceContainer extends Container
|
||||
$this->services['method_call1'] = $instance = new \Bar\FooClass();
|
||||
|
||||
$instance->setBar(${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'});
|
||||
$instance->setBar($this->get('foo2', ContainerInterface::NULL_ON_INVALID_REFERENCE));
|
||||
$instance->setBar(${($_ = isset($this->services['foo2']) ? $this->services['foo2'] : $this->get('foo2', ContainerInterface::NULL_ON_INVALID_REFERENCE)) && false ?: '_'});
|
||||
if ($this->has('foo3')) {
|
||||
$instance->setBar($this->get('foo3', ContainerInterface::NULL_ON_INVALID_REFERENCE));
|
||||
$instance->setBar(${($_ = isset($this->services['foo3']) ? $this->services['foo3'] : $this->get('foo3', ContainerInterface::NULL_ON_INVALID_REFERENCE)) && false ?: '_'});
|
||||
}
|
||||
if ($this->has('foobaz')) {
|
||||
$instance->setBar($this->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE));
|
||||
$instance->setBar(${($_ = isset($this->services['foobaz']) ? $this->services['foobaz'] : $this->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE)) && false ?: '_'});
|
||||
}
|
||||
$instance->setBar((${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'}->foo() . (($this->hasParameter("foo")) ? ($this->getParameter("foo")) : ("default"))));
|
||||
|
||||
|
Reference in New Issue
Block a user