1 | <?php |
||
20 | final class ComponentFactoryCommentSniff implements PHP_CodeSniffer_Sniff |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * @var int |
||
25 | */ |
||
26 | private $position; |
||
27 | |||
28 | /** |
||
29 | * @var PHP_CodeSniffer_File |
||
30 | */ |
||
31 | private $file; |
||
32 | |||
33 | /** |
||
34 | * @var array |
||
35 | */ |
||
36 | private $tokens; |
||
37 | |||
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | 1 | public function register() |
|
46 | |||
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | 1 | public function process(PHP_CodeSniffer_File $file, $position) |
|
70 | |||
71 | |||
72 | /** |
||
73 | * @return bool |
||
74 | */ |
||
75 | 1 | private function isComponentFactoryMethod() |
|
80 | |||
81 | |||
82 | /** |
||
83 | * @return bool|int |
||
84 | */ |
||
85 | 1 | private function getCommentEnd() |
|
89 | |||
90 | |||
91 | /** |
||
92 | * @param int $position |
||
93 | * @return bool |
||
94 | */ |
||
95 | 1 | private function hasMethodComment($position) |
|
102 | |||
103 | |||
104 | /** |
||
105 | * @param int $commentStartPosition |
||
106 | */ |
||
107 | 1 | private function processReturnTag($commentStartPosition) |
|
127 | |||
128 | } |
||
129 |
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.