public function enterAnonymousFunction(array $parameters, array $uses, $returnTypehint = null) : self
{
$variableTypes = [];
foreach ($parameters as $parameter) {
$isNullable = false;
if ($parameter->default instanceof ConstFetch && $parameter->default->name instanceof Name) {
$isNullable = strtolower((string) $parameter->default->name) === 'null';
}
$variableTypes[$parameter->name] = $this->getAnonymousFunctionType($parameter->type, $isNullable);
}
foreach ($uses as $use) {
if (!$this->hasVariableType($use->var)) {
if ($use->byRef) {
$variableTypes[$use->var] = new MixedType(true);
}
continue;
}
$variableTypes[$use->var] = $this->getVariableType($use->var);
}
if ($this->hasVariableType('this')) {
$variableTypes['this'] = $this->getVariableType('this');
}
$returnType = $this->getAnonymousFunctionType($returnTypehint, $returnTypehint === null);
return new self($this->broker, $this->printer, $this->getFile(), $this->isDeclareStrictTypes(), $this->getClass(), $this->getFunction(), $this->getNamespace(), $variableTypes, $this->inClosureBindScopeClass, $returnType, $this->isInAnonymousClass() ? $this->getAnonymousClass() : null, $this->getInFunctionCall());
}