mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
more typehints, removed more 32-bit leftovers
This commit is contained in:
@ -382,12 +382,11 @@ class Binary{
|
||||
|
||||
/**
|
||||
* Reads an 8-byte integer.
|
||||
* Note that this method will return a string on 32-bit PHP.
|
||||
*
|
||||
* @param string $x
|
||||
* @return int|string
|
||||
* @return int
|
||||
*/
|
||||
public static function readLong(string $x){
|
||||
public static function readLong(string $x) : int{
|
||||
self::checkLength($x, 8);
|
||||
$int = unpack("N*", $x);
|
||||
return ($int[1] << 32) | $int[2];
|
||||
@ -396,10 +395,10 @@ class Binary{
|
||||
/**
|
||||
* Writes an 8-byte integer.
|
||||
*
|
||||
* @param int|string $value
|
||||
* @param int $value
|
||||
* @return string
|
||||
*/
|
||||
public static function writeLong($value) : string{
|
||||
public static function writeLong(int $value) : string{
|
||||
return pack("NN", $value >> 32, $value & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
@ -407,19 +406,19 @@ class Binary{
|
||||
* Reads an 8-byte little-endian integer.
|
||||
*
|
||||
* @param string $str
|
||||
* @return int|string
|
||||
* @return int
|
||||
*/
|
||||
public static function readLLong(string $str){
|
||||
public static function readLLong(string $str) : int{
|
||||
return self::readLong(strrev($str));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an 8-byte little-endian integer.
|
||||
*
|
||||
* @param int|string $value
|
||||
* @param int $value
|
||||
* @return string
|
||||
*/
|
||||
public static function writeLLong($value) : string{
|
||||
public static function writeLLong(int $value) : string{
|
||||
return strrev(self::writeLong($value));
|
||||
}
|
||||
|
||||
|
@ -191,30 +191,30 @@ class BinaryStream{
|
||||
|
||||
|
||||
/**
|
||||
* @return int|string
|
||||
* @return int
|
||||
*/
|
||||
public function getLong(){
|
||||
public function getLong() : int{
|
||||
return Binary::readLong($this->get(8));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|string $v
|
||||
* @param int $v
|
||||
*/
|
||||
public function putLong($v){
|
||||
public function putLong(int $v){
|
||||
$this->buffer .= Binary::writeLong($v);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|string
|
||||
* @return int
|
||||
*/
|
||||
public function getLLong(){
|
||||
public function getLLong() : int{
|
||||
return Binary::readLLong($this->get(8));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|string $v
|
||||
* @param int $v
|
||||
*/
|
||||
public function putLLong($v){
|
||||
public function putLLong(int $v){
|
||||
$this->buffer .= Binary::writeLLong($v);
|
||||
}
|
||||
|
||||
@ -337,33 +337,33 @@ class BinaryStream{
|
||||
|
||||
/**
|
||||
* Reads a 64-bit variable-length integer from the buffer and returns it.
|
||||
* @return int|string int, or the string representation of an int64 on 32-bit platforms
|
||||
* @return int
|
||||
*/
|
||||
public function getUnsignedVarLong(){
|
||||
public function getUnsignedVarLong() : int{
|
||||
return Binary::readUnsignedVarLong($this->buffer, $this->offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a 64-bit variable-length integer to the end of the buffer.
|
||||
* @param int|string $v int, or the string representation of an int64 on 32-bit platforms
|
||||
* @param int $v
|
||||
*/
|
||||
public function putUnsignedVarLong($v){
|
||||
public function putUnsignedVarLong(int $v){
|
||||
$this->buffer .= Binary::writeUnsignedVarLong($v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a 64-bit zigzag-encoded variable-length integer from the buffer and returns it.
|
||||
* @return int|string int, or the string representation of an int64 on 32-bit platforms
|
||||
* @return int
|
||||
*/
|
||||
public function getVarLong(){
|
||||
public function getVarLong() : int{
|
||||
return Binary::readVarLong($this->buffer, $this->offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a 64-bit zigzag-encoded variable-length integer to the end of the buffer.
|
||||
* @param int|string $v int, or the string representation of an int64 on 32-bit platforms
|
||||
* @param int
|
||||
*/
|
||||
public function putVarLong($v){
|
||||
public function putVarLong(int $v){
|
||||
$this->buffer .= Binary::writeVarLong($v);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user