src/Tool/DuplicateCaseCondition.php
public function run(string $file, Node $node): array
    {
        $hints = [];
        $case_conds = [];

        foreach ($node->children as $case) {
            $cond = $case->children['cond'];
            foreach ($case_conds as $case_cond) {
                if ($this->isEqualsWithoutLineno($case_cond, $cond)) {
                    $hints[] = new Hint(
                        self::HINT_TYPE,
                        self::HINT_MESSAGE,
                        $file,
                        $case->lineno,
                        self::HINT_LINK
                    );
                }
            }
            $case_conds[] = $cond;
        }

        return $hints;
    }
public function run(string $file, Node $node): array
    {
        $hints = [];
        $case_conds = [];

        foreach ($node->children as $case) {
            $cond = $case->children['cond'];
            foreach ($case_conds as $case_cond) {
                if ($this->isEqualsWithoutLineno($case_cond, $cond)) {
                    $hints[] = new Hint(
                        self::HINT_TYPE,
                        self::HINT_MESSAGE,
                        $file,
                        $case->lineno,
                        self::HINT_LINK
                    );
                }
            }
            $case_conds[] = $cond;
        }

        return $hints;
    }
public function run ( string $ file , Node $ node ) : array { $ hints = [ ] ; $ case_conds = [ ] ; foreach ( $ node -> children as $ case ) { $ cond = $ case -> children [ 'cond' ] ; foreach ( $ case_conds as $ case_cond ) { if ( $ this -> isEqualsWithoutLineno ( $ case_cond , $ cond ) ) { $ hints [ ] = new Hint ( self :: HINT_TYPE , self :: HINT_MESSAGE , $ file , $ case -> lineno , self :: HINT_LINK ) ; } } $ case_conds [ ] = $ cond ; } return $ hints ; }
Detect case condition in switch statement.

@param string $file File name to be analyzed.
@param Node   $node AST node to be analyzed.
@return Hint[] List of hints obtained from results.
Detect case condition in switch statement .