mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 10:01:53 +00:00
Flag expectedType as nullable
This commit is contained in:
parent
f5378ab604
commit
bcefc3a54b
@ -82,7 +82,7 @@ class CompoundTag extends NamedTag implements \ArrayAccess{
|
|||||||
* @return NamedTag|null
|
* @return NamedTag|null
|
||||||
* @throws \RuntimeException if the tag exists and is not of the expected type (if specified)
|
* @throws \RuntimeException if the tag exists and is not of the expected type (if specified)
|
||||||
*/
|
*/
|
||||||
public function getTag(string $name, string $expectedType = null) : ?NamedTag{
|
public function getTag(string $name, ?string $expectedType = null) : ?NamedTag{
|
||||||
assert($expectedType === null or is_a($expectedType, NamedTag::class, true));
|
assert($expectedType === null or is_a($expectedType, NamedTag::class, true));
|
||||||
$tag = $this->{$name} ?? null;
|
$tag = $this->{$name} ?? null;
|
||||||
if($tag !== null and $expectedType !== null and !($tag instanceof $expectedType)){
|
if($tag !== null and $expectedType !== null and !($tag instanceof $expectedType)){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user