$validator =
$this->validatorFactory->
getInstance($constraint);
$validator->
initialize($context);
if ($value instanceof LazyProperty
) { $value =
$value->
getPropertyValue();
} try { $validator->
validate($value,
$constraint);
} catch (UnexpectedValueException
$e) { $context->
buildViolation('This value should be of type {{ type }}.'
) ->
setParameter('{{ type }}',
$e->
getExpectedType()) ->
addViolation();
} } } private function generateCacheKey(object
$object, bool
$dependsOnPropertyPath = false
): string
{ if ($this->context instanceof ExecutionContext
) { $cacheKey =
$this->context->
generateCacheKey($object);
} else { $cacheKey =
spl_object_hash($object);
}