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

        foreach ($node->children as $elem) {
            if (is_null($elem)) {
                continue;
            }

            $key = $elem->children['key'];
            // If the array does not have key, ignores this element.
            if (!is_null($key)) {
                foreach ($keys as $other_key) {
                    if ($this->isEqualsWithoutLineno($key, $other_key)) {
                        $hints[] = new Hint(
                            self::HINT_TYPE,
                            self::HINT_MESSAGE,
                            $file,
                            $elem->lineno,
                            self::HINT_LINK
                        );
                    }
                }
                $keys[] = $key;
            }
        }

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

        foreach ($node->children as $elem) {
            if (is_null($elem)) {
                continue;
            }

            $key = $elem->children['key'];
            // If the array does not have key, ignores this element.
            if (!is_null($key)) {
                foreach ($keys as $other_key) {
                    if ($this->isEqualsWithoutLineno($key, $other_key)) {
                        $hints[] = new Hint(
                            self::HINT_TYPE,
                            self::HINT_MESSAGE,
                            $file,
                            $elem->lineno,
                            self::HINT_LINK
                        );
                    }
                }
                $keys[] = $key;
            }
        }

        return $hints;
    }
public function run ( string $ file , Node $ node ) : array { $ hints = [ ] ; $ keys = [ ] ; foreach ( $ node -> children as $ elem ) { if ( is_null ( $ elem ) ) { continue ; } $ key = $ elem -> children [ 'key' ] ; // If the array does not have key, ignores this element. if ( ! is_null ( $ key ) ) { foreach ( $ keys as $ other_key ) { if ( $ this -> isEqualsWithoutLineno ( $ key , $ other_key ) ) { $ hints [ ] = new Hint ( self :: HINT_TYPE , self :: HINT_MESSAGE , $ file , $ elem -> lineno , self :: HINT_LINK ) ; } } $ keys [ ] = $ key ; } } return $ hints ; }
Detect duplicate numbers, strings, node key

@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 duplicate numbers strings node key