8000 minor #21785 [DependencyInjection] inline conditional statements (hha… · symfony/symfony@c1b3422 · GitHub
[go: up one dir, main page]

Skip to content

Commit c1b3422

Browse files
minor #21785 [DependencyInjection] inline conditional statements (hhamon)
This PR was merged into the 2.7 branch. Discussion ---------- [DependencyInjection] inline conditional statements | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | ~ <!-- - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch. - Please fill in this template according to the PR you're about to submit. - Replace this comment by a description of what your PR is solving. --> Commits ------- b7b7c54 [DependencyInjection] inline conditional statements.
2 parents eb750be + b7b7c54 commit c1b3422

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
}
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