Skip to content

Commit ccbaa96

Browse files
committed
coding style
1 parent e0f3113 commit ccbaa96

31 files changed

+219
-156
lines changed

src/Bridges/DITracy/ContainerPanel.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class ContainerPanel implements Tracy\IBarPanel
3434
public function __construct(Container $container)
3535
{
3636
$this->container = $container;
37-
$this->elapsedTime = self::$compilationTime ? microtime(true) - self::$compilationTime : null;
37+
$this->elapsedTime = self::$compilationTime
38+
? microtime(true) - self::$compilationTime
39+
: null;
3840
}
3941

4042

src/DI/CompilerExtension.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ public function validateConfig(array $expected, array $config = null, string $na
9090
if ($extra = array_diff_key((array) $config, $expected)) {
9191
$name = $name ? str_replace('.', ' › ', $name) : $this->name;
9292
$hint = Nette\Utils\Helpers::getSuggestion(array_keys($expected), key($extra));
93-
$extra = $hint ? key($extra) : implode("', '{$name} › ", array_keys($extra));
93+
$extra = $hint
94+
? key($extra)
95+
: implode("', '{$name} › ", array_keys($extra));
9496
throw new Nette\DI\InvalidConfigurationException("Unknown configuration option '{$name} › {$extra}'" . ($hint ? ", did you mean '{$name} › {$hint}'?" : '.'));
9597
}
9698
return Nette\Schema\Helpers::merge($config, $expected);

src/DI/Config/Loader.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ private function getAdapter(string $file): Adapter
120120
if (!isset($this->adapters[$extension])) {
121121
throw new Nette\InvalidArgumentException("Unknown file extension '$file'.");
122122
}
123-
return is_object($this->adapters[$extension]) ? $this->adapters[$extension] : new $this->adapters[$extension];
123+
return is_object($this->adapters[$extension])
124+
? $this->adapters[$extension]
125+
: new $this->adapters[$extension];
124126
}
125127

126128

src/DI/Container.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ public function createService(string $name, array $args = [])
200200

201201
try {
202202
$this->creating[$name] = true;
203-
$service = $cb instanceof \Closure ? $cb(...$args) : $this->$method(...$args);
203+
$service = $cb instanceof \Closure
204+
? $cb(...$args)
205+
: $this->$method(...$args);
204206

205207
} finally {
206208
unset($this->creating[$name]);
@@ -235,7 +237,7 @@ public function getByType(string $type, bool $throw = true)
235237
throw new MissingServiceException("Service of type '$type' not found. Check class name because it cannot be found.");
236238
}
237239
foreach ($this->methods as $method => $foo) {
238-
$methodType = (new \ReflectionMethod(get_class($this), $method))->getReturnType()->getName();
240+
$methodType = (new \ReflectionMethod(static::class, $method))->getReturnType()->getName();
239241
if (is_a($methodType, $type, true)) {
240242
throw new MissingServiceException("Service of type $type is not autowired or is missing in di › export › types.");
241243
}

src/DI/Definitions/AccessorDefinition.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ public function setImplement(string $type)
3434
$rc = new \ReflectionClass($type);
3535

3636
$method = $rc->getMethods()[0] ?? null;
37-
if (!$method || $method->isStatic() || $method->getName() !== self::METHOD_GET || count($rc->getMethods()) > 1) {
37+
if (
38+
!$method
39+
|| $method->isStatic()
40+
|| $method->getName() !== self::METHOD_GET
41+
|| count($rc->getMethods()) > 1
42+
) {
3843
throw new Nette\InvalidArgumentException("Service '{$this->getName()}': Interface $type must have just one non-static method get().");
3944
} elseif ($method->getNumberOfParameters()) {
4045
throw new Nette\InvalidArgumentException("Service '{$this->getName()}': Method $type::get() must have no parameters.");

src/DI/Definitions/Definition.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ final public function setAutowired($state = true)
119119
if ($this->notifier && $this->autowired !== $state) {
120120
($this->notifier)();
121121
}
122-
$this->autowired = is_string($state) || is_array($state) ? (array) $state : (bool) $state;
122+
$this->autowired = is_string($state) || is_array($state)
123+
? (array) $state
124+
: (bool) $state;
123125
return $this;
124126
}
125127

src/DI/Definitions/LocatorDefinition.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public function setImplement(string $type)
4343
)) {
4444
throw new Nette\InvalidArgumentException(sprintf(
4545
"Service '%s': Method %s::%s() does not meet the requirements: is create(\$name), get(\$name), create*() or get*() and is non-static.",
46-
$this->getName(), $type, $method->name
46+
$this->getName(),
47+
$type,
48+
$method->name
4749
));
4850
}
4951
}

