From 13e4772f98fe665cc60ad2a2d2cde0eaaf1321b4 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 2 Feb 2020 18:31:51 +0000 Subject: [PATCH 01/10] Release 3.11.5 --- changelogs/3.11.md | 13 +++++++++++++ src/pocketmine/VersionInfo.php | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/changelogs/3.11.md b/changelogs/3.11.md index d9e90b546..d6efefbd3 100644 --- a/changelogs/3.11.md +++ b/changelogs/3.11.md @@ -53,3 +53,16 @@ Plugin developers should **only** update their required API to this version if y - Populate type information in lots of places where it was previously missing; this will improve the quality of static analysis for plugins. - `MainLogger::logException()` now logs previous exceptions recursively. - `MainLogger::logException()` now always logs exceptions as `critical`. + +# 3.11.5 +- PHPStan and PHPUnit are now managed as Composer dev dependencies. +- Core code is now analyzed using PHPStan level 6 (full, including iterable types checking). +- Improved type information available to PHPStan in many areas. +- Mass-removal of useless PHPDoc. +- Fixed incorrect documentation of `Internet::getURL()`, `Internet::postURL()` and `Internet::simpleCurl()`. +- Fixed crash on use of case-mismatched recursive command aliases. +- Basic build instructions are now provided in `BUILDING.md`. +- `build/server-phar.php` now uses GZIP compression on created phars, providing a 75% size reduction. +- `ClientboundMapItemDataPacket` now uses `MapDecoration` objects for decorations instead of associative arrays. +- Updated Composer dependencies to get bug fixes in `pocketmine/nbt` and other libraries. +- Packages `pocketmine/classloader` and `pocketmine/log` are now required; these provide classes previously part of `pocketmine/spl`. This change has no effect on API compatibility. diff --git a/src/pocketmine/VersionInfo.php b/src/pocketmine/VersionInfo.php index e677a5705..627cdf482 100644 --- a/src/pocketmine/VersionInfo.php +++ b/src/pocketmine/VersionInfo.php @@ -32,5 +32,5 @@ const _VERSION_INFO_INCLUDED = true; const NAME = "PocketMine-MP"; const BASE_VERSION = "3.11.5"; -const IS_DEVELOPMENT_BUILD = true; +const IS_DEVELOPMENT_BUILD = false; const BUILD_NUMBER = 0; From eba8d770349b0a4c9510917ce0adccdd66f5e2e1 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 2 Feb 2020 18:31:51 +0000 Subject: [PATCH 02/10] 3.11.6 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 627cdf482..f06205889 100644 --- a/src/pocketmine/VersionInfo.php +++ b/src/pocketmine/VersionInfo.php @@ -31,6 +31,6 @@ if(defined('pocketmine\_VERSION_INFO_INCLUDED')){ const _VERSION_INFO_INCLUDED = true; const NAME = "PocketMine-MP"; -const BASE_VERSION = "3.11.5"; -const IS_DEVELOPMENT_BUILD = false; +const BASE_VERSION = "3.11.6"; +const IS_DEVELOPMENT_BUILD = true; const BUILD_NUMBER = 0; From 4a4c28cd8ccab18807303fdcea8f180a56ebb81a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 3 Feb 2020 09:30:43 +0000 Subject: [PATCH 03/10] travis.sh: ditch PHP_BINARY variable, use PATH prefix instead this is how normal people do it ... --- tests/travis.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/travis.sh b/tests/travis.sh index a4d0e744b..3259be303 100755 --- a/tests/travis.sh +++ b/tests/travis.sh @@ -1,13 +1,9 @@ #!/bin/bash -PHP_BINARY="php" PM_WORKERS="auto" -while getopts "p:t:" OPTION 2> /dev/null; do +while getopts "t:" OPTION 2> /dev/null; do case ${OPTION} in - p) - PHP_BINARY="$OPTARG" - ;; t) PM_WORKERS="$OPTARG" ;; @@ -22,10 +18,10 @@ rm -rf "$DATA_DIR" rm PocketMine-MP.phar 2> /dev/null cd tests/plugins/PocketMine-DevTools -"$PHP_BINARY" -dphar.readonly=0 ./src/DevTools/ConsoleScript.php --make ./ --relative ./ --out ../../../DevTools.phar +php -dphar.readonly=0 ./src/DevTools/ConsoleScript.php --make ./ --relative ./ --out ../../../DevTools.phar cd ../../.. -"$PHP_BINARY" -dphar.readonly=0 ./build/server-phar.php ./PocketMine-MP.phar +php -dphar.readonly=0 ./build/server-phar.php ./PocketMine-MP.phar if [ -f PocketMine-MP.phar ]; then echo Server phar created successfully. else @@ -37,7 +33,7 @@ mkdir "$DATA_DIR" mkdir "$PLUGINS_DIR" mv DevTools.phar "$PLUGINS_DIR" cp -r tests/plugins/TesterPlugin "$PLUGINS_DIR" -echo -e "stop\n" | "$PHP_BINARY" PocketMine-MP.phar --no-wizard --disable-ansi --disable-readline --debug.level=2 --data="$DATA_DIR" --plugins="$PLUGINS_DIR" --anonymous-statistics.enabled=0 --settings.async-workers="$PM_WORKERS" --settings.enable-dev-builds=1 +echo -e "stop\n" | php PocketMine-MP.phar --no-wizard --disable-ansi --disable-readline --debug.level=2 --data="$DATA_DIR" --plugins="$PLUGINS_DIR" --anonymous-statistics.enabled=0 --settings.async-workers="$PM_WORKERS" --settings.enable-dev-builds=1 output=$(grep '\[TesterPlugin\]' "$DATA_DIR/server.log") if [ "$output" == "" ]; then From f3209ccc335d4ee42e9eedd124b863725c3808f9 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 3 Feb 2020 11:16:51 +0000 Subject: [PATCH 04/10] build/make-release: remove unused import --- build/make-release.php | 1 - 1 file changed, 1 deletion(-) diff --git a/build/make-release.php b/build/make-release.php index 8106be1d9..068f89ba2 100644 --- a/build/make-release.php +++ b/build/make-release.php @@ -28,7 +28,6 @@ use function dirname; use function fgets; use function file_get_contents; use function file_put_contents; -use function preg_quote; use function preg_replace; use function sleep; use function sprintf; From d418dd7a090c408ce1b80eebf1eeb516c3b9c783 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 3 Feb 2020 11:17:16 +0000 Subject: [PATCH 05/10] build/make-release: fix formatting --- build/make-release.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/make-release.php b/build/make-release.php index 068f89ba2..f7be518e7 100644 --- a/build/make-release.php +++ b/build/make-release.php @@ -58,7 +58,7 @@ function replaceVersion(string $versionInfoPath, string $newVersion, bool $isDev ); $versionInfo = preg_replace( '/^const IS_DEVELOPMENT_BUILD = (?:true|false);$/m', - 'const IS_DEVELOPMENT_BUILD = ' . ($isDev ? 'true' : 'false'). ';', + 'const IS_DEVELOPMENT_BUILD = ' . ($isDev ? 'true' : 'false') . ';', $versionInfo ); file_put_contents($versionInfoPath, $versionInfo); From da5b7f47df4c52be7551bf14b7160d64e09d312f Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 3 Feb 2020 11:17:51 +0000 Subject: [PATCH 06/10] build/server-phar: import global functions --- build/server-phar.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/build/server-phar.php b/build/server-phar.php index f173b969d..2aafa34eb 100644 --- a/build/server-phar.php +++ b/build/server-phar.php @@ -24,6 +24,23 @@ declare(strict_types=1); namespace pocketmine\build\server_phar; use pocketmine\utils\Git; +use function array_map; +use function count; +use function defined; +use function dirname; +use function file_exists; +use function getcwd; +use function getopt; +use function implode; +use function ini_get; +use function microtime; +use function preg_quote; +use function realpath; +use function round; +use function rtrim; +use function sprintf; +use function str_replace; +use function unlink; require dirname(__DIR__) . '/vendor/autoload.php'; From 0e35ee8cb78bf7ae65cbc3e37310358de2c2ebd2 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 3 Feb 2020 11:18:21 +0000 Subject: [PATCH 07/10] build/server-phar: drop unused imports --- build/server-phar.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/build/server-phar.php b/build/server-phar.php index 2aafa34eb..d3d700be9 100644 --- a/build/server-phar.php +++ b/build/server-phar.php @@ -46,7 +46,6 @@ require dirname(__DIR__) . '/vendor/autoload.php'; /** * @param string[] $strings - * @param string|null $delim * * @return string[] */ @@ -55,13 +54,8 @@ function preg_quote_array(array $strings, string $delim = null) : array{ } /** - * @param string $pharPath - * @param string $basePath * @param string[] $includedPaths * @param mixed[] $metadata - * @param string $stub - * @param int $signatureAlgo - * @param int|null $compression * @phpstan-param array $metadata * * @return \Generator|string[] From dba14c9f08627c383510c7fa7a0629bf84ff3351 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 3 Feb 2020 12:35:34 +0000 Subject: [PATCH 08/10] PharPluginLoader: remove useless instanceof, offset is always PharFileInfo at this point --- src/pocketmine/plugin/PharPluginLoader.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pocketmine/plugin/PharPluginLoader.php b/src/pocketmine/plugin/PharPluginLoader.php index a2cffac8d..fd902dae8 100644 --- a/src/pocketmine/plugin/PharPluginLoader.php +++ b/src/pocketmine/plugin/PharPluginLoader.php @@ -57,10 +57,7 @@ class PharPluginLoader implements PluginLoader{ public function getPluginDescription(string $file) : ?PluginDescription{ $phar = new \Phar($file); if(isset($phar["plugin.yml"])){ - $pluginYml = $phar["plugin.yml"]; - if($pluginYml instanceof \PharFileInfo){ - return new PluginDescription($pluginYml->getContent()); - } + return new PluginDescription($phar["plugin.yml"]->getContent()); } return null; From 28c787371a8077c633f444807729b77da8a5ea19 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 3 Feb 2020 19:25:56 +0000 Subject: [PATCH 09/10] Server::$rcon may be null (disabled or failed to start) --- src/pocketmine/Server.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 4ca6c8eed..9688b085a 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -275,8 +275,8 @@ class Server{ /** @var bool */ private $autoSave; - /** @var RCON */ - private $rcon; + /** @var RCON|null */ + private $rcon = null; /** @var EntityMetadataStore */ private $entityMetadata; From 32d6ea0fba2264ecb7f17499d99ce82019b5975c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 3 Feb 2020 19:32:58 +0000 Subject: [PATCH 10/10] Chest: do not crash on failure to fetch pair, closes #2701 isPaired() returning true is not semantically equivalent to getPair() returning non-null. getPair() might return null if the pair is inaccessible, such as when it's in an unloaded chunk (it doesn't check this yet, but it should). For the sake of opening inventory, we don't care if the chest believes if it is paired, we care if there is actually a pair to be accessed for inventory viewing. In addition, it's possible to create this broken-data scenario artificially by close()ing a chest tile without unpairing it first, because a tile doesn't know the difference between being closed due to unload and being destroyed. --- src/pocketmine/block/Chest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/block/Chest.php b/src/pocketmine/block/Chest.php index a9cadbb1b..47d96e33f 100644 --- a/src/pocketmine/block/Chest.php +++ b/src/pocketmine/block/Chest.php @@ -116,7 +116,7 @@ class Chest extends Transparent{ if( !$this->getSide(Vector3::SIDE_UP)->isTransparent() or - ($chest->isPaired() and !$chest->getPair()->getBlock()->getSide(Vector3::SIDE_UP)->isTransparent()) or + (($pair = $chest->getPair()) !== null and !$pair->getBlock()->getSide(Vector3::SIDE_UP)->isTransparent()) or !$chest->canOpenWith($item->getCustomName()) ){ return true;