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 $position = 0; |
||
25 | |||
26 | /** |
||
27 | * Instantiate class, optionally taking Buffer or HEX. |
||
28 | * |
||
29 | * @param null|string|BufferInterface $input |
||
30 | * @param GmpMathInterface|null $math |
||
31 | */ |
||
32 | public function __construct($input = null, GmpMathInterface $math = null) |
||
43 | |||
44 | /** |
||
45 | * Get the position pointer of the parser - ie, how many bytes from 0 |
||
46 | * |
||
47 | * @return int |
||
48 | */ |
||
49 | public function getPosition() |
||
53 | |||
54 | /** |
||
55 | * Parse $bytes bytes from the string, and return the obtained buffer |
||
56 | * |
||
57 | * @param integer $bytes |
||
58 | * @param bool $flipBytes |
||
59 | * @return Buffer |
||
60 | * @throws \Exception |
||
61 | */ |
||
62 | public function readBytes($bytes, $flipBytes = false) |
||
81 | |||
82 | /** |
||
83 | * Write $data as $bytes bytes. Can be flipped if needed. |
||
84 | * |
||
85 | * @param integer $bytes |
||
86 | * @param $data |
||
87 | * @param bool $flipBytes |
||
88 | * @return $this |
||
89 | */ |
||
90 | public function writeBytes($bytes, $data, $flipBytes = false) |
||
108 | |||
109 | /** |
||
110 | * Write $data as $bytes bytes. Can be flipped if needed. |
||
111 | * |
||
112 | * @param integer $bytes |
||
113 | * @param string $data |
||
114 | * @param bool $flipBytes |
||
115 | * @return $this |
||
116 | */ |
||
117 | public function writeRawBinary($bytes, $data, $flipBytes = false) |
||
121 | |||
122 | /** |
||
123 | * @param BufferInterface $buffer |
||
124 | * @param bool $flipBytes |
||
125 | * @param int $bytes |
||
126 | * @return $this |
||
127 | */ |
||
128 | public function writeBuffer($bytes, BufferInterface $buffer, $flipBytes = false) |
||
139 | |||
140 | /** |
||
141 | * @param BufferInterface $buffer |
||
142 | * @param bool $flipBytes |
||
143 | * @return $this |
||
144 | */ |
||
145 | public function appendBuffer(BufferInterface $buffer, $flipBytes = false) |
||
150 | |||
151 | /** |
||
152 | * @param string $binary |
||
153 | * @param bool $flipBytes |
||
154 | * @return $this |
||
155 | */ |
||
156 | public function appendBinary($binary, $flipBytes = false) |
||
165 | |||
166 | /** |
||
167 | * Take an array containing serializable objects. |
||
168 | * @param SerializableInterface[]|Buffer[] |
||
169 | * @return $this |
||
170 | */ |
||
171 | public function writeArray($serializable) |
||
190 | |||
191 | /** |
||
192 | * Return the string as a buffer |
||
193 | * |
||
194 | * @return BufferInterface |
||
195 | */ |
||
196 | public function getBuffer() |
||
200 | } |
||
201 |
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.