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

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

        if (count($errors)) {
            return new Violation($node, $rule, $errors, ViolationInterface::TYPE_ERROR);
        }

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

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

        if (count($errors)) {
            return new Violation($node, $rule, $errors, ViolationInterface::TYPE_ERROR);
        }

        return null;
    }
private function checkOnlyRule ( RuleInterface $ rule , NodeInterface $ node ) : ? Violation { $ errors = array ( ) ; foreach ( $ node -> getTokens ( ) as $ token ) { if ( ! $ this -> checkTokenForOnlyRule ( $ rule , $ token ) && ! in_array ( $ token , $ errors ) ) { $ errors [ ] = $ token ; } } if ( count ( $ errors ) ) { return new Violation ( $ node , $ rule , $ errors , ViolationInterface :: TYPE_ERROR ) ; } return null ; }
Checks if a node respects a "only" rule.
A node respects such a rule if the node contains only tokens defined in the rule.
Checks if a node respects a only rule . A node respects such a rule if the node contains only tokens defined in the rule .