1 | <?php |
||
9 | class Parser |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | private $string; |
||
15 | |||
16 | /** |
||
17 | * @var \Mdanter\Ecc\Math\GmpMathInterface |
||
18 | */ |
||
19 | private $math; |
||
20 | |||
21 | /** |
||
22 | * @var int |
||
23 | */ |
||
24 | private $size = 0; |
||
25 | |||
26 | /** |
||
27 | * @var int |
||
28 | */ |
||
29 | private $position = 0; |
||
30 | |||
31 | /** |
||
32 | * Instantiate class, optionally taking Buffer or HEX. |
||
33 | * |
||
34 | * @param null|string|BufferInterface $input |
||
35 | * @param GmpMathInterface|null $math |
||
36 | */ |
||
37 | public function __construct($input = null, GmpMathInterface $math = null) |
||
49 | |||
50 | /** |
||
51 | * Get the position pointer of the parser - ie, how many bytes from 0 |
||
52 | * |
||
53 | * @return int |
||
54 | */ |
||
55 | public function getPosition() |
||
59 | |||
60 | /** |
||
61 | * Get the total size of the parser |
||
62 | * |
||
63 | * @return int |
||
64 | */ |
||
65 | public function getSize() |
||
69 | |||
70 | /** |
||
71 | * Parse $bytes bytes from the string, and return the obtained buffer |
||
72 | * |
||
73 | * @param integer $bytes |
||
74 | * @param bool $flipBytes |
||
75 | * @return Buffer |
||
76 | * @throws \Exception |
||
77 | */ |
||
78 | public function readBytes($bytes, $flipBytes = false) |
||
97 | |||
98 | /** |
||
99 | * Write $data as $bytes bytes. Can be flipped if needed. |
||
100 | * |
||
101 | * @param integer $bytes |
||
102 | * @param $data |
||
103 | * @param bool $flipBytes |
||
104 | * @return $this |
||
105 | */ |
||
106 | public function writeBytes($bytes, $data, $flipBytes = false) |
||
124 | |||
125 | /** |
||
126 | * Write $data as $bytes bytes. Can be flipped if needed. |
||
127 | * |
||
128 | * @param integer $bytes |
||
129 | * @param string $data |
||
130 | * @param bool $flipBytes |
||
131 | * @return $this |
||
132 | */ |
||
133 | public function writeRawBinary($bytes, $data, $flipBytes = false) |
||
137 | |||
138 | /** |
||
139 | * @param BufferInterface $buffer |
||
140 | * @param bool $flipBytes |
||
141 | * @param int $bytes |
||
142 | * @return $this |
||
143 | */ |
||
144 | public function writeBuffer($bytes, BufferInterface $buffer, $flipBytes = false) |
||
155 | |||
156 | /** |
||
157 | * @param BufferInterface $buffer |
||
158 | * @param bool $flipBytes |
||
159 | * @return $this |
||
160 | */ |
||
161 | public function appendBuffer(BufferInterface $buffer, $flipBytes = false) |
||
166 | |||
167 | /** |
||
168 | * @param string $binary |
||
169 | * @param bool $flipBytes |
||
170 | * @return $this |
||
171 | */ |
||
172 | public function appendBinary($binary, $flipBytes = false) |
||
182 | |||
183 | /** |
||
184 | * Take an array containing serializable objects. |
||
185 | * @param SerializableInterface[]|Buffer[] |
||
186 | * @return $this |
||
187 | */ |
||
188 | public function writeArray($serializable) |
||
208 | |||
209 | /** |
||
210 | * Return the string as a buffer |
||
211 | * |
||
212 | * @return BufferInterface |
||
213 | */ |
||
214 | public function getBuffer() |
||
218 | } |
||
219 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.