1 | <?php |
||
10 | class Parser implements \Iterator |
||
11 | { |
||
12 | /** |
||
13 | * @var Math |
||
14 | */ |
||
15 | private $math; |
||
16 | |||
17 | /** |
||
18 | * @var Buffer |
||
19 | */ |
||
20 | private $empty; |
||
21 | |||
22 | /** |
||
23 | * @var int |
||
24 | */ |
||
25 | private $position = 0; |
||
26 | |||
27 | /** |
||
28 | * @var int |
||
29 | */ |
||
30 | private $end = 0; |
||
31 | |||
32 | /** |
||
33 | * @var int |
||
34 | */ |
||
35 | private $execPtr = 0; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | private $data = ''; |
||
41 | |||
42 | /** |
||
43 | * @var Operation[] |
||
44 | */ |
||
45 | private $array = array(); |
||
46 | |||
47 | /** |
||
48 | * ScriptParser constructor. |
||
49 | * @param Math $math |
||
50 | * @param ScriptInterface $script |
||
51 | */ |
||
52 | 1125 | public function __construct(Math $math, ScriptInterface $script) |
|
61 | |||
62 | /** |
||
63 | * @return int |
||
64 | */ |
||
65 | public function getPosition() |
||
69 | |||
70 | /** |
||
71 | * @param string $packFormat |
||
72 | * @param integer $strSize |
||
73 | * @return array|bool |
||
74 | */ |
||
75 | 54 | private function unpackSize($packFormat, $strSize) |
|
86 | |||
87 | /** |
||
88 | * @param int $size |
||
89 | * @return bool |
||
90 | */ |
||
91 | 771 | private function validateSize($size) |
|
100 | |||
101 | /** |
||
102 | * @param int $ptr |
||
103 | * @return Operation |
||
104 | */ |
||
105 | 1041 | private function doNext($ptr) |
|
139 | |||
140 | /** |
||
141 | * |
||
142 | */ |
||
143 | 1083 | public function rewind() |
|
147 | |||
148 | /** |
||
149 | * @return Operation |
||
150 | */ |
||
151 | 1041 | public function current() |
|
161 | |||
162 | /** |
||
163 | * @return int |
||
164 | */ |
||
165 | public function key() |
||
169 | |||
170 | /** |
||
171 | * @return Operation |
||
172 | */ |
||
173 | 1065 | public function next() |
|
183 | |||
184 | /** |
||
185 | * @return bool |
||
186 | */ |
||
187 | 1083 | public function valid() |
|
191 | |||
192 | /** |
||
193 | * returns a mix of Buffer objects and strings |
||
194 | * |
||
195 | * @return Buffer[]|string[] |
||
196 | */ |
||
197 | 915 | public function parse() |
|
218 | |||
219 | /** |
||
220 | * @return Operation[] |
||
221 | */ |
||
222 | 687 | public function decode() |
|
231 | |||
232 | /** |
||
233 | * @return string |
||
234 | */ |
||
235 | 672 | public function getHumanReadable() |
|
250 | } |
||
251 |
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.