Closed
Description
Hello! I found out about a rather unexpected interaction. This code doesn't work, throwing an ConstraintDefinitionException (No default option is configured for constraint):
$options = ['message'=>'Hello'];
array_walk($options, function(&$item) { $item = $item . ' world!'; });
$constraint = new Email($options); // Not working
In order to make it work, I have to use reset($options)
after array_walk()
so that I get a valid array pointer. I propose to either output a meaningful error message (that Constraint cannot be initialized without valid internal pointer) or to replace is_string(key($options))
in Symfony\Component\Validator\Constraint
to something like is_string(array_keys($options)[0])
.
Metadata
Metadata
Assignees
Labels
No labels