Review the proposed patch then download it to apply it manually or execute the following command from the repository root directory:
curl https://fabbot.io/patch/symfony/ux/2654/d043cc2661cf7e6ccb31b24d7400f2b7b772b333/cs.diff | patch -p0
diff -ru src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php
--- src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php 2025-03-26 04:50:53.243804637 +0000
+++ src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php 2025-03-26 04:50:59.883819363 +0000
@@ -981,7 +981,7 @@
return HydrationTest::create(new class {
/**
- * @var \Symfony\UX\LiveComponent\Tests\Fixtures\Dto\Address[]
+ * @var Address[]
*/
#[LiveProp(writable: true, useSerializerForHydration: true)]
public array $addresses = [];
@@ -1012,7 +1012,7 @@
return HydrationTest::create(new class {
/**
- * @var \Symfony\UX\LiveComponent\Tests\Fixtures\Dto\Address[]
+ * @var Address[]
*/
#[LiveProp(writable: true, useSerializerForHydration: true)]
public array $addresses = [];
@@ -1040,7 +1040,7 @@
yield 'Array with DTOs: fully writable allows deep partial changes' => [function () {
return HydrationTest::create(new class {
/**
- * @var \Symfony\UX\LiveComponent\Tests\Fixtures\Dto\HoldsArrayOfDtos[] $dtos
+ * @var HoldsArrayOfDtos[] $dtos
*/
#[LiveProp(writable: true, useSerializerForHydration: true)]
public array $dtos = [];
@@ -1160,7 +1160,7 @@
yield 'Collection: using serializer (de)hydrates correctly' => [function () {
return HydrationTest::create(new class {
- /** @var \Symfony\UX\LiveComponent\Tests\Fixtures\Dto\Temperature[] */
+ /** @var Temperature[] */
#[LiveProp(useSerializerForHydration: true)]
public array $temperatures = [];
Review the proposed patch then download it to apply it manually or execute the following command from the repository root directory:
curl https://fabbot.io/patch/symfony/ux/2654/d043cc2661cf7e6ccb31b24d7400f2b7b772b333/exception_messages.diff | patch -p0
diff -ru src/LiveComponent/src/LiveComponentHydrator.php src/LiveComponent/src/LiveComponentHydrator.php
--- src/LiveComponent/src/LiveComponentHydrator.php 2025-03-26 04:50:53.037804180 +0000
+++ src/LiveComponent/src/LiveComponentHydrator.php 2025-03-26 04:51:00.563820871 +0000
@@ -105,7 +105,7 @@
} catch (NoSuchPropertyException $e) {
throw new \LogicException(\sprintf('The writable path "%s" does not exist on the "%s" property of the "%s" component.', $path, $propertyName, $component::class), 0, $e);
} catch (PropertyAccessExceptionInterface $e) {
- throw new \LogicException(\sprintf('The writable path "%s" on the "%s" property of the "%s" component could not be read: %s', $path, $propertyName, $component::class, $e->getMessage()), 0, $e);
+ throw new \LogicException(\sprintf('The writable path "%s" on the "%s" property of the "%s" component could not be read: "%s"', $path, $propertyName, $component::class, $e->getMessage()), 0, $e);
}
// TODO: maybe we allow support the same types as LiveProps later
@@ -188,7 +188,7 @@
*/
if ($dehydratedUpdatedProps->hasPropValue($frontendName)) {
if (!$propMetadata->isIdentityWritable()) {
- throw new HydrationException(\sprintf('The model "%s" was sent for update, but it is not writable. Try adding "writable: true" to the $%s property in %s.', $frontendName, $propMetadata->getName(), $component::class));
+ throw new HydrationException(\sprintf('The model "%s" was sent for update, but it is not writable. Try adding "writable: true" to the $%s property in "%s".', $frontendName, $propMetadata->getName(), $component::class));
}
try {
$propertyValue = $this->hydrateValue(
@@ -359,7 +359,7 @@
private function verifyChecksum(array $identifierPops, string $error = 'Invalid checksum sent when updating the live component.'): void
{
if (!\array_key_exists(self::CHECKSUM_KEY, $identifierPops)) {
- throw new HydrationException(\sprintf('Missing %s. key', self::CHECKSUM_KEY));
+ throw new HydrationException(\sprintf('Missing "%s". key', self::CHECKSUM_KEY));
}
$sentChecksum = $identifierPops[self::CHECKSUM_KEY];
unset($identifierPops[self::CHECKSUM_KEY]);
@@ -468,7 +468,7 @@
$collectionClass = $propMetadata->collectionValueType()->getClassName();
foreach ($value as $key => $objectItem) {
if (!$objectItem instanceof $collectionClass) {
- throw new \LogicException(\sprintf('The LiveProp "%s" on component "%s" is an array. We determined the array is full of %s objects, but at least one key had a different value of %s', $propMetadata->getName(), $parentObject::class, $collectionClass, get_debug_type($objectItem)));
+ throw new \LogicException(\sprintf('The LiveProp "%s" on component "%s" is an array. We determined the array is full of "%s" objects, but at least one key had a different value of "%s"', $propMetadata->getName(), $parentObject::class, $collectionClass, get_debug_type($objectItem)));
}
$value[$key] = $this->dehydrateObjectValue($objectItem, $collectionClass, $propMetadata->getFormat(), $parentObject);
@@ -629,7 +629,7 @@
if (\count($extraSentWritablePaths) > 0) {
// we could show multiple fields here in the message
- throw new HydrationException(\sprintf('The model "%s.%s" was sent for update, but it is not writable. Try adding "writable: [\'%s\']" to the $%s property in %s.', $frontendPropName, $extraSentWritablePaths[0], $extraSentWritablePaths[0], $propMetadata->getName(), $componentClass));
+ throw new HydrationException(\sprintf('The model "%s.%s" was sent for update, but it is not writable. Try adding "writable: [\'%s\']" to the $%s property in "%s".', $frontendPropName, $extraSentWritablePaths[0], $extraSentWritablePaths[0], $propMetadata->getName(), $componentClass));
}
return $writablePaths;