if (!
($typed_data instanceof PrimitiveInterface
)) { throw new \
LogicException('The data type must be a PrimitiveInterface at this point.'
);
} $value =
$typed_data->
getCastedValue();
// In a better world where typed data just returns typed values, we could
// set a constraint callback to use the OptionsProviderInterface.
// This is not possible right now though because we do the typecasting
// further down.
if ($constraint->callback
) { if (!\
is_callable($choices =
[$this->context->
getObject(),
$constraint->callback
]) && !\
is_callable($choices =
[$this->context->
getClassName(),
$constraint->callback
]) && !\
is_callable($choices =
$constraint->callback
) ) { throw new ConstraintDefinitionException('The AllowedValuesConstraint constraint expects a valid callback'
);
} $allowed_values = \
call_user_func($choices);
$constraint->choices =
$allowed_values;
// parent::validate() does not need to invoke the callback again.
$constraint->callback = NULL;
} // Force the choices to be the same type as the value.