8000 only allow ReflectionNamedType's for ServiceSubscriberTrait · symfony/symfony@fdb2c43 · GitHub
[go: up one dir, main page]

Skip to content

Commit fdb2c43

Browse files
committed
only allow ReflectionNamedType's for ServiceSubscriberTrait
1 parent 1cb6934 commit fdb2c43

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Symfony/Contracts/Service/ServiceSubscriberTrait.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,19 @@ public static function getSubscribedServices(): array
4242
continue;
4343
}
4444

45-
if (self::class === $method->getDeclaringClass()->name && ($returnType = $method->getReturnType()) && !$returnType->isBuiltin()) {
46-
$services[self::class.'::'.$method->name] = '?'.($returnType instanceof \ReflectionNamedType ? $returnType->getName() : $returnType);
45+
if (self::class !== $method->getDeclaringClass()->name) {
46+
continue;
47+
}
48+
49+
if (!($returnType = $method->getReturnType()) instanceof \ReflectionNamedType) {
50+
continue;
4751
}
52+
53+
if ($returnType->isBuiltin()) {
54+
continue;
55+
}
56+
57+
$services[self::class.'::'.$method->name] = '?'.$returnType->getName();
4858
}
4959

5060
return $services;

0 commit comments

Comments
 (0)
0