Skip to content

Commit d84504e

Browse files
committed
Only check return type against ReflectionNamedType
1 parent e2488d0 commit d84504e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/DataProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Webfox\InertiaDataProviders;
66

7+
use ReflectionNamedType;
78
use Illuminate\Contracts\Support\Arrayable;
89
use Inertia\LazyProp;
910
use ReflectionClass;
@@ -33,8 +34,9 @@ public function toArray(): array
3334
->filter(fn (ReflectionMethod $method) => ! $method->isStatic())
3435
->filter(fn (ReflectionMethod $method) => ! $method->isStatic() && ! in_array($method->name, ['toArray', '__construct']))
3536
->mapWithKeys(function (ReflectionMethod $method) {
37+
$returnType = $method->getReturnType();
3638
// @phpstan-ignore-next-line
37-
if ($method->getReturnType()?->getName() === LazyProp::class) {
39+
if ($returnType instanceof ReflectionNamedType && $returnType->getName() === LazyProp::class) {
3840
return [$method->name => $method->invoke($this)];
3941
}
4042

0 commit comments

Comments
 (0)