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.
This commit is contained in:
Nicolas Grekas 2017-02-28 13:23:43 +01:00
commit c1b3422900

View File

@ -1009,11 +1009,7 @@ EOF;
private function addAliases()
{
if (!$aliases = $this->container->getAliases()) {
if ($this->container->isFrozen()) {
return "\n \$this->aliases = array();\n";
} else {
return '';
}
return $this->container->isFrozen() ? "\n \$this->aliases = array();\n" : '';
}
$code = " \$this->aliases = array(\n";
@ -1382,9 +1378,9 @@ EOF;
$service = $this->dumpValue($value->getFactoryService(false));
return sprintf('%s->%s(%s)', 0 === strpos($service, '$') ? sprintf('$this->get(%s)', $service) : $this->getServiceCall($value->getFactoryService(false)), $value->getFactoryMethod(false), implode(', ', $arguments));
} else {
throw new RuntimeException('Cannot dump definitions which have factory method without factory service or factory class.');
}
throw new RuntimeException('Cannot dump definitions which have factory method without factory service or factory class.');
}
$class = $value->getClass();
@ -1422,9 +1418,9 @@ EOF;
}
} elseif (is_object($value) || is_resource($value)) {
throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.');
} else {
return $this->export($value);
}
return $this->export($value);
}
/**
@ -1493,13 +1489,13 @@ EOF;
if (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
return sprintf('$this->get(\'%s\', ContainerInterface::NULL_ON_INVALID_REFERENCE)', $id);
} else {
if ($this->container->hasAlias($id)) {
$id = (string) $this->container->getAlias($id);
}
return sprintf('$this->get(\'%s\')', $id);
}
if ($this->container->hasAlias($id)) {
$id = (string) $this->container->getAlias($id);
}
return sprintf('$this->get(\'%s\')', $id);
}
/**