Documentation

CompoundTag extends Tag
in package
implements Countable, IteratorAggregate Uses NoDynamicFieldsTrait

Tags
phpstan-implements

\IteratorAggregate<string, Tag>

Interfaces, Classes, Traits and Enums

Countable
IteratorAggregate

Table of Contents

$cloning  : bool
Used for recursive cloning protection when cloning tags with child tags.
$value  : array<string|int, Tag>
__clone()  : mixed
__construct()  : mixed
__get()  : mixed
__isset()  : mixed
__set()  : mixed
__toString()  : mixed
__unset()  : mixed
count()  : int
create()  : CompoundTag
Helper method for easier fluent usage.
equals()  : bool
Compares this Tag to the given Tag and determines whether or not they are equal, based on type and value.
getByte()  : int
getByteArray()  : string
getCompoundTag()  : CompoundTag|null
Returns the CompoundTag with the specified name, or null if it does not exist. Triggers an exception if a tag exists with that name and the tag is not a CompoundTag.
getCount()  : int
getDouble()  : float
getFloat()  : float
getInt()  : int
getIntArray()  : array<string|int, int>
getIterator()  : Generator|array<string|int, Tag>
getListTag()  : ListTag|null
Returns the ListTag with the specified name, or null if it does not exist. Triggers an exception if a tag exists with that name and the tag is not a ListTag.
getLong()  : int
getShort()  : int
getString()  : string
getTag()  : Tag|null
Returns the tag with the specified name, or null if it does not exist.
getType()  : int
getValue()  : array<string|int, Tag>
merge()  : CompoundTag
Returns a copy of this CompoundTag with values from the given CompoundTag merged into it. Tags that exist both in this tag and the other will be overwritten by the tag in the other.
read()  : self
removeTag()  : void
Removes the child tags with the specified names from the CompoundTag. This function accepts a variadic list of strings.
safeClone()  : Tag
Clones this tag safely, detecting recursive dependencies which would otherwise cause an infinite cloning loop.
setByte()  : $this
setByteArray()  : $this
setDouble()  : $this
setFloat()  : $this
setInt()  : $this
setIntArray()  : $this
setLong()  : $this
setShort()  : $this
setString()  : $this
setTag()  : $this
Sets the specified Tag as a child tag of the CompoundTag at the offset specified by the tag's name.
toString()  : string
write()  : void
getTypeName()  : string
makeCopy()  : static
restrictArgCount()  : void
stringifyValue()  : string
getTagValue()  : mixed
Returns the value of the child tag with the specified name, or $default if the tag doesn't exist. If the child tag is not of type $expectedType, an exception will be thrown.
throw()  : RuntimeException

Properties

$cloning

Used for recursive cloning protection when cloning tags with child tags.

protected bool $cloning = false

Methods

__clone()

public __clone() : mixed
Return values
mixed —

__construct()

public __construct() : mixed
Return values
mixed —

__get()

public __get(string $name) : mixed
Parameters
$name : string
Tags
phpstan-return

never

Return values
mixed —

__isset()

public __isset(string $name) : mixed
Parameters
$name : string
Tags
phpstan-return

never

Return values
mixed —

__set()

public __set(string $name, mixed $value) : mixed
Parameters
$name : string
$value : mixed
Tags
phpstan-return

never

Return values
mixed —

__toString()

public __toString() : mixed
Return values
mixed —

__unset()

public __unset(string $name) : mixed
Parameters
$name : string
Tags
phpstan-return

never

Return values
mixed —

equals()

Compares this Tag to the given Tag and determines whether or not they are equal, based on type and value.

public equals(Tag $that) : bool

Complex tag types should override this to provide proper value comparison.

Parameters
$that : Tag
Return values
bool —

getByte()

public getByte(string $name[, int|null $default = null ]) : int
Parameters
$name : string
$default : int|null = null
Return values
int —

getByteArray()

public getByteArray(string $name[, string|null $default = null ]) : string
Parameters
$name : string
$default : string|null = null
Return values
string —

getCompoundTag()

Returns the CompoundTag with the specified name, or null if it does not exist. Triggers an exception if a tag exists with that name and the tag is not a CompoundTag.

public getCompoundTag(string $name) : CompoundTag|null
Parameters
$name : string
Return values
CompoundTag|null —

getCount()

public getCount() : int
Return values
int —

getDouble()

public getDouble(string $name[, float|null $default = null ]) : float
Parameters
$name : string
$default : float|null = null
Return values
float —

getFloat()

public getFloat(string $name[, float|null $default = null ]) : float
Parameters
$name : string
$default : float|null = null
Return values
float —

getInt()

public getInt(string $name[, int|null $default = null ]) : int
Parameters
$name : string
$default : int|null = null
Return values
int —

