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 (isset($tag['bus']) && !\in_array($tag['bus'], $busIds, true)) {
79
-
thrownewRuntimeException(sprintf('Invalid handler service "%s": bus "%s" specified on the tag "%s" does not exist (known ones are: %s).', $serviceId, $tag['bus'], $this->handlerTag, implode(', ', $busIds)));
82
+
thrownewRuntimeException(sprintf(
83
+
'Invalid handler service "%s": bus "%s" specified on the tag "%s" does not exist (known ones are: %s).',
@@ -106,9 +120,20 @@ private function registerHandlers(ContainerBuilder $container, array $busIds)
106
120
if (\is_array($method)) {
107
121
if (isset($method['bus'])) {
108
122
if (!\in_array($method['bus'], $busIds)) {
109
-
$messageLocation = isset($tag['handles']) ? 'declared in your tag attribute "handles"' : $r->implementsInterface(MessageSubscriberInterface::class) ? sprintf('returned by method "%s::getHandledMessages()"', $r->getName()) : sprintf('used as argument type in method "%s::%s()"', $r->getName(), $method);
110
-
111
-
thrownewRuntimeException(sprintf('Invalid configuration %s for message "%s": bus "%s" does not exist.', $messageLocation, $message, $method['bus']));
? sprintf('returned by method "%s::getHandledMessages()"', $classReflector->getName())
128
+
: sprintf('used as argument type in method "%s::%s()"', $classReflector->getName(), $method)
129
+
);
130
+
131
+
thrownewRuntimeException(sprintf(
132
+
'Invalid configuration %s for message "%s": bus "%s" does not exist.',
133
+
$messageLocation,
134
+
$message,
135
+
$method['bus']
136
+
));
112
137
}
113
138
114
139
$buses = array($method['bus']);
@@ -119,19 +144,36 @@ private function registerHandlers(ContainerBuilder $container, array $busIds)
119
144
}
120
145
121
146
if ('*' !== $message && !class_exists($message) && !interface_exists($message, false)) {
122
-
$messageLocation = isset($tag['handles']) ? 'declared in your tag attribute "handles"' : $r->implementsInterface(MessageSubscriberInterface::class) ? sprintf('returned by method "%s::getHandledMessages()"', $r->getName()) : sprintf('used as argument type in method "%s::%s()"', $r->getName(), $method);
123
-
124
-
thrownewRuntimeException(sprintf('Invalid handler service "%s": class or interface "%s" %s not found.', $serviceId, $message, $messageLocation));
@@ -142,7 +184,11 @@ private function registerHandlers(ContainerBuilder $container, array $busIds)
142
184
}
143
185
144
186
if (null === $message) {
145
-
thrownewRuntimeException(sprintf('Invalid handler service "%s": method "%s::getHandledMessages()" must return one or more messages.', $serviceId, $r->getName()));
187
+
thrownewRuntimeException(sprintf(
188
+
'Invalid handler service "%s": method "%s::getHandledMessages()" must return one or more messages.',
189
+
$serviceId,
190
+
$classReflector->getName()
191
+
));
146
192
}
147
193
}
148
194
}
@@ -198,20 +244,39 @@ private function guessHandledClasses(\ReflectionClass $handlerClass, string $ser
198
244
try {
199
245
$method = $handlerClass->getMethod('__invoke');
200
246
} catch (\ReflectionException$e) {
201
-
thrownewRuntimeException(sprintf('Invalid handler service "%s": class "%s" must have an "__invoke()" method.', $serviceId, $handlerClass->getName()));
247
+
thrownewRuntimeException(sprintf(
248
+
'Invalid handler service "%s": class "%s" must have an "__invoke()" method.',
249
+
$serviceId,
250
+
$handlerClass->getName()
251
+
));
202
252
}
203
253
204
254
$parameters = $method->getParameters();
205
255
if (1 !== \count($parameters)) {
206
-
thrownewRuntimeException(sprintf('Invalid handler service "%s": method "%s::__invoke()" must have exactly one argument corresponding to the message it handles.', $serviceId, $handlerClass->getName()));
256
+
thrownewRuntimeException(sprintf(
257
+
'Invalid handler service "%s": method "%s::__invoke()" must have exactly one argument corresponding to the message it handles.',
258
+
$serviceId,
259
+
$handlerClass->getName()
260
+
));
207
261
}
208
262
209
263
if (!$type = $parameters[0]->getType()) {
210
-
thrownewRuntimeException(sprintf('Invalid handler service "%s": argument "$%s" of method "%s::__invoke()" must have a type-hint corresponding to the message class it handles.', $serviceId, $parameters[0]->getName(), $handlerClass->getName()));
264
+
thrownewRuntimeException(sprintf(
265
+
'Invalid handler service "%s": argument "$%s" of method "%s::__invoke()" must have a type-hint corresponding to the message class it handles.',
266
+
$serviceId,
267
+
$parameters[0]->getName(),
268
+
$handlerClass->getName()
269
+
));
211
270
}
212
271
213
272
if ($type->isBuiltin()) {
214
-
thrownewRuntimeException(sprintf('Invalid handler service "%s": type-hint of argument "$%s" in method "%s::__invoke()" must be a class , "%s" given.', $serviceId, $parameters[0]->getName(), $handlerClass->getName(), $type));
273
+
thrownewRuntimeException(sprintf(
274
+
'Invalid handler service "%s": type-hint of argument "$%s" in method "%s::__invoke()" must be a class , "%s" given.',
275
+
$serviceId,
276
+
$parameters[0]->getName(),
277
+
$handlerClass->getName(),
278
+
$type
279
+
));
215
280
}
216
281
217
282
returnarray((string) $parameters[0]->getType());
@@ -224,7 +289,12 @@ private function registerReceivers(ContainerBuilder $container, array $busIds)
* @expectedExceptionMessage Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\HandlerMappingWithNonExistentMethod": method "Symfony\Component\Messenger\Tests\DependencyInjection\HandlerMappingWithNonExistentMethod::dummyMethod()" does not exist.
0 commit comments