PHPStan\Analyser\Scope::intersectVariables PHP Method

intersectVariables() public method

public intersectVariables ( Scope $otherScope ) : self
$otherScope Scope
return self
    public function intersectVariables(Scope $otherScope) : self
    {
        $ourVariableTypes = $this->getVariableTypes();
        $theirVariableTypes = $otherScope->getVariableTypes();
        $intersectedVariableTypes = [];
        foreach ($ourVariableTypes as $name => $variableType) {
            if (!isset($theirVariableTypes[$name])) {
                continue;
            }
            $intersectedVariableTypes[$name] = $variableType->combineWith($theirVariableTypes[$name]);
        }
        return new self($this->broker, $this->printer, $this->getFile(), $this->isDeclareStrictTypes(), $this->getClass(), $this->getFunction(), $this->getNamespace(), $intersectedVariableTypes, $this->inClosureBindScopeClass, $this->getAnonymousFunctionReturnType(), $this->isInAnonymousClass() ? $this->getAnonymousClass() : null, $this->getInFunctionCall(), $this->isNegated(), $this->moreSpecificTypes);
    }