1 | <?php |
||
23 | class DBResult implements Iterator, ArrayAccess, Countable{ |
||
24 | use Enumerable, Magic; |
||
25 | |||
26 | /** |
||
27 | * @var \chillerlan\Database\DBResultRow[] |
||
28 | */ |
||
29 | protected $array = []; |
||
30 | |||
31 | /** |
||
32 | * @var int |
||
33 | */ |
||
34 | protected $offset = 0; |
||
35 | protected $sourceEncoding; |
||
36 | protected $destEncoding; |
||
37 | |||
38 | /** |
||
39 | * DBResult constructor. |
||
40 | * |
||
41 | * @param \Traversable|\stdClass|array|null $data |
||
42 | * @param string|null $sourceEncoding |
||
43 | * @param string $destEncoding |
||
44 | * |
||
45 | * @throws \chillerlan\Database\DBException |
||
46 | */ |
||
47 | public function __construct($data = null, $sourceEncoding = null, $destEncoding = 'UTF-8'){ |
||
67 | |||
68 | /** |
||
69 | * @param \chillerlan\Database\DBResult $DBResult |
||
70 | * |
||
71 | * @return \chillerlan\Database\DBResult |
||
72 | */ |
||
73 | public function __merge(DBResult $DBResult){ |
||
84 | |||
85 | /** |
||
86 | * @link http://api.prototypejs.org/language/Enumerable/prototype/toArray/ |
||
87 | * |
||
88 | * @return array |
||
89 | */ |
||
90 | public function __toArray():array { |
||
99 | |||
100 | |||
101 | /********* |
||
102 | * magic * |
||
103 | *********/ |
||
104 | |||
105 | /** |
||
106 | * @return int |
||
107 | */ |
||
108 | protected function magic_get_length():int{ |
||
111 | |||
112 | |||
113 | /*************** |
||
114 | * ArrayAccess * |
||
115 | ***************/ |
||
116 | |||
117 | /** |
||
118 | * @param int|string $offset |
||
119 | * |
||
120 | * @return bool |
||
121 | */ |
||
122 | public function offsetExists($offset):bool{ |
||
125 | |||
126 | /** |
||
127 | * @param int|string $offset |
||
128 | * |
||
129 | * @return \chillerlan\Database\DBResultRow|mixed|null |
||
130 | */ |
||
131 | public function offsetGet($offset){ |
||
134 | |||
135 | /** |
||
136 | * @param int|string $offset |
||
137 | * @param array $value |
||
138 | * |
||
139 | * @return void |
||
140 | */ |
||
141 | public function offsetSet($offset, $value){ |
||
151 | |||
152 | /** |
||
153 | * @param int|string $offset |
||
154 | * |
||
155 | * @return void |
||
156 | */ |
||
157 | public function offsetUnset($offset){ |
||
160 | |||
161 | |||
162 | /************* |
||
163 | * Countable * |
||
164 | *************/ |
||
165 | |||
166 | /** |
||
167 | * @return int |
||
168 | */ |
||
169 | public function count():int{ |
||
172 | |||
173 | |||
174 | /************ |
||
175 | * Iterator * |
||
176 | ************/ |
||
177 | |||
178 | /** |
||
179 | * @return \chillerlan\Database\DBResultRow|mixed |
||
180 | */ |
||
181 | public function current(){ |
||
184 | |||
185 | /** |
||
186 | * @return int |
||
187 | */ |
||
188 | public function key():int{ |
||
191 | |||
192 | /** |
||
193 | * @return bool |
||
194 | */ |
||
195 | public function valid():bool{ |
||
198 | |||
199 | /** |
||
200 | * @return void |
||
201 | */ |
||
202 | public function next(){ |
||
205 | |||
206 | /** |
||
207 | * @return void |
||
208 | */ |
||
209 | public function rewind(){ |
||
212 | |||
213 | } |
||
214 |
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.