Code Duplication    Length = 39-39 lines in 2 locations

Sniffs/PHP/RemovedFunctionParametersSniff.php 1 location

@@ 89-127 (lines=39) @@
86
     *
87
     * @return void
88
     */
89
    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
90
    {
91
        $tokens = $phpcsFile->getTokens();
92
93
        $ignore = array(
94
                T_DOUBLE_COLON,
95
                T_OBJECT_OPERATOR,
96
                T_FUNCTION,
97
                T_CONST,
98
        );
99
100
        $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
101
        if (in_array($tokens[$prevToken]['code'], $ignore) === true) {
102
            // Not a call to a PHP function.
103
            return;
104
        }
105
106
        $function = strtolower($tokens[$stackPtr]['content']);
107
108
        if (in_array($function, $this->removedFunctionParametersNames) === false) {
109
            return;
110
        }
111
112
        $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr);
113
        if ($parameterCount === 0) {
114
            return;
115
        }
116
117
        // If the parameter count returned > 0, we know there will be valid open parenthesis.
118
        $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
119
        $parameterOffsetFound = $parameterCount - 1;
120
121
        foreach($this->removedFunctionParameters[$function] as $offset => $parameterDetails) {
122
            if ($offset <= $parameterOffsetFound) {
123
                $this->addError($phpcsFile, $openParenthesis, $function, $offset);
124
            }
125
        }
126
127
    }//end process()
128
129
130
    /**

Sniffs/PHP/NewFunctionParametersSniff.php 1 location

@@ 752-790 (lines=39) @@
749
     *
750
     * @return void
751
     */
752
    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
753
    {
754
        $tokens = $phpcsFile->getTokens();
755
756
        $ignore = array(
757
                T_DOUBLE_COLON,
758
                T_OBJECT_OPERATOR,
759
                T_FUNCTION,
760
                T_CONST,
761
        );
762
763
        $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
764
        if (in_array($tokens[$prevToken]['code'], $ignore) === true) {
765
            // Not a call to a PHP function.
766
            return;
767
        }
768
769
        $function = strtolower($tokens[$stackPtr]['content']);
770
771
        if (in_array($function, $this->newFunctionParametersNames) === false) {
772
            return;
773
        }
774
775
        $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr);
776
        if ($parameterCount === 0) {
777
            return;
778
        }
779
780
        // If the parameter count returned > 0, we know there will be valid open parenthesis.
781
        $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
782
        $parameterOffsetFound = $parameterCount - 1;
783
784
        foreach($this->newFunctionParameters[$function] as $offset => $parameterDetails) {
785
            if ($offset <= $parameterOffsetFound) {
786
                $this->addError($phpcsFile, $openParenthesis, $function, $offset);
787
            }
788
        }
789
790
    }//end process()
791
792
793
    /**