Description
In the RecursiveContextualValidator.php file, it makes the class metadata map, with propertyName as a key for the caching.
This has a bad bug when a key (property name) is re-used between nested class instances, such that the value of the key is included in the cache name - however, if multiple entities / nested object instances have the same key/value pairs, this causes a collision and gives an error about the class metadata map expecting an object, but a boolean being returned.
The other portion of this bug is that the value used as part of the cache key is not escaped in anyway, and it is very likely and possible that the value has 'illegal' cache key characters (parenthesis etc.).
This is not extensively tested, but seems to fix for our use case (adding something similar to this after line 563 in Symfony/Component/Validator/Validator/RecursiveContextualValidator.php):
// Need to escape this and ensure uniqueness.
$propertyName = base64_encode($propertyPath . '.' . $propertyName);
Edit: This is with Symfony 3.1.5+ that seems to have introduced the issue