private function validateExpressionResult($className, Expression $expression, $allowsNull, ExpressionLanguage $expressionLanguage)
{
try {
$result = $expressionLanguage->evaluate($expression, array('container' => $this->containerBuilder));
} catch (\Exception $exception) {
throw new InvalidExpressionException($expression, $exception);
}
if ($result === null) {
if ($allowsNull) {
return;
}
throw new TypeHintMismatchException(sprintf('Argument for type-hint "%s" is an expression that evaluates to null, which is not allowed', $className));
}
if (!is_object($result)) {
throw new TypeHintMismatchException(sprintf('Argument for type-hint "%s" is an expression that evaluates to a non-object', $className));
}
$resultingClass = get_class($result);
$this->validateClass($className, $resultingClass);
}