8000 bug #24082 [DI] Minor fix in dumped code (nicolas-grekas) · symfony/symfony@2eee9e0 · GitHub
[go: up one dir, main page]

Skip to content < 8000 script type="application/json" data-target="react-partial.embeddedData">{"props":{"docsUrl":"https://docs.github.com/get-started/accessibility/keyboard-shortcuts"}}

Commit 2eee9e0

Browse files
committed
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 ------- 263b95e [DI] Minor fix in dumped code
2 parents c4ecb9c + 263b95e commit 2eee9e0

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,13 +1579,9 @@ private function getServiceCall($id, Reference $reference = null)
15791579
$code = sprintf('$this->get(\'%s\')', $id);
15801580
}
15811581

1582-
if ($this->container->hasDefinition($id) && $this->container->getDefinition($id)->isShared()) {
1583-
// The following is PHP 5.5 syntax for what could be written as "(\$this->services['$id'] ?? $code)" on PHP>=7.0
1582+
// The following is PHP 5.5 syntax for what could be written as "(\$this->services['$id'] ?? $code)" on PHP>=7.0
15841583

1585-
$code = "\${(\$_ = isset(\$this->services['$id']) ? \$this->services['$id'] : $code) && false ?: '_'}";
1586-
}
1587-
1588-
return $code;
1584+
return "\${(\$_ = isset(\$this->services['$id']) ? \$this->services['$id'] : $code) && false ?: '_'}";
15891585
}
15901586

15911587
/**

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ protected function getLazyContextIgnoreInvalidRefService()
280280
return $this->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () {
281281
yield 0 => ${($_ = isset($this->services['foo.baz']) ? $this->services['foo.baz'] : $this->get('foo.baz')) && false ?: '_'};
282282
if ($this->has('invalid')) {
283-
yield 1 => $this->get('invalid', ContainerInterface::NULL_ON_INVALID_REFERENCE);
283+
yield 1 => ${($_ = isset($this->services['invalid']) ? $this->services['invalid'] : $this->get('invalid', ContainerInterface::NULL_ON_INVALID_REFERENCE)) && false ?: '_'};
284284
}
285285
}, function () {
286286
return 1 + (int) ($this->has('invalid'));
@@ -301,12 +301,12 @@ protected function getMethodCall1Service()
301301
$this->services['method_call1'] = $instance = new \Bar\FooClass();
302302

303303
$instance->setBar(${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'});
304-
$instance->setBar($this->get('foo2', ContainerInterface::NULL_ON_INVALID_REFERENCE));
304+
$instance->setBar(${($_ = isset($this->services['foo2']) ? $this->services['foo2'] : $this->get('foo2', ContainerInterface::NULL_ON_INVALID_REFERENCE)) && false ?: '_'});
305305
if ($this->has('foo3')) {
306-
$instance->setBar($this->get('foo3', ContainerInterface::NULL_ON_INVALID_REFERENCE));
306+
$instance->setBar(${($_ = isset($this->services['foo3']) ? $this->services['foo3'] : $this->get('foo3', ContainerInterface::NULL_ON_INVALID_REFERENCE)) && false ?: '_'});
307307
}
308308
if ($this->has('foobaz')) {
309-
$instance->setBar($this->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE));
309+
$instance->setBar(${($_ = isset($this->services['foobaz']) ? $this->services['foobaz'] : $this->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE)) && false ?: '_'});
310310
}
311311
$instance->setBar((${($_ = isset($this->services['foo']) ? $this->services['foo'] : $this->get('foo')) && false ?: '_'}->foo() . (($this->hasParameter("foo")) ? ($this->getParameter("foo")) : ("default"))));
312312

0 commit comments

Comments
 (0)
0