55use Bolt \PackStream \IPacker ;
66use Bolt \error \PackException ;
77use Bolt \PackStream \{IPackListGenerator , IPackDictionaryGenerator };
8- use Generator ;
98use Bolt \structures \{
109 IStructure ,
1110 Date ,
@@ -52,10 +51,10 @@ class Packer implements IPacker
5251 * Pack message with parameters
5352 * @param $signature
5453 * @param mixed ...$params
55- * @return Generator
54+ * @return iterable
5655 * @throws PackException
5756 */
58- public function pack ($ signature , ...$ params ): Generator
57+ public function pack ($ signature , ...$ params ): iterable
5958 {
6059 $ this ->littleEndian = unpack ('S ' , "\x01\x00" )[1 ] === 1 ;
6160
@@ -91,9 +90,10 @@ public function pack($signature, ...$params): Generator
9190
9291 /**
9392 * @param mixed $param
93+ * @return iterable
9494 * @throws PackException
9595 */
96- private function p ($ param ): Generator
96+ private function p ($ param ): iterable
9797 {
9898 switch (gettype ($ param )) {
9999 case 'integer ' :
@@ -139,10 +139,10 @@ private function p($param): Generator
139139
140140 /**
141141 * @param string $str
142- * @return Generator
142+ * @return iterable
143143 * @throws PackException
144144 */
145- private function packString (string $ str ): Generator
145+ private function packString (string $ str ): iterable
146146 {
147147 $ length = mb_strlen ($ str , '8bit ' );
148148
@@ -161,20 +161,20 @@ private function packString(string $str): Generator
161161
162162 /**
163163 * @param float $value
164- * @return Generator
164+ * @return iterable
165165 */
166- private function packFloat (float $ value ): Generator
166+ private function packFloat (float $ value ): iterable
167167 {
168168 $ packed = pack ('d ' , $ value );
169169 yield chr (0xC1 ) . ($ this ->littleEndian ? strrev ($ packed ) : $ packed );
170170 }
171171
172172 /**
173173 * @param int $value
174- * @return Generator
174+ * @return iterable
175175 * @throws PackException
176176 */
177- private function packInteger (int $ value ): Generator
177+ private function packInteger (int $ value ): iterable
178178 {
179179 if ($ value >= -16 && $ value <= 127 ) { //TINY_INT
180180 yield pack ('c ' , $ value );
@@ -196,10 +196,10 @@ private function packInteger(int $value): Generator
196196
197197 /**
198198 * @param array|IPackDictionaryGenerator $param
199- * @return Generator
199+ * @return iterable
200200 * @throws PackException
201201 */
202- private function packDictionary ($ param ): Generator
202+ private function packDictionary ($ param ): iterable
203203 {
204204 $ size = is_array ($ param ) ? count ($ param ) : $ param ->count ();
205205
@@ -223,10 +223,10 @@ private function packDictionary($param): Generator
223223
224224 /**
225225 * @param array|IPackListGenerator $param
226- * @return Generator
226+ * @return iterable
227227 * @throws PackException
228228 */
229- private function packList ($ param ): Generator
229+ private function packList ($ param ): iterable
230230 {
231231 $ size = is_array ($ param ) ? count ($ param ) : $ param ->count ();
232232
@@ -249,10 +249,10 @@ private function packList($param): Generator
249249
250250 /**
251251 * @param IStructure $structure
252- * @return Generator
252+ * @return iterable
253253 * @throws PackException
254254 */
255- private function packStructure (IStructure $ structure ): Generator
255+ private function packStructure (IStructure $ structure ): iterable
256256 {
257257 $ arr = $ this ->structuresLt [get_class ($ structure )] ?? null ;
258258 if ($ arr === null ) {
@@ -268,10 +268,10 @@ private function packStructure(IStructure $structure): Generator
268268
269269 /**
270270 * @param Bytes $bytes
271- * @return Generator
271+ * @return iterable
272272 * @throws PackException
273273 */
274- private function packByteArray (Bytes $ bytes ): Generator
274+ private function packByteArray (Bytes $ bytes ): iterable
275275 {
276276 $ size = count ($ bytes );
277277 if ($ size < self ::MEDIUM ) {
0 commit comments