Skip to content

Commit 6e9cc0f

Browse files
Merge branch '3.3' into 3.4
* 3.3: [DI] Minor fix in dumped code #24046 added check for ext-dom to XmlUtil::loadFile
2 parents be42b3a + c4fb250 commit 6e9cc0f

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

Dumper/PhpDumper.php

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

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

1689-
$code = "\${(\$_ = isset(\$this->services['$id']) ? \$this->services['$id'] : $code) && false ?: '_'}";
1690-
}
1691-
1692-
return $code;
1688+
return "\${(\$_ = isset(\$this->services['$id']) ? \$this->services['$id'] : $code) && false ?: '_'}";
16931689
}
16941690

16951691
/**

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)