From af8936dba53f14ee9d42d027892ae23ff74fe900 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 24 Jan 2021 20:14:42 +0000 Subject: [PATCH 01/11] phpstan 0.12.69 --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index e85b011ea..2ecefd869 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "composer-runtime-api": "^2.0" }, "require-dev": { - "phpstan/phpstan": "0.12.67", + "phpstan/phpstan": "0.12.69", "phpstan/phpstan-phpunit": "^0.12.6", "phpstan/phpstan-strict-rules": "^0.12.2", "phpunit/phpunit": "^9.2" diff --git a/composer.lock b/composer.lock index 983d56ecc..c0e949196 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": "a0b7eefe1ad35462d08e876d942b9003", + "content-hash": "5466cbf8934081309e4c8ad5c2781f65", "packages": [ { "name": "adhocore/json-comment", @@ -1002,16 +1002,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.67", + "version": "0.12.69", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "ced7a5d9c5dba908c1c00cea3f1d4ad74da71b86" + "reference": "8f436ea35241da33487fd0d38b4bc3e6dfe30ea8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ced7a5d9c5dba908c1c00cea3f1d4ad74da71b86", - "reference": "ced7a5d9c5dba908c1c00cea3f1d4ad74da71b86", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/8f436ea35241da33487fd0d38b4bc3e6dfe30ea8", + "reference": "8f436ea35241da33487fd0d38b4bc3e6dfe30ea8", "shasum": "" }, "require": { @@ -1042,7 +1042,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.67" + "source": "https://github.com/phpstan/phpstan/tree/0.12.69" }, "funding": [ { @@ -1058,7 +1058,7 @@ "type": "tidelift" } ], - "time": "2021-01-14T14:16:19+00:00" + "time": "2021-01-24T14:55:37+00:00" }, { "name": "phpstan/phpstan-phpunit", From 34c1d455a7d2fff90113d098d73ce565d8edce40 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 24 Jan 2021 20:27:53 +0000 Subject: [PATCH 02/11] phpstan: enable checkMissingCallableSignature --- phpstan.neon.dist | 1 + src/pocketmine/plugin/PluginManager.php | 1 + src/pocketmine/utils/Utils.php | 5 +++++ tests/phpstan/configs/l8-baseline.neon | 5 ----- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index e4c7e4ecf..adab63b58 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -17,6 +17,7 @@ includes: parameters: level: 8 checkExplicitMixed: true + checkMissingCallableSignature: true bootstrapFiles: - tests/phpstan/bootstrap.php scanDirectories: diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index 0a52f58d9..6ee6fa1ec 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -701,6 +701,7 @@ class PluginManager{ } $handlerClosure = $method->getClosure($listener); + if($handlerClosure === null) throw new AssumptionFailedError("This should never happen"); try{ $paramType = $parameters[0]->getType(); diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 1f7dace93..53ca56490 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -117,6 +117,8 @@ class Utils{ /** * Generates an unique identifier to a callable * + * @phpstan-param callable(mixed...) : mixed $variable + * * @return string */ public static function getCallableIdentifier(callable $variable){ @@ -132,6 +134,7 @@ class Utils{ /** * Returns a readable identifier for the given Closure, including file and line. * + * @phpstan-param \Closure(mixed...) : mixed $closure * @throws \ReflectionException */ public static function getNiceClosureName(\Closure $closure) : string{ @@ -685,6 +688,8 @@ class Utils{ * * @param callable $signature Dummy callable with the required parameters and return type * @param callable $subject Callable to check the signature of + * @phpstan-param callable(mixed...) : mixed $signature + * @phpstan-param callable(mixed...) : mixed $subject * * @throws \DaveRandom\CallbackValidator\InvalidCallbackException * @throws \TypeError diff --git a/tests/phpstan/configs/l8-baseline.neon b/tests/phpstan/configs/l8-baseline.neon index 5df43badf..29fa38cca 100644 --- a/tests/phpstan/configs/l8-baseline.neon +++ b/tests/phpstan/configs/l8-baseline.neon @@ -1485,11 +1485,6 @@ parameters: count: 1 path: ../../../src/pocketmine/plugin/PluginBase.php - - - message: "#^Parameter \\#1 \\$closure of static method pocketmine\\\\utils\\\\Utils\\:\\:getNiceClosureName\\(\\) expects Closure, Closure\\|null given\\.$#" - count: 3 - path: ../../../src/pocketmine/plugin/PluginManager.php - - message: "#^Cannot call method handleException\\(\\) on pocketmine\\\\scheduler\\\\AsyncWorker\\|null\\.$#" count: 1 From f9e42b716a568db29cdbfc8d211a6b5e3ddba040 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 24 Jan 2021 20:31:22 +0000 Subject: [PATCH 03/11] Scrub PHPStan baselines these are now always generated with level 8. --- .../check-explicit-mixed-baseline.neon | 60 +++--- tests/phpstan/configs/l7-baseline.neon | 175 ------------------ tests/phpstan/configs/l8-baseline.neon | 5 - 3 files changed, 25 insertions(+), 215 deletions(-) diff --git a/tests/phpstan/configs/check-explicit-mixed-baseline.neon b/tests/phpstan/configs/check-explicit-mixed-baseline.neon index 71e0ffcb1..04e4504db 100644 --- a/tests/phpstan/configs/check-explicit-mixed-baseline.neon +++ b/tests/phpstan/configs/check-explicit-mixed-baseline.neon @@ -45,6 +45,31 @@ parameters: count: 1 path: ../../../src/pocketmine/Player.php + - + message: "#^Parameter \\#1 \\$str of function base64_decode expects string, mixed given\\.$#" + count: 5 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Parameter \\#1 \\$height of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinImage constructor expects int, mixed given\\.$#" + count: 2 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Parameter \\#2 \\$width of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinImage constructor expects int, mixed given\\.$#" + count: 2 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Parameter \\#8 \\$premium of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects bool, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + + - + message: "#^Parameter \\#9 \\$persona of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects bool, mixed given\\.$#" + count: 1 + path: ../../../src/pocketmine/Player.php + - message: "#^Parameter \\#10 \\$personaCapeOnClassic of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects bool, mixed given\\.$#" count: 1 @@ -65,31 +90,6 @@ parameters: count: 1 path: ../../../src/pocketmine/Player.php - - - message: "#^Parameter \\#8 \\$premium of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects bool, mixed given\\.$#" - count: 1 - path: ../../../src/pocketmine/Player.php - - - - message: "#^Parameter \\#9 \\$persona of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects bool, mixed given\\.$#" - count: 1 - path: ../../../src/pocketmine/Player.php - - - - message: "#^Parameter \\#1 \\$str of function base64_decode expects string, mixed given\\.$#" - count: 5 - path: ../../../src/pocketmine/Player.php - - - - message: "#^Parameter \\#1 \\$height of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinImage constructor expects int, mixed given\\.$#" - count: 2 - path: ../../../src/pocketmine/Player.php - - - - message: "#^Parameter \\#2 \\$width of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinImage constructor expects int, mixed given\\.$#" - count: 2 - path: ../../../src/pocketmine/Player.php - - message: "#^Parameter \\#1 \\.\\.\\.\\$slots of method pocketmine\\\\inventory\\\\BaseInventory\\:\\:addItem\\(\\) expects pocketmine\\\\item\\\\Item, mixed given\\.$#" count: 1 @@ -275,11 +275,6 @@ parameters: count: 6 path: ../../../src/pocketmine/level/generator/noise/Noise.php - - - message: "#^Cannot call method invalidate\\(\\) on mixed\\.$#" - count: 1 - path: ../../../src/pocketmine/metadata/MetadataStore.php - - message: "#^Parameter \\#1 \\$buffer of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\BatchPacket constructor expects string, mixed given\\.$#" count: 1 @@ -450,11 +445,6 @@ parameters: count: 1 path: ../../../src/pocketmine/network/mcpe/protocol/SetActorDataPacket.php - - - message: "#^Parameter \\#1 \\$table of static method pocketmine\\\\network\\\\mcpe\\\\protocol\\\\StartGamePacket\\:\\:serializeItemTable\\(\\) expects array\\, mixed given\\.$#" - count: 1 - path: ../../../src/pocketmine/network/mcpe/protocol/StartGamePacket.php - - message: "#^Parameter \\#1 \\$value of static method pocketmine\\\\permission\\\\Permission\\:\\:getByName\\(\\) expects bool\\|string, mixed given\\.$#" count: 1 diff --git a/tests/phpstan/configs/l7-baseline.neon b/tests/phpstan/configs/l7-baseline.neon index 0abcf76ad..18de57e8f 100644 --- a/tests/phpstan/configs/l7-baseline.neon +++ b/tests/phpstan/configs/l7-baseline.neon @@ -60,16 +60,6 @@ parameters: count: 1 path: ../../../src/pocketmine/PocketMine.php - - - message: "#^Parameter \\#1 \\$filename of function is_file expects string, array\\\\|string given\\.$#" - count: 1 - path: ../../../src/pocketmine/PocketMine.php - - - - message: "#^Binary operation \"\\.\" between 'Composer autoloader…' and array\\\\|string\\|false results in an error\\.$#" - count: 1 - path: ../../../src/pocketmine/PocketMine.php - - message: "#^Binary operation \"\\.\" between array\\\\|string\\|false and '/'\\|'\\\\\\\\' results in an error\\.$#" count: 2 @@ -155,51 +145,6 @@ parameters: count: 1 path: ../../../src/pocketmine/block/Cactus.php - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getBlockIdAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/Farmland.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getBlockIdAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/Farmland.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getBlockIdAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/Farmland.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/Grass.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/Grass.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/Grass.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getBlockIdAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/Grass.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getBlockIdAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/Grass.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getBlockIdAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/Grass.php - - message: "#^Parameter \\#1 \\$min of function mt_rand expects int, float\\|int given\\.$#" count: 3 @@ -210,36 +155,6 @@ parameters: count: 3 path: ../../../src/pocketmine/block/Grass.php - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getHighestAdjacentBlockLight\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/Ice.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getHighestAdjacentBlockLight\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/Ice.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getHighestAdjacentBlockLight\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/Ice.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 23 - path: ../../../src/pocketmine/block/Liquid.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 23 - path: ../../../src/pocketmine/block/Liquid.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 23 - path: ../../../src/pocketmine/block/Liquid.php - - message: "#^Parameter \\#1 \\$x of static method pocketmine\\\\level\\\\Level\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#" count: 3 @@ -295,36 +210,6 @@ parameters: count: 2 path: ../../../src/pocketmine/block/Sapling.php - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/Sapling.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/Sapling.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/Sapling.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getBlockLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/SnowLayer.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getBlockLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/SnowLayer.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getBlockLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/SnowLayer.php - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" count: 2 @@ -400,21 +285,6 @@ parameters: count: 1 path: ../../../src/pocketmine/entity/Human.php - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/entity/Living.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/entity/Living.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/entity/Living.php - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" count: 1 @@ -435,21 +305,6 @@ parameters: count: 3 path: ../../../src/pocketmine/entity/projectile/Projectile.php - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/pocketmine/entity/projectile/Projectile.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/pocketmine/entity/projectile/Projectile.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/pocketmine/entity/projectile/Projectile.php - - message: "#^Parameter \\#1 \\$argument of class ReflectionClass constructor expects class\\-string\\\\|T of object, string given\\.$#" count: 1 @@ -685,11 +540,6 @@ parameters: count: 1 path: ../../../src/pocketmine/level/Level.php - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\format\\\\Chunk\\:\\:setBlock\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/level/Level.php - - message: "#^Parameter \\#1 \\$x of static method pocketmine\\\\level\\\\Level\\:\\:chunkBlockHash\\(\\) expects int, float\\|int given\\.$#" count: 1 @@ -770,16 +620,6 @@ parameters: count: 1 path: ../../../src/pocketmine/level/generator/object/TallGrass.php - - - message: "#^Method pocketmine\\\\metadata\\\\MetadataStore\\:\\:getMetadataInternal\\(\\) should return array\\ but returns array\\\\|SplObjectStorage\\.$#" - count: 1 - path: ../../../src/pocketmine/metadata/MetadataStore.php - - - - message: "#^Cannot call method count\\(\\) on array\\\\|SplObjectStorage\\.$#" - count: 1 - path: ../../../src/pocketmine/metadata/MetadataStore.php - - message: "#^Parameter \\#1 \\$str of method pocketmine\\\\utils\\\\BinaryStream\\:\\:put\\(\\) expects string, string\\|false given\\.$#" count: 2 @@ -985,18 +825,3 @@ parameters: count: 3 path: ../../../src/pocketmine/tile/Tile.php - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/tile/Tile.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/tile/Tile.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/pocketmine/tile/Tile.php - diff --git a/tests/phpstan/configs/l8-baseline.neon b/tests/phpstan/configs/l8-baseline.neon index 29fa38cca..05c285760 100644 --- a/tests/phpstan/configs/l8-baseline.neon +++ b/tests/phpstan/configs/l8-baseline.neon @@ -1445,11 +1445,6 @@ parameters: count: 1 path: ../../../src/pocketmine/network/mcpe/convert/RuntimeBlockMapping.php - - - message: "#^Parameter \\#1 \\$that of method pocketmine\\\\nbt\\\\tag\\\\NamedTag\\:\\:equals\\(\\) expects pocketmine\\\\nbt\\\\tag\\\\NamedTag, pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null given\\.$#" - count: 1 - path: ../../../src/pocketmine/network/mcpe/convert/RuntimeBlockMapping.php - - message: "#^Method pocketmine\\\\network\\\\mcpe\\\\convert\\\\RuntimeBlockMapping\\:\\:getBedrockKnownStates\\(\\) should return array\\ but returns array\\\\|null\\.$#" count: 1 From b296ae1b872aa0dbb6d118993aaab70913326b13 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 25 Jan 2021 17:15:31 +0000 Subject: [PATCH 04/11] Release 3.17.3 --- changelogs/3.17.md | 6 ++++++ src/pocketmine/VersionInfo.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelogs/3.17.md b/changelogs/3.17.md index 0e710dbed..277c10ee0 100644 --- a/changelogs/3.17.md +++ b/changelogs/3.17.md @@ -26,3 +26,9 @@ Plugin developers should **only** update their required API to this version if y - Fixed region header corruption when chunks with larger-than-expected lengths are found. These chunks are now treated as corrupted, instead of automatically attempting to salvage them (which usually fails anyway). - `RegionLoader->removeChunk()` now allows the space used by the removed chunk to be reused by future region saves. - Extracted `Living->applyConsumptionResults()` from `Living->consumeObject()` (preparation for a future bug fix). + +# 3.17.3 +- Improved performance of chunk loading in Region-based worlds. +- Improved performance of region header validation in Region-based worlds (indirect improvement to chunk loading performance). +- Fixed some PHP 8.0 language-level compatibility issues. +- Source installations will now exit with an error when Composer dependencies are not in sync with the current Git revision. Now, it's required to run `composer install` after every git pull to make sure the correct dependency versions are installed. diff --git a/src/pocketmine/VersionInfo.php b/src/pocketmine/VersionInfo.php index 4d7ea3316..d981e08ef 100644 --- a/src/pocketmine/VersionInfo.php +++ b/src/pocketmine/VersionInfo.php @@ -34,5 +34,5 @@ const _VERSION_INFO_INCLUDED = true; const NAME = "PocketMine-MP"; const BASE_VERSION = "3.17.3"; -const IS_DEVELOPMENT_BUILD = true; +const IS_DEVELOPMENT_BUILD = false; const BUILD_NUMBER = 0; From 31b6df43760104a5023f187e101e8df53b18ed70 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 25 Jan 2021 17:15:43 +0000 Subject: [PATCH 05/11] 3.17.4 is next --- src/pocketmine/VersionInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/VersionInfo.php b/src/pocketmine/VersionInfo.php index d981e08ef..df0e46c88 100644 --- a/src/pocketmine/VersionInfo.php +++ b/src/pocketmine/VersionInfo.php @@ -33,6 +33,6 @@ if(defined('pocketmine\_VERSION_INFO_INCLUDED')){ const _VERSION_INFO_INCLUDED = true; const NAME = "PocketMine-MP"; -const BASE_VERSION = "3.17.3"; -const IS_DEVELOPMENT_BUILD = false; +const BASE_VERSION = "3.17.4"; +const IS_DEVELOPMENT_BUILD = true; const BUILD_NUMBER = 0; From 62deafda4839649a627a8699fbad94d28260e2ef Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 25 Jan 2021 17:53:25 +0000 Subject: [PATCH 06/11] CommandReader: removed readline support readline has been borked for a long time and it's not thread safe. --- src/pocketmine/command/CommandReader.php | 78 ++++++++---------------- 1 file changed, 27 insertions(+), 51 deletions(-) diff --git a/src/pocketmine/command/CommandReader.php b/src/pocketmine/command/CommandReader.php index 5a779b48c..10970d64b 100644 --- a/src/pocketmine/command/CommandReader.php +++ b/src/pocketmine/command/CommandReader.php @@ -25,23 +25,18 @@ namespace pocketmine\command; use pocketmine\snooze\SleeperNotifier; use pocketmine\Thread; -use pocketmine\utils\Utils; -use function extension_loaded; use function fclose; use function fgets; use function fopen; use function fstat; -use function getopt; use function is_resource; use function microtime; use function preg_replace; use function readline; -use function readline_add_history; use function stream_isatty; use function stream_select; use function trim; use function usleep; -use const STDIN; class CommandReader extends Thread{ @@ -65,12 +60,6 @@ class CommandReader extends Thread{ public function __construct(?SleeperNotifier $notifier = null){ $this->buffer = new \Threaded; $this->notifier = $notifier; - - $opts = getopt("", ["disable-readline", "enable-readline"]); - - if(extension_loaded("readline") and (Utils::getOS() === Utils::OS_WINDOWS ? isset($opts["enable-readline"]) : !isset($opts["disable-readline"])) and !$this->isPipe(STDIN)){ - $this->type = self::TYPE_READLINE; - } } /** @@ -128,41 +117,34 @@ class CommandReader extends Thread{ */ private function readLine() : bool{ $line = ""; - if($this->type === self::TYPE_READLINE){ - if(($raw = readline("> ")) !== false and ($line = trim($raw)) !== ""){ - readline_add_history($line); - }else{ - return true; - } - }else{ - if(!is_resource(self::$stdin)){ - $this->initStdin(); - } - switch($this->type){ - /** @noinspection PhpMissingBreakStatementInspection */ - case self::TYPE_STREAM: - //stream_select doesn't work on piped streams for some reason - $r = [self::$stdin]; - $w = $e = null; - if(($count = stream_select($r, $w, $e, 0, 200000)) === 0){ //nothing changed in 200000 microseconds - return true; - }elseif($count === false){ //stream error - $this->initStdin(); - } + if(!is_resource(self::$stdin)){ + $this->initStdin(); + } - case self::TYPE_PIPED: - if(($raw = fgets(self::$stdin)) === false){ //broken pipe or EOF - $this->initStdin(); - $this->synchronized(function() : void{ - $this->wait(200000); - }); //prevent CPU waste if it's end of pipe - return true; //loop back round - } + switch($this->type){ + /** @noinspection PhpMissingBreakStatementInspection */ + case self::TYPE_STREAM: + //stream_select doesn't work on piped streams for some reason + $r = [self::$stdin]; + $w = $e = null; + if(($count = stream_select($r, $w, $e, 0, 200000)) === 0){ //nothing changed in 200000 microseconds + return true; + }elseif($count === false){ //stream error + $this->initStdin(); + } - $line = trim($raw); - break; - } + case self::TYPE_PIPED: + if(($raw = fgets(self::$stdin)) === false){ //broken pipe or EOF + $this->initStdin(); + $this->synchronized(function() : void{ + $this->wait(200000); + }); //prevent CPU waste if it's end of pipe + return true; //loop back round + } + + $line = trim($raw); + break; } if($line !== ""){ @@ -193,17 +175,11 @@ class CommandReader extends Thread{ */ public function run(){ $this->registerClassLoader(); - - if($this->type !== self::TYPE_READLINE){ - $this->initStdin(); - } + $this->initStdin(); while(!$this->shutdown and $this->readLine()); - if($this->type !== self::TYPE_READLINE){ - fclose(self::$stdin); - } - + fclose(self::$stdin); } public function getThreadName() : string{ From c134b1cd8a0c9f6e7113895458f358371f7659fc Mon Sep 17 00:00:00 2001 From: Dylan T Date: Tue, 26 Jan 2021 17:34:05 +0000 Subject: [PATCH 07/11] [ci skip] README: add some badges --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 55f8cad38..1c02cb9ed 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@

![CI](https://github.com/pmmp/PocketMine-MP/workflows/CI/badge.svg) +[![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/pmmp/PocketMine-MP?label=release&logo=github)](https://github.com/pmmp/PocketMine-MP/releases) +[![Docker Image Version (latest semver)](https://img.shields.io/docker/v/pmmp/pocketmine-mp?logo=docker&label=image)](https://hub.docker.com/r/pmmp/pocketmine-mp) +[![Discord](https://img.shields.io/discord/373199722573201408?label=discord&color=7289DA&logo=discord)](https://discord.gg/bmSAZBG) ## Getting started - [Documentation](http://pmmp.readthedocs.org/) From 38b2d83799ff796c15b784510ff983a8daf0eafe Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 26 Jan 2021 20:32:09 +0000 Subject: [PATCH 08/11] MemoryManager: fixed protected properties being dumped multiple times we don't need to scan the parent classes for anything other than private properties, because protected and public properties will appear on the main reflection as if they were declared directly as such. --- src/pocketmine/MemoryManager.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/MemoryManager.php b/src/pocketmine/MemoryManager.php index bf819fe03..ec31d9181 100644 --- a/src/pocketmine/MemoryManager.php +++ b/src/pocketmine/MemoryManager.php @@ -423,8 +423,12 @@ class MemoryManager{ } $name = $property->getName(); - if($reflection !== $original and !$property->isPublic()){ - $name = $reflection->getName() . ":" . $name; + if($reflection !== $original){ + if($property->isPrivate()){ + $name = $reflection->getName() . ":" . $name; + }else{ + continue; + } } if(!$property->isPublic()){ $property->setAccessible(true); From bac57c159f83a21945f41cae07c4f4fee673fd7b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 27 Jan 2021 00:09:55 +0000 Subject: [PATCH 09/11] Player: fix bridging, towering and various other fast building bugs clickPos is relative to the base block position, so if you keep aiming at the same spot on the block and jump, it thinks you're still spamming. closes #2730 --- src/pocketmine/Player.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 066041b70..bc228f9af 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -408,8 +408,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** @var float */ protected $lastRightClickTime = 0.0; - /** @var Vector3|null */ - protected $lastRightClickPos = null; + /** @var \stdClass|null */ + protected $lastRightClickData = null; /** * @return TranslationContainer|string @@ -2495,12 +2495,16 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ switch($type){ case InventoryTransactionPacket::USE_ITEM_ACTION_CLICK_BLOCK: //TODO: start hack for client spam bug - $spamBug = ($this->lastRightClickPos !== null and + $spamBug = ($this->lastRightClickData !== null and microtime(true) - $this->lastRightClickTime < 0.1 and //100ms - $this->lastRightClickPos->distanceSquared($packet->trData->clickPos) < 0.00001 //signature spam bug has 0 distance, but allow some error + $this->lastRightClickData->playerPos->distanceSquared($packet->trData->playerPos) < 0.00001 and + $this->lastRightClickData->x === $packet->trData->x and + $this->lastRightClickData->y === $packet->trData->y and + $this->lastRightClickData->z === $packet->trData->z and + $this->lastRightClickData->clickPos->distanceSquared($packet->trData->clickPos) < 0.00001 //signature spam bug has 0 distance, but allow some error ); //get rid of continued spam if the player clicks and holds right-click - $this->lastRightClickPos = clone $packet->trData->clickPos; + $this->lastRightClickData = $packet->trData; $this->lastRightClickTime = microtime(true); if($spamBug){ return true; From 16fa9584164c18f682435f0e84dc90e9155c3df4 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 27 Jan 2021 19:25:28 +0000 Subject: [PATCH 10/11] phpstan: better hack for any-callable parameters variadics are a bad fit for this because what we really need is to accept callable with any number of arguments. LSP requires that the provided number of arguments must be >= than the required number of arguments. --- phpstan.neon.dist | 6 ++++++ src/pocketmine/utils/Utils.php | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index adab63b58..7586d7e11 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -42,3 +42,9 @@ parameters: reportUnmatchedIgnoredErrors: false #no other way to silence platform-specific non-warnings staticReflectionClassNamePatterns: - "#^COM$#" + typeAliases: + #variadics don't work for this - mixed probably shouldn't work either, but for now it does + #what we actually need is something that accepts an infinite number of parameters, but in the absence of that, + #we'll just fill it with 10 - it's very unlikely to encounter a callable with 10 parameters anyway. + anyCallable: 'callable(mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed) : mixed' + anyClosure: '\Closure(mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed) : mixed' diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 53ca56490..5e8deeb81 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -117,7 +117,7 @@ class Utils{ /** * Generates an unique identifier to a callable * - * @phpstan-param callable(mixed...) : mixed $variable + * @phpstan-param anyCallable $variable * * @return string */ @@ -134,7 +134,7 @@ class Utils{ /** * Returns a readable identifier for the given Closure, including file and line. * - * @phpstan-param \Closure(mixed...) : mixed $closure + * @phpstan-param anyClosure $closure * @throws \ReflectionException */ public static function getNiceClosureName(\Closure $closure) : string{ @@ -688,8 +688,8 @@ class Utils{ * * @param callable $signature Dummy callable with the required parameters and return type * @param callable $subject Callable to check the signature of - * @phpstan-param callable(mixed...) : mixed $signature - * @phpstan-param callable(mixed...) : mixed $subject + * @phpstan-param anyCallable $signature + * @phpstan-param anyCallable $subject * * @throws \DaveRandom\CallbackValidator\InvalidCallbackException * @throws \TypeError From ccf969192743fe8b305cb23dd95ff9598f4510c1 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 27 Jan 2021 19:28:36 +0000 Subject: [PATCH 11/11] Bump phpunit/phpunit from 9.5.0 to 9.5.1 (#4010) --- composer.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.lock b/composer.lock index c0e949196..2b644913d 100644 --- a/composer.lock +++ b/composer.lock @@ -1486,16 +1486,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.0", + "version": "9.5.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "8e16c225d57c3d6808014df6b1dd7598d0a5bbbe" + "reference": "e7bdf4085de85a825f4424eae52c99a1cec2f360" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8e16c225d57c3d6808014df6b1dd7598d0a5bbbe", - "reference": "8e16c225d57c3d6808014df6b1dd7598d0a5bbbe", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e7bdf4085de85a825f4424eae52c99a1cec2f360", + "reference": "e7bdf4085de85a825f4424eae52c99a1cec2f360", "shasum": "" }, "require": { @@ -1573,7 +1573,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.0" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.1" }, "funding": [ { @@ -1585,7 +1585,7 @@ "type": "github" } ], - "time": "2020-12-04T05:05:53+00:00" + "time": "2021-01-17T07:42:25+00:00" }, { "name": "sebastian/cli-parser", @@ -2685,12 +2685,12 @@ "version": "1.9.1", "source": { "type": "git", - "url": "https://github.com/webmozart/assert.git", + "url": "https://github.com/webmozarts/assert.git", "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", "shasum": "" }, @@ -2728,8 +2728,8 @@ "validate" ], "support": { - "issues": "https://github.com/webmozart/assert/issues", - "source": "https://github.com/webmozart/assert/tree/master" + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.9.1" }, "time": "2020-07-08T17:02:28+00:00" }