src/RuleChecker.php
public function check(RuleInterface $rule, NodeInterface $node): ?ViolationInterface
    {
        if (!$this->match($rule, $node)) {
            return null;
        }

        switch ($rule->getType()) {
            case RuleInterface::TYPE_FORBIDDEN:
            case RuleInterface::TYPE_DISCOURAGED:
                $violation = $this->checkForbiddenOrDiscouragedRule($rule, $node);
                break;
            case RuleInterface::TYPE_ONLY:
                $violation = $this->checkOnlyRule($rule, $node);
                break;
            default:
                throw new \RuntimeException(sprintf('Unknown rule type "%s".', $rule->getType()));
        }

        return $violation;
    }
public function check(RuleInterface $rule, NodeInterface $node): ?ViolationInterface
    {
        if (!$this->match($rule, $node)) {
            return null;
        }

        switch ($rule->getType()) {
            case RuleInterface::TYPE_FORBIDDEN:
            case RuleInterface::TYPE_DISCOURAGED:
                $violation = $this->checkForbiddenOrDiscouragedRule($rule, $node);
                break;
            case RuleInterface::TYPE_ONLY:
                $violation = $this->checkOnlyRule($rule, $node);
                break;
            default:
                throw new \RuntimeException(sprintf('Unknown rule type "%s".', $rule->getType()));
        }

        return $violation;
    }
public function check ( RuleInterface $ rule , NodeInterface $ node ) : ? ViolationInterface { if ( ! $ this -> match ( $ rule , $ node ) ) { return null ; } switch ( $ rule -> getType ( ) ) { case RuleInterface :: TYPE_FORBIDDEN : case RuleInterface :: TYPE_DISCOURAGED : $ violation = $ this -> checkForbiddenOrDiscouragedRule ( $ rule , $ node ) ; break ; case RuleInterface :: TYPE_ONLY : $ violation = $ this -> checkOnlyRule ( $ rule , $ node ) ; break ; default : throw new \ RuntimeException ( sprintf ( 'Unknown rule type "%s".' , $ rule -> getType ( ) ) ) ; } return $ violation ; }
Checks if a node respect a rule.
Checks if a node respect a rule .