Code Duplication    Length = 45-45 lines in 2 locations

PHPCompatibility/Sniffs/PHP/NewFunctionParametersSniff.php 1 location

@@ 861-905 (lines=45) @@
858
     *
859
     * @return void
860
     */
861
    public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
862
    {
863
        $tokens = $phpcsFile->getTokens();
864
865
        $ignore = array(
866
            T_DOUBLE_COLON,
867
            T_OBJECT_OPERATOR,
868
            T_FUNCTION,
869
            T_CONST,
870
        );
871
872
        $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
873
        if (in_array($tokens[$prevToken]['code'], $ignore) === true) {
874
            // Not a call to a PHP function.
875
            return;
876
        }
877
878
        $function   = $tokens[$stackPtr]['content'];
879
        $functionLc = strtolower($function);
880
881
        if (isset($this->newFunctionParameters[$functionLc]) === false) {
882
            return;
883
        }
884
885
        $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr);
886
        if ($parameterCount === 0) {
887
            return;
888
        }
889
890
        // If the parameter count returned > 0, we know there will be valid open parenthesis.
891
        $openParenthesis      = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
892
        $parameterOffsetFound = $parameterCount - 1;
893
894
        foreach ($this->newFunctionParameters[$functionLc] as $offset => $parameterDetails) {
895
            if ($offset <= $parameterOffsetFound) {
896
                $itemInfo = array(
897
                    'name'   => $function,
898
                    'nameLc' => $functionLc,
899
                    'offset' => $offset,
900
                );
901
                $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
902
            }
903
        }
904
905
    }//end process()
906
907
908
    /**

PHPCompatibility/Sniffs/PHP/RemovedFunctionParametersSniff.php 1 location

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