| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 17 |
| Ratio | 100 % |
| Tests | 9 |
| CRAP Score | 3.009 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | 1 | View Code Duplication | public static function hasMethodDocBlock(PHP_CodeSniffer_File $file, int $position) : bool |
| 19 | { |
||
| 20 | 1 | $tokens = $file->getTokens(); |
|
| 21 | 1 | $currentToken = $tokens[$position]; |
|
| 22 | 1 | $docBlockClosePosition = $file->findPrevious(T_DOC_COMMENT_CLOSE_TAG, $position); |
|
| 23 | |||
| 24 | 1 | if ($docBlockClosePosition === FALSE) { |
|
| 25 | 1 | return FALSE; |
|
| 26 | } |
||
| 27 | |||
| 28 | 1 | $docBlockCloseToken = $tokens[$docBlockClosePosition]; |
|
| 29 | 1 | if ($docBlockCloseToken['line'] === ($currentToken['line'] - 1)) { |
|
| 30 | 1 | return TRUE; |
|
| 31 | } |
||
| 32 | |||
| 33 | return FALSE; |
||
| 34 | } |
||
| 35 | |||
| 49 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.