Changes since 1.1.x
ListTagnow uses PHPStan generic types. By default, aListTagwill beListTag<Tag>.CompoundTag::getListTag()now supports checking the type of list via astring $tagClassparameter.- This uses PHPStan generic inference, so e.g. doing
getListTag("name", StringTag::class)will returnListTag<StringTag>|null. - An
UnexpectedTagTypeExceptionwill be thrown if the tag is a list of a different type.
- This uses PHPStan generic inference, so e.g. doing
- Added
ListTag::cast(), which accepts astring $tagClassand returnsnullif the list type doesn't match. This uses PHPStan generic inference, so e.g. doingcast(StringTag::class)will returnListTag<StringTag>|null. ListTagPHPStan generics will be narrowed by doing any of the following: passing a non-empty array to the constructor,push(),unshift(),set()
Note: If you don't use PHPStan, you won't be affected. These changes mostly benefit static analysis.