You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the cascade constraint on a class with a union typed property, the ClassMetadata will give an error: Attempted to call an undefined method named 'getName' of class 'ReflectionUnionType'.
This is caused by ClassMetadata#L201 since $property->getType() returns an ReflectionUnionType.
How to reproduce
<?phpnamespaceAcme;
useSymfony\Component\Validator\ConstraintsasAssert;
#[Assert\Cascade]
class AnotherClass
{
privatenull|FirstClass|SecondClass$value = null;
}
I think we can check if the property type is instance of ReflectionUnionType and if one of the types is an array or the defined class_exists the constraint could be added.
I am busy until end of next week, i can work on a PR.
Additional Context
No response
The text was updated successfully, but these errors were encountered:
…ed validations (xabbuh)
This PR was merged into the 5.4 branch.
Discussion
----------
[Validator] handle union and intersection types for cascaded validations
| Q | A
| ------------- | ---
| Branch? | 5.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | Fix#49629, Fix#53735
| License | MIT
Commits
-------
18e06a8 handle union and intersection types for cascaded validations
Symfony version(s) affected
6.4.2
Description
When using the cascade constraint on a class with a union typed property, the ClassMetadata will give an error:
Attempted to call an undefined method named 'getName' of class 'ReflectionUnionType'.
This is caused by ClassMetadata#L201 since
$property->getType()
returns anReflectionUnionType
.How to reproduce
Possible Solution
I think we can check if the property type is instance of
ReflectionUnionType
and if one of the types is anarray
or the definedclass_exists
the constraint could be added.I am busy until end of next week, i can work on a PR.
Additional Context
No response
The text was updated successfully, but these errors were encountered: