| @@ 102-140 (lines=39) @@ | ||
| 99 | * |
|
| 100 | * @return void |
|
| 101 | */ |
|
| 102 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
| 103 | { |
|
| 104 | $tokens = $phpcsFile->getTokens(); |
|
| 105 | ||
| 106 | $ignore = array( |
|
| 107 | T_DOUBLE_COLON, |
|
| 108 | T_OBJECT_OPERATOR, |
|
| 109 | T_FUNCTION, |
|
| 110 | T_CONST, |
|
| 111 | ); |
|
| 112 | ||
| 113 | $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); |
|
| 114 | if (in_array($tokens[$prevToken]['code'], $ignore) === true) { |
|
| 115 | // Not a call to a PHP function. |
|
| 116 | return; |
|
| 117 | } |
|
| 118 | ||
| 119 | $function = strtolower($tokens[$stackPtr]['content']); |
|
| 120 | ||
| 121 | if (in_array($function, $this->removedFunctionParametersNames) === false) { |
|
| 122 | return; |
|
| 123 | } |
|
| 124 | ||
| 125 | $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr); |
|
| 126 | if ($parameterCount === 0) { |
|
| 127 | return; |
|
| 128 | } |
|
| 129 | ||
| 130 | // If the parameter count returned > 0, we know there will be valid open parenthesis. |
|
| 131 | $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true); |
|
| 132 | $parameterOffsetFound = $parameterCount - 1; |
|
| 133 | ||
| 134 | foreach($this->removedFunctionParameters[$function] as $offset => $parameterDetails) { |
|
| 135 | if ($offset <= $parameterOffsetFound) { |
|
| 136 | $this->addError($phpcsFile, $openParenthesis, $function, $offset); |
|
| 137 | } |
|
| 138 | } |
|
| 139 | ||
| 140 | }//end process() |
|
| 141 | ||
| 142 | ||
| 143 | /** |
|
| @@ 738-776 (lines=39) @@ | ||
| 735 | * |
|
| 736 | * @return void |
|
| 737 | */ |
|
| 738 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
| 739 | { |
|
| 740 | $tokens = $phpcsFile->getTokens(); |
|
| 741 | ||
| 742 | $ignore = array( |
|
| 743 | T_DOUBLE_COLON, |
|
| 744 | T_OBJECT_OPERATOR, |
|
| 745 | T_FUNCTION, |
|
| 746 | T_CONST, |
|
| 747 | ); |
|
| 748 | ||
| 749 | $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); |
|
| 750 | if (in_array($tokens[$prevToken]['code'], $ignore) === true) { |
|
| 751 | // Not a call to a PHP function. |
|
| 752 | return; |
|
| 753 | } |
|
| 754 | ||
| 755 | $function = strtolower($tokens[$stackPtr]['content']); |
|
| 756 | ||
| 757 | if (in_array($function, $this->newFunctionParametersNames) === false) { |
|
| 758 | return; |
|
| 759 | } |
|
| 760 | ||
| 761 | $parameterCount = $this->getFunctionCallParameterCount($phpcsFile, $stackPtr); |
|
| 762 | if ($parameterCount === 0) { |
|
| 763 | return; |
|
| 764 | } |
|
| 765 | ||
| 766 | // If the parameter count returned > 0, we know there will be valid open parenthesis. |
|
| 767 | $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true); |
|
| 768 | $parameterOffsetFound = $parameterCount - 1; |
|
| 769 | ||
| 770 | foreach($this->newFunctionParameters[$function] as $offset => $parameterDetails) { |
|
| 771 | if ($offset <= $parameterOffsetFound) { |
|
| 772 | $this->addError($phpcsFile, $openParenthesis, $function, $offset); |
|
| 773 | } |
|
| 774 | } |
|
| 775 | ||
| 776 | }//end process() |
|
| 777 | ||
| 778 | ||
| 779 | /** |
|