From ff27c5f7dbd33a6432fd19aed602bfcb7ca8f82c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 1 Nov 2021 17:24:20 +0000 Subject: [PATCH] PHPStan 1.0.0 --- composer.json | 6 +- composer.lock | 54 ++--- phpstan.neon.dist | 4 +- tests/phpstan/configs/actual-problems.neon | 105 +++++++++ .../check-explicit-mixed-baseline.neon | 217 ++++++++++++++++-- tests/phpstan/configs/l7-baseline.neon | 19 +- tests/phpstan/configs/l8-baseline.neon | 5 - tests/phpstan/configs/phpstan-bugs.neon | 109 +++++---- .../phpstan/configs/runtime-type-checks.neon | 67 +----- 9 files changed, 419 insertions(+), 167 deletions(-) diff --git a/composer.json b/composer.json index 262d67a10..b835e1124 100644 --- a/composer.json +++ b/composer.json @@ -38,9 +38,9 @@ "pocketmine/spl": "^0.4.0" }, "require-dev": { - "phpstan/phpstan": "0.12.99", - "phpstan/phpstan-phpunit": "^0.12.6", - "phpstan/phpstan-strict-rules": "^0.12.2", + "phpstan/phpstan": "1.0.0", + "phpstan/phpstan-phpunit": "^1.0.0", + "phpstan/phpstan-strict-rules": "^1.0.0", "phpunit/phpunit": "^9.2" }, "autoload": { diff --git a/composer.lock b/composer.lock index e8c116de0..9250f7dfb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cfba71d2ad0dd961ed00520b5d52e4d7", + "content-hash": "83afdaf7b072e11090279f87f57bebb5", "packages": [ { "name": "adhocore/json-comment", @@ -1011,16 +1011,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.99", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7" + "reference": "0d13a99513182e521271d46bde8f28caa4f84d97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b4d40f1d759942f523be267a1bab6884f46ca3f7", - "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d13a99513182e521271d46bde8f28caa4f84d97", + "reference": "0d13a99513182e521271d46bde8f28caa4f84d97", "shasum": "" }, "require": { @@ -1036,7 +1036,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "0.12-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -1051,7 +1051,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.99" + "source": "https://github.com/phpstan/phpstan/tree/1.0.0" }, "funding": [ { @@ -1071,38 +1071,39 @@ "type": "tidelift" } ], - "time": "2021-09-12T20:09:55+00:00" + "time": "2021-11-01T06:38:20+00:00" }, { "name": "phpstan/phpstan-phpunit", - "version": "0.12.22", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "7c01ef93bf128b4ac8bdad38c54b2a4fd6b0b3cc" + "reference": "9eb88c9f689003a8a2a5ae9e010338ee94dc39b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/7c01ef93bf128b4ac8bdad38c54b2a4fd6b0b3cc", - "reference": "7c01ef93bf128b4ac8bdad38c54b2a4fd6b0b3cc", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/9eb88c9f689003a8a2a5ae9e010338ee94dc39b3", + "reference": "9eb88c9f689003a8a2a5ae9e010338ee94dc39b3", "shasum": "" }, "require": { "php": "^7.1 || ^8.0", - "phpstan/phpstan": "^0.12.92" + "phpstan/phpstan": "^1.0" }, "conflict": { "phpunit/phpunit": "<7.0" }, "require-dev": { + "nikic/php-parser": "^4.13.0", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-strict-rules": "^0.12.6", + "phpstan/phpstan-strict-rules": "^1.0", "phpunit/phpunit": "^9.5" }, "type": "phpstan-extension", "extra": { "branch-alias": { - "dev-master": "0.12-dev" + "dev-master": "1.0-dev" }, "phpstan": { "includes": [ @@ -1123,37 +1124,38 @@ "description": "PHPUnit extensions and rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-phpunit/issues", - "source": "https://github.com/phpstan/phpstan-phpunit/tree/0.12.22" + "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.0.0" }, - "time": "2021-08-12T10:53:43+00:00" + "time": "2021-10-14T08:03:54+00:00" }, { "name": "phpstan/phpstan-strict-rules", - "version": "0.12.11", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-strict-rules.git", - "reference": "2b72e8e17d2034145f239126e876e5fb659675e2" + "reference": "7f50eb112f37fda2ef956813d3f1e9b1e69d7940" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/2b72e8e17d2034145f239126e876e5fb659675e2", - "reference": "2b72e8e17d2034145f239126e876e5fb659675e2", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/7f50eb112f37fda2ef956813d3f1e9b1e69d7940", + "reference": "7f50eb112f37fda2ef956813d3f1e9b1e69d7940", "shasum": "" }, "require": { "php": "^7.1 || ^8.0", - "phpstan/phpstan": "^0.12.96" + "phpstan/phpstan": "^1.0" }, "require-dev": { + "nikic/php-parser": "^4.13.0", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^0.12.16", + "phpstan/phpstan-phpunit": "^1.0", "phpunit/phpunit": "^9.5" }, "type": "phpstan-extension", "extra": { "branch-alias": { - "dev-master": "0.12-dev" + "dev-master": "1.0-dev" }, "phpstan": { "includes": [ @@ -1173,9 +1175,9 @@ "description": "Extra strict and opinionated rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-strict-rules/issues", - "source": "https://github.com/phpstan/phpstan-strict-rules/tree/0.12.11" + "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.0.0" }, - "time": "2021-08-21T11:36:27+00:00" + "time": "2021-10-11T06:57:58+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index df2c4a10b..54e7cd6f6 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -15,9 +15,9 @@ includes: - vendor/phpstan/phpstan-strict-rules/rules.neon parameters: - level: 8 - checkExplicitMixed: true + level: 9 checkMissingCallableSignature: true + treatPhpDocTypesAsCertain: false bootstrapFiles: - tests/phpstan/bootstrap.php scanDirectories: diff --git a/tests/phpstan/configs/actual-problems.neon b/tests/phpstan/configs/actual-problems.neon index bd6e4784d..12a6a1251 100644 --- a/tests/phpstan/configs/actual-problems.neon +++ b/tests/phpstan/configs/actual-problems.neon @@ -5,11 +5,21 @@ parameters: count: 1 path: ../../../src/pocketmine/CrashDump.php + - + message: "#^Only booleans are allowed in &&, mixed given on the right side\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + - message: "#^pocketmine\\\\Player\\:\\:__construct\\(\\) does not call parent constructor from pocketmine\\\\entity\\\\Human\\.$#" count: 1 path: ../../../src/pocketmine/Player.php + - + message: "#^Do\\-while loop condition is always false\\.$#" + count: 1 + path: ../../../src/pocketmine/PocketMine.php + - message: "#^Instanceof between pocketmine\\\\command\\\\CommandReader and pocketmine\\\\command\\\\CommandReader will always evaluate to true\\.$#" count: 1 @@ -705,16 +715,46 @@ parameters: count: 1 path: ../../../src/pocketmine/event/entity/EntityShootBowEvent.php + - + message: "#^PHPDoc type pocketmine\\\\level\\\\Position of property pocketmine\\\\inventory\\\\AnvilInventory\\:\\:\\$holder is not the same as PHPDoc type pocketmine\\\\math\\\\Vector3 of overridden property pocketmine\\\\inventory\\\\ContainerInventory\\:\\:\\$holder\\.$#" + count: 1 + path: ../../../src/pocketmine/inventory/AnvilInventory.php + + - + message: "#^PHPDoc type pocketmine\\\\tile\\\\Chest of property pocketmine\\\\inventory\\\\ChestInventory\\:\\:\\$holder is not the same as PHPDoc type pocketmine\\\\math\\\\Vector3 of overridden property pocketmine\\\\inventory\\\\ContainerInventory\\:\\:\\$holder\\.$#" + count: 1 + path: ../../../src/pocketmine/inventory/ChestInventory.php + - message: "#^pocketmine\\\\inventory\\\\DoubleChestInventory\\:\\:__construct\\(\\) does not call parent constructor from pocketmine\\\\inventory\\\\ChestInventory\\.$#" count: 1 path: ../../../src/pocketmine/inventory/DoubleChestInventory.php + - + message: "#^PHPDoc type pocketmine\\\\level\\\\Position of property pocketmine\\\\inventory\\\\EnchantInventory\\:\\:\\$holder is not the same as PHPDoc type pocketmine\\\\math\\\\Vector3 of overridden property pocketmine\\\\inventory\\\\ContainerInventory\\:\\:\\$holder\\.$#" + count: 1 + path: ../../../src/pocketmine/inventory/EnchantInventory.php + + - + message: "#^PHPDoc type pocketmine\\\\level\\\\Position of property pocketmine\\\\inventory\\\\EnderChestInventory\\:\\:\\$holder is not the same as PHPDoc type pocketmine\\\\tile\\\\Chest of overridden property pocketmine\\\\inventory\\\\ChestInventory\\:\\:\\$holder\\.$#" + count: 1 + path: ../../../src/pocketmine/inventory/EnderChestInventory.php + - message: "#^pocketmine\\\\inventory\\\\EnderChestInventory\\:\\:__construct\\(\\) does not call parent constructor from pocketmine\\\\inventory\\\\ChestInventory\\.$#" count: 1 path: ../../../src/pocketmine/inventory/EnderChestInventory.php + - + message: "#^PHPDoc type pocketmine\\\\tile\\\\Furnace of property pocketmine\\\\inventory\\\\FurnaceInventory\\:\\:\\$holder is not the same as PHPDoc type pocketmine\\\\math\\\\Vector3 of overridden property pocketmine\\\\inventory\\\\ContainerInventory\\:\\:\\$holder\\.$#" + count: 1 + path: ../../../src/pocketmine/inventory/FurnaceInventory.php + + - + message: "#^Property pocketmine\\\\inventory\\\\MultiRecipe\\:\\:\\$uuid is never read, only written\\.$#" + count: 1 + path: ../../../src/pocketmine/inventory/MultiRecipe.php + - message: "#^pocketmine\\\\item\\\\GoldenAppleEnchanted\\:\\:__construct\\(\\) does not call parent constructor from pocketmine\\\\item\\\\GoldenApple\\.$#" count: 1 @@ -725,6 +765,31 @@ parameters: count: 1 path: ../../../src/pocketmine/item/WrittenBook.php + - + message: "#^Only booleans are allowed in &&, mixed given on the right side\\.$#" + count: 1 + path: ../../../src/pocketmine/level/Level.php + + - + message: "#^Only booleans are allowed in \\|\\|, bool\\|null given on the right side\\.$#" + count: 1 + path: ../../../src/pocketmine/level/Level.php + + - + message: "#^Only booleans are allowed in \\|\\|, bool\\|null given on the right side\\.$#" + count: 1 + path: ../../../src/pocketmine/level/format/Chunk.php + + - + message: "#^Parameter \\#2 \\$length of function fread expects int\\<0, max\\>, int given\\.$#" + count: 1 + path: ../../../src/pocketmine/level/format/io/region/RegionLoader.php + + - + message: "#^Parameter \\#2 \\$size of function ftruncate expects int\\<0, max\\>, int given\\.$#" + count: 1 + path: ../../../src/pocketmine/level/format/io/region/RegionLoader.php + - message: "#^Variable property access on \\$this\\(pocketmine\\\\level\\\\generator\\\\PopulationTask\\)\\.$#" count: 4 @@ -740,16 +805,56 @@ parameters: count: 1 path: ../../../src/pocketmine/level/generator/normal/Normal.php + - + message: "#^Property pocketmine\\\\level\\\\generator\\\\object\\\\Pond\\:\\:\\$random is never read, only written\\.$#" + count: 1 + path: ../../../src/pocketmine/level/generator/object/Pond.php + + - + message: "#^Property pocketmine\\\\level\\\\generator\\\\populator\\\\Pond\\:\\:\\$lavaOdd is never read, only written\\.$#" + count: 1 + path: ../../../src/pocketmine/level/generator/populator/Pond.php + + - + message: "#^Property pocketmine\\\\level\\\\generator\\\\populator\\\\Pond\\:\\:\\$lavaSurfaceOdd is never read, only written\\.$#" + count: 1 + path: ../../../src/pocketmine/level/generator/populator/Pond.php + - message: "#^Method pocketmine\\\\metadata\\\\MetadataStore\\:\\:getMetadataInternal\\(\\) should return array\\ but returns SplObjectStorage\\\\.$#" count: 1 path: ../../../src/pocketmine/metadata/MetadataStore.php + - + message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\AvailableActorIdentifiersPacket\\:\\:\\$namedtag \\(string\\) on left side of \\?\\? is not nullable\\.$#" + count: 1 + path: ../../../src/pocketmine/network/mcpe/protocol/AvailableActorIdentifiersPacket.php + + - + message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\BiomeDefinitionListPacket\\:\\:\\$namedtag \\(string\\) on left side of \\?\\? is not nullable\\.$#" + count: 1 + path: ../../../src/pocketmine/network/mcpe/protocol/BiomeDefinitionListPacket.php + + - + message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\UnknownPacket\\:\\:\\$payload \\(string\\) on left side of \\?\\? is not nullable\\.$#" + count: 1 + path: ../../../src/pocketmine/network/mcpe/protocol/UnknownPacket.php + - message: "#^Variable method call on pocketmine\\\\event\\\\Listener\\.$#" count: 1 path: ../../../src/pocketmine/plugin/MethodEventExecutor.php + - + message: "#^Parameter \\#2 \\$length of function fread expects int\\<0, max\\>, int given\\.$#" + count: 1 + path: ../../../src/pocketmine/resourcepacks/ZippedResourcePack.php + + - + message: "#^PHPDoc type pocketmine\\\\scheduler\\\\AsyncWorker\\|null of property pocketmine\\\\scheduler\\\\AsyncTask\\:\\:\\$worker is not the same as PHPDoc type Worker of overridden property Threaded\\:\\:\\$worker\\.$#" + count: 1 + path: ../../../src/pocketmine/scheduler/AsyncTask.php + - message: "#^Constructor of class pocketmine\\\\scheduler\\\\TaskScheduler has an unused parameter \\$logger\\.$#" count: 1 diff --git a/tests/phpstan/configs/check-explicit-mixed-baseline.neon b/tests/phpstan/configs/check-explicit-mixed-baseline.neon index 9c7492962..eda18a112 100644 --- a/tests/phpstan/configs/check-explicit-mixed-baseline.neon +++ b/tests/phpstan/configs/check-explicit-mixed-baseline.neon @@ -25,6 +25,66 @@ parameters: count: 3 path: ../../../src/pocketmine/Player.php + - + message: "#^Cannot access offset 'AnimationExpression' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Cannot access offset 'Colors' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Cannot access offset 'Frames' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Cannot access offset 'Image' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Cannot access offset 'ImageHeight' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Cannot access offset 'ImageWidth' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Cannot access offset 'IsDefault' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Cannot access offset 'PackId' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Cannot access offset 'PieceId' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Cannot access offset 'PieceType' on mixed\\.$#" + count: 2 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Cannot access offset 'ProductId' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Cannot access offset 'Type' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + - message: "#^Cannot cast mixed to int\\.$#" count: 1 @@ -32,7 +92,17 @@ parameters: - message: "#^Parameter \\#1 \\$height of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinImage constructor expects int, mixed given\\.$#" - count: 2 + count: 3 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Parameter \\#1 \\$pieceId of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\PersonaSkinPiece constructor expects string, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Parameter \\#1 \\$pieceType of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\PersonaPieceTintColor constructor expects string, mixed given\\.$#" + count: 1 path: ../../../src/pocketmine/Player.php - @@ -42,7 +112,7 @@ parameters: - message: "#^Parameter \\#1 \\$string of function base64_decode expects string, mixed given\\.$#" - count: 6 + count: 7 path: ../../../src/pocketmine/Player.php - @@ -80,14 +150,54 @@ parameters: count: 1 path: ../../../src/pocketmine/Player.php + - + message: "#^Parameter \\#2 \\$colors of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\PersonaPieceTintColor constructor expects array\\, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Parameter \\#2 \\$pieceType of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\PersonaSkinPiece constructor expects string, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + - message: "#^Parameter \\#2 \\$playFabId of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, mixed given\\.$#" count: 1 path: ../../../src/pocketmine/Player.php + - + message: "#^Parameter \\#2 \\$type of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinAnimation constructor expects int, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + - message: "#^Parameter \\#2 \\$width of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinImage constructor expects int, mixed given\\.$#" - count: 2 + count: 3 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Parameter \\#3 \\$frames of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinAnimation constructor expects float, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Parameter \\#3 \\$packId of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\PersonaSkinPiece constructor expects string, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Parameter \\#4 \\$expressionType of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinAnimation constructor expects int, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Parameter \\#4 \\$isDefaultPiece of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\PersonaSkinPiece constructor expects bool, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Parameter \\#5 \\$productId of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\PersonaSkinPiece constructor expects string, mixed given\\.$#" + count: 1 path: ../../../src/pocketmine/Player.php - @@ -157,6 +267,11 @@ parameters: - message: "#^Cannot access offset 0 on mixed\\.$#" + count: 2 + path: ../../../src/pocketmine/command/defaults/TimingsCommand.php + + - + message: "#^Parameter \\#1 \\$json of function json_decode expects string, mixed given\\.$#" count: 1 path: ../../../src/pocketmine/command/defaults/TimingsCommand.php @@ -200,6 +315,11 @@ parameters: count: 1 path: ../../../src/pocketmine/item/Item.php + - + message: "#^Parameter \\#1 \\$data of static method pocketmine\\\\item\\\\Item\\:\\:jsonDeserialize\\(\\) expects array\\{id\\: int, damage\\?\\: int, count\\?\\: int, nbt\\?\\: string, nbt_hex\\?\\: string, nbt_b64\\?\\: string\\}, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/item/Item.php + - message: "#^Parameter \\#1 \\$id of static method pocketmine\\\\item\\\\ItemFactory\\:\\:get\\(\\) expects int, mixed given\\.$#" count: 1 @@ -330,6 +450,16 @@ parameters: count: 1 path: ../../../src/pocketmine/network/mcpe/RakLibInterface.php + - + message: "#^Parameter \\#1 \\$upload of method pocketmine\\\\network\\\\Network\\:\\:addStatistics\\(\\) expects float, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/network/mcpe/RakLibInterface.php + + - + message: "#^Parameter \\#2 \\$download of method pocketmine\\\\network\\\\Network\\:\\:addStatistics\\(\\) expects float, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/network/mcpe/RakLibInterface.php + - message: "#^Cannot access offset 'exp' on mixed\\.$#" count: 2 @@ -350,6 +480,16 @@ parameters: count: 2 path: ../../../src/pocketmine/network/mcpe/VerifyLoginTask.php + - + message: "#^Cannot use array destructuring on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/network/mcpe/VerifyLoginTask.php + + - + message: "#^Parameter \\#1 \\$string of function wordwrap expects string, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/network/mcpe/VerifyLoginTask.php + - message: "#^Cannot access offset string on mixed\\.$#" count: 1 @@ -361,20 +501,30 @@ parameters: path: ../../../src/pocketmine/network/mcpe/convert/RuntimeBlockMapping.php - - message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\AddActorPacket\\:\\:\\$metadata \\(array\\\\) does not accept array\\\\.$#" + message: "#^Parameter \\#2 \\$legacyId of static method pocketmine\\\\network\\\\mcpe\\\\convert\\\\RuntimeBlockMapping\\:\\:registerMapping\\(\\) expects int, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/network/mcpe/convert/RuntimeBlockMapping.php + + - + message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\AddActorPacket\\:\\:\\$metadata \\(array\\\\) does not accept array\\\\.$#" count: 1 path: ../../../src/pocketmine/network/mcpe/protocol/AddActorPacket.php - - message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\AddItemActorPacket\\:\\:\\$metadata \\(array\\\\) does not accept array\\\\.$#" + message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\AddItemActorPacket\\:\\:\\$metadata \\(array\\\\) does not accept array\\\\.$#" count: 1 path: ../../../src/pocketmine/network/mcpe/protocol/AddItemActorPacket.php - - message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\AddPlayerPacket\\:\\:\\$metadata \\(array\\\\) does not accept array\\\\.$#" + message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\AddPlayerPacket\\:\\:\\$metadata \\(array\\\\) does not accept array\\\\.$#" count: 1 path: ../../../src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php + - + message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" + count: 1 + path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php + - message: "#^Cannot access offset 'XUID' on mixed\\.$#" count: 2 @@ -396,7 +546,12 @@ parameters: path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php - - message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\LoginPacket\\:\\:\\$chainData \\(array\\(\\?'chain' \\=\\> array\\\\)\\) does not accept mixed\\.$#" + message: "#^Parameter \\#1 \\$token of static method pocketmine\\\\utils\\\\Utils\\:\\:decodeJWT\\(\\) expects string, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php + + - + message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\LoginPacket\\:\\:\\$chainData \\(array\\{chain\\?\\: array\\\\}\\) does not accept mixed\\.$#" count: 1 path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php @@ -405,6 +560,11 @@ parameters: count: 1 path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php + - + message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\LoginPacket\\:\\:\\$clientUUID \\(string\\) does not accept mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php + - message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\LoginPacket\\:\\:\\$identityPublicKey \\(string\\) does not accept mixed\\.$#" count: 1 @@ -421,7 +581,17 @@ parameters: path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php - - message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\SetActorDataPacket\\:\\:\\$metadata \\(array\\\\) does not accept array\\\\.$#" + message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\LoginPacket\\:\\:\\$username \\(string\\) does not accept mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php + + - + message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\LoginPacket\\:\\:\\$xuid \\(string\\|null\\) does not accept mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php + + - + message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\SetActorDataPacket\\:\\:\\$metadata \\(array\\\\) does not accept array\\\\.$#" count: 1 path: ../../../src/pocketmine/network/mcpe/protocol/SetActorDataPacket.php @@ -442,7 +612,7 @@ parameters: - message: "#^Array \\(array\\\\) does not accept mixed\\.$#" - count: 1 + count: 2 path: ../../../src/pocketmine/plugin/PluginDescription.php - @@ -480,6 +650,16 @@ parameters: count: 1 path: ../../../src/pocketmine/plugin/PluginDescription.php + - + message: "#^Property pocketmine\\\\plugin\\\\PluginDescription\\:\\:\\$depend \\(array\\\\) does not accept array\\.$#" + count: 1 + path: ../../../src/pocketmine/plugin/PluginDescription.php + + - + message: "#^Property pocketmine\\\\plugin\\\\PluginDescription\\:\\:\\$loadBefore \\(array\\\\) does not accept array\\.$#" + count: 1 + path: ../../../src/pocketmine/plugin/PluginDescription.php + - message: "#^Property pocketmine\\\\plugin\\\\PluginDescription\\:\\:\\$main \\(string\\) does not accept mixed\\.$#" count: 1 @@ -495,6 +675,11 @@ parameters: count: 1 path: ../../../src/pocketmine/plugin/PluginDescription.php + - + message: "#^Property pocketmine\\\\plugin\\\\PluginDescription\\:\\:\\$softDepend \\(array\\\\) does not accept array\\.$#" + count: 1 + path: ../../../src/pocketmine/plugin/PluginDescription.php + - message: "#^Parameter \\#1 \\$description of method pocketmine\\\\command\\\\Command\\:\\:setDescription\\(\\) expects string, mixed given\\.$#" count: 1 @@ -550,6 +735,11 @@ parameters: count: 1 path: ../../../src/pocketmine/updater/AutoUpdater.php + - + message: "#^Cannot access offset string on mixed\\.$#" + count: 3 + path: ../../../src/pocketmine/utils/Config.php + - message: "#^Parameter \\#2 \\$offset of function substr expects int, mixed given\\.$#" count: 1 @@ -561,14 +751,9 @@ parameters: path: ../../../src/pocketmine/utils/Internet.php - - message: "#^Cannot access offset 'status' on mixed\\.$#" + message: "#^Cannot cast mixed to string\\.$#" count: 1 - path: ../../../src/pocketmine/utils/Timezone.php - - - - message: "#^Cannot access offset 'timezone' on mixed\\.$#" - count: 2 - path: ../../../src/pocketmine/utils/Timezone.php + path: ../../../src/pocketmine/utils/Utils.php - message: "#^Parameter \\#1 \\$path of static method pocketmine\\\\utils\\\\Utils\\:\\:cleanPath\\(\\) expects string, mixed given\\.$#" diff --git a/tests/phpstan/configs/l7-baseline.neon b/tests/phpstan/configs/l7-baseline.neon index 52ea0cd26..f0962404d 100644 --- a/tests/phpstan/configs/l7-baseline.neon +++ b/tests/phpstan/configs/l7-baseline.neon @@ -25,6 +25,11 @@ parameters: count: 1 path: ../../../src/pocketmine/MemoryManager.php + - + message: "#^Parameter \\#1 \\$start of method pocketmine\\\\resourcepacks\\\\ResourcePack\\:\\:getPackChunk\\(\\) expects int\\<0, max\\>, int given\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + - message: "#^Parameter \\#3 \\$data of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinImage constructor expects string, string\\|false given\\.$#" count: 3 @@ -196,7 +201,7 @@ parameters: path: ../../../src/pocketmine/block/Sugarcane.php - - message: "#^Cannot access offset 'mode' on array\\(0 \\=\\> int, 1 \\=\\> int, 2 \\=\\> int, 3 \\=\\> int, 4 \\=\\> int, 5 \\=\\> int, 6 \\=\\> int, 7 \\=\\> int, \\.\\.\\.\\)\\|false\\.$#" + message: "#^Cannot access offset 'mode' on array\\{0\\: int, 1\\: int, 2\\: int, 3\\: int, 4\\: int, 5\\: int, 6\\: int, 7\\: int, \\.\\.\\.\\}\\|false\\.$#" count: 1 path: ../../../src/pocketmine/command/CommandReader.php @@ -396,12 +401,12 @@ parameters: path: ../../../src/pocketmine/level/Explosion.php - - message: "#^Cannot access offset 'data' on array\\('priority' \\=\\> int, 'data' \\=\\> pocketmine\\\\math\\\\Vector3\\)\\|int\\|pocketmine\\\\math\\\\Vector3\\.$#" + message: "#^Cannot access offset 'data' on array\\{priority\\: int, data\\: pocketmine\\\\math\\\\Vector3\\}\\|int\\|pocketmine\\\\math\\\\Vector3\\.$#" count: 1 path: ../../../src/pocketmine/level/Level.php - - message: "#^Cannot access offset 'priority' on array\\('priority' \\=\\> int, 'data' \\=\\> pocketmine\\\\math\\\\Vector3\\)\\|int\\|pocketmine\\\\math\\\\Vector3\\.$#" + message: "#^Cannot access offset 'priority' on array\\{priority\\: int, data\\: pocketmine\\\\math\\\\Vector3\\}\\|int\\|pocketmine\\\\math\\\\Vector3\\.$#" count: 1 path: ../../../src/pocketmine/level/Level.php @@ -551,7 +556,7 @@ parameters: path: ../../../src/pocketmine/level/format/io/region/McRegion.php - - message: "#^Only numeric types are allowed in %%, int\\|false given on the left side\\.$#" + message: "#^Only numeric types are allowed in %%, int\\<0, max\\>\\|false given on the left side\\.$#" count: 1 path: ../../../src/pocketmine/level/format/io/region/RegionLoader.php @@ -581,7 +586,7 @@ parameters: path: ../../../src/pocketmine/level/generator/object/TallGrass.php - - message: "#^Method pocketmine\\\\network\\\\mcpe\\\\NetworkBinaryStream\\:\\:getGameRules\\(\\) should return array\\ but returns array\\\\.$#" + message: "#^Method pocketmine\\\\network\\\\mcpe\\\\NetworkBinaryStream\\:\\:getGameRules\\(\\) should return array\\ but returns array\\\\.$#" count: 1 path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php @@ -606,7 +611,7 @@ parameters: path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php - - message: "#^Offset 'chain' does not exist on array\\(\\?'chain' \\=\\> array\\\\)\\.$#" + message: "#^Offset 'chain' does not exist on array\\{chain\\?\\: array\\\\}\\.$#" count: 1 path: ../../../src/pocketmine/network/mcpe/VerifyLoginTask.php @@ -716,7 +721,7 @@ parameters: path: ../../../src/pocketmine/resourcepacks/ZippedResourcePack.php - - message: "#^Method pocketmine\\\\resourcepacks\\\\ZippedResourcePack\\:\\:getPackSize\\(\\) should return int but returns int\\|false\\.$#" + message: "#^Method pocketmine\\\\resourcepacks\\\\ZippedResourcePack\\:\\:getPackSize\\(\\) should return int but returns int\\<0, max\\>\\|false\\.$#" count: 1 path: ../../../src/pocketmine/resourcepacks/ZippedResourcePack.php diff --git a/tests/phpstan/configs/l8-baseline.neon b/tests/phpstan/configs/l8-baseline.neon index 636f93250..19ca8fa1f 100644 --- a/tests/phpstan/configs/l8-baseline.neon +++ b/tests/phpstan/configs/l8-baseline.neon @@ -970,11 +970,6 @@ parameters: count: 1 path: ../../../src/pocketmine/item/PoisonousPotato.php - - - message: "#^Parameter \\#1 \\$effectType of class pocketmine\\\\entity\\\\EffectInstance constructor expects pocketmine\\\\entity\\\\Effect, pocketmine\\\\entity\\\\Effect\\|null given\\.$#" - count: 32 - path: ../../../src/pocketmine/item/Potion.php - - message: "#^Parameter \\#1 \\$effectType of class pocketmine\\\\entity\\\\EffectInstance constructor expects pocketmine\\\\entity\\\\Effect, pocketmine\\\\entity\\\\Effect\\|null given\\.$#" count: 3 diff --git a/tests/phpstan/configs/phpstan-bugs.neon b/tests/phpstan/configs/phpstan-bugs.neon index d538a89ca..4291463fa 100644 --- a/tests/phpstan/configs/phpstan-bugs.neon +++ b/tests/phpstan/configs/phpstan-bugs.neon @@ -1,75 +1,100 @@ parameters: ignoreErrors: - - message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(pocketmine\\\\Player\\)\\: bool given\\.$#" + message: "#^Cannot access offset 'base_version' on mixed\\.$#" count: 1 - path: ../../../src/pocketmine/Server.php + path: ../../../src/pocketmine/CrashDump.php - - message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(string\\)\\: bool given\\.$#" + message: "#^Cannot access offset 'build' on mixed\\.$#" count: 1 - path: ../../../src/pocketmine/Server.php + path: ../../../src/pocketmine/CrashDump.php + + - + message: "#^Cannot access offset 'composer_libraries' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/CrashDump.php + + - + message: "#^Cannot access offset 'git' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/CrashDump.php + + - + message: "#^Cannot access offset 'is_dev' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/CrashDump.php + + - + message: "#^Cannot access offset 'os' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/CrashDump.php + + - + message: "#^Cannot access offset 'php' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/CrashDump.php + + - + message: "#^Cannot access offset 'php_os' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/CrashDump.php + + - + message: "#^Cannot access offset 'protocol' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/CrashDump.php + + - + message: "#^Cannot access offset 'uname' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/CrashDump.php + + - + message: "#^Cannot access offset 'zend' on mixed\\.$#" + count: 1 + path: ../../../src/pocketmine/CrashDump.php - message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#" - count: 3 + count: 2 path: ../../../src/pocketmine/command/CommandReader.php - - - message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(pocketmine\\\\Player\\)\\: bool given\\.$#" - count: 1 - path: ../../../src/pocketmine/command/defaults/ListCommand.php - - - - message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(pocketmine\\\\entity\\\\Attribute\\)\\: bool given\\.$#" - count: 1 - path: ../../../src/pocketmine/entity/AttributeMap.php - - - - message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(pocketmine\\\\item\\\\Item\\)\\: bool given\\.$#" - count: 1 - path: ../../../src/pocketmine/entity/Human.php - - message: "#^Call to function assert\\(\\) with false and 'unknown hit type' will always evaluate to false\\.$#" count: 1 path: ../../../src/pocketmine/entity/projectile/Projectile.php - - message: "#^Parameter \\#2 \\$callback of function usort expects callable\\(mixed, mixed\\)\\: int, array\\('pocketmine\\\\\\\\inventory\\\\\\\\CraftingManager', 'sort'\\) given\\.$#" + message: "#^Dead catch \\- ReflectionException is never thrown in the try block\\.$#" count: 1 - path: ../../../src/pocketmine/inventory/CraftingManager.php - - - - message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(string\\)\\: bool given\\.$#" - count: 1 - path: ../../../src/pocketmine/lang/BaseLang.php - - - - message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(pocketmine\\\\entity\\\\Entity\\)\\: bool given\\.$#" - count: 1 - path: ../../../src/pocketmine/level/format/Chunk.php - - - - message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(string\\)\\: bool given\\.$#" - count: 1 - path: ../../../src/pocketmine/level/format/io/region/McRegion.php + path: ../../../src/pocketmine/level/format/io/LevelProviderManager.php - message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#" count: 2 path: ../../../src/pocketmine/level/format/io/region/RegionLoader.php - - - message: "#^Parameter \\#2 \\$count of function array_fill expects int\\<0, max\\>, int given\\.$#" - count: 2 - path: ../../../src/pocketmine/level/generator/noise/Noise.php - - message: "#^Call to function method_exists\\(\\) with pocketmine\\\\network\\\\mcpe\\\\CachedEncapsulatedPacket and '__toString' will always evaluate to true\\.$#" count: 1 path: ../../../src/pocketmine/network/mcpe/protocol/DataPacket.php + - + message: "#^Parameter \\#1 \\$array of function array_values expects array, array given\\.$#" + count: 1 + path: ../../../src/pocketmine/plugin/PluginDescription.php + + - + message: "#^Parameter \\#2 \\$array of function array_map expects array, array given\\.$#" + count: 3 + path: ../../../src/pocketmine/plugin/PluginDescription.php + + - + message: "#^Dead catch \\- ReflectionException is never thrown in the try block\\.$#" + count: 2 + path: ../../../src/pocketmine/utils/Utils.php + - message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#" count: 1 diff --git a/tests/phpstan/configs/runtime-type-checks.neon b/tests/phpstan/configs/runtime-type-checks.neon index 8383e39fa..88459daaf 100644 --- a/tests/phpstan/configs/runtime-type-checks.neon +++ b/tests/phpstan/configs/runtime-type-checks.neon @@ -1,77 +1,12 @@ parameters: ignoreErrors: - - - message: "#^Call to function is_subclass_of\\(\\) with class\\-string\\ and 'pocketmine\\\\\\\\level\\\\\\\\generator\\\\\\\\Generator' will always evaluate to true\\.$#" - count: 1 - path: ../../../src/pocketmine/Server.php - - - - message: "#^If condition is always true\\.$#" - count: 2 - path: ../../../src/pocketmine/ThreadManager.php - - - - message: "#^Instanceof between pocketmine\\\\Worker and pocketmine\\\\Worker will always evaluate to true\\.$#" - count: 2 - path: ../../../src/pocketmine/ThreadManager.php - - - - message: "#^Instanceof between pocketmine\\\\plugin\\\\RegisteredListener and pocketmine\\\\plugin\\\\RegisteredListener will always evaluate to true\\.$#" - count: 1 - path: ../../../src/pocketmine/event/HandlerList.php - - message: "#^Casting to int something that's already int\\.$#" - count: 3 + count: 2 path: ../../../src/pocketmine/item/Item.php - - - message: "#^Call to function is_object\\(\\) with \\*NEVER\\* will always evaluate to true\\.$#" - count: 1 - path: ../../../src/pocketmine/item/ItemFactory.php - - - - message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" - count: 1 - path: ../../../src/pocketmine/item/ItemFactory.php - - - - message: "#^If condition is always false\\.$#" - count: 1 - path: ../../../src/pocketmine/item/ItemFactory.php - - - - message: "#^Strict comparison using \\!\\=\\= between null and null will always evaluate to false\\.$#" - count: 1 - path: ../../../src/pocketmine/item/ItemFactory.php - - - - message: "#^Call to function is_object\\(\\) with \\*NEVER\\* will always evaluate to true\\.$#" - count: 2 - path: ../../../src/pocketmine/level/Level.php - - - - message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" - count: 2 - path: ../../../src/pocketmine/level/Level.php - - - - message: "#^Instanceof between pocketmine\\\\math\\\\Vector3 and pocketmine\\\\math\\\\Vector3 will always evaluate to true\\.$#" - count: 2 - path: ../../../src/pocketmine/level/Level.php - - - - message: "#^Call to function is_subclass_of\\(\\) with class\\-string\\ and 'pocketmine\\\\\\\\level\\\\\\\\generator\\\\\\\\Generator' will always evaluate to true\\.$#" - count: 1 - path: ../../../src/pocketmine/level/generator/GeneratorManager.php - - message: "#^Call to function is_array\\(\\) with array\\ will always evaluate to true\\.$#" count: 1 path: ../../../src/pocketmine/plugin/PluginManager.php - - - message: "#^Call to function is_subclass_of\\(\\) with class\\-string\\ and 'pocketmine\\\\\\\\event\\\\\\\\Event' will always evaluate to true\\.$#" - count: 1 - path: ../../../src/pocketmine/plugin/PluginManager.php -