1 | <?php |
||
13 | class ApiDataSource implements IDataSource |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $data = []; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $url; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $query_params; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $sort_column; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $order_column; |
||
40 | |||
41 | /** |
||
42 | * @var int |
||
43 | */ |
||
44 | protected $limit; |
||
45 | |||
46 | /** |
||
47 | * @var int |
||
48 | */ |
||
49 | protected $offset; |
||
50 | |||
51 | /** |
||
52 | * @var int |
||
53 | */ |
||
54 | protected $filter_one = 0; |
||
55 | |||
56 | /** |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $filter = []; |
||
60 | |||
61 | |||
62 | /** |
||
63 | * @param string $url |
||
64 | */ |
||
65 | public function __construct($url, array $query_params = []) |
||
70 | |||
71 | |||
72 | /** |
||
73 | * Get data of remote source |
||
74 | * @param array $params |
||
75 | * @return mixed |
||
76 | */ |
||
77 | protected function getResponse(array $params = []) |
||
83 | |||
84 | |||
85 | /******************************************************************************** |
||
86 | * IDataSource implementation * |
||
87 | ********************************************************************************/ |
||
88 | |||
89 | |||
90 | /** |
||
91 | * Get count of data |
||
92 | * @return int |
||
93 | */ |
||
94 | public function getCount() |
||
98 | |||
99 | |||
100 | /** |
||
101 | * Get the data |
||
102 | * @return array |
||
103 | */ |
||
104 | public function getData() |
||
115 | |||
116 | |||
117 | /** |
||
118 | * Filter data |
||
119 | * @param array $filters |
||
120 | * @return static |
||
121 | */ |
||
122 | public function filter(array $filters) |
||
152 | |||
153 | |||
154 | /** |
||
155 | * Filter data - get one row |
||
156 | * @param array $condition |
||
157 | * @return static |
||
158 | */ |
||
159 | public function filterOne(array $condition) |
||
166 | |||
167 | |||
168 | /** |
||
169 | * Apply limit and offset on data |
||
170 | * @param int $offset |
||
171 | * @param int $limit |
||
172 | * @return static |
||
173 | */ |
||
174 | public function limit($offset, $limit) |
||
181 | |||
182 | |||
183 | /** |
||
184 | * Sort data |
||
185 | * @param Sorting $sorting |
||
186 | * @return static |
||
187 | */ |
||
188 | public function sort(Sorting $sorting) |
||
200 | |||
201 | /** |
||
202 | * @param string $aggregation_type |
||
203 | * @param string $column |
||
204 | * @return mixed |
||
205 | */ |
||
206 | public function addAggregationColumn($aggregation_type, $column) |
||
210 | |||
211 | /** |
||
212 | * get aggregation row |
||
213 | * @return array |
||
214 | */ |
||
215 | public function getAggregationData() |
||
219 | } |
||
220 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.