protected final function resolveFunction(IFunction $function)
{
$callable = $function->getCallable();
$this->resolveParameter($this->getFunctionCallableParameter($function), $function->getCallable());
if ($function instanceof CallableFunction) {
$reflection = $this->functionInterpreter->getReflection($callable);
$this->resolveFunctionScope($function, $reflection);
} elseif ($function instanceof ClosureExpressionFunction) {
$expression = $function->getExpression();
$this->hash .= $expression->hash();
if ($function->hasEvaluationContext()) {
$evaluationContext = $function->getEvaluationContext();
$this->resolveParameter($this->getFunctionScopedVariableParameter($function, 'this'), $evaluationContext->getThis());
foreach (array_intersect_key($evaluationContext->getVariableTable(), array_flip($expression->getUsedVariableNames())) as $variableName => $value) {
$this->resolveParameter($this->getFunctionScopedVariableParameter($function, $variableName), $value);
}
}
} else {
throw new PinqException('Cannot resolve function: unsupported function type %s', get_class($function));
}
}