| @@ 276-330 (lines=55) @@ | ||
| 273 | * |
|
| 274 | * @return void |
|
| 275 | */ |
|
| 276 | public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
| 277 | { |
|
| 278 | $tokens = $phpcsFile->getTokens(); |
|
| 279 | ||
| 280 | // Find the next non-empty token. |
|
| 281 | $openBracket = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); |
|
| 282 | ||
| 283 | if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) { |
|
| 284 | // Not a function call. |
|
| 285 | return; |
|
| 286 | } |
|
| 287 | ||
| 288 | if (isset($tokens[$openBracket]['parenthesis_closer']) === false) { |
|
| 289 | // Not a function call. |
|
| 290 | return; |
|
| 291 | } |
|
| 292 | ||
| 293 | // Find the previous non-empty token. |
|
| 294 | $search = \PHP_CodeSniffer_Tokens::$emptyTokens; |
|
| 295 | $search[] = T_BITWISE_AND; |
|
| 296 | $previous = $phpcsFile->findPrevious($search, ($stackPtr - 1), null, true); |
|
| 297 | if ($tokens[$previous]['code'] === T_FUNCTION) { |
|
| 298 | // It's a function definition, not a function call. |
|
| 299 | return; |
|
| 300 | } |
|
| 301 | ||
| 302 | if ($tokens[$previous]['code'] === T_NEW) { |
|
| 303 | // We are creating an object, not calling a function. |
|
| 304 | return; |
|
| 305 | } |
|
| 306 | ||
| 307 | if ($tokens[$previous]['code'] === T_OBJECT_OPERATOR) { |
|
| 308 | // We are calling a method of an object. |
|
| 309 | return; |
|
| 310 | } |
|
| 311 | ||
| 312 | $function = $tokens[$stackPtr]['content']; |
|
| 313 | $functionLc = strtolower($function); |
|
| 314 | ||
| 315 | if ($this->isWhiteListed($functionLc) === true) { |
|
| 316 | // Function is whitelisted. |
|
| 317 | return; |
|
| 318 | } |
|
| 319 | ||
| 320 | foreach ($this->removedExtensions as $extension => $versionList) { |
|
| 321 | if (strpos($functionLc, $extension) === 0) { |
|
| 322 | $itemInfo = array( |
|
| 323 | 'name' => $extension, |
|
| 324 | ); |
|
| 325 | $this->handleFeature($phpcsFile, $stackPtr, $itemInfo); |
|
| 326 | break; |
|
| 327 | } |
|
| 328 | } |
|
| 329 | ||
| 330 | }//end process() |
|
| 331 | ||
| 332 | ||
| 333 | /** |
|
| @@ 249-303 (lines=55) @@ | ||
| 246 | * |
|
| 247 | * @return void |
|
| 248 | */ |
|
| 249 | public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
| 250 | { |
|
| 251 | $tokens = $phpcsFile->getTokens(); |
|
| 252 | ||
| 253 | // Find the next non-empty token. |
|
| 254 | $openBracket = $phpcsFile->findNext(\PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); |
|
| 255 | ||
| 256 | if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) { |
|
| 257 | // Not a function call. |
|
| 258 | return; |
|
| 259 | } |
|
| 260 | ||
| 261 | if (isset($tokens[$openBracket]['parenthesis_closer']) === false) { |
|
| 262 | // Not a function call. |
|
| 263 | return; |
|
| 264 | } |
|
| 265 | ||
| 266 | // Find the previous non-empty token. |
|
| 267 | $search = \PHP_CodeSniffer_Tokens::$emptyTokens; |
|
| 268 | $search[] = T_BITWISE_AND; |
|
| 269 | $previous = $phpcsFile->findPrevious($search, ($stackPtr - 1), null, true); |
|
| 270 | if ($tokens[$previous]['code'] === T_FUNCTION) { |
|
| 271 | // It's a function definition, not a function call. |
|
| 272 | return; |
|
| 273 | } |
|
| 274 | ||
| 275 | if ($tokens[$previous]['code'] === T_NEW) { |
|
| 276 | // We are creating an object, not calling a function. |
|
| 277 | return; |
|
| 278 | } |
|
| 279 | ||
| 280 | if ($tokens[$previous]['code'] === T_OBJECT_OPERATOR) { |
|
| 281 | // We are calling a method of an object. |
|
| 282 | return; |
|
| 283 | } |
|
| 284 | ||
| 285 | $function = $tokens[$stackPtr]['content']; |
|
| 286 | $functionLc = strtolower($function); |
|
| 287 | ||
| 288 | if ($this->isWhiteListed($functionLc) === true) { |
|
| 289 | // Function is whitelisted. |
|
| 290 | return; |
|
| 291 | } |
|
| 292 | ||
| 293 | foreach ($this->removedExtensions as $extension => $versionList) { |
|
| 294 | if (strpos($functionLc, $extension) === 0) { |
|
| 295 | $itemInfo = array( |
|
| 296 | 'name' => $extension, |
|
| 297 | ); |
|
| 298 | $this->handleFeature($phpcsFile, $stackPtr, $itemInfo); |
|
| 299 | break; |
|
| 300 | } |
|
| 301 | } |
|
| 302 | ||
| 303 | }//end process() |
|
| 304 | ||
| 305 | ||
| 306 | /** |
|