public function createAnalysisContext(O\IEvaluationContext $evaluationContext);
/** * @param callable $function * @param array $variableTypeMap * @param mixed $expression * * @return ITypeAnalysis */ protected function getAnalysis(callable $function, array $variableTypeMap = [], &$expression = null) { $reflection = $this->functionInterpreter->getReflection($function); foreach ($reflection->getSignature()->getParameterExpressions() as $parameterExpression) { $variableTypeMap[$parameterExpression->getName()] = $this->typeSystem->getTypeFromTypeHint($parameterExpression->getTypeHint()); } $analysisContext = $this->expressionAnalyser->createAnalysisContext($reflection->asEvaluationContext()); foreach ($variableTypeMap as $variable => $type) { $analysisContext->setExpressionType(O\Expression::variable(O\Expression::value($variable)), $type); } $bodyExpressions = $this->functionInterpreter->getStructure($reflection)->getBodyExpressions(); foreach ($bodyExpressions as $expression) { if ($expression instanceof O\ReturnExpression) { return $this->expressionAnalyser->analyse($analysisContext, $expression->getValue()); } elseif (count($bodyExpressions) === 1) { return $this->expressionAnalyser->analyse($analysisContext, $expression); } else { $this->expressionAnalyser->analyse($analysisContext, $expression); } } }