Skip to content

Commit 22a5f2a

Browse files
author
Bart Vanderstukken
committed
Throw error when using union types for LiveProps
1 parent 8119f8f commit 22a5f2a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/LiveComponent/src/Metadata/LiveComponentMetadataFactory.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ public function createPropMetadatas(\ReflectionClass $class): array
7171
}
7272

7373
$type = $property->getType();
74+
if ($type instanceof \ReflectionUnionType) {
75+
throw new \LogicException(
76+
sprintf(
77+
'Union types are not supported for LiveProps. You may want to change the type of property %s in %s.',
78+
$property->getName(),
79+
$property->getDeclaringClass()->getName()
80+
)
81+
);
82+
}
7483
$metadatas[$property->getName()] = new LivePropMetadata(
7584
$property->getName(),
7685
$attribute->newInstance(),

0 commit comments

Comments
 (0)