8000 [DependencyInjection] inline conditional statements. · symfony/symfony@b7b7c54 · GitHub
[go: up one dir, main page]

Skip to content

Commit b7b7c54

Browse files
author
Hugo Hamon
committed
[DependencyInjection] inline conditional statements.
1 parent eb750be commit b7b7c54

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,11 +1009,7 @@ private function addMethodMap()
10091009
private function addAliases()
10101010
{
10111011
if (!$aliases = $this->container->getAliases()) {
1012-
if ($this->container->isFrozen()) {
1013-
return "\n \$this->aliases = array();\n";
1014-
} else {
1015-
return '';
1016-
}
1012+
return $this->container->isFrozen() ? "\n \$this->aliases = array();\n" : '';
10171013
}
10181014

10191015
$code = " \$this->aliases = array(\n";
@@ -1382,9 +1378,9 @@ private function dumpValue($value, $interpolate = true)
13821378
$service = $this->dumpValue($value->getFactoryService(false));
13831379

13841380
return sprintf('%s->%s(%s)', 0 === strpos($service, '$') ? sprintf('$this->get(%s)', $service) : $this->getServiceCall($value->getFactoryService(false)), $value->getFactoryMethod(false), implode(', ', $arguments));
1385-
} else {
1386-
throw new RuntimeException('Cannot dump definitions which have factory method without factory service or factory class.');
13871381
}
1382+
1383+
throw new RuntimeException('Cannot dump definitions which have factory method without factory service or factory class.');
13881384
}
13891385

13901386
$class = $value->getClass();
@@ -1422,9 +1418,9 @@ private function dumpValue($value, $interpolate = true)
14221418
}
14231419
} elseif (is_object($value) || is_resource($value)) {
14241420
throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.');
1425-
} else {
1426-
return $this->export($value);
14271421
}
1422+
1423+
return $this->export($value);
14281424
}
< B478 /code>
14291425

14301426
/**
@@ -1493,13 +1489,13 @@ private function getServiceCall($id, Reference $reference = null)
14931489

14941490
if (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
14951491
return sprintf('$this->get(\'%s\', ContainerInterface::NULL_ON_INVALID_REFERENCE)', $id);
1496-
} else {
1497-
if ($this->container->hasAlias($id)) {
1498-
$id = (string) $this->container->getAlias($id);
1499-
}
1492+
}
15001493

1501-
return sprintf('$this->get(\'%s\')', $id);
1494+
if ($this->container->hasAlias($id)) {
1495+
$id = (string) $this->container->getAlias($id);
15021496
}
1497+
1498+
return sprintf('$this->get(\'%s\')', $id);
15031499
}
15041500

15051501
/**

0 commit comments

Comments
 (0)
0