PHPStan\Analyser\NodeScopeResolver::hasStatementEarlyTermination PHP Method

hasStatementEarlyTermination() private method

private hasStatementEarlyTermination ( PhpParser\Node $statement, Scope $scope ) : boolean
$statement PhpParser\Node
$scope Scope
return boolean
    private function hasStatementEarlyTermination(Node $statement, Scope $scope) : bool
    {
        if ($statement instanceof Throw_ || $statement instanceof Return_ || $statement instanceof Continue_ || $statement instanceof Break_ || $statement instanceof Exit_) {
            return true;
        } elseif ($statement instanceof MethodCall && count($this->earlyTerminatingMethodCalls) > 0) {
            if (!is_string($statement->name)) {
                return false;
            }
            $methodCalledOnType = $scope->getType($statement->var);
            if ($methodCalledOnType->getClass() === null) {
                return false;
            }
            if (!$this->broker->hasClass($methodCalledOnType->getClass())) {
                return false;
            }
            $classReflection = $this->broker->getClass($methodCalledOnType->getClass());
            foreach (array_merge([$methodCalledOnType->getClass()], $classReflection->getParentClassesNames()) as $className) {
                if (!isset($this->earlyTerminatingMethodCalls[$className])) {
                    continue;
                }
                return in_array($statement->name, $this->earlyTerminatingMethodCalls[$className], true);
            }
            return false;
        }
        return false;
    }