Skip to content

Commit 41106bc

Browse files
committed
update to PHP 8.1
1 parent c6b0d14 commit 41106bc

12 files changed

+50
-40
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
],
1717
"require": {
1818
"pocketmine/binaryutils": "^0.2.1",
19-
"php": ">=8.0",
19+
"php": ">=8.1",
2020
"php-64bit": "*",
2121
"ext-zlib": "*",
2222
"ext-json": "*",

composer.lock

Lines changed: 19 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Deserializer/BedrockEditionNbtDeserializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function readInt(): DeserializerIntReadResult
6868
public function readLong(): DeserializerIntReadResult
6969
{
7070
$raw = $this->getReader()->read(8);
71-
$value = @unpack("q", MachineByteOrder::isBigEndian() ? strrev($raw) : $raw)[1] ?? 0;;
71+
$value = @unpack("q", MachineByteOrder::isBigEndian() ? strrev($raw) : $raw)[1] ?? 0;
7272
return new DeserializerIntReadResult($value, $raw);
7373
}
7474

src/String/StringDataFormatException.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace Aternos\Nbt\String;
44

5-
class StringDataFormatException extends \Exception
5+
use Exception;
6+
7+
class StringDataFormatException extends Exception
68
{
79

8-
}
10+
}

src/Tag/ArrayValueTag.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,23 @@ abstract protected function checkArrayValue($value): bool;
8181
/**
8282
* @inheritDoc
8383
*/
84-
public function current()
84+
public function current(): mixed
8585
{
8686
return current($this->valueArray);
8787
}
8888

8989
/**
9090
* @inheritDoc
9191
*/
92-
public function next()
92+
public function next(): void
9393
{
9494
next($this->valueArray);
9595
}
9696

9797
/**
9898
* @inheritDoc
9999
*/
100-
public function key()
100+
public function key(): string|int|null
101101
{
102102
return key($this->valueArray);
103103
}
@@ -113,7 +113,7 @@ public function valid(): bool
113113
/**
114114
* @inheritDoc
115115
*/
116-
public function rewind()
116+
public function rewind(): void
117117
{
118118
reset($this->valueArray);
119119
}
@@ -129,7 +129,7 @@ public function offsetExists($offset): bool
129129
/**
130130
* @inheritDoc
131131
*/
132-
public function offsetGet($offset)
132+
public function offsetGet($offset): mixed
133133
{
134134
return $this->valueArray[$offset];
135135
}
@@ -138,7 +138,7 @@ public function offsetGet($offset)
138138
* @inheritDoc
139139
* @throws Exception
140140
*/
141-
public function offsetSet($offset, $value)
141+
public function offsetSet($offset, $value): void
142142
{
143143
if (!$this->checkArrayValue($value)) {
144144
throw new Exception("Invalid array value");
@@ -156,7 +156,7 @@ public function offsetSet($offset, $value)
156156
/**
157157
* @inheritDoc
158158
*/
159-
public function offsetUnset($offset)
159+
public function offsetUnset($offset): void
160160
{
161161
unset($this->valueArray[$offset]);
162162
}
@@ -181,14 +181,14 @@ abstract protected function checkArrayKey($offset): bool;
181181
protected function getValueString(): string
182182
{
183183
return $this->count() . " entr" . ($this->count() === 1 ? "y" : "ies") . "\n[\n" .
184-
$this->indent(implode(", \n", array_map("strval", $this->valueArray))) .
184+
$this->indent(implode(", \n", array_map(strval(...), $this->valueArray))) .
185185
"\n]";
186186
}
187187

188188
/**
189189
* @inheritDoc
190190
*/
191-
public function jsonSerialize()
191+
public function jsonSerialize(): array
192192
{
193193
return $this->valueArray;
194194
}

src/Tag/ByteArrayTag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected function checkArrayKey($offset): bool
6868
protected function getValueString(): string
6969
{
7070
$values = array_map(function ($elem) {
71-
return str_pad(dechex($elem), 2, "0", STR_PAD_RIGHT);
71+
return str_pad(dechex($elem), 2, "0");
7272
}, array_slice($this->valueArray, 0, 32));
7373
if (count($this->valueArray) > 32) {
7474
$values[] = "...";

src/Tag/CompoundTag.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function writeContent(Writer $writer): static
4747
if (in_array($value->getName(), $writtenNames)) {
4848
throw new Exception("Duplicate key '" . $value->getName() . "' in compound tag");
4949
}
50-
$value->writeData($writer, true);
50+
$value->writeData($writer);
5151
}
5252
(new EndTag($this->options))->writeData($writer);
5353
return $this;
@@ -116,23 +116,23 @@ public function offsetSet($offset, $value): void
116116
/**
117117
* @inheritDoc
118118
*/
119-
public function current()
119+
public function current(): bool|Tag
120120
{
121121
return current($this->valueArray);
122122
}
123123

124124
/**
125125
* @inheritDoc
126126
*/
127-
public function next()
127+
public function next(): void
128128
{
129129
next($this->valueArray);
130130
}
131131

132132
/**
133133
* @inheritDoc
134134
*/
135-
public function key()
135+
public function key(): ?string
136136
{
137137
return $this->current()->getName();
138138
}
@@ -148,7 +148,7 @@ public function valid(): bool
148148
/**
149149
* @inheritDoc
150150
*/
151-
public function rewind()
151+
public function rewind(): void
152152
{
153153
reset($this->valueArray);
154154
}
@@ -169,7 +169,7 @@ public function offsetExists($offset): bool
169169
/**
170170
* @inheritDoc
171171
*/
172-
public function offsetGet($offset)
172+
public function offsetGet($offset): ?Tag
173173
{
174174
foreach ($this->valueArray as $val) {
175175
if ($val->getName() === $offset) {
@@ -183,7 +183,7 @@ public function offsetGet($offset)
183183
* @inheritDoc
184184
* @throws Exception
185185
*/
186-
public function offsetUnset($offset)
186+
public function offsetUnset($offset): void
187187
{
188188
if($this->isRaw()) {
189189
throw new Exception("Raw compound tags cannot be modified");
@@ -214,14 +214,14 @@ protected function getValueString(): string
214214
return strlen($this->rawContent) . " bytes";
215215
}
216216
return $this->count() . " entr" . ($this->count() === 1 ? "y" : "ies") . "\n{\n" .
217-
$this->indent(implode(", \n", array_map("strval", array_values($this->valueArray)))) .
217+
$this->indent(implode(", \n", array_map(strval(...), array_values($this->valueArray)))) .
218218
"\n}";
219219
}
220220

221221
/**
222222
* @inheritDoc
223223
*/
224-
public function jsonSerialize()
224+
public function jsonSerialize(): array
225225
{
226226
$data = [];
227227
foreach ($this->valueArray as $value) {

src/Tag/EndTag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function getValueString(): string
5252
/**
5353
* @inheritDoc
5454
*/
55-
public function jsonSerialize()
55+
public function jsonSerialize(): mixed
5656
{
5757
return null;
5858
}

src/Tag/FloatValueTag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function getValueString(): string
3535
/**
3636
* @inheritDoc
3737
*/
38-
public function jsonSerialize()
38+
public function jsonSerialize(): int|float
3939
{
4040
return $this->value;
4141
}

src/Tag/IntValueTag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function getValueString(): string
3535
/**
3636
* @inheritDoc
3737
*/
38-
public function jsonSerialize()
38+
public function jsonSerialize(): int
3939
{
4040
return $this->value;
4141
}

0 commit comments

Comments
 (0)