コード例 #1
0
 public function testVarIntTooLarge()
 {
     //more than 5 bytes = failure
     //bin - 1000 0000 1000 0000 1000 0000 1000 0000 1000 0000 1000 0000
     //hex - 0x808080808080
     $data = hex2bin('808080808080');
     $this->setExpectedException('\\PublicUHC\\MinecraftAuth\\ReactServer\\InvalidDataException');
     VarInt::readUnsignedVarInt($data);
 }
コード例 #2
0
ファイル: jsr331.php プロジェクト: hemantshekhawat/Snippets
 public function variableArray($name, $min, $max, $size)
 {
     foreach (range(1, $size) as $i) {
         $var = new VarInt();
         $var->setName("name[{$i}]");
         $var->setValue(range($min, $max));
         $var->setDomainType(DomainType::DOMAIN_MIN_MAX);
         $this->add($var);
     }
 }
コード例 #3
0
 public static function write($data)
 {
     $stringLength = strlen($data);
     $stringLengthVarInt = VarInt::writeUnsignedVarInt($stringLength);
     return new StringType($data, $stringLengthVarInt->getEncoded() . $data, $stringLengthVarInt->getDataLength() + $stringLength);
 }