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
thrownewRuntimeException(sprintf('Unable to autowire argument of type "%s" for the service "%s". Multiple services exist for this %s (%s).', $type, $id, $classOrInterface, $matchingServices));
56
+
thrownewRuntimeException(sprintf('Cannot autowire service "%s": multiple candidate services exist for %s "%s".%s', $id, $classOrInterface, $type, $this->createTypeAlternatives($type)));
57
57
}
58
58
} finally {
59
-
// Free memory
59
+
$this->container = null;
60
60
$this->definedTypes = array();
61
61
$this->types = null;
62
62
$this->ambiguousServiceTypes = array();
@@ -108,7 +108,12 @@ protected function processValue($value, $isRoot = false)
108
108
$this->currentDefinition = $value;
109
109
110
110
try {
111
-
if (!$value->isAutowired() || !$reflectionClass = $this->container->getReflectionClass($value->getClass())) {
111
+
if (!$value->isAutowired() || $value->isAbstract() || !$value->getClass()) {
112
+
returnparent::processValue($value, $isRoot);
113
+
}
114
+
if (!$reflectionClass = $this->container->getReflectionClass($value->getClass())) {
115
+
$this->container->log($this, sprintf('Skipping service "%s": Class or interface "%s" does not exist.', $this->currentId, $value->getClass()));
116
+
112
117
returnparent::processValue($value, $isRoot);
113
118
}
114
119
@@ -117,8 +122,6 @@ protected function processValue($value, $isRoot = false)
117
122
118
123
if ($constructor = $reflectionClass->getConstructor()) {
thrownewRuntimeException(sprintf('Cannot autowire service "%s": class %s has no constructor but arguments are defined.', $this->currentId, $reflectionClass->name));
thrownewRuntimeException(sprintf('Cannot autowire service "%s": method %s::%s() must be public.', $this->currentId, $reflectionClass->name, $method));
214
+
$class = $reflectionClass->name;
215
+
thrownewRuntimeException(sprintf('Cannot autowire service "%s": method %s() must be public.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
211
216
}
212
217
}
213
218
@@ -222,10 +227,13 @@ private function autowireCalls(\ReflectionClass $reflectionClass, array $methodC
222
227
if (!$reflectionMethod->getNumberOfParameters()) {
223
228
continue; // skip getters
224
229
}
230
+
$method = $reflectionMethod->name;
231
+
225
232
if (!$reflectionMethod->isPublic()) {
226
-
thrownewRuntimeException(sprintf('Cannot autowire service "%s": method %s::%s() must be public.', $this->currentId, $reflectionClass->name, $reflectionMethod->name));
233
+
$class = $reflectionClass->name;
234
+
thrownewRuntimeException(sprintf('Cannot autowire service "%s": method %s() must be public.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
if (!$isConstructor && !$arguments && !$reflectionMethod->getNumberOfRequiredParameters()) {
249
-
thrownewRuntimeException(sprintf('Cannot autowire service "%s": method %s::%s() has only optional arguments, thus must be wired explicitly.', $this->currentId, $reflectionMethod->class, $reflectionMethod->name));
259
+
thrownewRuntimeException(sprintf('Cannot autowire service "%s": method %s() has only optional arguments, thus must be wired explicitly.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
@@ -265,7 +275,7 @@ private function autowireMethod(\ReflectionMethod $reflectionMethod, array $argu
265
275
if (!$type) {
266
276
// no default value? Then fail
267
277
if (!$parameter->isOptional()) {
268
-
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));
278
+
thrownewRuntimeException(sprintf('Cannot autowire service "%s": argument $%s of method %s() must have a type-hint or be given a value explicitly.', $this->currentId, $parameter->name, $class !== $this->currentId ? $class.'::'.$method : $method));
269
279
}
270
280
271
281
if (!array_key_exists($index, $arguments)) {
@@ -279,7 +289,7 @@ private function autowireMethod(\ReflectionMethod $reflectionMethod, array $argu
279
289
if ($value = $this->getAutowiredReference($type)) {
280
290
$this->usedTypes[$type] = $this->currentId;
281
291
} else {
282
-
$failureMessage = $this->createTypeNotFoundMessage($type, 'argument $'.$parameter->name.' of method '.$reflectionMethod->class.'::'.$reflectionMethod->name.'()');
thrownewRuntimeException(sprintf('Cannot autowire service "%s": getter %s::%s() must%s have its return value be configured explicitly.', $this->currentId, $reflectionMethod->class, $reflectionMethod->name, $type ? '' : ' have a return-type hint or'));
334
+
thrownewRuntimeException(sprintf('Cannot autowire service "%s": getter %s() must%s have its return value be configured explicitly.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method, $type ? '' : ' have a return-type hint or'));
322
335
}
323
336
324
337
if (!$typeRef = $this->getAutowiredReference($type)) {
325
-
$this->container->log($this, $this->createTypeNotFoundMessage($type, 'return value of method '.$reflectionMethod->class.'::'.$reflectionMethod->name.'()'));
338
+
$this->container->log($this, $this->createTypeNotFoundMessage($type, sprintf('return value of method %s()', $class !== $this->currentId ? $class.'::'.$method : $method)));
326
339
continue;
327
340
}
328
341
@@ -446,15 +459,14 @@ private function set($type, $id)
thrownewRuntimeException(sprintf('Unable to autowire argument of type "%s" for the service "%s". Multiple services exist for this %s (%s).', $typeHint->name, $this->currentId, $classOrInterface, $matchingServices));
465
+
thrownewRuntimeException(sprintf('Cannot autowire service "%s": multiple candidate services exist for %s "%s".%s', $this->currentId, $classOrInterface, $type, $this->createTypeAlternatives($type)));
454
466
}
455
467
456
468
if (!$typeHint->isInstantiable()) {
457
-
$this->container->log($this, sprintf('Type "%s" is not instantiable thus cannot be auto-registered for service "%s".', $typeHint->name, $this->currentId));
469
+
$this->container->log($this, sprintf('Type "%s" is not instantiable thus cannot be auto-registered for service "%s".', $type, $this->currentId));
458
470
459
471
return;
460
472
}
@@ -463,8 +475,8 @@ private function createAutowiredDefinition(\ReflectionClass $typeHint)
0 commit comments