mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 23:59:53 +00:00
Added expectedClass parameter to hasTag() to allow type-checking
This commit is contained in:
parent
1b5746fd97
commit
c8379efbce
@ -140,10 +140,13 @@ class CompoundTag extends NamedTag implements \ArrayAccess{
|
|||||||
* Returns whether the CompoundTag contains a child tag with the specified name.
|
* Returns whether the CompoundTag contains a child tag with the specified name.
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
* @param string $expectedClass
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasTag(string $name) : bool{
|
public function hasTag(string $name, string $expectedClass = NamedTag::class) : bool{
|
||||||
return ($this->{$name} ?? null) instanceof NamedTag;
|
assert(is_a($expectedClass, NamedTag::class, true));
|
||||||
|
return ($this->{$name} ?? null) instanceof $expectedClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user