getIntArray()

public getIntArray(string $name[, array<string|int, int>|null $default = null ]) : array<string|int, int>
Parameters
$name : string
$default : array<string|int, int>|null = null
Return values
array<string|int, int> —

getIterator()

public getIterator() : Generator|array<string|int, Tag>
Tags
phpstan-return

\Generator<string, Tag, void, void>

Return values
Generator|array<string|int, Tag> —

getListTag()

Returns the ListTag with the specified name, or null if it does not exist. Triggers an exception if a tag exists with that name and the tag is not a ListTag.

public getListTag(string $name) : ListTag|null
Parameters
$name : string
Return values
ListTag|null —

getLong()

public getLong(string $name[, int|null $default = null ]) : int
Parameters
$name : string
$default : int|null = null
Return values
int —

getShort()

public getShort(string $name[, int|null $default = null ]) : int
Parameters
$name : string
$default : int|null = null
Return values
int —

getString()

public getString(string $name[, string|null $default = null ]) : string
Parameters
$name : string
$default : string|null = null
Return values
string —

getTag()

Returns the tag with the specified name, or null if it does not exist.

public getTag(string $name) : Tag|null
Parameters
$name : string
Return values
Tag|null —

getType()

public getType() : int
Return values
int —

getValue()

public getValue() : array<string|int, Tag>
Return values
array<string|int, Tag> —

merge()

Returns a copy of this CompoundTag with values from the given CompoundTag merged into it. Tags that exist both in this tag and the other will be overwritten by the tag in the other.

public merge(CompoundTag $other) : CompoundTag

This deep-clones all tags.

Parameters
$other : CompoundTag
Return values
CompoundTag —

removeTag()

Removes the child tags with the specified names from the CompoundTag. This function accepts a variadic list of strings.

public removeTag(string ...$names) : void
Parameters
$names : string
Return values
void —

safeClone()

Clones this tag safely, detecting recursive dependencies which would otherwise cause an infinite cloning loop.

public safeClone() : Tag

Used for cloning tags in tags that have children.

Tags
throws
RuntimeException

if a recursive dependency was detected

Return values
Tag —

setByte()

public setByte(string $name, int $value) : $this
Parameters
$name : string
$value : int
Return values
$this —

setByteArray()

public setByteArray(string $name, string $value) : $this
Parameters
$name : string
$value : string
Return values
$this —

setDouble()

public setDouble(string $name, float $value) : $this
Parameters
$name : string
$value : float
Return values
$this —

setFloat()

public setFloat(string $name, float $value) : $this
Parameters
$name : string
$value : float
Return values
$this —

setInt()

public setInt(string $name, int $value) : $this
Parameters
$name : string
$value : int
Return values
$this —

setIntArray()

public setIntArray(string $name, array<string|int, int> $value) : $this
Parameters
$name : string
$value : array<string|int, int>
Return values
$this —

setLong()

public setLong(string $name, int $value) : $this
Parameters
$name : string
$value : int
Return values
$this —

setShort()

public setShort(string $name, int $value) : $this
Parameters
$name : string
$value : int
Return values
$this —

setString()

public setString(string $name, string $value) : $this
Parameters
$name : string
$value : string
Return values
$this —

setTag()

Sets the specified Tag as a child tag of the CompoundTag at the offset specified by the tag's name.

public setTag(string $name, Tag $tag) : $this
Parameters
$name : string
$tag : Tag
Return values
$this —

toString()

public final toString([int $indentation = 0 ]) : string
Parameters
$indentation : int = 0
Return values
string —

write()

public write(NbtStreamWriter $writer) : void
Parameters
$writer : NbtStreamWriter
Return values
void —

getTypeName()

protected getTypeName() : string
Return values
string —

makeCopy()

protected makeCopy() : static
Return values
static —

restrictArgCount()

protected static restrictArgCount(string $func, int $haveArgs, int $wantMaxArgs) : void
Parameters
$func : string
$haveArgs : int
$wantMaxArgs : int
Return values
void —

stringifyValue()

protected stringifyValue(int $indentation) : string
Parameters
$indentation : int
Return values
string —

getTagValue()

Returns the value of the child tag with the specified name, or $default if the tag doesn't exist. If the child tag is not of type $expectedType, an exception will be thrown.

private getTagValue(string $name, string $expectedClass[, mixed $default = null ]) : mixed
Parameters
$name : string
$expectedClass : string
$default : mixed = null
Tags
phpstan-template

T of Tag

phpstan-param

class-string<T> $expectedClass

throws
UnexpectedTagTypeException
throws
NoSuchTagException
Return values
mixed —

throw()

private throw(string $field) : RuntimeException
Parameters
$field : string
Return values
RuntimeException —

Search results