diff --git a/composer.lock b/composer.lock index a3eea84d6..26b239330 100644 --- a/composer.lock +++ b/composer.lock @@ -160,16 +160,16 @@ }, { "name": "pocketmine/nbt", - "version": "0.2.11", + "version": "0.2.12", "source": { "type": "git", "url": "https://github.com/pmmp/NBT.git", - "reference": "78784b93632c51f0fad0719b2d6ffe072529db6d" + "reference": "b5777265329753b74dd40bb105eedabeefb98724" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/NBT/zipball/78784b93632c51f0fad0719b2d6ffe072529db6d", - "reference": "78784b93632c51f0fad0719b2d6ffe072529db6d", + "url": "https://api.github.com/repos/pmmp/NBT/zipball/b5777265329753b74dd40bb105eedabeefb98724", + "reference": "b5777265329753b74dd40bb105eedabeefb98724", "shasum": "" }, "require": { @@ -194,10 +194,10 @@ ], "description": "PHP library for working with Named Binary Tags", "support": { - "source": "https://github.com/pmmp/NBT/tree/0.2.11", + "source": "https://github.com/pmmp/NBT/tree/0.2", "issues": "https://github.com/pmmp/NBT/issues" }, - "time": "2019-10-21T14:50:43+00:00" + "time": "2019-12-01T08:20:26+00:00" }, { "name": "pocketmine/raklib", @@ -276,23 +276,20 @@ }, { "name": "pocketmine/spl", - "version": "0.3.2", + "version": "0.3.3", "source": { "type": "git", "url": "https://github.com/pmmp/SPL.git", - "reference": "7fd53857cd000491ba69e8db865792a024dd2c49" + "reference": "94d4df142fe837ba836e9348dd00209e4bdcc307" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/SPL/zipball/7fd53857cd000491ba69e8db865792a024dd2c49", - "reference": "7fd53857cd000491ba69e8db865792a024dd2c49", + "url": "https://api.github.com/repos/pmmp/SPL/zipball/94d4df142fe837ba836e9348dd00209e4bdcc307", + "reference": "94d4df142fe837ba836e9348dd00209e4bdcc307", "shasum": "" }, "type": "library", "autoload": { - "exclude-from-classmap": [ - "stubs" - ], "classmap": [ "./" ] @@ -302,9 +299,10 @@ ], "description": "Standard library files required by PocketMine-MP and related projects", "support": { - "source": "https://github.com/pmmp/SPL/tree/master" + "source": "https://github.com/pmmp/SPL/tree/0.3.3", + "issues": "https://github.com/pmmp/SPL/issues" }, - "time": "2018-08-12T15:17:39+00:00" + "time": "2019-10-28T11:41:20+00:00" } ], "packages-dev": [], diff --git a/phpstan.neon b/phpstan.neon index eeae576fe..e2d3ca6d5 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,11 @@ - +includes: + - tests/phpstan/configs/optional-com-dotnet.neon + - tests/phpstan/configs/optional-leveldb.neon + - tests/phpstan/configs/phpstan-bugs.neon + - tests/phpstan/configs/pthreads-bugs.neon parameters: - level: 1 + level: 2 autoload_files: - tests/phpstan/bootstrap.php - src/pocketmine/PocketMine.php @@ -57,22 +61,11 @@ parameters: count: 1 path: src/pocketmine/network/mcpe/protocol/StartGamePacket.php - - - message: "#^Instantiated class COM not found\\.$#" - count: 2 - path: src/pocketmine/network/upnp/UPnP.php - comment: "only available on Windows" - - message: "#^Constructor of class pocketmine\\\\scheduler\\\\TaskScheduler has an unused parameter \\$logger\\.$#" count: 1 path: src/pocketmine/scheduler/TaskScheduler.php - - - message: "#^Variable \\$GLOBALS in isset\\(\\) always exists and is not nullable\\.$#" - path: src/pocketmine/MemoryManager.php - comment: "this isn't defined on threads (thanks pthreads)" - - message: "#^Constant pocketmine\\\\COMPOSER_AUTOLOADER_PATH not found\\.$#" path: src/pocketmine @@ -104,21 +97,9 @@ parameters: - message: "#^Constant pocketmine\\\\VERSION not found\\.$#" path: src/pocketmine + - - message: "#^Used constant LEVELDB_ZLIB_RAW_COMPRESSION not found\\.$#" - path: src/pocketmine/level/format/io/leveldb/LevelDB.php - comment: "explicitly checked" - - - message: "#^Constant LEVELDB_ZLIB_RAW_COMPRESSION not found\\.$#" - path: src/pocketmine/level/format/io/leveldb/LevelDB.php - comment: "explicitly checked" - - - message: "#^Instantiated class LevelDB not found\\.$#" - path: src/pocketmine/level/format/io/leveldb/LevelDB.php - comment: "leveldb extension currently optional" - - - message: "#^Return typehint of method pocketmine\\\\level\\\\format\\\\io\\\\leveldb\\\\LevelDB\\:\\:createDB\\(\\) has invalid type LevelDB\\.$#" - path: src/pocketmine/level/format/io/leveldb/LevelDB.php - - - message: "#^Return typehint of method pocketmine\\\\level\\\\format\\\\io\\\\leveldb\\\\LevelDB\\:\\:getDatabase\\(\\) has invalid type LevelDB\\.$#" - path: src/pocketmine/level/format/io/leveldb/LevelDB.php + message: "#^Call to an undefined method pocketmine\\\\command\\\\CommandSender\\:\\:teleport\\(\\)\\.$#" + count: 1 + path: src/pocketmine/command/defaults/TeleportCommand.php + comment: "not actually possible, but high cost to fix warning" diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 7342808c7..1cf723eff 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -228,7 +228,7 @@ class Server{ * @var int */ private $tickCounter = 0; - /** @var int */ + /** @var float */ private $nextTick = 0; /** @var float[] */ private $tickAverage = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]; @@ -1445,7 +1445,7 @@ class Server{ } /** - * @return string[] + * @return string[][] */ public function getCommandAliases() : array{ $section = $this->getProperty("aliases"); @@ -1790,7 +1790,7 @@ class Server{ /** * @param TextContainer|string $message - * @param Player[] $recipients + * @param CommandSender[] $recipients * * @return int */ @@ -1799,7 +1799,7 @@ class Server{ return $this->broadcast($message, self::BROADCAST_CHANNEL_USERS); } - /** @var Player[] $recipients */ + /** @var CommandSender[] $recipients */ foreach($recipients as $recipient){ $recipient->sendMessage($message); } diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 0ed6eb803..3fee8b260 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -763,7 +763,7 @@ class Block extends Position implements BlockIds, Metadatable{ return $this->level->getBlockMetadata()->getMetadata($this, $metadataKey); } - return null; + return []; } public function hasMetadata(string $metadataKey) : bool{ diff --git a/src/pocketmine/block/BurningFurnace.php b/src/pocketmine/block/BurningFurnace.php index 01bbd6779..c189f5b65 100644 --- a/src/pocketmine/block/BurningFurnace.php +++ b/src/pocketmine/block/BurningFurnace.php @@ -80,6 +80,9 @@ class BurningFurnace extends Solid{ $furnace = $this->getLevel()->getTile($this); if(!($furnace instanceof TileFurnace)){ $furnace = Tile::createTile(Tile::FURNACE, $this->getLevel(), TileFurnace::createNBT($this)); + if(!($furnace instanceof TileFurnace)){ + return true; + } } if(!$furnace->canOpenWith($item->getCustomName())){ diff --git a/src/pocketmine/block/Chest.php b/src/pocketmine/block/Chest.php index b11809ef2..a9cadbb1b 100644 --- a/src/pocketmine/block/Chest.php +++ b/src/pocketmine/block/Chest.php @@ -109,6 +109,9 @@ class Chest extends Transparent{ $chest = $t; }else{ $chest = Tile::createTile(Tile::CHEST, $this->getLevel(), TileChest::createNBT($this)); + if(!($chest instanceof TileChest)){ + return true; + } } if( diff --git a/src/pocketmine/block/ItemFrame.php b/src/pocketmine/block/ItemFrame.php index 6038e0a55..6644c682b 100644 --- a/src/pocketmine/block/ItemFrame.php +++ b/src/pocketmine/block/ItemFrame.php @@ -47,6 +47,9 @@ class ItemFrame extends Flowable{ $tile = $this->level->getTile($this); if(!($tile instanceof TileItemFrame)){ $tile = Tile::createTile(Tile::ITEM_FRAME, $this->getLevel(), TileItemFrame::createNBT($this)); + if(!($tile instanceof TileItemFrame)){ + return true; + } } if($tile->hasItem()){ diff --git a/src/pocketmine/command/Command.php b/src/pocketmine/command/Command.php index 2f47e2029..33b8a645b 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -55,7 +55,7 @@ abstract class Command{ */ private $activeAliases = []; - /** @var CommandMap */ + /** @var CommandMap|null */ private $commandMap = null; /** @var string */ diff --git a/src/pocketmine/command/defaults/GamemodeCommand.php b/src/pocketmine/command/defaults/GamemodeCommand.php index 063993aee..6070d7866 100644 --- a/src/pocketmine/command/defaults/GamemodeCommand.php +++ b/src/pocketmine/command/defaults/GamemodeCommand.php @@ -60,7 +60,6 @@ class GamemodeCommand extends VanillaCommand{ return true; } - $target = $sender; if(isset($args[1])){ $target = $sender->getServer()->getPlayer($args[1]); if($target === null){ @@ -68,7 +67,9 @@ class GamemodeCommand extends VanillaCommand{ return true; } - }elseif(!($sender instanceof Player)){ + }elseif($sender instanceof Player){ + $target = $sender; + }else{ throw new InvalidCommandSyntaxException(); } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index fac66b10c..a2b3468e9 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -318,7 +318,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ public const DATA_PLAYER_FLAG_DEAD = 2; //TODO: CHECK public static $entityCount = 1; - /** @var Entity[] */ + /** @var string[] */ private static $knownEntities = []; /** @var string[][] */ private static $saveNames = []; @@ -460,8 +460,8 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ /** @var EntityDamageEvent|null */ protected $lastDamageCause = null; - /** @var Block[] */ - protected $blocksAround = []; + /** @var Block[]|null */ + protected $blocksAround = null; /** @var float|null */ public $lastX = null; @@ -2048,7 +2048,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * @param Player $player */ public function spawnTo(Player $player) : void{ - if(!isset($this->hasSpawned[$player->getLoaderId()])){ + if(!isset($this->hasSpawned[$player->getLoaderId()]) and $this->chunk !== null and isset($player->usedChunks[Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())])){ $this->hasSpawned[$player->getLoaderId()] = $player; $this->sendSpawnPacket($player); diff --git a/src/pocketmine/entity/Squid.php b/src/pocketmine/entity/Squid.php index abce81095..950164fc0 100644 --- a/src/pocketmine/entity/Squid.php +++ b/src/pocketmine/entity/Squid.php @@ -40,7 +40,7 @@ class Squid extends WaterAnimal{ public $width = 0.95; public $height = 0.95; - /** @var Vector3 */ + /** @var Vector3|null */ public $swimDirection = null; public $swimSpeed = 0.1; diff --git a/src/pocketmine/event/player/PlayerChatEvent.php b/src/pocketmine/event/player/PlayerChatEvent.php index 4ebddecdd..1b8bbcaff 100644 --- a/src/pocketmine/event/player/PlayerChatEvent.php +++ b/src/pocketmine/event/player/PlayerChatEvent.php @@ -23,10 +23,12 @@ declare(strict_types=1); namespace pocketmine\event\player; +use pocketmine\command\CommandSender; use pocketmine\event\Cancellable; use pocketmine\permission\PermissionManager; use pocketmine\Player; use pocketmine\Server; +use function spl_object_id; /** * Called when a player chats something @@ -39,15 +41,15 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{ protected $format; /** - * @var Player[] + * @var CommandSender[] */ protected $recipients = []; /** - * @param Player $player - * @param string $message - * @param string $format - * @param Player[] $recipients + * @param Player $player + * @param string $message + * @param string $format + * @param CommandSender[] $recipients */ public function __construct(Player $player, string $message, string $format = "chat.type.text", array $recipients = null){ $this->player = $player; @@ -56,7 +58,11 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{ $this->format = $format; if($recipients === null){ - $this->recipients = PermissionManager::getInstance()->getPermissionSubscriptions(Server::BROADCAST_CHANNEL_USERS); + foreach(PermissionManager::getInstance()->getPermissionSubscriptions(Server::BROADCAST_CHANNEL_USERS) as $permissible){ + if($permissible instanceof CommandSender){ + $this->recipients[spl_object_id($permissible)] = $permissible; + } + } }else{ $this->recipients = $recipients; } @@ -100,14 +106,14 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{ } /** - * @return Player[] + * @return CommandSender[] */ public function getRecipients() : array{ return $this->recipients; } /** - * @param Player[] $recipients + * @param CommandSender[] $recipients */ public function setRecipients(array $recipients) : void{ $this->recipients = $recipients; diff --git a/src/pocketmine/event/player/PlayerCreationEvent.php b/src/pocketmine/event/player/PlayerCreationEvent.php index a67be8792..f79a3411d 100644 --- a/src/pocketmine/event/player/PlayerCreationEvent.php +++ b/src/pocketmine/event/player/PlayerCreationEvent.php @@ -39,15 +39,15 @@ class PlayerCreationEvent extends Event{ /** @var int */ private $port; - /** @var Player::class */ + /** @var string */ private $baseClass; - /** @var Player::class */ + /** @var string */ private $playerClass; /** * @param SourceInterface $interface - * @param Player::class $baseClass - * @param Player::class $playerClass + * @param string $baseClass + * @param string $playerClass * @param string $address * @param int $port */ @@ -91,14 +91,14 @@ class PlayerCreationEvent extends Event{ } /** - * @return Player::class + * @return string */ public function getBaseClass(){ return $this->baseClass; } /** - * @param Player::class $class + * @param string $class */ public function setBaseClass($class){ if(!is_a($class, $this->baseClass, true)){ @@ -109,14 +109,14 @@ class PlayerCreationEvent extends Event{ } /** - * @return Player::class + * @return string */ public function getPlayerClass(){ return $this->playerClass; } /** - * @param Player::class $class + * @param string $class */ public function setPlayerClass($class){ if(!is_a($class, $this->baseClass, true)){ diff --git a/src/pocketmine/inventory/BaseInventory.php b/src/pocketmine/inventory/BaseInventory.php index bc6f7dcfb..b703442d6 100644 --- a/src/pocketmine/inventory/BaseInventory.php +++ b/src/pocketmine/inventory/BaseInventory.php @@ -47,7 +47,7 @@ abstract class BaseInventory implements Inventory{ /** @var string */ protected $title; /** @var \SplFixedArray|Item[] */ - protected $slots = []; + protected $slots; /** @var Player[] */ protected $viewers = []; /** @var InventoryEventProcessor */ diff --git a/src/pocketmine/inventory/CraftingManager.php b/src/pocketmine/inventory/CraftingManager.php index 33dba506f..bec35765a 100644 --- a/src/pocketmine/inventory/CraftingManager.php +++ b/src/pocketmine/inventory/CraftingManager.php @@ -43,7 +43,7 @@ class CraftingManager{ /** @var FurnaceRecipe[] */ protected $furnaceRecipes = []; - /** @var BatchPacket */ + /** @var BatchPacket|null */ private $craftingDataCache; public function __construct(){ diff --git a/src/pocketmine/item/enchantment/Enchantment.php b/src/pocketmine/item/enchantment/Enchantment.php index 80831911e..58dfba841 100644 --- a/src/pocketmine/item/enchantment/Enchantment.php +++ b/src/pocketmine/item/enchantment/Enchantment.php @@ -94,7 +94,7 @@ class Enchantment{ public const SLOT_ELYTRA = 0x4000; public const SLOT_TRIDENT = 0x8000; - /** @var Enchantment[] */ + /** @var \SplFixedArray|Enchantment[] */ protected static $enchantments; public static function init() : void{ diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 6fc37039a..2dbf4073d 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -265,7 +265,7 @@ class Level implements ChunkManager, Metadatable{ /** @var LevelTimings */ public $timings; - /** @var int */ + /** @var float */ public $tickRateTime = 0; /** * @deprecated diff --git a/src/pocketmine/level/format/Chunk.php b/src/pocketmine/level/format/Chunk.php index 8bbdefe19..5847dd0ab 100644 --- a/src/pocketmine/level/format/Chunk.php +++ b/src/pocketmine/level/format/Chunk.php @@ -694,50 +694,48 @@ class Chunk{ public function initChunk(Level $level){ if(!$this->isInit){ $changed = false; - if($this->NBTentities !== null){ - $level->timings->syncChunkLoadEntitiesTimer->startTiming(); - foreach($this->NBTentities as $nbt){ - if($nbt instanceof CompoundTag){ - if(!$nbt->hasTag("id")){ //allow mixed types (because of leveldb) - $changed = true; - continue; - } - try{ - $entity = Entity::createEntity($nbt->getTag("id")->getValue(), $level, $nbt); - if(!($entity instanceof Entity)){ - $changed = true; - continue; - } - }catch(\Throwable $t){ - $level->getServer()->getLogger()->logException($t); + $level->timings->syncChunkLoadEntitiesTimer->startTiming(); + foreach($this->NBTentities as $nbt){ + if($nbt instanceof CompoundTag){ + if(!$nbt->hasTag("id")){ //allow mixed types (because of leveldb) + $changed = true; + continue; + } + + try{ + $entity = Entity::createEntity($nbt->getTag("id")->getValue(), $level, $nbt); + if(!($entity instanceof Entity)){ $changed = true; continue; } + }catch(\Throwable $t){ + $level->getServer()->getLogger()->logException($t); + $changed = true; + continue; } } - $level->timings->syncChunkLoadEntitiesTimer->stopTiming(); - - $level->timings->syncChunkLoadTileEntitiesTimer->startTiming(); - foreach($this->NBTtiles as $nbt){ - if($nbt instanceof CompoundTag){ - if(!$nbt->hasTag(Tile::TAG_ID, StringTag::class)){ - $changed = true; - continue; - } - - if(Tile::createTile($nbt->getString(Tile::TAG_ID), $level, $nbt) === null){ - $changed = true; - continue; - } - } - } - - $level->timings->syncChunkLoadTileEntitiesTimer->stopTiming(); - - $this->NBTentities = null; - $this->NBTtiles = null; } + $this->NBTentities = []; + $level->timings->syncChunkLoadEntitiesTimer->stopTiming(); + + $level->timings->syncChunkLoadTileEntitiesTimer->startTiming(); + foreach($this->NBTtiles as $nbt){ + if($nbt instanceof CompoundTag){ + if(!$nbt->hasTag(Tile::TAG_ID, StringTag::class)){ + $changed = true; + continue; + } + + if(Tile::createTile($nbt->getString(Tile::TAG_ID), $level, $nbt) === null){ + $changed = true; + continue; + } + } + } + + $this->NBTtiles = []; + $level->timings->syncChunkLoadTileEntitiesTimer->stopTiming(); $this->hasChanged = $changed; diff --git a/src/pocketmine/network/mcpe/NetworkBinaryStream.php b/src/pocketmine/network/mcpe/NetworkBinaryStream.php index 32a3629e9..85c6766ab 100644 --- a/src/pocketmine/network/mcpe/NetworkBinaryStream.php +++ b/src/pocketmine/network/mcpe/NetworkBinaryStream.php @@ -93,7 +93,11 @@ class NetworkBinaryStream extends BinaryStream{ if($c !== 1){ throw new \UnexpectedValueException("Unexpected NBT count $c"); } - $nbt = (new NetworkLittleEndianNBTStream())->read($this->buffer, false, $this->offset, 512); + $decodedNBT = (new NetworkLittleEndianNBTStream())->read($this->buffer, false, $this->offset, 512); + if(!($decodedNBT instanceof CompoundTag)){ + throw new \UnexpectedValueException("Unexpected root tag type for itemstack"); + } + $nbt = $decodedNBT; }elseif($nbtLen !== 0){ throw new \UnexpectedValueException("Unexpected fake NBT length $nbtLen"); } diff --git a/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php b/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php index 9af852bba..86088c8dc 100644 --- a/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php @@ -227,6 +227,7 @@ class AvailableCommandsPacket extends DataPacket{ $retval->aliases = $enums[$this->getLInt()] ?? null; for($overloadIndex = 0, $overloadCount = $this->getUnsignedVarInt(); $overloadIndex < $overloadCount; ++$overloadIndex){ + $retval->overloads[$overloadIndex] = []; for($paramIndex = 0, $paramCount = $this->getUnsignedVarInt(); $paramIndex < $paramCount; ++$paramIndex){ $parameter = new CommandParameter(); $parameter->paramName = $this->getString(); diff --git a/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php b/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php index 27f59e73b..bb5f7cd8f 100644 --- a/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php @@ -140,7 +140,7 @@ class CraftingDataPacket extends DataPacket{ } $this->decodedEntries[] = $entry; } - $this->getBool(); //cleanRecipes + $this->cleanRecipes = $this->getBool(); } private static function writeEntry($entry, NetworkBinaryStream $stream, int $pos){ diff --git a/src/pocketmine/network/mcpe/protocol/DataPacket.php b/src/pocketmine/network/mcpe/protocol/DataPacket.php index f2e60caa5..aeeeaf054 100644 --- a/src/pocketmine/network/mcpe/protocol/DataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/DataPacket.php @@ -135,7 +135,7 @@ abstract class DataPacket extends NetworkBinaryStream{ abstract public function handle(NetworkSession $session) : bool; public function clean(){ - $this->buffer = null; + $this->buffer = ""; $this->isEncoded = false; $this->offset = 0; return $this; diff --git a/src/pocketmine/scheduler/AsyncPool.php b/src/pocketmine/scheduler/AsyncPool.php index a0b6200b0..069da62de 100644 --- a/src/pocketmine/scheduler/AsyncPool.php +++ b/src/pocketmine/scheduler/AsyncPool.php @@ -262,6 +262,7 @@ class AsyncPool{ while(($task = $worker->unstack()) !== null){ //cancelRun() is not strictly necessary here, but it might be used to inform plugins of the task state //(i.e. it never executed). + assert($task instanceof AsyncTask); $task->cancelRun(); $this->removeTask($task, true); } diff --git a/tests/phpstan/configs/optional-com-dotnet.neon b/tests/phpstan/configs/optional-com-dotnet.neon new file mode 100644 index 000000000..efa2d82ab --- /dev/null +++ b/tests/phpstan/configs/optional-com-dotnet.neon @@ -0,0 +1,12 @@ +parameters: + ignoreErrors: + - + message: "#^Instantiated class COM not found\\.$#" + count: 2 + path: src/pocketmine/network/upnp/UPnP.php + + - + message: "#^Access to property \\$StaticPortMappingCollection on an unknown class COM\\.$#" + count: 4 + path: src/pocketmine/network/upnp/UPnP.php + diff --git a/tests/phpstan/configs/optional-leveldb.neon b/tests/phpstan/configs/optional-leveldb.neon new file mode 100644 index 000000000..7ad8f1e28 --- /dev/null +++ b/tests/phpstan/configs/optional-leveldb.neon @@ -0,0 +1,30 @@ +parameters: + ignoreErrors: + - + message: "#^Used constant LEVELDB_ZLIB_RAW_COMPRESSION not found\\.$#" + path: src/pocketmine/level/format/io/leveldb/LevelDB.php + + - + message: "#^Constant LEVELDB_ZLIB_RAW_COMPRESSION not found\\.$#" + path: src/pocketmine/level/format/io/leveldb/LevelDB.php + + - + message: "#^Instantiated class LevelDB not found\\.$#" + path: src/pocketmine/level/format/io/leveldb/LevelDB.php + + - + message: "#^Return typehint of method pocketmine\\\\level\\\\format\\\\io\\\\leveldb\\\\LevelDB\\:\\:createDB\\(\\) has invalid type LevelDB\\.$#" + path: src/pocketmine/level/format/io/leveldb/LevelDB.php + + - + message: "#^Return typehint of method pocketmine\\\\level\\\\format\\\\io\\\\leveldb\\\\LevelDB\\:\\:getDatabase\\(\\) has invalid type LevelDB\\.$#" + path: src/pocketmine/level/format/io/leveldb/LevelDB.php + + - + message: "#^Property pocketmine\\\\level\\\\format\\\\io\\\\leveldb\\\\LevelDB\\:\\:\\$db has unknown class LevelDB as its type\\.$#" + path: src/pocketmine/level/format/io/leveldb/LevelDB.php + + - + message: "#^Call to method (get|put|delete|close)\\(\\) on an unknown class LevelDB\\.$#" + path: src/pocketmine/level/format/io/leveldb/LevelDB.php + diff --git a/tests/phpstan/configs/phpstan-bugs.neon b/tests/phpstan/configs/phpstan-bugs.neon new file mode 100644 index 000000000..90fef5cea --- /dev/null +++ b/tests/phpstan/configs/phpstan-bugs.neon @@ -0,0 +1,10 @@ +parameters: + ignoreErrors: + - + message: "#^PHPDoc tag @param has invalid value \\(.+\\)\\: Unexpected token \"&\", expected TOKEN_VARIABLE at offset \\d+$#" + path: src/pocketmine + + - + message: "#^Default value of the parameter \\#\\d+ \\$[A-Za-z\\d_]+ \\(\\-?\\d+\\) of method .+\\(\\) is incompatible with type float\\.$#" + path: src/pocketmine + diff --git a/tests/phpstan/configs/pthreads-bugs.neon b/tests/phpstan/configs/pthreads-bugs.neon new file mode 100644 index 000000000..65979a989 --- /dev/null +++ b/tests/phpstan/configs/pthreads-bugs.neon @@ -0,0 +1,6 @@ +parameters: + ignoreErrors: + - + message: "#^Variable \\$GLOBALS in isset\\(\\) always exists and is not nullable\\.$#" + path: src/pocketmine/MemoryManager.php +