Closed
Description
My model is a Product
which has a typed discount
property of type DiscountInterface
:
namespace App\Model;
class Product
{
public ?DiscountInterface $discount = null;
}
I'musing Product
as a LiveProp
(it doesn't matter how I use it or where, keep reading).
During the de/hydration process, a warning is raised:
Warning: foreach() argument must be of type array|object, null given.
in vendor/symfony/ux-live-component/src/LiveComponentHydrator.php (line 490)
Investigating more, around the dehydrateObjectValue
of LiveComponentHydrator
:
- The passed
$value
is the instance ofApp\Model\StackableDiscount
- The
$classType
isDiscountInterface
- The
getProperties
onPropertyInfoExtractor
returnsnull
(hence theforeach
warning)
I think this is a bug but I don't know how to fix it. Logically, we can't get properties from an interface. $classType
is cleary wrong here.
Maybe:
if (is_subclass_of($value, $classType, true)) {
$classType = get_class($value);
}
Metadata
Metadata
Assignees
Labels
No labels