@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | if ($resultDef instanceof Definitions\ServiceDefinition) { |
108 | 108 | if ($resultDef->getEntity() instanceof Definitions\Reference && !$resultDef->getFactory()->arguments) { |
109 | - $resultDef->setFactory([ // render as $container->createMethod() |
|
109 | + $resultDef->setFactory([// render as $container->createMethod() |
|
110 | 110 | new Definitions\Reference(Nette\DI\ContainerBuilder::THIS_CONTAINER), |
111 | 111 | Nette\DI\Container::getMethodName($resultDef->getEntity()->getValue()), |
112 | 112 | ]); |
@@ -130,16 +130,16 @@ discard block |
||
130 | 130 | $code = new Definitions\Statement('class', $this->resultDefinition->getFactory()->arguments); |
131 | 131 | $code = $generator->formatStatement($code); |
132 | 132 | |
133 | - $method->setBody('$service = ' . "{$code} " . $class->addExtend($entity) . ';'); |
|
133 | + $method->setBody('$service = '."{$code} ".$class->addExtend($entity).';'); |
|
134 | 134 | |
135 | 135 | if (!empty($this->resultDefinition->getSetup())) { |
136 | 136 | $setups = ''; |
137 | 137 | |
138 | 138 | foreach ($this->resultDefinition->getSetup() as $setup) { |
139 | - $setups .= $generator->formatStatement($setup) . ";\n"; |
|
139 | + $setups .= $generator->formatStatement($setup).";\n"; |
|
140 | 140 | } |
141 | 141 | |
142 | - $method->addBody("\n" . $setups); |
|
142 | + $method->addBody("\n".$setups); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | $method->addBody('return $service;'); |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | |
251 | 251 | if (!\is_object($service)) { |
252 | 252 | throw new UnexpectedValueException( |
253 | - "Unable to create service '$name', value returned by " . |
|
254 | - ($cb instanceof Closure ? 'closure' : "method $method()") . ' is not object.' |
|
253 | + "Unable to create service '$name', value returned by ". |
|
254 | + ($cb instanceof Closure ? 'closure' : "method $method()").' is not object.' |
|
255 | 255 | ); |
256 | 256 | } |
257 | 257 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | \natsort($names); |
273 | 273 | |
274 | 274 | throw new MissingServiceException( |
275 | - "Multiple services of type $type found: " . \implode(', ', $names) . '.' |
|
275 | + "Multiple services of type $type found: ".\implode(', ', $names).'.' |
|
276 | 276 | ); |
277 | 277 | } |
278 | 278 | |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | |
438 | 438 | if (($expectedType = $this->getServiceType($abstract)) && !\is_a($type, $expectedType, true)) { |
439 | 439 | throw new ContainerResolutionException( |
440 | - "Service '$abstract' must be instance of $expectedType, " . |
|
440 | + "Service '$abstract' must be instance of $expectedType, ". |
|
441 | 441 | ($type ? "$type given." : 'add typehint to closure.') |
442 | 442 | ); |
443 | 443 | } |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | |
479 | 479 | private function autowireArguments(ReflectionFunctionAbstract $function, array $args = []): array |
480 | 480 | { |
481 | - return Resolver::autowireArguments($function, $args, function (string $type, bool $single) { |
|
481 | + return Resolver::autowireArguments($function, $args, function(string $type, bool $single) { |
|
482 | 482 | return $single |
483 | 483 | ? $this->getByType($type) |
484 | 484 | : \array_map([$this, 'get'], $this->findAutowired($type)); |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | { |
511 | 511 | return \array_flip(\array_filter( |
512 | 512 | $methods, |
513 | - function ($s) { |
|
513 | + function($s) { |
|
514 | 514 | return \preg_match('#^createService.#', $s); |
515 | 515 | } |
516 | 516 | )); |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function getTab(): string |
55 | 55 | { |
56 | - return Nette\Utils\Helpers::capture(function (): void { |
|
56 | + return Nette\Utils\Helpers::capture(function(): void { |
|
57 | 57 | $elapsedTime = $this->elapsedTime; |
58 | 58 | |
59 | - require $this->diPath . '/templates/ContainerPanel.tab.phtml'; |
|
59 | + require $this->diPath.'/templates/ContainerPanel.tab.phtml'; |
|
60 | 60 | }); |
61 | 61 | } |
62 | 62 | |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | - return Nette\Utils\Helpers::capture(function () use ($tags, $types, $rc): void { |
|
86 | + return Nette\Utils\Helpers::capture(function() use ($tags, $types, $rc): void { |
|
87 | 87 | $container = $this->container; |
88 | 88 | $file = $rc->getFileName(); |
89 | 89 | $instances = $this->getContainerProperty('instances'); |
90 | 90 | $wiring = $this->getContainerProperty('wiring'); |
91 | 91 | |
92 | - require $this->diPath . '/templates/ContainerPanel.panel.phtml'; |
|
92 | + require $this->diPath.'/templates/ContainerPanel.panel.phtml'; |
|
93 | 93 | }); |
94 | 94 | } |
95 | 95 |
@@ -69,10 +69,10 @@ |
||
69 | 69 | } else { |
70 | 70 | $this->message .= ' Did you mean one of these: "'; |
71 | 71 | } |
72 | - $this->message .= \implode('", "', $this->alternatives) . '"?'; |
|
72 | + $this->message .= \implode('", "', $this->alternatives).'"?'; |
|
73 | 73 | } elseif (null !== $this->nonNestedAlternative) { |
74 | - $this->message .= ' You cannot access nested array items, do you want to inject "' . |
|
75 | - $this->nonNestedAlternative . '" instead?'; |
|
74 | + $this->message .= ' You cannot access nested array items, do you want to inject "'. |
|
75 | + $this->nonNestedAlternative.'" instead?'; |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | try { |
120 | 120 | $method = new Nette\PhpGenerator\Method(Container::getMethodName($name)); |
121 | 121 | $method->setProtected(); |
122 | - $method->setComment(\sprintf($comment . "\n" . $comment2, $name, $def->getType())); |
|
122 | + $method->setComment(\sprintf($comment."\n".$comment2, $name, $def->getType())); |
|
123 | 123 | $method->setReturnType($def->getType()); |
124 | 124 | $def->generateMethod($method, $this); |
125 | 125 | |
126 | 126 | return $method; |
127 | 127 | } catch (Exception $e) { |
128 | - throw new ServiceCreationException("Service '$name': " . $e->getMessage(), 0, $e); |
|
128 | + throw new ServiceCreationException("Service '$name': ".$e->getMessage(), 0, $e); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function formatPhp(string $statement, array $args): string |
138 | 138 | { |
139 | - \array_walk_recursive($args, function (&$val): void { |
|
139 | + \array_walk_recursive($args, function(&$val): void { |
|
140 | 140 | if ($val instanceof Definitions\Statement) { |
141 | 141 | $val = new Php\Literal($this->formatStatement($val)); |
142 | 142 | } elseif ($val instanceof Definitions\Reference) { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function parse(string $content, $schemaOrCallable = null): DOMDocument |
62 | 62 | { |
63 | - $internalErrors = \libxml_use_internal_errors(true); |
|
63 | + $internalErrors = \libxml_use_internal_errors(true); |
|
64 | 64 | \libxml_clear_errors(); |
65 | 65 | |
66 | 66 | $dom = new DOMDocument(); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $writer->startElement('container-config'); |
226 | 226 | } |
227 | 227 | |
228 | - $data = \array_map(function ($value) { |
|
228 | + $data = \array_map(function($value) { |
|
229 | 229 | $value = $this->resolveClassObject($value); |
230 | 230 | |
231 | 231 | if (\is_array($value)) { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | unset($value['value']); |
288 | 288 | |
289 | 289 | $writer->startElement($key); |
290 | - \array_walk_recursive($value, function ($item, $id) use (&$writer): void { |
|
290 | + \array_walk_recursive($value, function($item, $id) use (&$writer): void { |
|
291 | 291 | $writer->writeAttribute($id, $item); |
292 | 292 | }); |
293 | 293 | |
@@ -337,10 +337,10 @@ discard block |
||
337 | 337 | return true; |
338 | 338 | case 'false' === $lowercaseValue: |
339 | 339 | return false; |
340 | - case isset($value[1]) && '0b' == $value[0] . $value[1] && \preg_match('/^0b[01]*$/', $value): |
|
340 | + case isset($value[1]) && '0b' == $value[0].$value[1] && \preg_match('/^0b[01]*$/', $value): |
|
341 | 341 | return \bindec($value); |
342 | 342 | case \is_numeric($value): |
343 | - return '0x' === $value[0] . $value[1] ? \hexdec($value) : (float) $value; |
|
343 | + return '0x' === $value[0].$value[1] ? \hexdec($value) : (float) $value; |
|
344 | 344 | case \preg_match('/^0x[0-9a-f]++$/i', $value): |
345 | 345 | return \hexdec($value); |
346 | 346 | case \preg_match('/^[+-]?[0-9]+(\.[0-9]+)?$/', $value): |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | return 'true'; |
372 | 372 | case false === $value: |
373 | 373 | return 'false'; |
374 | - case isset($value[1]) && '0b' == $value[0] . $value[1] && \preg_match('/^0b[01]*$/', (string) $value): |
|
374 | + case isset($value[1]) && '0b' == $value[0].$value[1] && \preg_match('/^0b[01]*$/', (string) $value): |
|
375 | 375 | return (string) \bindec($value); |
376 | 376 | case \preg_match('/^0x[0-9a-f]++$/i', (string) $value): |
377 | 377 | return \hexdec($value); |
@@ -81,59 +81,59 @@ |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
84 | - * Resolves missing argument using autowiring. |
|
84 | + * Resolves missing argument using autowiring. |
|
85 | 85 | * @param ReflectionParameter $parameter |
86 | - * @param (callable(string $type, bool $single): object|object[]|null) $getter |
|
86 | + * @param (callable(string $type, bool $single): object|object[]|null) $getter |
|
87 | 87 | * |
88 | - * @throws ServiceCreationException |
|
88 | + * @throws ServiceCreationException |
|
89 | 89 | * |
90 | - * @return mixed |
|
91 | - */ |
|
92 | - private static function autowireArgument(ReflectionParameter $parameter, callable $getter) |
|
93 | - { |
|
94 | - $type = Reflection::getParameterType($parameter); |
|
95 | - $method = $parameter->getDeclaringFunction(); |
|
96 | - $desc = Reflection::toString($parameter); |
|
90 | + * @return mixed |
|
91 | + */ |
|
92 | + private static function autowireArgument(ReflectionParameter $parameter, callable $getter) |
|
93 | + { |
|
94 | + $type = Reflection::getParameterType($parameter); |
|
95 | + $method = $parameter->getDeclaringFunction(); |
|
96 | + $desc = Reflection::toString($parameter); |
|
97 | 97 | |
98 | - if ($type && !Reflection::isBuiltinType($type)) { |
|
99 | - try { |
|
100 | - $res = $getter($type, true); |
|
101 | - } catch (MissingServiceException $e) { |
|
102 | - $res = null; |
|
103 | - } catch (ServiceCreationException $e) { |
|
104 | - throw new ServiceCreationException("{$e->getMessage()} (needed by $desc)", 0, $e); |
|
105 | - } |
|
98 | + if ($type && !Reflection::isBuiltinType($type)) { |
|
99 | + try { |
|
100 | + $res = $getter($type, true); |
|
101 | + } catch (MissingServiceException $e) { |
|
102 | + $res = null; |
|
103 | + } catch (ServiceCreationException $e) { |
|
104 | + throw new ServiceCreationException("{$e->getMessage()} (needed by $desc)", 0, $e); |
|
105 | + } |
|
106 | 106 | |
107 | - if ($res !== null || $parameter->allowsNull()) { |
|
108 | - return $res; |
|
109 | - } elseif (class_exists($type) || interface_exists($type)) { |
|
110 | - throw new ServiceCreationException("Service of type $type needed by $desc not found. Did you add it to configuration file?"); |
|
111 | - } else { |
|
112 | - throw new ServiceCreationException("Class $type needed by $desc not found. Check type hint and 'use' statements."); |
|
113 | - } |
|
107 | + if ($res !== null || $parameter->allowsNull()) { |
|
108 | + return $res; |
|
109 | + } elseif (class_exists($type) || interface_exists($type)) { |
|
110 | + throw new ServiceCreationException("Service of type $type needed by $desc not found. Did you add it to configuration file?"); |
|
111 | + } else { |
|
112 | + throw new ServiceCreationException("Class $type needed by $desc not found. Check type hint and 'use' statements."); |
|
113 | + } |
|
114 | 114 | |
115 | - } elseif ( |
|
116 | - $method instanceof \ReflectionMethod |
|
117 | - && $type === 'array' |
|
118 | - && preg_match('#@param[ \t]+([\w\\\\]+)\[\][ \t]+\$' . $parameter->name . '#', (string) $method->getDocComment(), $m) |
|
119 | - && ($itemType = Reflection::expandClassName($m[1], $method->getDeclaringClass())) |
|
120 | - && (class_exists($itemType) || interface_exists($itemType)) |
|
121 | - ) { |
|
122 | - return $getter($itemType, false); |
|
115 | + } elseif ( |
|
116 | + $method instanceof \ReflectionMethod |
|
117 | + && $type === 'array' |
|
118 | + && preg_match('#@param[ \t]+([\w\\\\]+)\[\][ \t]+\$' . $parameter->name . '#', (string) $method->getDocComment(), $m) |
|
119 | + && ($itemType = Reflection::expandClassName($m[1], $method->getDeclaringClass())) |
|
120 | + && (class_exists($itemType) || interface_exists($itemType)) |
|
121 | + ) { |
|
122 | + return $getter($itemType, false); |
|
123 | 123 | |
124 | - } elseif ( |
|
125 | - ($type && $parameter->allowsNull()) |
|
126 | - || $parameter->isOptional() |
|
127 | - || $parameter->isDefaultValueAvailable() |
|
128 | - ) { |
|
129 | - // !optional + defaultAvailable = func($a = null, $b) since 5.4.7 |
|
130 | - // optional + !defaultAvailable = i.e. Exception::__construct, mysqli::mysqli, ... |
|
131 | - return $parameter->isDefaultValueAvailable() |
|
132 | - ? Reflection::getParameterDefaultValue($parameter) |
|
133 | - : null; |
|
124 | + } elseif ( |
|
125 | + ($type && $parameter->allowsNull()) |
|
126 | + || $parameter->isOptional() |
|
127 | + || $parameter->isDefaultValueAvailable() |
|
128 | + ) { |
|
129 | + // !optional + defaultAvailable = func($a = null, $b) since 5.4.7 |
|
130 | + // optional + !defaultAvailable = i.e. Exception::__construct, mysqli::mysqli, ... |
|
131 | + return $parameter->isDefaultValueAvailable() |
|
132 | + ? Reflection::getParameterDefaultValue($parameter) |
|
133 | + : null; |
|
134 | 134 | |
135 | - } else { |
|
136 | - throw new ServiceCreationException("Parameter $desc has no class type hint or default value, so its value must be specified."); |
|
137 | - } |
|
138 | - } |
|
135 | + } else { |
|
136 | + throw new ServiceCreationException("Parameter $desc has no class type hint or default value, so its value must be specified."); |
|
137 | + } |
|
138 | + } |
|
139 | 139 | } |
@@ -115,7 +115,7 @@ |
||
115 | 115 | } elseif ( |
116 | 116 | $method instanceof \ReflectionMethod |
117 | 117 | && $type === 'array' |
118 | - && preg_match('#@param[ \t]+([\w\\\\]+)\[\][ \t]+\$' . $parameter->name . '#', (string) $method->getDocComment(), $m) |
|
118 | + && preg_match('#@param[ \t]+([\w\\\\]+)\[\][ \t]+\$'.$parameter->name.'#', (string) $method->getDocComment(), $m) |
|
119 | 119 | && ($itemType = Reflection::expandClassName($m[1], $method->getDeclaringClass())) |
120 | 120 | && (class_exists($itemType) || interface_exists($itemType)) |
121 | 121 | ) { |