1 | <?php |
||
8 | class TemplateFactory |
||
9 | { |
||
10 | /** |
||
11 | * @var GmpMathInterface |
||
12 | */ |
||
13 | private $math; |
||
14 | |||
15 | /** |
||
16 | * @var \BitWasp\Buffertools\Template |
||
17 | */ |
||
18 | private $template; |
||
19 | |||
20 | /** |
||
21 | * @var TypeFactory |
||
22 | */ |
||
23 | private $types; |
||
24 | |||
25 | /** |
||
26 | * TemplateFactory constructor. |
||
27 | * @param Template|null $template |
||
28 | * @param GmpMathInterface|null $math |
||
29 | * @param TypeFactoryInterface|null $typeFactory |
||
30 | */ |
||
31 | public function __construct(Template $template = null, GmpMathInterface $math = null, TypeFactoryInterface $typeFactory = null) |
||
37 | |||
38 | /** |
||
39 | * Return the Template as it stands. |
||
40 | * |
||
41 | * @return Template |
||
42 | */ |
||
43 | public function getTemplate() |
||
47 | |||
48 | /** |
||
49 | * Add a Uint8 serializer to the template |
||
50 | * |
||
51 | * @return $this |
||
52 | */ |
||
53 | public function uint8() |
||
58 | |||
59 | /** |
||
60 | * Add a little-endian Uint8 serializer to the template |
||
61 | * |
||
62 | * @return $this |
||
63 | */ |
||
64 | public function uint8le() |
||
69 | |||
70 | /** |
||
71 | * Add a Uint16 serializer to the template |
||
72 | * |
||
73 | * @return $this |
||
74 | */ |
||
75 | public function uint16() |
||
80 | |||
81 | /** |
||
82 | * Add a little-endian Uint16 serializer to the template |
||
83 | * |
||
84 | * @return $this |
||
85 | */ |
||
86 | public function uint16le() |
||
91 | |||
92 | /** |
||
93 | * Add a Uint32 serializer to the template |
||
94 | * |
||
95 | * @return $this |
||
96 | */ |
||
97 | public function uint32() |
||
102 | |||
103 | /** |
||
104 | * Add a little-endian Uint32 serializer to the template |
||
105 | * |
||
106 | * @return $this |
||
107 | */ |
||
108 | public function uint32le() |
||
113 | |||
114 | /** |
||
115 | * Add a Uint64 serializer to the template |
||
116 | * |
||
117 | * @return $this |
||
118 | */ |
||
119 | public function uint64() |
||
124 | |||
125 | /** |
||
126 | * Add a little-endian Uint64 serializer to the template |
||
127 | * |
||
128 | * @return $this |
||
129 | */ |
||
130 | public function uint64le() |
||
135 | |||
136 | /** |
||
137 | * Add a Uint128 serializer to the template |
||
138 | * |
||
139 | * @return $this |
||
140 | */ |
||
141 | public function uint128() |
||
146 | |||
147 | /** |
||
148 | * Add a little-endian Uint128 serializer to the template |
||
149 | * |
||
150 | * @return $this |
||
151 | */ |
||
152 | public function uint128le() |
||
157 | |||
158 | /** |
||
159 | * Add a Uint256 serializer to the template |
||
160 | * |
||
161 | * @return $this |
||
162 | */ |
||
163 | public function uint256() |
||
168 | |||
169 | /** |
||
170 | * Add a little-endian Uint256 serializer to the template |
||
171 | * |
||
172 | * @return $this |
||
173 | */ |
||
174 | public function uint256le() |
||
179 | |||
180 | /** |
||
181 | * Add a int8 serializer to the template |
||
182 | * |
||
183 | * @return $this |
||
184 | */ |
||
185 | public function int8() |
||
190 | |||
191 | /** |
||
192 | * Add a little-endian Int8 serializer to the template |
||
193 | * |
||
194 | * @return $this |
||
195 | */ |
||
196 | public function int8le() |
||
201 | |||
202 | /** |
||
203 | * Add a int16 serializer to the template |
||
204 | * |
||
205 | * @return $this |
||
206 | */ |
||
207 | public function int16() |
||
212 | |||
213 | /** |
||
214 | * Add a little-endian Int16 serializer to the template |
||
215 | * |
||
216 | * @return $this |
||
217 | */ |
||
218 | public function int16le() |
||
223 | |||
224 | /** |
||
225 | * Add a int32 serializer to the template |
||
226 | * |
||
227 | * @return $this |
||
228 | */ |
||
229 | public function int32() |
||
234 | |||
235 | /** |
||
236 | * Add a little-endian Int serializer to the template |
||
237 | * |
||
238 | * @return $this |
||
239 | */ |
||
240 | public function int32le() |
||
245 | |||
246 | /** |
||
247 | * Add a int64 serializer to the template |
||
248 | * |
||
249 | * @return $this |
||
250 | */ |
||
251 | public function int64() |
||
256 | |||
257 | /** |
||
258 | * Add a little-endian Int64 serializer to the template |
||
259 | * |
||
260 | * @return $this |
||
261 | */ |
||
262 | public function int64le() |
||
267 | |||
268 | /** |
||
269 | * Add a int128 serializer to the template |
||
270 | * |
||
271 | * @return $this |
||
272 | */ |
||
273 | public function int128() |
||
278 | |||
279 | /** |
||
280 | * Add a little-endian Int128 serializer to the template |
||
281 | * |
||
282 | * @return $this |
||
283 | */ |
||
284 | public function int128le() |
||
289 | |||
290 | /** |
||
291 | * Add a int256 serializer to the template |
||
292 | * |
||
293 | * @return $this |
||
294 | */ |
||
295 | public function int256() |
||
300 | |||
301 | /** |
||
302 | * Add a little-endian Int256 serializer to the template |
||
303 | * |
||
304 | * @return $this |
||
305 | */ |
||
306 | public function int256le() |
||
311 | |||
312 | /** |
||
313 | * Add a VarInt serializer to the template |
||
314 | * |
||
315 | * @return $this |
||
316 | */ |
||
317 | public function varint() |
||
322 | |||
323 | /** |
||
324 | * Add a VarString serializer to the template |
||
325 | * |
||
326 | * @return $this |
||
327 | */ |
||
328 | public function varstring() |
||
333 | |||
334 | /** |
||
335 | * Add a byte string serializer to the template. This serializer requires a length to |
||
336 | * pad/truncate to. |
||
337 | * |
||
338 | * @param $length |
||
339 | * @return $this |
||
340 | */ |
||
341 | public function bytestring($length) |
||
346 | |||
347 | /** |
||
348 | * Add a little-endian byte string serializer to the template. This serializer requires |
||
349 | * a length to pad/truncate to. |
||
350 | * |
||
351 | * @param $length |
||
352 | * @return $this |
||
353 | */ |
||
354 | public function bytestringle($length) |
||
359 | |||
360 | /** |
||
361 | * Add a vector serializer to the template. A $readHandler must be provided if the |
||
362 | * template will be used to deserialize a vector, since it's contents are not known. |
||
363 | * |
||
364 | * The $readHandler should operate on the parser reference, reading the bytes for each |
||
365 | * item in the collection. |
||
366 | * |
||
367 | * @param callable $readHandler |
||
368 | * @return $this |
||
369 | */ |
||
370 | public function vector(callable $readHandler) |
||
375 | } |
||
376 |
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 given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.