1 | <?php |
||
9 | class Parser |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | private $string = ''; |
||
15 | |||
16 | /** |
||
17 | * @var int |
||
18 | */ |
||
19 | private $size = 0; |
||
20 | |||
21 | /** |
||
22 | * @var int |
||
23 | */ |
||
24 | private $position = 0; |
||
25 | |||
26 | /** |
||
27 | * Instantiate class, optionally taking Buffer or HEX. |
||
28 | * |
||
29 | * @param BufferInterface $input |
||
30 | */ |
||
31 | 164 | public function __construct(BufferInterface $input = null) |
|
39 | 142 | ||
40 | 142 | /** |
|
41 | * Get the position pointer of the parser - ie, how many bytes from 0 |
||
42 | * |
||
43 | * @return int |
||
44 | */ |
||
45 | 164 | public function getPosition(): int |
|
49 | |||
50 | /** |
||
51 | * Get the total size of the parser |
||
52 | * |
||
53 | * @return int |
||
54 | */ |
||
55 | 148 | public function getSize() |
|
59 | |||
60 | /** |
||
61 | * Parse $bytes bytes from the string, and return the obtained buffer |
||
62 | * |
||
63 | * @param int $numBytes |
||
64 | * @param bool $flipBytes |
||
65 | 16 | * @return BufferInterface |
|
66 | * @throws \Exception |
||
67 | 16 | */ |
|
68 | public function readBytes(int $numBytes, bool $flipBytes = false): BufferInterface |
||
88 | |||
89 | 142 | /** |
|
90 | * @param BufferInterface $buffer |
||
91 | 142 | * @param bool $flipBytes |
|
92 | 2 | * @return Parser |
|
93 | */ |
||
94 | public function appendBuffer(BufferInterface $buffer, bool $flipBytes = false): Parser |
||
99 | |||
100 | /** |
||
101 | * @param string $binary |
||
102 | * @param bool $flipBytes |
||
103 | * @return Parser |
||
104 | */ |
||
105 | public function appendBinary(string $binary, bool $flipBytes = false): Parser |
||
115 | |||
116 | /** |
||
117 | 10 | * Take an array containing serializable objects. |
|
118 | * @param SerializableInterface[]|BufferInterface[] $serializable |
||
119 | * @return Parser |
||
120 | */ |
||
121 | 10 | public function writeArray(array $serializable): Parser |
|
141 | |||
142 | /** |
||
143 | * Return the string as a buffer |
||
144 | * |
||
145 | 10 | * @return BufferInterface |
|
146 | */ |
||
147 | public function getBuffer(): BufferInterface |
||
151 | } |
||
152 |
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.