Conditions | 2 |
Paths | 2 |
Total Lines | 10 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
37 | 1 | public static function getMethodDocBlock(PHP_CodeSniffer_File $file, int $position) : string |
|
38 | { |
||
39 | 1 | if ( ! self::hasMethodDocBlock($file, $position)) { |
|
40 | 1 | return ''; |
|
41 | } |
||
42 | |||
43 | 1 | $commentStart = $file->findPrevious(T_DOC_COMMENT_OPEN_TAG, $position - 1); |
|
44 | 1 | $commentEnd = $file->findPrevious(T_DOC_COMMENT_CLOSE_TAG, $position - 1); |
|
45 | 1 | return $file->getTokensAsString($commentStart, $commentEnd - $commentStart + 1); |
|
|
|||
46 | } |
||
47 | |||
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.