| @@ 104-140 (lines=37) @@ | ||
| 101 | * |
|
| 102 | * @return void |
|
| 103 | */ |
|
| 104 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
| 105 | { |
|
| 106 | $tokens = $phpcsFile->getTokens(); |
|
| 107 | ||
| 108 | $ignore = array( |
|
| 109 | T_DOUBLE_COLON, |
|
| 110 | T_OBJECT_OPERATOR, |
|
| 111 | T_FUNCTION, |
|
| 112 | T_CONST, |
|
| 113 | ); |
|
| 114 | ||
| 115 | $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); |
|
| 116 | if (in_array($tokens[$prevToken]['code'], $ignore) === true) { |
|
| 117 | // Not a call to a PHP function. |
|
| 118 | return; |
|
| 119 | } |
|
| 120 | ||
| 121 | $function = strtolower($tokens[$stackPtr]['content']); |
|
| 122 | ||
| 123 | if (in_array($function, $this->newFunctionParametersNames) === false) { |
|
| 124 | return; |
|
| 125 | } |
|
| 126 | ||
| 127 | if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') { |
|
| 128 | $closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer']; |
|
| 129 | ||
| 130 | $nextComma = $stackPtr + 1; |
|
| 131 | $cnt = 0; |
|
| 132 | while ($nextComma = $phpcsFile->findNext(array(T_COMMA, T_CLOSE_PARENTHESIS), $nextComma + 1, $closeParenthesis + 1)) { |
|
| 133 | if (isset($this->newFunctionParameters[$function][$cnt])) { |
|
| 134 | $this->addError($phpcsFile, $nextComma, $function, $cnt); |
|
| 135 | } |
|
| 136 | $cnt++; |
|
| 137 | } |
|
| 138 | ||
| 139 | } |
|
| 140 | }//end process() |
|
| 141 | ||
| 142 | ||
| 143 | /** |
|
| @@ 96-132 (lines=37) @@ | ||
| 93 | * |
|
| 94 | * @return void |
|
| 95 | */ |
|
| 96 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
| 97 | { |
|
| 98 | $tokens = $phpcsFile->getTokens(); |
|
| 99 | ||
| 100 | $ignore = array( |
|
| 101 | T_DOUBLE_COLON, |
|
| 102 | T_OBJECT_OPERATOR, |
|
| 103 | T_FUNCTION, |
|
| 104 | T_CONST, |
|
| 105 | ); |
|
| 106 | ||
| 107 | $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); |
|
| 108 | if (in_array($tokens[$prevToken]['code'], $ignore) === true) { |
|
| 109 | // Not a call to a PHP function. |
|
| 110 | return; |
|
| 111 | } |
|
| 112 | ||
| 113 | $function = strtolower($tokens[$stackPtr]['content']); |
|
| 114 | ||
| 115 | if (in_array($function, $this->removedFunctionParametersNames) === false) { |
|
| 116 | return; |
|
| 117 | } |
|
| 118 | ||
| 119 | if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') { |
|
| 120 | $closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer']; |
|
| 121 | ||
| 122 | $nextComma = $stackPtr + 1; |
|
| 123 | $cnt = 0; |
|
| 124 | while ($nextComma = $phpcsFile->findNext(array(T_COMMA, T_CLOSE_PARENTHESIS), $nextComma + 1, $closeParenthesis + 1)) { |
|
| 125 | if (isset($this->removedFunctionParameters[$function][$cnt])) { |
|
| 126 | $this->addError($phpcsFile, $nextComma, $function, $cnt); |
|
| 127 | } |
|
| 128 | $cnt++; |
|
| 129 | } |
|
| 130 | ||
| 131 | } |
|
| 132 | }//end process() |
|
| 133 | ||
| 134 | ||
| 135 | /** |
|