1 | <?php |
||
8 | class SortRequest implements SortOptions |
||
9 | { |
||
10 | /** |
||
11 | * @var string|array |
||
12 | */ |
||
13 | private $sorts; |
||
14 | |||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | private $property; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private $direction; |
||
24 | |||
25 | /** |
||
26 | * @param $sorts |
||
27 | * @param string|null $property |
||
28 | * @param string|null $direction |
||
29 | */ |
||
30 | 22 | public function __construct($sorts, $property = null, $direction = null) |
|
36 | |||
37 | /** |
||
38 | * @param array $sortMap |
||
39 | * @return array |
||
40 | */ |
||
41 | 20 | public function getSorts(array $sortMap = array()) |
|
56 | |||
57 | /** |
||
58 | * @return array|string|null |
||
59 | */ |
||
60 | 20 | private function normalizeSorts($sorts) |
|
76 | |||
77 | /** |
||
78 | * @param $sort |
||
79 | * @return array |
||
80 | */ |
||
81 | 18 | private function extractSortProperty($sort) |
|
93 | |||
94 | /** |
||
95 | * @param array $sortMap |
||
96 | * @param $sort |
||
97 | * @param $direction |
||
98 | * @return Sort |
||
99 | */ |
||
100 | 18 | private function mapSortProperty(array $sortMap, $sort, $direction) |
|
108 | } |
||
109 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.