Code Duplication    Length = 45-45 lines in 3 locations

Sniffs/PHP/NewFunctionParametersSniff.php 1 location

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

Sniffs/PHP/RemovedFunctionParametersSniff.php 1 location

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

Sniffs/PHP/RequiredOptionalFunctionParametersSniff.php 1 location

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