| @@ 104-142 (lines=39) @@ | ||
| 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 | $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr); |
|
| 128 | if ($parameterCount === 0) { |
|
| 129 | return; |
|
| 130 | } |
|
| 131 | ||
| 132 | // If the parameter count returned > 0, we know there will be valid open parenthesis. |
|
| 133 | $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true); |
|
| 134 | $parameterOffsetFound = $parameterCount - 1; |
|
| 135 | ||
| 136 | foreach($this->newFunctionParameters[$function] as $offset => $parameterDetails) { |
|
| 137 | if ($offset <= $parameterOffsetFound) { |
|
| 138 | $this->addError($phpcsFile, $openParenthesis, $function, $offset); |
|
| 139 | } |
|
| 140 | } |
|
| 141 | ||
| 142 | }//end process() |
|
| 143 | ||
| 144 | ||
| 145 | /** |
|
| @@ 89-127 (lines=39) @@ | ||
| 86 | * |
|
| 87 | * @return void |
|
| 88 | */ |
|
| 89 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
| 90 | { |
|
| 91 | $tokens = $phpcsFile->getTokens(); |
|
| 92 | ||
| 93 | $ignore = array( |
|
| 94 | T_DOUBLE_COLON, |
|
| 95 | T_OBJECT_OPERATOR, |
|
| 96 | T_FUNCTION, |
|
| 97 | T_CONST, |
|
| 98 | ); |
|
| 99 | ||
| 100 | $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); |
|
| 101 | if (in_array($tokens[$prevToken]['code'], $ignore) === true) { |
|
| 102 | // Not a call to a PHP function. |
|
| 103 | return; |
|
| 104 | } |
|
| 105 | ||
| 106 | $function = strtolower($tokens[$stackPtr]['content']); |
|
| 107 | ||
| 108 | if (in_array($function, $this->removedFunctionParametersNames) === false) { |
|
| 109 | return; |
|
| 110 | } |
|
| 111 | ||
| 112 | $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr); |
|
| 113 | if ($parameterCount === 0) { |
|
| 114 | return; |
|
| 115 | } |
|
| 116 | ||
| 117 | // If the parameter count returned > 0, we know there will be valid open parenthesis. |
|
| 118 | $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true); |
|
| 119 | $parameterOffsetFound = $parameterCount - 1; |
|
| 120 | ||
| 121 | foreach($this->removedFunctionParameters[$function] as $offset => $parameterDetails) { |
|
| 122 | if ($offset <= $parameterOffsetFound) { |
|
| 123 | $this->addError($phpcsFile, $openParenthesis, $function, $offset); |
|
| 124 | } |
|
| 125 | } |
|
| 126 | ||
| 127 | }//end process() |
|
| 128 | ||
| 129 | ||
| 130 | /** |
|