Skip to content

Commit 8e717ae

Browse files
committed
coding style
1 parent db5e2dc commit 8e717ae

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

src/DI/ContainerBuilder.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ public function getByType($type, $throw = false)
216216
{
217217
$type = Helpers::normalizeClass($type);
218218

219-
if ($this->currentService !== null
219+
if (
220+
$this->currentService !== null
220221
&& is_a($this->definitions[$this->currentService]->getType(), $type, true)
221222
) {
222223
return $this->currentService;
@@ -337,7 +338,8 @@ public function prepareClassList()
337338
}
338339

339340
// auto-disable autowiring for aliases
340-
if ($def->getAutowired() === true
341+
if (
342+
$def->getAutowired() === true
341343
&& ($alias = $this->getServiceName($def->getFactory()->getEntity()))
342344
&& (!$def->getImplement() || (!Strings::contains($alias, '\\') && $this->definitions[$alias]->getImplement()))
343345
) {
@@ -438,7 +440,8 @@ private function resolveImplement(ServiceDefinition $def, $name)
438440
if (!$def->getEntity()) {
439441
$def->setFactory($def->getType(), $def->getFactory() ? $def->getFactory()->arguments : []);
440442
}
441-
if (($class = $this->resolveEntityType($def->getFactory(), [$name => 1]))
443+
if (
444+
($class = $this->resolveEntityType($def->getFactory(), [$name => 1]))
442445
&& ($ctor = (new ReflectionClass($class))->getConstructor())
443446
) {
444447
foreach ($ctor->getParameters() as $param) {
@@ -657,9 +660,10 @@ public function completeStatement(Statement $statement)
657660
if (!$arguments && substr($entity[1], -2) === '[]') {
658661
throw new ServiceCreationException("Missing argument for $entity[1].");
659662
}
660-
} elseif ($type = empty($service) || $entity[1] === 'create'
661-
? $this->resolveEntityType($entity[0])
662-
: $this->definitions[$service]->getType()
663+
} elseif (
664+
$type = empty($service) || $entity[1] === 'create'
665+
? $this->resolveEntityType($entity[0])
666+
: $this->definitions[$service]->getType()
663667
) {
664668
$arguments = $this->autowireArguments($type, $entity[1], $arguments);
665669
}

src/DI/PhpGenerator.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ private function generateService($name)
118118
$this->currentService = null;
119119
$code = '$service = ' . $this->formatStatement($factory) . ";\n";
120120

121-
if ((PHP_VERSION_ID < 70000 || $def->getSetup()) && ($type = $def->getType()) && !$serviceRef && $type !== $entity
121+
if (
122+
(PHP_VERSION_ID < 70000 || $def->getSetup())
123+
&& ($type = $def->getType())
124+
&& !$serviceRef && $type !== $entity
122125
&& !(is_string($entity) && preg_match('#^[\w\\\\]+\z#', $entity) && is_subclass_of($entity, $type))
123126
) {
124127
$code .= PhpHelpers::formatArgs("if (!\$service instanceof $type) {\n"

src/DI/Statement.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ class Statement
3131
*/
3232
public function __construct($entity, array $arguments = [])
3333
{
34-
if (!is_string($entity) && !(is_array($entity) && isset($entity[0], $entity[1]))
35-
&& !$entity instanceof ServiceDefinition && $entity !== null
34+
if (
35+
!is_string($entity)
36+
&& !(is_array($entity) && isset($entity[0], $entity[1]))
37+
&& !$entity instanceof ServiceDefinition
38+
&& $entity !== null
3639
) {
3740
throw new Nette\InvalidArgumentException('Argument is not valid Statement entity.');
3841
}

0 commit comments

Comments
 (0)