Code Duplication    Length = 45-45 lines in 3 locations

PHPCompatibility/Sniffs/PHP/NewFunctionParametersSniff.php 1 location

@@ 766-810 (lines=45) @@
763
     *
764
     * @return void
765
     */
766
    public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)
767
    {
768
        $tokens = $phpcsFile->getTokens();
769
770
        $ignore = array(
771
            T_DOUBLE_COLON,
772
            T_OBJECT_OPERATOR,
773
            T_FUNCTION,
774
            T_CONST,
775
        );
776
777
        $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
778
        if (in_array($tokens[$prevToken]['code'], $ignore) === true) {
779
            // Not a call to a PHP function.
780
            return;
781
        }
782
783
        $function   = $tokens[$stackPtr]['content'];
784
        $functionLc = strtolower($function);
785
786
        if (isset($this->newFunctionParameters[$functionLc]) === false) {
787
            return;
788
        }
789
790
        $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr);
791
        if ($parameterCount === 0) {
792
            return;
793
        }
794
795
        // If the parameter count returned > 0, we know there will be valid open parenthesis.
796
        $openParenthesis = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
797
        $parameterOffsetFound = $parameterCount - 1;
798
799
        foreach ($this->newFunctionParameters[$functionLc] as $offset => $parameterDetails) {
800
            if ($offset <= $parameterOffsetFound) {
801
                $itemInfo = array(
802
                    'name'   => $function,
803
                    'nameLc' => $functionLc,
804
                    'offset' => $offset,
805
                );
806
                $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
807
            }
808
        }
809
810
    }//end process()
811
812
813
    /**

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
    /**

PHPCompatibility/Sniffs/PHP/RequiredOptionalFunctionParametersSniff.php 1 location

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