Skip to content

Commit f021b05

Browse files
committed
Fix ServiceMethodsSubscriberTrait for nullable service
1 parent 5ad3869 commit f021b05

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ServiceMethodsSubscriberTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static function getSubscribedServices(): array
5353
$attribute = $attribute->newInstance();
5454
$attribute->key ??= self::class.'::'.$method->name;
5555
$attribute->type ??= $returnType instanceof \ReflectionNamedType ? $returnType->getName() : (string) $returnType;
56-
$attribute->nullable = $returnType->allowsNull();
56+
$attribute->nullable = $attribute->nullable ?: $returnType->allowsNull();
5757

5858
if ($attribute->attributes) {
5959
$services[] = $attribute;

ServiceSubscriberTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static function getSubscribedServices(): array
5757
$attribute = $attribute->newInstance();
5858
$attribute->key ??= self::class.'::'.$method->name;
5959
$attribute->type ??= $returnType instanceof \ReflectionNamedType ? $returnType->getName() : (string) $returnType;
60-
$attribute->nullable = $returnType->allowsNull();
60+
$attribute->nullable = $attribute->nullable ?: $returnType->allowsNull();
6161

6262
if ($attribute->attributes) {
6363
$services[] = $attribute;

0 commit comments

Comments
 (0)