Passed
Push — master ( 019dde...157966 )
by Divine Niiquaye
07:53 queued 05:56
created
src/Definitions/InterfaceDefinition.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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;');
Please login to merge, or discard this patch.
src/Container.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         ));
Please login to merge, or discard this patch.
src/ContainerPanel.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Exceptions/ParameterNotFoundException.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -69,10 +69,10 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Resolver.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -81,59 +81,59 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@
 block discarded – undo
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
 		) {
Please login to merge, or discard this patch.
src/Adapters/XmlAdapter.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
225 225
             $writer->startElement('container');
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/PhpGenerator.php 5 patches
Indentation   -24 removed lines patch added patch discarded remove patch
@@ -58,27 +58,3 @@
 block discarded – undo
58 58
     {
59 59
         $class->setExtends(Container::class);
60 60
         $class->setComment(<<<'COMMENT'
61
-
62
-Main DependencyInjection Container. This class has been auto-generated
63
-by the Nette Dependency Injection Component.
64
-
65
-Automatically detects if "container" property are presented in class or uses
66
-global container as fallback.
67
-COMMENT);
68
-
69
-        return parent::toString($class);
70
-    }
71
-
72
-    public function generateMethod(Definitions\Definition $def): Nette\PhpGenerator\Method
73
-    {
74
-        $method   = parent::generateMethod($def);
75
-        $name     = $def->getName();
76
-        $comment  = 'This service can be accessed by it\'s name in lower case,';
77
-        $comment2 = "thus `%s`, using container get or make methods.\n\n@return %s";
78
-
79
-        $method->setProtected();
80
-        $method->setComment(\sprintf($comment . "\n" . $comment2, $name, $def->getType()));
81
-
82
-        return $method;
83
-    }
84
-}
Please login to merge, or discard this patch.
Switch Indentation   -24 removed lines patch added patch discarded remove patch
@@ -58,27 +58,3 @@
 block discarded – undo
58 58
     {
59 59
         $class->setExtends(Container::class);
60 60
         $class->setComment(<<<'COMMENT'
61
-
62
-Main DependencyInjection Container. This class has been auto-generated
63
-by the Nette Dependency Injection Component.
64
-
65
-Automatically detects if "container" property are presented in class or uses
66
-global container as fallback.
67
-COMMENT);
68
-
69
-        return parent::toString($class);
70
-    }
71
-
72
-    public function generateMethod(Definitions\Definition $def): Nette\PhpGenerator\Method
73
-    {
74
-        $method   = parent::generateMethod($def);
75
-        $name     = $def->getName();
76
-        $comment  = 'This service can be accessed by it\'s name in lower case,';
77
-        $comment2 = "thus `%s`, using container get or make methods.\n\n@return %s";
78
-
79
-        $method->setProtected();
80
-        $method->setComment(\sprintf($comment . "\n" . $comment2, $name, $def->getType()));
81
-
82
-        return $method;
83
-    }
84
-}
Please login to merge, or discard this patch.
Spacing   -24 removed lines patch added patch discarded remove patch
@@ -58,27 +58,3 @@
 block discarded – undo
58 58
     {
59 59
         $class->setExtends(Container::class);
60 60
         $class->setComment(<<<'COMMENT'
61
-
62
-Main DependencyInjection Container. This class has been auto-generated
63
-by the Nette Dependency Injection Component.
64
-
65
-Automatically detects if "container" property are presented in class or uses
66
-global container as fallback.
67
-COMMENT);
68
-
69
-        return parent::toString($class);
70
-    }
71
-
72
-    public function generateMethod(Definitions\Definition $def): Nette\PhpGenerator\Method
73
-    {
74
-        $method   = parent::generateMethod($def);
75
-        $name     = $def->getName();
76
-        $comment  = 'This service can be accessed by it\'s name in lower case,';
77
-        $comment2 = "thus `%s`, using container get or make methods.\n\n@return %s";
78
-
79
-        $method->setProtected();
80
-        $method->setComment(\sprintf($comment . "\n" . $comment2, $name, $def->getType()));
81
-
82
-        return $method;
83
-    }
84
-}
Please login to merge, or discard this patch.
Braces   -24 removed lines patch added patch discarded remove patch
@@ -58,27 +58,3 @@
 block discarded – undo
58 58
     {
59 59
         $class->setExtends(Container::class);
60 60
         $class->setComment(<<<'COMMENT'
61
-
62
-Main DependencyInjection Container. This class has been auto-generated
63
-by the Nette Dependency Injection Component.
64
-
65
-Automatically detects if "container" property are presented in class or uses
66
-global container as fallback.
67
-COMMENT);
68
-
69
-        return parent::toString($class);
70
-    }
71
-
72
-    public function generateMethod(Definitions\Definition $def): Nette\PhpGenerator\Method
73
-    {
74
-        $method   = parent::generateMethod($def);
75
-        $name     = $def->getName();
76
-        $comment  = 'This service can be accessed by it\'s name in lower case,';
77
-        $comment2 = "thus `%s`, using container get or make methods.\n\n@return %s";
78
-
79
-        $method->setProtected();
80
-        $method->setComment(\sprintf($comment . "\n" . $comment2, $name, $def->getType()));
81
-
82
-        return $method;
83
-    }
84
-}
Please login to merge, or discard this patch.
Upper-Lower-Casing   -24 removed lines patch added patch discarded remove patch
@@ -58,27 +58,3 @@
 block discarded – undo
58 58
     {
59 59
         $class->setExtends(Container::class);
60 60
         $class->setComment(<<<'COMMENT'
61
-
62
-Main DependencyInjection Container. This class has been auto-generated
63
-by the Nette Dependency Injection Component.
64
-
65
-Automatically detects if "container" property are presented in class or uses
66
-global container as fallback.
67
-COMMENT);
68
-
69
-        return parent::toString($class);
70
-    }
71
-
72
-    public function generateMethod(Definitions\Definition $def): Nette\PhpGenerator\Method
73
-    {
74
-        $method   = parent::generateMethod($def);
75
-        $name     = $def->getName();
76
-        $comment  = 'This service can be accessed by it\'s name in lower case,';
77
-        $comment2 = "thus `%s`, using container get or make methods.\n\n@return %s";
78
-
79
-        $method->setProtected();
80
-        $method->setComment(\sprintf($comment . "\n" . $comment2, $name, $def->getType()));
81
-
82
-        return $method;
83
-    }
84
-}
Please login to merge, or discard this patch.