Skip to content

Commit 881c643

Browse files
committed
Let serializer handle too generic types
1 parent b3d305b commit 881c643

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/LiveComponent/src/LiveComponentHydrator.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,12 @@ public function hydrateValue(mixed $value, LivePropMetadata $propMetadata, objec
256256
throw new \LogicException(sprintf('The LiveProp "%s" on component "%s" has "useSerializerForHydration: true", but the given serializer does not implement DenormalizerInterface.', $propMetadata->getName(), $parentObject::class));
257257
}
258258

259-
$type = null;
260259
if ($propMetadata->collectionValueType()) {
261260
$builtInType = $propMetadata->collectionValueType()->getBuiltinType();
262261
if (Type::BUILTIN_TYPE_OBJECT === $builtInType) {
263-
$type = $propMetadata->collectionValueType()->getClassName();
264-
} elseif (\in_array($builtInType, ['string', 'int', 'float', 'bool'])) {
265-
$type = $builtInType;
262+
$type = $propMetadata->collectionValueType()->getClassName().'[]';
263+
} else {
264+
$type = $builtInType.'[]';
266265
}
267266
} else {
268267
$type = $propMetadata->getType();
@@ -272,10 +271,6 @@ public function hydrateValue(mixed $value, LivePropMetadata $propMetadata, objec
272271
throw new \LogicException(sprintf('The "%s::%s" object should be hydrated with the Serializer, but no type could be guessed.', $parentObject::class, $propMetadata->getName()));
273272
}
274273

275-
if ($propMetadata->collectionValueType()) {
276-
$type .= '[]';
277-
}
278-
279274
return $this->serializer->denormalize($value, $type, 'json', $propMetadata->serializationContext());
280275
}
281276

0 commit comments

Comments
 (0)