@@ -143,6 +143,9 @@ discard block |
||
| 143 | 143 | return $bool ? "\xc3" : "\xc2"; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | + /** |
|
| 147 | + * @param integer $int |
|
| 148 | + */ |
|
| 146 | 149 | public function packInt($int) |
| 147 | 150 | { |
| 148 | 151 | if ($int >= 0) { |
@@ -178,6 +181,9 @@ discard block |
||
| 178 | 181 | return \pack('CJ', 0xd3, $int); |
| 179 | 182 | } |
| 180 | 183 | |
| 184 | + /** |
|
| 185 | + * @param double $float |
|
| 186 | + */ |
|
| 181 | 187 | public function packFloat($float) |
| 182 | 188 | { |
| 183 | 189 | return $this->isForceFloat32 |
@@ -195,6 +201,9 @@ discard block |
||
| 195 | 201 | return "\xcb".\pack('E', $float); |
| 196 | 202 | } |
| 197 | 203 | |
| 204 | + /** |
|
| 205 | + * @param string $str |
|
| 206 | + */ |
|
| 198 | 207 | public function packStr($str) |
| 199 | 208 | { |
| 200 | 209 | $length = \strlen($str); |
@@ -212,6 +221,9 @@ discard block |
||
| 212 | 221 | return \pack('CN', 0xdb, $length).$str; |
| 213 | 222 | } |
| 214 | 223 | |
| 224 | + /** |
|
| 225 | + * @param string $str |
|
| 226 | + */ |
|
| 215 | 227 | public function packBin($str) |
| 216 | 228 | { |
| 217 | 229 | $length = \strlen($str); |
@@ -237,6 +249,9 @@ discard block |
||
| 237 | 249 | return $data; |
| 238 | 250 | } |
| 239 | 251 | |
| 252 | + /** |
|
| 253 | + * @param integer $size |
|
| 254 | + */ |
|
| 240 | 255 | public function packArrayHeader($size) |
| 241 | 256 | { |
| 242 | 257 | if ($size <= 0xf) { |
@@ -281,6 +296,9 @@ discard block |
||
| 281 | 296 | return $data; |
| 282 | 297 | } |
| 283 | 298 | |
| 299 | + /** |
|
| 300 | + * @param integer $size |
|
| 301 | + */ |
|
| 284 | 302 | public function packMapHeader($size) |
| 285 | 303 | { |
| 286 | 304 | if ($size <= 0xf) { |
@@ -293,6 +311,10 @@ discard block |
||
| 293 | 311 | return \pack('CN', 0xdf, $size); |
| 294 | 312 | } |
| 295 | 313 | |
| 314 | + /** |
|
| 315 | + * @param integer $type |
|
| 316 | + * @param string $data |
|
| 317 | + */ |
|
| 296 | 318 | public function packExt($type, $data) |
| 297 | 319 | { |
| 298 | 320 | $length = \strlen($data); |
@@ -593,6 +593,9 @@ discard block |
||
| 593 | 593 | throw UnpackingFailedException::unexpectedCode($c, 'ext'); |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | + /** |
|
| 597 | + * @param string $buffer |
|
| 598 | + */ |
|
| 596 | 599 | private static function unpackUint8($buffer, &$offset) |
| 597 | 600 | { |
| 598 | 601 | if (!isset($buffer[$offset])) { |
@@ -602,6 +605,9 @@ discard block |
||
| 602 | 605 | return \ord($buffer[$offset++]); |
| 603 | 606 | } |
| 604 | 607 | |
| 608 | + /** |
|
| 609 | + * @param string $buffer |
|
| 610 | + */ |
|
| 605 | 611 | private static function unpackUint16($buffer, &$offset) |
| 606 | 612 | { |
| 607 | 613 | if (!isset($buffer[$offset + 1])) { |
@@ -612,6 +618,9 @@ discard block |
||
| 612 | 618 | | \ord($buffer[$offset++]); |
| 613 | 619 | } |
| 614 | 620 | |
| 621 | + /** |
|
| 622 | + * @param string $buffer |
|
| 623 | + */ |
|
| 615 | 624 | private static function unpackUint32($buffer, &$offset) |
| 616 | 625 | { |
| 617 | 626 | if (!isset($buffer[$offset + 3])) { |
@@ -649,6 +658,9 @@ discard block |
||
| 649 | 658 | return \sprintf('%u', $num); |
| 650 | 659 | } |
| 651 | 660 | |
| 661 | + /** |
|
| 662 | + * @param string $buffer |
|
| 663 | + */ |
|
| 652 | 664 | private static function unpackInt8($buffer, &$offset) |
| 653 | 665 | { |
| 654 | 666 | if (!isset($buffer[$offset])) { |
@@ -661,6 +673,9 @@ discard block |
||
| 661 | 673 | return $num > 0x7f ? $num - 0x100 : $num; |
| 662 | 674 | } |
| 663 | 675 | |
| 676 | + /** |
|
| 677 | + * @param string $buffer |
|
| 678 | + */ |
|
| 664 | 679 | private static function unpackInt16($buffer, &$offset) |
| 665 | 680 | { |
| 666 | 681 | if (!isset($buffer[$offset + 1])) { |
@@ -674,6 +689,9 @@ discard block |
||
| 674 | 689 | return $num > 0x7fff ? $num - 0x10000 : $num; |
| 675 | 690 | } |
| 676 | 691 | |
| 692 | + /** |
|
| 693 | + * @param string $buffer |
|
| 694 | + */ |
|
| 677 | 695 | private static function unpackInt32($buffer, &$offset) |
| 678 | 696 | { |
| 679 | 697 | if (!isset($buffer[$offset + 3])) { |
@@ -689,6 +707,9 @@ discard block |
||
| 689 | 707 | return $num > 0x7fffffff ? $num - 0x100000000 : $num; |
| 690 | 708 | } |
| 691 | 709 | |
| 710 | + /** |
|
| 711 | + * @param string $buffer |
|
| 712 | + */ |
|
| 692 | 713 | private static function unpackInt64($buffer, &$offset) |
| 693 | 714 | { |
| 694 | 715 | if (!isset($buffer[$offset + 7])) { |
@@ -701,6 +722,9 @@ discard block |
||
| 701 | 722 | return $num; |
| 702 | 723 | } |
| 703 | 724 | |
| 725 | + /** |
|
| 726 | + * @param string $buffer |
|
| 727 | + */ |
|
| 704 | 728 | private static function unpackFloat32($buffer, &$offset) |
| 705 | 729 | { |
| 706 | 730 | if (!isset($buffer[$offset + 3])) { |
@@ -713,6 +737,9 @@ discard block |
||
| 713 | 737 | return $num; |
| 714 | 738 | } |
| 715 | 739 | |
| 740 | + /** |
|
| 741 | + * @param string $buffer |
|
| 742 | + */ |
|
| 716 | 743 | private static function unpackFloat64($buffer, &$offset) |
| 717 | 744 | { |
| 718 | 745 | if (!isset($buffer[$offset + 7])) { |
@@ -725,6 +752,9 @@ discard block |
||
| 725 | 752 | return $num; |
| 726 | 753 | } |
| 727 | 754 | |
| 755 | + /** |
|
| 756 | + * @param integer $length |
|
| 757 | + */ |
|
| 728 | 758 | private function unpackExtData($length) |
| 729 | 759 | { |
| 730 | 760 | $buffer = &$this->buffer; |
@@ -761,6 +791,10 @@ discard block |
||
| 761 | 791 | public $value; |
| 762 | 792 | public $key; |
| 763 | 793 | |
| 794 | + /** |
|
| 795 | + * @param integer $type |
|
| 796 | + * @param integer $size |
|
| 797 | + */ |
|
| 764 | 798 | public function __construct($type, $size) |
| 765 | 799 | { |
| 766 | 800 | $this->type = $type; |