8000 Merge branch '3.3' into 3.4 · symfony/symfony@80c0ec1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 80c0ec1

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 1a24a10 + 28e7a13 commit 80c0ec1

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ private function __construct()
3737
* @return \DOMDocument
3838
*
3939
* @throws \InvalidArgumentException When loading of XML file returns error
40+
* @throws \RuntimeException When DOM extension is missing
4041
*/
4142
public static function loadFile($file, $schemaOrCallable = null)
4243
{
44+
if (!extension_loaded('dom')) {
45+
throw new \RuntimeException('Extension DOM is required.');
46+
}
47+
4348
$content = @file_get_contents($file);
4449
if ('' === trim($content)) {
4550
throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file));

src/Symfony/Component/DependencyInjection/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
/**

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