Skip to content

Commit eb28f8a

Browse files
committed
coding style
1 parent 32483ad commit eb28f8a

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
@@ -184,7 +184,8 @@ public function getByType(string $type, bool $throw = false): ?string
184184
{
185185
$type = Helpers::normalizeClass($type);
186186

187-
if ($this->currentService !== null
187+
if (
188+
$this->currentService !== null
188189
&& is_a($this->definitions[$this->currentService]->getType(), $type, true)
189190
) {
190191
return $this->currentService;
@@ -300,7 +301,8 @@ public function prepareClassList(): void
300301
}
301302

302303
// auto-disable autowiring for aliases
303-
if ($def->getAutowired() === true
304+
if (
305+
$def->getAutowired() === true
304306
&& ($alias = $this->getServiceName($def->getFactory()->getEntity()))
305307
&& (!$def->getImplement() || (!Strings::contains($alias, '\\') && $this->definitions[$alias]->getImplement()))
306308
) {
@@ -401,7 +403,8 @@ private function resolveImplement(ServiceDefinition $def, $name): void
401403
if (!$def->getEntity()) {
402404
$def->setFactory($def->getType(), $def->getFactory() ? $def->getFactory()->arguments : []);
403405
}
404-
if (($class = $this->resolveEntityType($def->getFactory(), [$name => 1]))
406+
if (
407+
($class = $this->resolveEntityType($def->getFactory(), [$name => 1]))
405408
&& ($ctor = (new ReflectionClass($class))->getConstructor())
406409
) {
407410
foreach ($ctor->getParameters() as $param) {
@@ -613,9 +616,10 @@ public function completeStatement(Statement $statement): Statement
613616
if (!$arguments && substr($entity[1], -2) === '[]') {
614617
throw new ServiceCreationException("Missing argument for $entity[1].");
615618
}
616-
} elseif ($type = empty($service) || $entity[1] === 'create'
617-
? $this->resolveEntityType($entity[0])
618-
: $this->definitions[$service]->getType()
619+
} elseif (
620+
$type = empty($service) || $entity[1] === 'create'
621+
? $this->resolveEntityType($entity[0])
622+
: $this->definitions[$service]->getType()
619623
) {
620624
$arguments = $this->autowireArguments($type, $entity[1], $arguments);
621625
}

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(string $name): string
118118
$this->currentService = null;
119119
$code = '$service = ' . $this->formatStatement($factory) . ";\n";
120120

121-
if ($def->getSetup() && ($type = $def->getType()) && !$serviceRef && $type !== $entity
121+
if (
122+
$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
@@ -33,8 +33,11 @@ final class Statement
3333
*/
3434
public function __construct($entity, array $arguments = [])
3535
{
36-
if (!is_string($entity) && !(is_array($entity) && isset($entity[0], $entity[1]))
37-
&& !$entity instanceof ServiceDefinition && $entity !== null
36+
if (
37+
!is_string($entity)
38+
&& !(is_array($entity) && isset($entity[0], $entity[1]))
39+
&& !$entity instanceof ServiceDefinition
40+
&& $entity !== null
3841
) {
3942
throw new Nette\InvalidArgumentException('Argument is not valid Statement entity.');
4043
}

0 commit comments

Comments
 (0)