diff --git a/src/pocketmine/nbt/tag/ByteArrayTag.php b/src/pocketmine/nbt/tag/ByteArrayTag.php index 1a92a23c5..641a490ef 100644 --- a/src/pocketmine/nbt/tag/ByteArrayTag.php +++ b/src/pocketmine/nbt/tag/ByteArrayTag.php @@ -39,15 +39,15 @@ class ByteArrayTag extends NamedTag{ parent::__construct($name, $value); } - public function getType(){ + public function getType() : int{ return NBT::TAG_ByteArray; } - public function read(NBT $nbt, bool $network = false){ + public function read(NBT $nbt, bool $network = false) : void{ $this->value = $nbt->get($nbt->getInt($network)); } - public function write(NBT $nbt, bool $network = false){ + public function write(NBT $nbt, bool $network = false) : void{ $nbt->putInt(strlen($this->value), $network); $nbt->put($this->value); } @@ -64,7 +64,7 @@ class ByteArrayTag extends NamedTag{ * * @throws \TypeError */ - public function setValue($value){ + public function setValue($value) : void{ if(!is_string($value)){ throw new \TypeError("ByteArrayTag value must be of type string, " . gettype($value) . " given"); } diff --git a/src/pocketmine/nbt/tag/ByteTag.php b/src/pocketmine/nbt/tag/ByteTag.php index 6a5c9311f..21cc6c213 100644 --- a/src/pocketmine/nbt/tag/ByteTag.php +++ b/src/pocketmine/nbt/tag/ByteTag.php @@ -39,15 +39,15 @@ class ByteTag extends NamedTag{ parent::__construct($name, $value); } - public function getType(){ + public function getType() : int{ return NBT::TAG_Byte; } - public function read(NBT $nbt, bool $network = false){ + public function read(NBT $nbt, bool $network = false) : void{ $this->value = $nbt->getSignedByte(); } - public function write(NBT $nbt, bool $network = false){ + public function write(NBT $nbt, bool $network = false) : void{ $nbt->putByte($this->value); } @@ -63,7 +63,7 @@ class ByteTag extends NamedTag{ * * @throws \TypeError */ - public function setValue($value){ + public function setValue($value) : void{ if(!is_int($value)){ throw new \TypeError("ByteTag value must be of type int, " . gettype($value) . " given"); }elseif($value < -(2 ** 7) or $value > ((2 ** 7) - 1)){ diff --git a/src/pocketmine/nbt/tag/CompoundTag.php b/src/pocketmine/nbt/tag/CompoundTag.php index 844213e35..1e83cafe7 100644 --- a/src/pocketmine/nbt/tag/CompoundTag.php +++ b/src/pocketmine/nbt/tag/CompoundTag.php @@ -55,7 +55,7 @@ class CompoundTag extends NamedTag implements \ArrayAccess{ * * @throws \TypeError */ - public function setValue($value){ + public function setValue($value) : void{ if(is_array($value)){ foreach($value as $name => $tag){ if($tag instanceof NamedTag){ @@ -385,11 +385,11 @@ class CompoundTag extends NamedTag implements \ArrayAccess{ unset($this->{$offset}); } - public function getType(){ + public function getType() : int{ return NBT::TAG_Compound; } - public function read(NBT $nbt, bool $network = false){ + public function read(NBT $nbt, bool $network = false) : void{ $this->value = []; do{ $tag = $nbt->readTag($network); @@ -399,7 +399,7 @@ class CompoundTag extends NamedTag implements \ArrayAccess{ }while(!($tag instanceof EndTag) and !$nbt->feof()); } - public function write(NBT $nbt, bool $network = false){ + public function write(NBT $nbt, bool $network = false) : void{ foreach($this as $tag){ if($tag instanceof Tag and !($tag instanceof EndTag)){ $nbt->writeTag($tag, $network); diff --git a/src/pocketmine/nbt/tag/DoubleTag.php b/src/pocketmine/nbt/tag/DoubleTag.php index e60647daf..7fa31e5d9 100644 --- a/src/pocketmine/nbt/tag/DoubleTag.php +++ b/src/pocketmine/nbt/tag/DoubleTag.php @@ -39,15 +39,15 @@ class DoubleTag extends NamedTag{ parent::__construct($name, $value); } - public function getType(){ + public function getType() : int{ return NBT::TAG_Double; } - public function read(NBT $nbt, bool $network = false){ + public function read(NBT $nbt, bool $network = false) : void{ $this->value = $nbt->getDouble(); } - public function write(NBT $nbt, bool $network = false){ + public function write(NBT $nbt, bool $network = false) : void{ $nbt->putDouble($this->value); } @@ -63,7 +63,7 @@ class DoubleTag extends NamedTag{ * * @throws \TypeError */ - public function setValue($value){ + public function setValue($value) : void{ if(!is_float($value) and !is_int($value)){ throw new \TypeError("DoubleTag value must be of type double, " . gettype($value) . " given"); } diff --git a/src/pocketmine/nbt/tag/EndTag.php b/src/pocketmine/nbt/tag/EndTag.php index 19ea1e558..3fca03005 100644 --- a/src/pocketmine/nbt/tag/EndTag.php +++ b/src/pocketmine/nbt/tag/EndTag.php @@ -27,15 +27,15 @@ use pocketmine\nbt\NBT; class EndTag extends Tag{ - public function getType(){ + public function getType() : int{ return NBT::TAG_End; } - public function read(NBT $nbt, bool $network = false){ + public function read(NBT $nbt, bool $network = false) : void{ } - public function write(NBT $nbt, bool $network = false){ + public function write(NBT $nbt, bool $network = false) : void{ } } \ No newline at end of file diff --git a/src/pocketmine/nbt/tag/FloatTag.php b/src/pocketmine/nbt/tag/FloatTag.php index b0cea1fb3..9923f4fec 100644 --- a/src/pocketmine/nbt/tag/FloatTag.php +++ b/src/pocketmine/nbt/tag/FloatTag.php @@ -39,15 +39,15 @@ class FloatTag extends NamedTag{ parent::__construct($name, $value); } - public function getType(){ + public function getType() : int{ return NBT::TAG_Float; } - public function read(NBT $nbt, bool $network = false){ + public function read(NBT $nbt, bool $network = false) : void{ $this->value = $nbt->getFloat(); } - public function write(NBT $nbt, bool $network = false){ + public function write(NBT $nbt, bool $network = false) : void{ $nbt->putFloat($this->value); } @@ -58,7 +58,7 @@ class FloatTag extends NamedTag{ return parent::getValue(); } - public function setValue($value){ + public function setValue($value) : void{ if(!is_float($value) and !is_int($value)){ throw new \TypeError("FloatTag value must be of type float, " . gettype($value) . " given"); } diff --git a/src/pocketmine/nbt/tag/IntArrayTag.php b/src/pocketmine/nbt/tag/IntArrayTag.php index f409f7fb6..bb1c9e8ea 100644 --- a/src/pocketmine/nbt/tag/IntArrayTag.php +++ b/src/pocketmine/nbt/tag/IntArrayTag.php @@ -39,16 +39,16 @@ class IntArrayTag extends NamedTag{ parent::__construct($name, $value); } - public function getType(){ + public function getType() : int{ return NBT::TAG_IntArray; } - public function read(NBT $nbt, bool $network = false){ + public function read(NBT $nbt, bool $network = false) : void{ $size = $nbt->getInt($network); $this->value = array_values(unpack($nbt->endianness === NBT::LITTLE_ENDIAN ? "V*" : "N*", $nbt->get($size * 4))); } - public function write(NBT $nbt, bool $network = false){ + public function write(NBT $nbt, bool $network = false) : void{ $nbt->putInt(count($this->value), $network); $nbt->put(pack($nbt->endianness === NBT::LITTLE_ENDIAN ? "V*" : "N*", ...$this->value)); } @@ -71,7 +71,7 @@ class IntArrayTag extends NamedTag{ * * @throws \TypeError */ - public function setValue($value){ + public function setValue($value) : void{ if(!is_array($value)){ throw new \TypeError("IntArrayTag value must be of type int[], " . gettype($value) . " given"); } diff --git a/src/pocketmine/nbt/tag/IntTag.php b/src/pocketmine/nbt/tag/IntTag.php index 990433808..da4e555db 100644 --- a/src/pocketmine/nbt/tag/IntTag.php +++ b/src/pocketmine/nbt/tag/IntTag.php @@ -37,15 +37,15 @@ class IntTag extends NamedTag{ parent::__construct($name, $value); } - public function getType(){ + public function getType() : int{ return NBT::TAG_Int; } - public function read(NBT $nbt, bool $network = false){ + public function read(NBT $nbt, bool $network = false) : void{ $this->value = $nbt->getInt($network); } - public function write(NBT $nbt, bool $network = false){ + public function write(NBT $nbt, bool $network = false) : void{ $nbt->putInt($this->value, $network); } @@ -61,7 +61,7 @@ class IntTag extends NamedTag{ * * @throws \TypeError */ - public function setValue($value){ + public function setValue($value) : void{ if(!is_int($value)){ throw new \TypeError("IntTag value must be of type int, " . gettype($value) . " given"); }elseif($value < -(2 ** 31) or $value > ((2 ** 31) - 1)){ diff --git a/src/pocketmine/nbt/tag/ListTag.php b/src/pocketmine/nbt/tag/ListTag.php index c03fb0f7c..bb0501ce5 100644 --- a/src/pocketmine/nbt/tag/ListTag.php +++ b/src/pocketmine/nbt/tag/ListTag.php @@ -63,7 +63,7 @@ class ListTag extends NamedTag implements \ArrayAccess, \Countable{ * * @throws \TypeError */ - public function setValue($value){ + public function setValue($value) : void{ if(is_array($value)){ foreach($value as $name => $tag){ if($tag instanceof NamedTag){ @@ -129,7 +129,7 @@ class ListTag extends NamedTag implements \ArrayAccess, \Countable{ return $count; } - public function getType(){ + public function getType() : int{ return NBT::TAG_List; } @@ -141,7 +141,7 @@ class ListTag extends NamedTag implements \ArrayAccess, \Countable{ return $this->tagType; } - public function read(NBT $nbt, bool $network = false){ + public function read(NBT $nbt, bool $network = false) : void{ $this->value = []; $this->tagType = $nbt->getByte(); $size = $nbt->getInt($network); @@ -154,7 +154,7 @@ class ListTag extends NamedTag implements \ArrayAccess, \Countable{ } } - public function write(NBT $nbt, bool $network = false){ + public function write(NBT $nbt, bool $network = false) : void{ if($this->tagType === NBT::TAG_End){ //previously empty list, try detecting type from tag children $id = NBT::TAG_End; foreach($this as $tag){ @@ -162,7 +162,7 @@ class ListTag extends NamedTag implements \ArrayAccess, \Countable{ if($id === NBT::TAG_End){ $id = $tag->getType(); }elseif($id !== $tag->getType()){ - return false; + return; //TODO: throw exception? } } } @@ -182,8 +182,6 @@ class ListTag extends NamedTag implements \ArrayAccess, \Countable{ foreach($tags as $tag){ $tag->write($nbt, $network); } - - return true; } public function __toString(){ diff --git a/src/pocketmine/nbt/tag/LongTag.php b/src/pocketmine/nbt/tag/LongTag.php index c10d05e3d..fe1e1fff2 100644 --- a/src/pocketmine/nbt/tag/LongTag.php +++ b/src/pocketmine/nbt/tag/LongTag.php @@ -39,15 +39,15 @@ class LongTag extends NamedTag{ parent::__construct($name, $value); } - public function getType(){ + public function getType() : int{ return NBT::TAG_Long; } - public function read(NBT $nbt, bool $network = false){ + public function read(NBT $nbt, bool $network = false) : void{ $this->value = $nbt->getLong($network); } - public function write(NBT $nbt, bool $network = false){ + public function write(NBT $nbt, bool $network = false) : void{ $nbt->putLong($this->value, $network); } diff --git a/src/pocketmine/nbt/tag/NamedTag.php b/src/pocketmine/nbt/tag/NamedTag.php index 745bbe1e2..4e5cda766 100644 --- a/src/pocketmine/nbt/tag/NamedTag.php +++ b/src/pocketmine/nbt/tag/NamedTag.php @@ -25,7 +25,7 @@ namespace pocketmine\nbt\tag; abstract class NamedTag extends Tag{ - + /** @var string */ protected $__name; /** @@ -39,11 +39,17 @@ abstract class NamedTag extends Tag{ } } - public function getName(){ + /** + * @return string + */ + public function getName() : string{ return $this->__name; } - public function setName($name){ + /** + * @param string $name + */ + public function setName(string $name) : void{ $this->__name = $name; } } \ No newline at end of file diff --git a/src/pocketmine/nbt/tag/ShortTag.php b/src/pocketmine/nbt/tag/ShortTag.php index 2c833e804..70338fbad 100644 --- a/src/pocketmine/nbt/tag/ShortTag.php +++ b/src/pocketmine/nbt/tag/ShortTag.php @@ -39,15 +39,15 @@ class ShortTag extends NamedTag{ parent::__construct($name, $value); } - public function getType(){ + public function getType() : int{ return NBT::TAG_Short; } - public function read(NBT $nbt, bool $network = false){ + public function read(NBT $nbt, bool $network = false) : void{ $this->value = $nbt->getSignedShort(); } - public function write(NBT $nbt, bool $network = false){ + public function write(NBT $nbt, bool $network = false) : void{ $nbt->putShort($this->value); } @@ -63,7 +63,7 @@ class ShortTag extends NamedTag{ * * @throws \TypeError */ - public function setValue($value){ + public function setValue($value) : void{ if(!is_int($value)){ throw new \TypeError("ShortTag value must be of type int, " . gettype($value) . " given"); }elseif($value < -(2 ** 15) or $value > ((2 ** 15) - 1)){ diff --git a/src/pocketmine/nbt/tag/StringTag.php b/src/pocketmine/nbt/tag/StringTag.php index 1f3e1c41b..8ed19757a 100644 --- a/src/pocketmine/nbt/tag/StringTag.php +++ b/src/pocketmine/nbt/tag/StringTag.php @@ -39,15 +39,15 @@ class StringTag extends NamedTag{ parent::__construct($name, $value); } - public function getType(){ + public function getType() : int{ return NBT::TAG_String; } - public function read(NBT $nbt, bool $network = false){ + public function read(NBT $nbt, bool $network = false) : void{ $this->value = $nbt->getString($network); } - public function write(NBT $nbt, bool $network = false){ + public function write(NBT $nbt, bool $network = false) : void{ $nbt->putString($this->value, $network); } @@ -63,7 +63,7 @@ class StringTag extends NamedTag{ * * @throws \TypeError */ - public function setValue($value){ + public function setValue($value) : void{ if(!is_string($value)){ throw new \TypeError("ShortTag value must be of type int, " . gettype($value) . " given"); } diff --git a/src/pocketmine/nbt/tag/Tag.php b/src/pocketmine/nbt/tag/Tag.php index 849b43ffc..74e4d7b78 100644 --- a/src/pocketmine/nbt/tag/Tag.php +++ b/src/pocketmine/nbt/tag/Tag.php @@ -36,15 +36,15 @@ abstract class Tag extends \stdClass{ return $this->value; } - abstract public function getType(); + abstract public function getType() : int; - public function setValue($value){ + public function setValue($value) : void{ $this->value = $value; } - abstract public function write(NBT $nbt, bool $network = false); + abstract public function write(NBT $nbt, bool $network = false) : void; - abstract public function read(NBT $nbt, bool $network = false); + abstract public function read(NBT $nbt, bool $network = false) : void; public function __toString(){ return (string) $this->value;