Closed
Description
While working on #2824, I created a live component with many #[LiveProp]
:
#[AsLiveComponent]
final class TonsOfLiveProp
{
use DefaultActionTrait;
#[LiveProp]
public ?string $description = null;
}
Given the following code:
if ($type instanceof UnionType && !$type instanceof NullableType || $type instanceof IntersectionType) {
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".', $propertyName, $className));
}
It can not works because NullableType
has been introduced in TypeInfo 7.2, !$type instanceof NullableType
fails because the class NullableType
does not exist, and it throws the exception.
As a workaround, I believe we can use replace !$type instanceof NullableType
by !$type->isNullable()
.
I'm wondering why the CI didn't catch the issue, we have a nullable-string LiveProp in our fixtures... 🤔
cc @mtarld