mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +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.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $expectedClass
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasTag(string $name) : bool{
|
||||
return ($this->{$name} ?? null) instanceof NamedTag;
|
||||
public function hasTag(string $name, string $expectedClass = NamedTag::class) : bool{
|
||||
assert(is_a($expectedClass, NamedTag::class, true));
|
||||
return ($this->{$name} ?? null) instanceof $expectedClass;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user