Skip to content

1.2.0

Latest

Choose a tag to compare

@dktapps dktapps released this 19 Sep 22:35
· 1 commit to stable since this release
51b8d6a

Changes since 1.1.x

  • ListTag now uses PHPStan generic types. By default, a ListTag will be ListTag<Tag>.
  • CompoundTag::getListTag() now supports checking the type of list via a string $tagClass parameter.
    • This uses PHPStan generic inference, so e.g. doing getListTag("name", StringTag::class) will return ListTag<StringTag>|null.
    • An UnexpectedTagTypeException will be thrown if the tag is a list of a different type.
  • Added ListTag::cast(), which accepts a string $tagClass and returns null if the list type doesn't match. This uses PHPStan generic inference, so e.g. doing cast(StringTag::class) will return ListTag<StringTag>|null.
  • ListTag PHPStan 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.