src/DI/Definitions/ServiceDefinition.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace Nette\DI\Definitions;
1111

1212
use Nette;
13-
use Nette\DI\Definitions\Reference;
1413
use Nette\DI\ServiceCreationException;
1514
use Nette\PhpGenerator\Helpers as PhpHelpers;
1615

@@ -64,7 +63,9 @@ public function setType(?string $type)
6463
*/
6564
public function setFactory($factory, array $args = [])
6665
{
67-
$this->factory = $factory instanceof Statement ? $factory : new Statement($factory, $args);
66+
$this->factory = $factory instanceof Statement
67+
? $factory
68+
: new Statement($factory, $args);
6869
return $this;
6970
}
7071

@@ -127,7 +128,9 @@ public function getSetup(): array
127128
*/
128129
public function addSetup($entity, array $args = [])
129130
{
130-
$this->setup[] = $entity instanceof Statement ? $entity : new Statement($entity, $args);
131+
$this->setup[] = $entity instanceof Statement
132+
? $entity
133+
: new Statement($entity, $args);
131134
return $this;
132135
}
133136

@@ -204,7 +207,10 @@ public function complete(Nette\DI\Resolver $resolver): void
204207
$this->factory = $resolver->completeStatement($this->factory);
205208

206209
foreach ($this->setup as &$setup) {
207-
if (is_string($setup->getEntity()) && strpbrk($setup->getEntity(), ':@?\\') === false) { // auto-prepend @self
210+
if (
211+
is_string($setup->getEntity())
212+
&& strpbrk($setup->getEntity(), ':@?\\') === false
213+
) { // auto-prepend @self
208214
$setup = new Statement([new Reference(Reference::SELF), $setup->getEntity()], $setup->arguments);
209215
}
210216
$setup = $resolver->completeStatement($setup, true);
@@ -228,7 +234,8 @@ public function generateMethod(Nette\PhpGenerator\Method $method, Nette\DI\PhpGe
228234
&& !(is_array($entity) && $entity[0] instanceof Reference && $entity[0]->getValue() === Nette\DI\ContainerBuilder::THIS_CONTAINER)
229235
&& !(is_string($entity) && preg_match('#^[\w\\\\]+$#D', $entity) && is_subclass_of($entity, $type))
230236
) {
231-
$code .= PhpHelpers::formatArgs("if (!\$service instanceof $type) {\n"
237+
$code .= PhpHelpers::formatArgs(
238+
"if (!\$service instanceof $type) {\n"
232239
. "\tthrow new Nette\\UnexpectedValueException(?);\n}\n",
233240
["Unable to create service '{$this->getName()}', value returned by factory is not $type type."]
234241
);

src/DI/DependencyChecker.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,14 @@ public function export(): array
8080
/**
8181
* Are dependencies expired?
8282
*/
83-
public static function isExpired(int $version, array $files, array &$phpFiles, array $classes, array $functions, string $hash): bool
84-
{
83+
public static function isExpired(
84+
int $version,
85+
array $files,
86+
array &$phpFiles,
87+
array $classes,
88+
array $functions,
89+
string $hash
90+
): bool {
8591
try {
8692
$currentFiles = @array_map('filemtime', array_combine($tmp = array_keys($files), $tmp)); // @ - files may not exist
8793
$origPhpFiles = $phpFiles;

src/DI/Extensions/DIExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,23 @@ public function __construct(bool $debugMode = false)
3838
$this->config = new class {
3939
/** @var ?bool */
4040
public $debugger;
41+
4142
/** @var string[] */
4243
public $excluded = [];
44+
4345
/** @var ?string */
4446
public $parentClass;
47+
4548
/** @var object */
4649
public $export;
4750
};
4851
$this->config->export = new class {
4952
/** @var bool */
5053
public $parameters = true;
54+
5155
/** @var string[]|bool|null */
5256
public $tags = true;
57+
5358
/** @var string[]|bool|null */
5459
public $types = true;
5560
};

0 commit comments

Comments
 (0)