Closed
Description
Symfony version(s) affected: 5.1
Description
An exception 'Unable to call method of a non-object.' is thrown by Symfony\Component\ExpressionLanguage\Node\GetAttrNode
when using this
keyword in an Expression constraint when embeded in AtLeastOneOf
How to reproduce
When validating an entity with this kind of constraint:
/**
* @Assert\AtLeastOneOf({
* @Assert\Expression("this.getCategory() in ['php', 'symfony']"),
* @Assert\IdenticalTo("Baz")
* })
*/
private $foo;
Since the AtLeastOneOfValidator validates the sub-constraint without context, $variables['this'] = $this->context->getObject();
in Symfony\Component\Validator\Constraints\ExpressionValidator
results in a null value