PHPStan\Rules\Comparison\StrictComparisonOfDifferentTypesRule::processNode PHP Method

processNode() public method

public processNode ( PhpParser\Node $node, Scope $scope ) : array
$node PhpParser\Node
$scope PHPStan\Analyser\Scope
return array errors
    public function processNode(Node $node, Scope $scope) : array
    {
        if (!$node instanceof Node\Expr\BinaryOp\Identical && !$node instanceof Node\Expr\BinaryOp\NotIdentical) {
            return [];
        }
        $leftType = $scope->getType($node->left);
        $rightType = $scope->getType($node->right);
        if ($leftType instanceof MixedType || $rightType instanceof MixedType || $leftType instanceof NullType || $rightType instanceof NullType) {
            return [];
        }
        if (get_class($leftType) !== get_class($rightType)) {
            return [sprintf('Strict comparison using %s between %s and %s will always evaluate to false.', $node instanceof Node\Expr\BinaryOp\Identical ? '===' : '!==', $leftType->describe(), $rightType->describe())];
        }
        return [];
    }
StrictComparisonOfDifferentTypesRule