Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 33dd1c6

Browse files
committed
Added class existence check if is_subclass_of() fails in compiler passes
1 parent 1f2d6fb commit 33dd1c6

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,15 @@ public function process(ContainerBuilder $container)
9797

9898
// We must assume that the class value has been correctly filled, even if the service is created by a factory
9999
$class = $container->getParameterBag()->resolveValue($def->getClass());
100-
101100
$interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface';
101+
102102
if (!is_subclass_of($class, $interface)) {
103+
if (!class_exists($class, true)) {
104+
throw new \RuntimeException(
105+
sprintf('Class "%s" from definition of service "%s" can not be found. Check existence of file and correct naming', $class, $id)
106+
);
107+
}
108+
103109
throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
104110
}
105111

src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ public function process(ContainerBuilder $container)
5454

5555
$class = $container->getParameterBag()->resolveValue($def->getClass());
5656
$interface = 'Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface';
57+
5758
if (!is_subclass_of($class, $interface)) {
59+
if (!class_exists($class, true)) {
60+
throw new \RuntimeException(
61+
sprintf('Class "%s" from definition of service "%s" can not be found. Check existence of file and correct naming', $class, $id)
62+
);
63+
}
64+
5865
throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
5966
}
6067

0 commit comments

Comments
 (0)