Skip to content

Commit 74b6ad3

Browse files
bug #25976 [Config] Handle Service/EventSubscriberInterface in ReflectionClassResource (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [Config] Handle Service/EventSubscriberInterface in ReflectionClassResource | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #25906 | License | MIT | Doc PR | - @weaverryan that should fix an issue you reported. Commits ------- 67e821b [Config] Handle Service/EventSubscriberInterface in ReflectionClassResource
2 parents 4b3926a + e32f1b3 commit 74b6ad3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Compiler/RegisterServiceSubscribersPass.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ protected function processValue($value, $isRoot = false)
5656
}
5757
$class = $value->getClass();
5858

59-
if (!is_subclass_of($class, ServiceSubscriberInterface::class)) {
60-
if (!class_exists($class, false)) {
61-
throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $this->currentId));
62-
}
63-
59+
if (!$r = $this->container->getReflectionClass($class)) {
60+
throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $this->currentId));
61+
}
62+
if (!$r->isSubclassOf(ServiceSubscriberInterface::class)) {
6463
throw new InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $this->currentId, ServiceSubscriberInterface::class));
6564
}
66-
$this->container->addObjectResource($class);
65+
$class = $r->name;
66+
6767
$subscriberMap = array();
6868
$declaringClass = (new \ReflectionMethod($class, 'getSubscribedServices'))->class;
6969

0 commit comments

Comments
 (0)