1 | <?php |
||
22 | class Comparator extends AbstractCallable implements ComparatorInterface |
||
23 | { |
||
24 | use VisiteeTrait; |
||
25 | |||
26 | /** |
||
27 | * @var ComparatorInterface |
||
28 | */ |
||
29 | private static $default = null; |
||
30 | |||
31 | /** |
||
32 | * @param callable $comparator |
||
33 | * |
||
34 | * @return \Cubiche\Core\Comparable\ComparatorInterface |
||
35 | */ |
||
36 | public static function from(callable $comparator) |
||
44 | |||
45 | /** |
||
46 | * @param callable $selector |
||
47 | * @param Direction $direction |
||
48 | * |
||
49 | * @return \Cubiche\Core\Comparable\ComparatorInterface |
||
50 | */ |
||
51 | public static function by(callable $selector, Direction $direction = null) |
||
55 | |||
56 | /** |
||
57 | * @return \Cubiche\Core\Comparable\ComparatorInterface |
||
58 | */ |
||
59 | public static function defaultComparator() |
||
67 | |||
68 | /** |
||
69 | * @param callable $comparator |
||
70 | * @param callable $default |
||
71 | * |
||
72 | * @return \Cubiche\Core\Comparable\ComparatorInterface |
||
73 | */ |
||
74 | public static function ensure(callable $comparator = null, callable $default = null) |
||
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | */ |
||
83 | public function compare($a, $b) |
||
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | */ |
||
99 | public function reverse() |
||
103 | |||
104 | /** |
||
105 | * {@inheritdoc} |
||
106 | */ |
||
107 | public function otherwise(callable $comparator) |
||
111 | |||
112 | /** |
||
113 | * {@inheritdoc} |
||
114 | */ |
||
115 | protected function innerCallback() |
||
119 | } |
||
120 |
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.