PHPStan\Analyser\Scope::enterAnonymousFunction PHP Method

enterAnonymousFunction() public method

public enterAnonymousFunction ( array $parameters, array $uses, Name | string | null $returnTypehint = null ) : self
$parameters array
$uses array
$returnTypehint PhpParser\Node\Name | string | null
return self
    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());
    }