Skip to content

Keeps forgetting about @var doc comments #5921

@dktapps

Description

@dktapps

Bug report

I'm not sure exactly what triggers this. Hopefully someone reading this issue does.

I hate that this is one of those "it randomly happens" issues, but unfortunately this is the best I got right now.

Note that deleting PHPStan's cache in $TEMP/phpstan resolves the issue.

Summary

Analysing latest PM, PHPStan randomly forgets @var doc comments like these:

https://github.com/pmmp/PocketMine-MP/blob/c77829f4adee4d5fe61829823f4dbad545c100e9/src/entity/Human.php#L254
https://github.com/pmmp/PocketMine-MP/blob/b9b1ba95261f90e61657a0220ca8a59fa0dad9d7/src/entity/Living.php#L153
https://github.com/pmmp/PocketMine-MP/blob/3be9548b1ea240cdf352fa08a603cc3729f88682/src/network/mcpe/compression/CompressBatchTask.php#L48
https://github.com/pmmp/PocketMine-MP/blob/bb05af103d22148dbe3aa053a2119c2603282343/src/plugin/PluginManager.php#L497
https://github.com/pmmp/PocketMine-MP/blob/f827a555d5f98f22aea919f165853dff224b5176/src/utils/Utils.php#L178

which spontaneously leads to bogus errors like these:

 ------ -------------------------------------------------------------------------------------------------------------------------------------------------
  Line   src\entity\Human.php
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------
  256    Call to an undefined method pocketmine\nbt\tag\Tag::getByte().
  260    Parameter #1 $tag of static method pocketmine\item\Item::nbtDeserialize() expects pocketmine\nbt\tag\CompoundTag, pocketmine\nbt\tag\Tag given.
  262    Parameter #1 $tag of static method pocketmine\item\Item::nbtDeserialize() expects pocketmine\nbt\tag\CompoundTag, pocketmine\nbt\tag\Tag given.
  283    Call to an undefined method pocketmine\nbt\tag\Tag::getByte().
  283    Parameter #1 $tag of static method pocketmine\item\Item::nbtDeserialize() expects pocketmine\nbt\tag\CompoundTag, pocketmine\nbt\tag\Tag given.
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------

 ------ ----------------------------------------------------------------
  Line   src\entity\Living.php
 ------ ----------------------------------------------------------------
  157    Call to an undefined method pocketmine\nbt\tag\Tag::getByte().
  164    Call to an undefined method pocketmine\nbt\tag\Tag::getInt().
  165    Call to an undefined method pocketmine\nbt\tag\Tag::getByte().
  166    Call to an undefined method pocketmine\nbt\tag\Tag::getByte().
  167    Call to an undefined method pocketmine\nbt\tag\Tag::getByte().
 ------ ----------------------------------------------------------------

 ------ ----------------------------------------------------
  Line   src\network\mcpe\compression\CompressBatchTask.php
 ------ ----------------------------------------------------
  50     Cannot call method resolve() on mixed.
 ------ ----------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------------
  Line   src\plugin\PluginManager.php
 ------ -------------------------------------------------------------------------------------------------------------------------------
  499    Parameter #1 $objectOrClass of class ReflectionClass constructor expects class-string<T of object>|T of object, string given.
 ------ -------------------------------------------------------------------------------------------------------------------------------

 ------ ---------------------------------------------------------------------------------------------------------------
  Line   src\utils\Utils.php
 ------ ---------------------------------------------------------------------------------------------------------------
  180    Method pocketmine\utils\Utils::cloneObjectArray() should return array<T of object> but returns array<object>.
 ------ ---------------------------------------------------------------------------------------------------------------

Deleting PHPStan's cache $TEMP/phpstan resolves the issue, but it keeps recurring.

Code snippet that reproduces the problem

Linked above, but like I said, it doesn't happen all the time.

Expected output

The above errors shouldn't be reported (they are bogus).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions