src/RuleChecker.php
private function checkForbiddenOrDiscouragedRule(RuleInterface $rule, NodeInterface $node): ?ViolationInterface
    {
        $errors = array();

        foreach ($node->getTokens() as $token) {
            if (!$this->checkTokenForForbiddenOrDiscouragedRule($rule, $token) &&
                !in_array($token, $errors)) {
                $errors[] = $token;
            }
        }

        if (count($errors)) {
            $type = $rule->getType() === RuleInterface::TYPE_FORBIDDEN ?
                    ViolationInterface::TYPE_ERROR :
                    ViolationInterface::TYPE_WARNING
            ;

            return new Violation($node, $rule, $errors, $type);
        }

        return null;
    }
private function checkForbiddenOrDiscouragedRule(RuleInterface $rule, NodeInterface $node): ?ViolationInterface
    {
        $errors = array();

        foreach ($node->getTokens() as $token) {
            if (!$this->checkTokenForForbiddenOrDiscouragedRule($rule, $token) &&
                !in_array($token, $errors)) {
                $errors[] = $token;
            }
        }

        if (count($errors)) {
            $type = $rule->getType() === RuleInterface::TYPE_FORBIDDEN ?
                    ViolationInterface::TYPE_ERROR :
                    ViolationInterface::TYPE_WARNING
            ;

            return new Violation($node, $rule, $errors, $type);
        }

        return null;
    }
private function checkForbiddenOrDiscouragedRule ( RuleInterface $ rule , NodeInterface $ node ) : ? ViolationInterface { $ errors = array ( ) ; foreach ( $ node -> getTokens ( ) as $ token ) { if ( ! $ this -> checkTokenForForbiddenOrDiscouragedRule ( $ rule , $ token ) && ! in_array ( $ token , $ errors ) ) { $ errors [ ] = $ token ; } } if ( count ( $ errors ) ) { $ type = $ rule -> getType ( ) === RuleInterface :: TYPE_FORBIDDEN ? ViolationInterface :: TYPE_ERROR : ViolationInterface :: TYPE_WARNING ; return new Violation ( $ node , $ rule , $ errors , $ type ) ; } return null ; }
Checks if a node respects a "forbidden" or "discouraged" rule.
A node respects such a rule if no rule token is present in the node.
Checks if a node respects a forbidden or discouraged rule . A node respects such a rule if no rule token is present in the node .