From b7b7c5433a7cb4992b274a0cf832ab85ef8394e5 Mon Sep 17 00:00:00 2001 From: Hugo Hamon Date: Mon, 27 Feb 2017 16:58:13 +0100 Subject: [PATCH] [DependencyInjection] inline conditional statements. --- .../DependencyInjection/Dumper/PhpDumper.php | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index c4bfa93d2a..cabcbcd657 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -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); } /**