Code Duplication    Length = 45-45 lines in 3 locations

Sniffs/PHP/NewFunctionParametersSniff.php 1 location

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

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