Documentation

ListTag extends Tag
in package
implements Countable, IteratorAggregate Uses NoDynamicFieldsTrait

Tags
phpstan-implements

\IteratorAggregate<int, Tag>

Interfaces, Classes, Traits and Enums

Countable
IteratorAggregate

Table of Contents

$cloning  : bool
Used for recursive cloning protection when cloning tags with child tags.
$tagType  : int
$value  : SplDoublyLinkedList|array<string|int, Tag>
__clone()  : mixed
__construct()  : mixed
__get()  : mixed
__isset()  : mixed
__set()  : mixed
__toString()  : mixed
__unset()  : mixed
count()  : int
empty()  : bool
Returns whether there are any tags in the list.
equals()  : bool
Compares this Tag to the given Tag and determines whether or not they are equal, based on type and value.
first()  : Tag
Returns the element in the first position of the list, without removing it.
get()  : Tag
Returns the tag at the specified offset.
getAllValues()  : array<string|int, mixed>
Returns an array of tag values inserted into this list.
getCount()  : int
getIterator()  : Generator|array<string|int, Tag>
getTagType()  : int
Returns the type of tag contained in this list.
getType()  : int
getValue()  : array<string|int, Tag>
insert()  : void
Inserts a tag into the list between existing tags, at the specified offset. Later values in the list are moved up by 1 position.
isset()  : bool
Returns whether a tag exists at the specified offset.
last()  : Tag
Returns the element in the last position in the list (the end), without removing it.
pop()  : Tag
Removes the last tag from the list and returns it.
push()  : void
Appends the specified tag to the end of the list.
read()  : self
remove()  : void
Removes a value from the list. All later tags in the list are moved down by 1 position.
safeClone()  : Tag
Clones this tag safely, detecting recursive dependencies which would otherwise cause an infinite cloning loop.
set()  : void
Overwrites the tag at the specified offset.
setTagType()  : void
Sets the type of tag that can be added to this list. If TAG_End is used, the type will be auto-detected from the first tag added to the list.
shift()  : Tag
Removes the first tag from the list and returns it.
toString()  : string
unshift()  : void
Adds the specified tag to the start of the list.
write()  : void
getTypeName()  : string
makeCopy()  : static
restrictArgCount()  : void
stringifyValue()  : string
checkTagType()  : void
Type-checks the given Tag for addition to the list, updating the list tag type as appropriate.
throw()  : RuntimeException

Properties

$cloning

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

protected bool $cloning = false

$value

private SplDoublyLinkedList|array<string|int, Tag> $value
Tags
phpstan-var

\SplDoublyLinkedList<Tag>

Methods

__clone()

public __clone() : mixed
Return values
mixed

__construct()

public __construct([array<string|int, Tag$value = [] ][, int $tagType = NBT::TAG_End ]) : mixed
Parameters
$value : array<string|int, Tag> = []
$tagType : int = NBT::TAG_End
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

count()

public count() : int
Return values
int

empty()

Returns whether there are any tags in the list.

public empty() : bool
Return values
bool

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

first()

Returns the element in the first position of the list, without removing it.

public first() : Tag
Return values
Tag

get()

Returns the tag at the specified offset.

public get(int $offset) : Tag
Parameters
$offset : int
Tags
throws
OutOfRangeException

if the offset is not within the bounds of the list

Return values
Tag

getAllValues()

Returns an array of tag values inserted into this list.

public getAllValues() : array<string|int, mixed>
Tags
phpstan-return

list

Return values
array<string|int, mixed>

getCount()

public getCount() : int
Return values
int

getIterator()

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

\Generator<int, Tag, void, void>

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

getTagType()

Returns the type of tag contained in this list.

public getTagType() : int
Return values
int

getType()

public getType() : int
Return values
int

getValue()

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

insert()

Inserts a tag into the list between existing tags, at the specified offset. Later values in the list are moved up by 1 position.

public insert(int $offset, Tag $tag) : void
Parameters
$offset : int
$tag : Tag
Tags
throws
OutOfRangeException

if the offset is not within the bounds of the list

Return values
void

isset()

Returns whether a tag exists at the specified offset.

public isset(int $offset) : bool
Parameters
$offset : int
Return values
bool

last()

Returns the element in the last position in the list (the end), without removing it.

public last() : Tag
Return values
Tag

pop()

Removes the last tag from the list and returns it.

public pop() : Tag
Return values
Tag

push()

Appends the specified tag to the end of the list.

public push(Tag $tag) : void
Parameters
$tag : Tag
Return values
void

read()

public static read(NbtStreamReader $reader, ReaderTracker $tracker) : self
Parameters
$reader : NbtStreamReader
$tracker : ReaderTracker
Return values
self

remove()

Removes a value from the list. All later tags in the list are moved down by 1 position.

public remove(int $offset) : void
Parameters
$offset : int
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

set()

Overwrites the tag at the specified offset.

public set(int $offset, Tag $tag) : void
Parameters
$offset : int
$tag : Tag
Tags
throws
OutOfRangeException

if the offset is not within the bounds of the list

Return values
void

setTagType()

Sets the type of tag that can be added to this list. If TAG_End is used, the type will be auto-detected from the first tag added to the list.

public setTagType(int $type) : void
Parameters
$type : int
Tags
throws
LogicException

if the list is not empty

Return values
void

shift()

Removes the first tag from the list and returns it.

public shift() : Tag
Return values
Tag

toString()

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

unshift()

Adds the specified tag to the start of the list.

public unshift(Tag $tag) : void
Parameters
$tag : Tag
Return values
void

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

checkTagType()

Type-checks the given Tag for addition to the list, updating the list tag type as appropriate.

private checkTagType(Tag $tag) : void
Parameters
$tag : Tag
Tags
throws
TypeError

if the tag type is not compatible.

Return values
void

throw()

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

Search results