| Conditions | 5 |
| Paths | 12 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types = 1); |
||
| 34 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
||
| 35 | { |
||
| 36 | $tokens = $phpcsFile->getTokens(); |
||
| 37 | $token = $tokens[$stackPtr]; |
||
| 38 | $openParenIndex = $token['parenthesis_opener']; |
||
| 39 | $closedParenIndex = $token['parenthesis_closer']; |
||
| 40 | |||
| 41 | $numberOfParameters = 0; |
||
| 42 | for ($index=$openParenIndex+1; $index <= $closedParenIndex; $index++) { |
||
| 43 | $tokens[$index]['type'] == 'T_VARIABLE' ? $numberOfParameters++ : null; |
||
| 44 | } |
||
| 45 | |||
| 46 | if ($numberOfParameters > $this->maxParameters) { |
||
| 47 | $phpcsFile->addError("Function has more than {$this->maxParameters} parameters. Please reduce.", $stackPtr, __CLASS__ . 'MoreThan'); |
||
| 48 | } |
||
| 49 | |||
| 50 | if ($numberOfParameters == $this->maxParameters) { |
||
| 51 | $phpcsFile->addWarning("Function has {$this->maxParameters} parameters.", $stackPtr, __CLASS__ . 'hasMax'); |
||
| 52 | } |
||
| 55 |