Passed
Push — master ( ed990b...cd5214 )
by Divine Niiquaye
07:33
created
src/Resolver.php 1 patch
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.
src/PhpGenerator.php 1 patch
Indentation   -26 removed lines patch added patch discarded remove patch
@@ -57,29 +57,3 @@
 block discarded – undo
57 57
     public function toString(Nette\PhpGenerator\ClassType $class): string
58 58
     {
59 59
         $class->setComment(<<<'COMMENT'
60
-/**
61
- * Main DependencyInjection Container. This class has been auto-generated
62
- * by the Nette Dependency Injection Component.
63
- *
64
- * Automatically detects if "container" property are presented in class or uses
65
- * global container as fallback.
66
- *
67
- */
68
-COMMENT);
69
-
70
-        return parent::toString($class);
71
-    }
72
-
73
-    public function generateMethod(Definitions\Definition $def): Nette\PhpGenerator\Method
74
-    {
75
-        $method   = parent::generateMethod($def);
76
-        $name     = $def->getName();
77
-        $comment  = 'This service can be accessed by it\'s name in lower case,';
78
-        $comment2 = "thus `%s`, using container get or make methods.\n\n@return %s";
79
-
80
-        $method->setProtected();
81
-        $method->setComment(\sprintf($comment . "\n" . $comment2, $name, $def->getType()));
82
-
83
-        return $method;
84
-    }
85
-}
Please login to merge, or discard this patch.