Skip to content

Commit

Permalink
Added class existence check if is_subclass_of() fails in compiler passes
Browse files Browse the repository at this point in the history
  • Loading branch information
SCIF committed Jul 18, 2016
1 parent 1f2d6fb commit 72db6e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Expand Up @@ -97,9 +97,13 @@ public function process(ContainerBuilder $container)

// 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());

$interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface';

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));
}

Expand Down
Expand Up @@ -54,7 +54,12 @@ public function process(ContainerBuilder $container)

$class = $container->getParameterBag()->resolveValue($def->getClass());
$interface = 'Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface';

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));
}

Expand Down

0 comments on commit 72db6e7

Please sign in to comment.