1 | <?php |
||
20 | final class YodaConditionSniff implements PHP_CodeSniffer_Sniff |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | const NAME = 'ZenifyCodingStandard.ControlStructures.YodaCondition'; |
||
27 | |||
28 | /** |
||
29 | * @var int |
||
30 | */ |
||
31 | private $position; |
||
32 | |||
33 | /** |
||
34 | * @var PHP_CodeSniffer_File |
||
35 | */ |
||
36 | private $file; |
||
37 | |||
38 | |||
39 | /** |
||
40 | * @return int[] |
||
41 | */ |
||
42 | 1 | public function register() : array |
|
55 | |||
56 | |||
57 | /** |
||
58 | * @param PHP_CodeSniffer_File $file |
||
59 | * @param int $position |
||
60 | */ |
||
61 | 1 | public function process(PHP_CodeSniffer_File $file, $position) |
|
78 | |||
79 | |||
80 | /** |
||
81 | * @return array|bool |
||
82 | */ |
||
83 | 1 | private function getPreviousNonEmptyToken() |
|
93 | |||
94 | |||
95 | 1 | private function isExpressionToken(array $token) : bool |
|
99 | |||
100 | } |
||
101 |
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.