Added class existence check if is_subclass_of() fails in compiler passes
This commit is contained in:
parent
1f2d6fb590
commit
72db6e7068
@ -97,9 +97,13 @@ class RegisterListenersPass implements CompilerPassInterface
|
|||||||
|
|
||||||
// We must assume that the class value has been correctly filled, even if the service is created by a factory
|
// We must assume that the class value has been correctly filled, even if the service is created by a factory
|
||||||
$class = $container->getParameterBag()->resolveValue($def->getClass());
|
$class = $container->getParameterBag()->resolveValue($def->getClass());
|
||||||
|
|
||||||
$interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface';
|
$interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface';
|
||||||
|
|
||||||
if (!is_subclass_of($class, $interface)) {
|
if (!is_subclass_of($class, $interface)) {
|
||||||
|
if (!class_exists($class, false)) {
|
||||||
|
throw new \InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
|
||||||
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
|
throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,12 @@ class FragmentRendererPass implements CompilerPassInterface
|
|||||||
|
|
||||||
$class = $container->getParameterBag()->resolveValue($def->getClass());
|
$class = $container->getParameterBag()->resolveValue($def->getClass());
|
||||||
$interface = 'Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface';
|
$interface = 'Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface';
|
||||||
|
|
||||||
if (!is_subclass_of($class, $interface)) {
|
if (!is_subclass_of($class, $interface)) {
|
||||||
|
if (!class_exists($class, false)) {
|
||||||
|
throw new \InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
|
||||||
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
|
throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user