Skip to content

Commit 9fc90d4

Browse files
committed
bug #856 [LiveComponent] Throw clear error when using union types for LiveProps (Bart Vanderstukken)
This PR was merged into the 2.x branch. Discussion ---------- [LiveComponent] Throw clear error when using union types for LiveProps | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Tickets | Fix #853 | License | MIT As mentioned in #853 (comment), supporting union types for LiveProps will be quite tricky. Given that, at least a clear error should be thrown. Commits ------- af27571 Throw error when using union types for LiveProps
2 parents a0221d9 + af27571 commit 9fc90d4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/LiveComponent/src/Metadata/LiveComponentMetadataFactory.php

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

7373
$type = $property->getType();
74+
if ($type instanceof \ReflectionUnionType || $type instanceof \ReflectionIntersectionType) {
75+
throw new \LogicException(sprintf('Union or intersection types are not supported for LiveProps. You may want to change the type of property %s in %s.', $property->getName(), $property->getDeclaringClass()->getName()));
76+
}
7477
$metadatas[$property->getName()] = new LivePropMetadata(
7578
$property->getName(),
7679
$attribute->newInstance(),

0 commit comments

Comments
 (0)