You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if ($constructor = $reflectionClass->getConstructor()) {
@@ -89,7 +92,7 @@ protected function processValue($value, $isRoot = false)
89
92
thrownewRuntimeException(sprintf('Cannot autowire service "%s": class %s has no constructor but arguments are defined.', $this->currentId, $reflectionClass->name, $method));
if (array_key_exists($index, $arguments) && '' !== $arguments[$index]) {
217
221
continue;
218
222
}
223
+
if (method_exists($parameter, 'isVariadic') && $parameter->isVariadic()) {
224
+
continue;
225
+
}
219
226
220
227
if (method_exists($parameter, 'getType')) {
221
228
if ($typeName = $parameter->getType()) {
@@ -228,7 +235,7 @@ private function autowireMethodCall(\ReflectionMethod $reflectionMethod, array $
228
235
if (!$typeName) {
229
236
// no default value? Then fail
230
237
if (!$parameter->isOptional()) {
231
-
if ($mustAutowire) {
238
+
if (self::MODE_REQUIRED === $mode) {
232
239
thrownewRuntimeException(sprintf('Cannot autowire service "%s": argument $%s of method %s::%s() must have a type-hint or be given a value explicitly.', $this->currentId, $parameter->name, $reflectionMethod->class, $reflectionMethod->name));
233
240
}
234
241
@@ -268,7 +275,7 @@ private function autowireMethodCall(\ReflectionMethod $reflectionMethod, array $
268
275
$value = $parameter->getDefaultValue();
269
276
} else {
270
277
// The exception code is set to 1 if the exception must be thrown even if it's an optional setter
271
-
if (1 === $e->getCode() || $mustAutowire) {
278
+
if (1 === $e->getCode() || self::MODE_REQUIRED === $mode) {
272
279
throw$e;
273
280
}
274
281
@@ -279,7 +286,7 @@ private function autowireMethodCall(\ReflectionMethod $reflectionMethod, array $
279
286
// Typehint against a non-existing class
280
287
281
288
if (!$parameter->isDefaultValueAvailable()) {
282
-
if ($mustAutowire) {
289
+
if (self::MODE_REQUIRED === $mode) {
283
290
thrownewRuntimeException(sprintf('Cannot autowire argument $%s of method %s::%s() for service "%s": Class %s does not exist.', $parameter->name, $reflectionMethod->class, $reflectionMethod->name, $this->currentId, $typeName));
284
291
}
285
292
@@ -292,7 +299,7 @@ private function autowireMethodCall(\ReflectionMethod $reflectionMethod, array $
292
299
$arguments[$index] = $value;
293
300
}
294
301
295
-
if (!$mustAutowire && !$didAutowire) {
302
+
if (self::MODE_REQUIRED !== $mode && !$didAutowire) {
296
303
returnarray();
297
304
}
298
305
@@ -313,8 +320,8 @@ private function autowireMethodCall(\ReflectionMethod $reflectionMethod, array $
thrownewRuntimeException(sprintf('Unable to configure getter injection for service "%s": method "%s::%s" does not exist.', $id, $class->name, $name));
1335
-
}
F438
1336
-
$r = $class->getMethod($name);
1337
-
if ($r->isPrivate()) {
1338
-
thrownewRuntimeException(sprintf('Unable to configure getter injection for service "%s": method "%s::%s" must be public or protected.', $id, $class->name, $r->name));
1339
-
}
1340
-
if ($r->isStatic()) {
1341
-
thrownewRuntimeException(sprintf('Unable to configure getter injection for service "%s": method "%s::%s" cannot be static.', $id, $class->name, $r->name));
1342
-
}
1343
-
if ($r->isFinal()) {
1344
-
thrownewRuntimeException(sprintf('Unable to configure getter injection for service "%s": method "%s::%s" cannot be marked as final.', $id, $class->name, $r->name));
1345
-
}
1346
-
if ($r->returnsReference()) {
1347
-
thrownewRuntimeException(sprintf('Unable to configure getter injection for service "%s": method "%s::%s" cannot return by reference.', $id, $class->name, $r->name));
1348
-
}
1349
-
if (0 < $r->getNumberOfParameters()) {
1350
-
thrownewRuntimeException(sprintf('Unable to configure getter injection for service "%s": method "%s::%s" cannot have any arguments.', $id, $class->name, $r->name));
1351
-
}
1352
-
if ($type = method_exists($r, 'getReturnType') ? $r->getReturnType() : null) {
0 commit comments