Closed
Description
Problem
CollectionValidator uses array_key_exists to find missing field
vendor/symfony/src/Symfony/Component/Validator/Constraints/CollectionValidator.php
foreach ($constraint->fields as $field => $constraints) {
if (array_key_exists($field, $value)) {
// cannot simply cast to array, because then the object is converted to an
// array instead of wrapped inside
$constraints = is_array($constraints) ? $constraints : array($constraints);
foreach ($constraints as $constr) {
$walker->walkConstraint($constr, $value[$field], $group, $propertyPath.'['.$field.']');
}
unset($extraFields[$field]);
} else {
$missingFields[] = $field;
}
}
Description
I'm using a so-called POJO as a form data class.
To enable validation, I'm using CollectionValidator**
Of course, to make it work with my form data class, I extend it from \ArrayAccess and Traversable
CollectionValidator uses array_key_exists, which is buggy and does not work with ArrayAccess
https://bugs.php.net/bug.php?id=34849
https://bugs.php.net/bug.php?id=41727