From 456439566b573fb90fbab62ea40ecaafe65b926a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 31 Aug 2022 01:53:15 +0100 Subject: [PATCH 01/32] Language: treat empty translation files the same as missing ones --- src/lang/Language.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lang/Language.php b/src/lang/Language.php index 7e992d323..ee5865c93 100644 --- a/src/lang/Language.php +++ b/src/lang/Language.php @@ -27,6 +27,7 @@ use pocketmine\utils\Utils; use Webmozart\PathUtil\Path; use function array_filter; use function array_map; +use function count; use function explode; use function file_exists; use function is_dir; @@ -124,7 +125,10 @@ class Language{ protected static function loadLang(string $path, string $languageCode) : array{ $file = Path::join($path, $languageCode . ".ini"); if(file_exists($file)){ - return array_map('\stripcslashes', Utils::assumeNotFalse(parse_ini_file($file, false, INI_SCANNER_RAW), "Missing or inaccessible required resource files")); + $strings = array_map('\stripcslashes', Utils::assumeNotFalse(parse_ini_file($file, false, INI_SCANNER_RAW), "Missing or inaccessible required resource files")); + if(count($strings) > 0){ + return $strings; + } } throw new LanguageNotFoundException("Language \"$languageCode\" not found"); From b7a15b6e012ced87a4ca8ea976aa53802f1a17ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 31 Aug 2022 02:11:18 +0100 Subject: [PATCH 02/32] Bump phpunit/phpunit from 9.5.23 to 9.5.24 (#5266) Bumps [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) from 9.5.23 to 9.5.24. - [Release notes](https://github.com/sebastianbergmann/phpunit/releases) - [Changelog](https://github.com/sebastianbergmann/phpunit/blob/main/ChangeLog-9.5.md) - [Commits](https://github.com/sebastianbergmann/phpunit/compare/9.5.23...9.5.24) --- updated-dependencies: - dependency-name: phpunit/phpunit dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/composer.lock b/composer.lock index 6fceb9bc2..fe7ab72bf 100644 --- a/composer.lock +++ b/composer.lock @@ -1982,16 +1982,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.23", + "version": "9.5.24", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "888556852e7e9bbeeedb9656afe46118765ade34" + "reference": "d0aa6097bef9fd42458a9b3c49da32c6ce6129c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/888556852e7e9bbeeedb9656afe46118765ade34", - "reference": "888556852e7e9bbeeedb9656afe46118765ade34", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d0aa6097bef9fd42458a9b3c49da32c6ce6129c5", + "reference": "d0aa6097bef9fd42458a9b3c49da32c6ce6129c5", "shasum": "" }, "require": { @@ -2020,7 +2020,7 @@ "sebastian/global-state": "^5.0.1", "sebastian/object-enumerator": "^4.0.3", "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.0", + "sebastian/type": "^3.1", "sebastian/version": "^3.0.2" }, "suggest": { @@ -2064,7 +2064,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.23" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.24" }, "funding": [ { @@ -2076,7 +2076,7 @@ "type": "github" } ], - "time": "2022-08-22T14:01:36+00:00" + "time": "2022-08-30T07:42:16+00:00" }, { "name": "sebastian/cli-parser", @@ -2935,16 +2935,16 @@ }, { "name": "sebastian/type", - "version": "3.0.0", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad" + "reference": "fb44e1cc6e557418387ad815780360057e40753e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb44e1cc6e557418387ad815780360057e40753e", + "reference": "fb44e1cc6e557418387ad815780360057e40753e", "shasum": "" }, "require": { @@ -2956,7 +2956,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -2979,7 +2979,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.0.0" + "source": "https://github.com/sebastianbergmann/type/tree/3.1.0" }, "funding": [ { @@ -2987,7 +2987,7 @@ "type": "github" } ], - "time": "2022-03-15T09:54:48+00:00" + "time": "2022-08-29T06:55:37+00:00" }, { "name": "sebastian/version", From a25cb3741a666ba740f44161cfdcfb02edd9866d Mon Sep 17 00:00:00 2001 From: ShockedPlot7560 <66992287+ShockedPlot7560@users.noreply.github.com> Date: Wed, 31 Aug 2022 03:18:18 +0200 Subject: [PATCH 03/32] Limit valid supporting blocks of dead bush (#5055) --- src/block/DeadBush.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/block/DeadBush.php b/src/block/DeadBush.php index 09754b07d..72cbc0de5 100644 --- a/src/block/DeadBush.php +++ b/src/block/DeadBush.php @@ -34,7 +34,7 @@ use function mt_rand; class DeadBush extends Flowable{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ - if(!$this->getSide(Facing::DOWN)->isTransparent()){ + if($this->canBeSupportedBy($this->getSide(Facing::DOWN))){ return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); } @@ -42,7 +42,7 @@ class DeadBush extends Flowable{ } public function onNearbyBlockChange() : void{ - if($this->getSide(Facing::DOWN)->isTransparent()){ + if(!$this->canBeSupportedBy($this->getSide(Facing::DOWN))){ $this->position->getWorld()->useBreakOn($this->position); } } @@ -64,4 +64,14 @@ class DeadBush extends Flowable{ public function getFlammability() : int{ return 100; } + + private function canBeSupportedBy(Block $block) : bool{ + $blockId = $block->getId(); + return $blockId === BlockLegacyIds::SAND + || $blockId === BlockLegacyIds::PODZOL + || $blockId === BlockLegacyIds::MYCELIUM + || $blockId === BlockLegacyIds::DIRT + || $blockId === BlockLegacyIds::HARDENED_CLAY + || $blockId === BlockLegacyIds::STAINED_HARDENED_CLAY; + } } From 65ec318c3096da089afc37777749f09bb48f8ca8 Mon Sep 17 00:00:00 2001 From: Dylan T Date: Wed, 31 Aug 2022 18:43:30 +0100 Subject: [PATCH 04/32] PluginManager: Ensure dependents are disabled before dependencies in disablePlugins() (#5227) this could later be expanded to disablePlugin() to make this disable order mandatory, to provide certainty for plugin devs. Alternative solutions to this include disabling plugins in the opposite order that they were enabled in, but this doesn't allow for random plugin disables. This way seemed to make sense. --- src/plugin/PluginManager.php | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/plugin/PluginManager.php b/src/plugin/PluginManager.php index acffae53e..4fdd7ee76 100644 --- a/src/plugin/PluginManager.php +++ b/src/plugin/PluginManager.php @@ -75,6 +75,9 @@ class PluginManager{ /** @var Plugin[] */ protected $enabledPlugins = []; + /** @var array> */ + private array $pluginDependents = []; + private bool $loadPluginsGuard = false; /** @@ -453,6 +456,15 @@ class PluginManager{ if($plugin->isEnabled()){ //the plugin may have disabled itself during onEnable() $this->enabledPlugins[$plugin->getDescription()->getName()] = $plugin; + foreach($plugin->getDescription()->getDepend() as $dependency){ + $this->pluginDependents[$dependency][$plugin->getDescription()->getName()] = true; + } + foreach($plugin->getDescription()->getSoftDepend() as $dependency){ + if(isset($this->plugins[$dependency])){ + $this->pluginDependents[$dependency][$plugin->getDescription()->getName()] = true; + } + } + (new PluginEnableEvent($plugin))->call(); return true; @@ -472,8 +484,19 @@ class PluginManager{ } public function disablePlugins() : void{ - foreach($this->getPlugins() as $plugin){ - $this->disablePlugin($plugin); + while(count($this->enabledPlugins) > 0){ + foreach($this->enabledPlugins as $plugin){ + if(!$plugin->isEnabled()){ + continue; //in case a plugin disabled another plugin + } + $name = $plugin->getDescription()->getName(); + if(isset($this->pluginDependents[$name]) && count($this->pluginDependents[$name]) > 0){ + $this->server->getLogger()->debug("Deferring disable of plugin $name due to dependent plugins still enabled: " . implode(", ", array_keys($this->pluginDependents[$name]))); + continue; + } + + $this->disablePlugin($plugin); + } } } @@ -483,6 +506,12 @@ class PluginManager{ (new PluginDisableEvent($plugin))->call(); unset($this->enabledPlugins[$plugin->getDescription()->getName()]); + foreach(Utils::stringifyKeys($this->pluginDependents) as $dependency => $dependentList){ + unset($this->pluginDependents[$dependency][$plugin->getDescription()->getName()]); + if(count($this->pluginDependents[$dependency]) === 0){ + unset($this->pluginDependents[$dependency]); + } + } $plugin->onEnableStateChange(false); $plugin->getScheduler()->shutdown(); From 14d3e6c7d5f98b13ddbc39fab55a0512f9c9c262 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 1 Sep 2022 23:43:13 +0100 Subject: [PATCH 05/32] Allow disabling the console reader via pocketmine.yml Useful to save resources on headless servers where the console is never used (e.g. hosted server, Docker, etc.) --- resources/pocketmine.yml | 3 +++ src/Server.php | 28 +++++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/resources/pocketmine.yml b/resources/pocketmine.yml index f922cb225..4ad8ea9c0 100644 --- a/resources/pocketmine.yml +++ b/resources/pocketmine.yml @@ -168,6 +168,9 @@ timings: host: timings.pmmp.io console: + #Whether to accept commands via the console. If disabled, anything typed on the console will be ignored. + #Useful to save resources on headless servers where the console is never used (e.g. hosted server, Docker, etc.) + enable-input: true #Choose whether to enable server stats reporting on the console title. #NOTE: The title ticker will be disabled regardless if console colours are not enabled. title-tick: true diff --git a/src/Server.php b/src/Server.php index 3128a7c39..25b689093 100644 --- a/src/Server.php +++ b/src/Server.php @@ -225,7 +225,7 @@ class Server{ private MemoryManager $memoryManager; - private ConsoleReaderThread $console; + private ?ConsoleReaderThread $console = null; private SimpleCommandMap $commandMap; @@ -1048,17 +1048,19 @@ class Server{ $this->subscribeToBroadcastChannel(self::BROADCAST_CHANNEL_ADMINISTRATIVE, $consoleSender); $this->subscribeToBroadcastChannel(self::BROADCAST_CHANNEL_USERS, $consoleSender); - $consoleNotifier = new SleeperNotifier(); - $commandBuffer = new \Threaded(); - $this->console = new ConsoleReaderThread($commandBuffer, $consoleNotifier); - $this->tickSleeper->addNotifier($consoleNotifier, function() use ($commandBuffer, $consoleSender) : void{ - Timings::$serverCommand->startTiming(); - while(($line = $commandBuffer->shift()) !== null){ - $this->dispatchCommand($consoleSender, (string) $line); - } - Timings::$serverCommand->stopTiming(); - }); - $this->console->start(PTHREADS_INHERIT_NONE); + if($this->configGroup->getPropertyBool("console.enable-input", true)){ + $consoleNotifier = new SleeperNotifier(); + $commandBuffer = new \Threaded(); + $this->console = new ConsoleReaderThread($commandBuffer, $consoleNotifier); + $this->tickSleeper->addNotifier($consoleNotifier, function() use ($commandBuffer, $consoleSender) : void{ + Timings::$serverCommand->startTiming(); + while(($line = $commandBuffer->shift()) !== null){ + $this->dispatchCommand($consoleSender, (string) $line); + } + Timings::$serverCommand->stopTiming(); + }); + $this->console->start(PTHREADS_INHERIT_NONE); + } $this->tickProcessor(); $this->forceShutdown(); @@ -1511,7 +1513,7 @@ class Server{ $this->configGroup->save(); } - if(isset($this->console)){ + if($this->console !== null){ $this->getLogger()->debug("Closing console"); $this->console->quit(); } From 2585160ca2c4df5758b8b980331307402ff9f0fb Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 00:25:31 +0100 Subject: [PATCH 06/32] ConsoleReaderChildProcess: Commit suicide if the parent process dies and doesn't clean up This happens if the main server process was forcibly killed, e.g. by the kill command on Linux, or taskkill/TaskManager on Windows. Previously, the process would stick around as a zombie, which messed up terminals in some cases (e.g. git bash), though even having zombies with no side effects is bad enough. --- src/console/ConsoleReaderChildProcess.php | 42 +++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/console/ConsoleReaderChildProcess.php b/src/console/ConsoleReaderChildProcess.php index 5bf2ff71f..2d4e3fc56 100644 --- a/src/console/ConsoleReaderChildProcess.php +++ b/src/console/ConsoleReaderChildProcess.php @@ -23,12 +23,14 @@ declare(strict_types=1); namespace pocketmine\console; +use pocketmine\utils\Process; use function cli_set_process_title; use function count; use function dirname; use function feof; use function fwrite; use function stream_socket_client; +use const PTHREADS_INHERIT_NONE; require dirname(__DIR__, 2) . '/vendor/autoload.php'; @@ -43,9 +45,40 @@ $socket = stream_socket_client($argv[1], $errCode, $errMessage, 15.0); if($socket === false){ throw new \RuntimeException("Failed to connect to server process ($errCode): $errMessage"); } -$consoleReader = new ConsoleReader(); + +$channel = new \Threaded(); +$thread = new class($channel) extends \Thread{ + public function __construct( + private \Threaded $channel, + ){} + + public function run(){ + require dirname(__DIR__, 2) . '/vendor/autoload.php'; + + $channel = $this->channel; + $reader = new ConsoleReader(); + while(true){ // @phpstan-ignore-line + $line = $reader->readLine(); + if($line !== null){ + $channel->synchronized(function() use ($channel, $line) : void{ + $channel[] = $line; + $channel->notify(); + }); + } + } + } +}; + +$thread->start(PTHREADS_INHERIT_NONE); while(!feof($socket)){ - $line = $consoleReader->readLine(); + $line = $channel->synchronized(function() use ($channel) : ?string{ + if(count($channel) === 0){ + $channel->wait(1_000_000); + } + /** @var string|null $line */ + $line = $channel->shift(); + return $line; + }); if(@fwrite($socket, ($line ?? "") . "\n") === false){ //Always send even if there's no line, to check if the parent is alive //If the parent process was terminated forcibly, it won't close the connection properly, so feof() will return @@ -53,3 +86,8 @@ while(!feof($socket)){ break; } } + +//For simplicity's sake, we don't bother with a graceful shutdown here. +//The parent process would normally forcibly terminate the child process anyway, so we only reach this point if the +//parent process was terminated forcibly and didn't clean up after itself. +Process::kill(Process::pid(), false); From b3f03d7ae645de67a54b7300c09b94eeca16298e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 00:58:49 +0100 Subject: [PATCH 07/32] Poll console on the main thread, instead of using a separate thread There's no need to use an extra thread for this, since there's no concern of a socket getting stuck in a blocking read. This is one less thing that can go wrong because of pthreads. --- src/Server.php | 24 ++-- ...hp => ConsoleReaderChildProcessDaemon.php} | 115 +++++++++--------- 2 files changed, 68 insertions(+), 71 deletions(-) rename src/console/{ConsoleReaderThread.php => ConsoleReaderChildProcessDaemon.php} (50%) diff --git a/src/Server.php b/src/Server.php index 25b689093..3c289f4fa 100644 --- a/src/Server.php +++ b/src/Server.php @@ -31,7 +31,7 @@ use pocketmine\command\Command; use pocketmine\command\CommandSender; use pocketmine\command\SimpleCommandMap; use pocketmine\console\ConsoleCommandSender; -use pocketmine\console\ConsoleReaderThread; +use pocketmine\console\ConsoleReaderChildProcessDaemon; use pocketmine\crafting\CraftingManager; use pocketmine\crafting\CraftingManagerFromDataHelper; use pocketmine\crash\CrashDump; @@ -225,7 +225,8 @@ class Server{ private MemoryManager $memoryManager; - private ?ConsoleReaderThread $console = null; + private ?ConsoleReaderChildProcessDaemon $console = null; + private ?ConsoleCommandSender $consoleSender = null; private SimpleCommandMap $commandMap; @@ -1049,17 +1050,7 @@ class Server{ $this->subscribeToBroadcastChannel(self::BROADCAST_CHANNEL_USERS, $consoleSender); if($this->configGroup->getPropertyBool("console.enable-input", true)){ - $consoleNotifier = new SleeperNotifier(); - $commandBuffer = new \Threaded(); - $this->console = new ConsoleReaderThread($commandBuffer, $consoleNotifier); - $this->tickSleeper->addNotifier($consoleNotifier, function() use ($commandBuffer, $consoleSender) : void{ - Timings::$serverCommand->startTiming(); - while(($line = $commandBuffer->shift()) !== null){ - $this->dispatchCommand($consoleSender, (string) $line); - } - Timings::$serverCommand->stopTiming(); - }); - $this->console->start(PTHREADS_INHERIT_NONE); + $this->console = new ConsoleReaderChildProcessDaemon($this->logger); } $this->tickProcessor(); @@ -1855,6 +1846,13 @@ class Server{ $this->getMemoryManager()->check(); + if($this->console !== null){ + while(($line = $this->console->readLine()) !== null){ + $this->consoleSender ??= new ConsoleCommandSender($this, $this->language); + $this->dispatchCommand($this->consoleSender, $line); + } + } + Timings::$serverTick->stopTiming(); $now = microtime(true); diff --git a/src/console/ConsoleReaderThread.php b/src/console/ConsoleReaderChildProcessDaemon.php similarity index 50% rename from src/console/ConsoleReaderThread.php rename to src/console/ConsoleReaderChildProcessDaemon.php index eac19ef84..a0c689d37 100644 --- a/src/console/ConsoleReaderThread.php +++ b/src/console/ConsoleReaderChildProcessDaemon.php @@ -23,8 +23,6 @@ declare(strict_types=1); namespace pocketmine\console; -use pocketmine\snooze\SleeperNotifier; -use pocketmine\thread\Thread; use pocketmine\utils\AssumptionFailedError; use pocketmine\utils\Utils; use Webmozart\PathUtil\Path; @@ -45,36 +43,35 @@ use function trim; use const PHP_BINARY; use const STREAM_SHUT_RDWR; -final class ConsoleReaderThread extends Thread{ +/** + * This pile of shit exists because PHP on Windows is broken, and can't handle stream_select() on stdin or pipes + * properly - stdin native triggers stream_select() when a key is pressed, causing it to get stuck in fgets() + * waiting for a line that might never come (and Windows doesn't support character-based reading either), and + * pipes just constantly trigger stream_select() instead of only when data is returned, rendering it useless. + * + * This results in whichever process reads stdin getting stuck on shutdown, which previously forced us to kill + * the entire server process to make it go away. + * + * To get around this problem, we delegate the responsibility of reading stdin to a subprocess, which we can + * then brutally murder when the server shuts down, without killing the entire server process. + * Thankfully, stream_select() actually works properly on sockets, so we can use them for inter-process + * communication. + */ +final class ConsoleReaderChildProcessDaemon{ + private \PrefixedLogger $logger; + /** @var resource */ + private $subprocess; + /** @var resource */ + private $socket; + public function __construct( - private \Threaded $buffer, - private ?SleeperNotifier $notifier = null - ){} - - protected function onRun() : void{ - $buffer = $this->buffer; - $notifier = $this->notifier; - - while(!$this->isKilled){ - $this->runSubprocess($buffer, $notifier); - } + \Logger $logger + ){ + $this->logger = new \PrefixedLogger($logger, "Console Reader Daemon"); + $this->prepareSubprocess(); } - /** - * This pile of shit exists because PHP on Windows is broken, and can't handle stream_select() on stdin or pipes - * properly - stdin native triggers stream_select() when a key is pressed, causing it to get stuck in fgets() - * waiting for a line that might never come (and Windows doesn't support character-based reading either), and - * pipes just constantly trigger stream_select() instead of only when data is returned, rendering it useless. - * - * This results in whichever process reads stdin getting stuck on shutdown, which previously forced us to kill - * the entire server process to make it go away. - * - * To get around this problem, we delegate the responsibility of reading stdin to a subprocess, which we can - * then brutally murder when the server shuts down, without killing the entire server process. - * Thankfully, stream_select() actually works properly on sockets, so we can use them for inter-process - * communication. - */ - private function runSubprocess(\Threaded $buffer, ?SleeperNotifier $notifier) : void{ + private function prepareSubprocess() : void{ $server = stream_socket_server("tcp://127.0.0.1:0"); if($server === false){ throw new \RuntimeException("Failed to open console reader socket server"); @@ -96,41 +93,43 @@ final class ConsoleReaderThread extends Thread{ throw new AssumptionFailedError("stream_socket_accept() returned false"); } stream_socket_shutdown($server, STREAM_SHUT_RDWR); - while(!$this->isKilled){ - $r = [$client]; - $w = null; - $e = null; - if(stream_select($r, $w, $e, 0, 200000) === 1){ - $command = fgets($client); - if($command === false){ - //subprocess died for some reason; this could be someone killed it manually from outside (e.g. - //mistyped PID) or it might be a ctrl+c signal to this process that the child is handling - //differently (different signal handlers). - //since we have no way to know the difference, we just kill the sub and start a new one. - break; - } - $command = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", trim($command)) ?? throw new AssumptionFailedError("This regex is assumed to be valid"); - $command = preg_replace('/[[:cntrl:]]/', '', $command) ?? throw new AssumptionFailedError("This regex is assumed to be valid"); - if($command === ""){ - continue; - } - $buffer[] = $command; - if($notifier !== null){ - $notifier->wakeupSleeper(); - } - } - } + $this->subprocess = $sub; + $this->socket = $client; + } + private function shutdownSubprocess() : void{ //we have no way to signal to the subprocess to shut down gracefully; besides, Windows sucks, and the subprocess //gets stuck in a blocking fgets() read because stream_select() is a hunk of junk (hence the separate process in //the first place). - proc_terminate($sub); - proc_close($sub); - stream_socket_shutdown($client, STREAM_SHUT_RDWR); + proc_terminate($this->subprocess); + proc_close($this->subprocess); + stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR); } - public function getThreadName() : string{ - return "Console"; + public function readLine() : ?string{ + $r = [$this->socket]; + $w = null; + $e = null; + if(stream_select($r, $w, $e, 0, 0) === 1){ + $command = fgets($this->socket); + if($command === false){ + $this->logger->debug("Lost connection to subprocess, restarting (maybe the child process was killed from outside?)"); + $this->shutdownSubprocess(); + $this->prepareSubprocess(); + return null; + } + + $command = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", trim($command)) ?? throw new AssumptionFailedError("This regex is assumed to be valid"); + $command = preg_replace('/[[:cntrl:]]/', '', $command) ?? throw new AssumptionFailedError("This regex is assumed to be valid"); + + return $command !== "" ? $command : null; + } + + return null; + } + + public function quit() : void{ + $this->shutdownSubprocess(); } } From ffb3af3e0dae4d323952d726cad8be5e72b165fd Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 00:59:58 +0100 Subject: [PATCH 08/32] fix CS --- src/Server.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Server.php b/src/Server.php index 3c289f4fa..153789aa3 100644 --- a/src/Server.php +++ b/src/Server.php @@ -88,7 +88,6 @@ use pocketmine\promise\PromiseResolver; use pocketmine\resourcepacks\ResourcePackManager; use pocketmine\scheduler\AsyncPool; use pocketmine\snooze\SleeperHandler; -use pocketmine\snooze\SleeperNotifier; use pocketmine\stats\SendUsageTask; use pocketmine\timings\Timings; use pocketmine\timings\TimingsHandler; @@ -165,7 +164,6 @@ use function zlib_encode; use const DIRECTORY_SEPARATOR; use const PHP_EOL; use const PHP_INT_MAX; -use const PTHREADS_INHERIT_NONE; use const ZLIB_ENCODING_GZIP; /** From 9e0b4621be3ac891d24d455a076879314b303fc4 Mon Sep 17 00:00:00 2001 From: DiamondStrider1 <62265561+Swift-Strider@users.noreply.github.com> Date: Thu, 1 Sep 2022 21:51:31 -0500 Subject: [PATCH 09/32] Fixed languages-not-found bug (#5272) * Fixed languages-not-found bug * Update Language.php Co-authored-by: Dylan T --- src/lang/Language.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lang/Language.php b/src/lang/Language.php index ee5865c93..0cba6bd21 100644 --- a/src/lang/Language.php +++ b/src/lang/Language.php @@ -68,10 +68,14 @@ class Language{ $result = []; foreach($files as $file){ - $code = explode(".", $file)[0]; - $strings = self::loadLang($path, $code); - if(isset($strings["language.name"])){ - $result[$code] = $strings["language.name"]; + try{ + $code = explode(".", $file)[0]; + $strings = self::loadLang($path, $code); + if(isset($strings["language.name"])){ + $result[$code] = $strings["language.name"]; + } + }catch(LanguageNotFoundException $e){ + // no-op } } From 973a56ab285088ad9c82bb213e38892edcfa865d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 18:02:16 +0100 Subject: [PATCH 10/32] Update composer dependencies --- composer.lock | 76 +++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/composer.lock b/composer.lock index fe7ab72bf..b517c33db 100644 --- a/composer.lock +++ b/composer.lock @@ -63,16 +63,16 @@ }, { "name": "brick/math", - "version": "0.10.1", + "version": "0.10.2", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "de846578401f4e58f911b3afeb62ced56365ed87" + "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/de846578401f4e58f911b3afeb62ced56365ed87", - "reference": "de846578401f4e58f911b3afeb62ced56365ed87", + "url": "https://api.github.com/repos/brick/math/zipball/459f2781e1a08d52ee56b0b1444086e038561e3f", + "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f", "shasum": "" }, "require": { @@ -107,7 +107,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.10.1" + "source": "https://github.com/brick/math/tree/0.10.2" }, "funding": [ { @@ -115,7 +115,7 @@ "type": "github" } ], - "time": "2022-08-01T22:54:31+00:00" + "time": "2022-08-10T22:54:19+00:00" }, { "name": "fgrosse/phpasn1", @@ -532,16 +532,16 @@ }, { "name": "pocketmine/locale-data", - "version": "2.8.7", + "version": "2.8.9", "source": { "type": "git", "url": "https://github.com/pmmp/Language.git", - "reference": "e115d3d64a508065f1cedad1be55528906308456" + "reference": "27637272e5230511e3b6568192d0422e5e97a571" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/Language/zipball/e115d3d64a508065f1cedad1be55528906308456", - "reference": "e115d3d64a508065f1cedad1be55528906308456", + "url": "https://api.github.com/repos/pmmp/Language/zipball/27637272e5230511e3b6568192d0422e5e97a571", + "reference": "27637272e5230511e3b6568192d0422e5e97a571", "shasum": "" }, "type": "library", @@ -549,9 +549,9 @@ "description": "Language resources used by PocketMine-MP", "support": { "issues": "https://github.com/pmmp/Language/issues", - "source": "https://github.com/pmmp/Language/tree/2.8.7" + "source": "https://github.com/pmmp/Language/tree/2.8.9" }, - "time": "2022-08-21T20:37:16+00:00" + "time": "2022-08-25T18:54:39+00:00" }, { "name": "pocketmine/log", @@ -640,16 +640,16 @@ }, { "name": "pocketmine/math", - "version": "0.4.2", + "version": "0.4.3", "source": { "type": "git", "url": "https://github.com/pmmp/Math.git", - "reference": "aacc3759a508a69dfa5bc4dfa770ab733c5c94bf" + "reference": "47a243d320b01c8099d65309967934c188111549" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/Math/zipball/aacc3759a508a69dfa5bc4dfa770ab733c5c94bf", - "reference": "aacc3759a508a69dfa5bc4dfa770ab733c5c94bf", + "url": "https://api.github.com/repos/pmmp/Math/zipball/47a243d320b01c8099d65309967934c188111549", + "reference": "47a243d320b01c8099d65309967934c188111549", "shasum": "" }, "require": { @@ -658,7 +658,7 @@ }, "require-dev": { "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "1.2.0", + "phpstan/phpstan": "1.8.2", "phpstan/phpstan-strict-rules": "^1.0", "phpunit/phpunit": "^8.5 || ^9.5" }, @@ -675,9 +675,9 @@ "description": "PHP library containing math related code used in PocketMine-MP", "support": { "issues": "https://github.com/pmmp/Math/issues", - "source": "https://github.com/pmmp/Math/tree/0.4.2" + "source": "https://github.com/pmmp/Math/tree/0.4.3" }, - "time": "2021-12-05T01:15:17+00:00" + "time": "2022-08-25T18:43:37+00:00" }, { "name": "pocketmine/nbt", @@ -723,16 +723,16 @@ }, { "name": "pocketmine/raklib", - "version": "0.14.4", + "version": "0.14.5", "source": { "type": "git", "url": "https://github.com/pmmp/RakLib.git", - "reference": "1ea8e3b95a1b6bf785dc27d76578657be4185f42" + "reference": "85b4e5cb7117d37e010eeadb3ff53b21276c6f48" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/RakLib/zipball/1ea8e3b95a1b6bf785dc27d76578657be4185f42", - "reference": "1ea8e3b95a1b6bf785dc27d76578657be4185f42", + "url": "https://api.github.com/repos/pmmp/RakLib/zipball/85b4e5cb7117d37e010eeadb3ff53b21276c6f48", + "reference": "85b4e5cb7117d37e010eeadb3ff53b21276c6f48", "shasum": "" }, "require": { @@ -744,7 +744,7 @@ "pocketmine/log": "^0.3.0 || ^0.4.0" }, "require-dev": { - "phpstan/phpstan": "1.5.4", + "phpstan/phpstan": "1.7.7", "phpstan/phpstan-strict-rules": "^1.0" }, "type": "library", @@ -760,9 +760,9 @@ "description": "A RakNet server implementation written in PHP", "support": { "issues": "https://github.com/pmmp/RakLib/issues", - "source": "https://github.com/pmmp/RakLib/tree/0.14.4" + "source": "https://github.com/pmmp/RakLib/tree/0.14.5" }, - "time": "2022-04-17T18:42:17+00:00" + "time": "2022-08-25T16:16:44+00:00" }, { "name": "pocketmine/raklib-ipc", @@ -1616,16 +1616,16 @@ }, { "name": "phpstan/phpstan-strict-rules", - "version": "1.3.0", + "version": "1.4.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-strict-rules.git", - "reference": "543675a9be82d4befb9ca0bd8cdc9d211665037f" + "reference": "4e57160a710dea304fbd1a177ce38edd9b3848db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/543675a9be82d4befb9ca0bd8cdc9d211665037f", - "reference": "543675a9be82d4befb9ca0bd8cdc9d211665037f", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/4e57160a710dea304fbd1a177ce38edd9b3848db", + "reference": "4e57160a710dea304fbd1a177ce38edd9b3848db", "shasum": "" }, "require": { @@ -1658,22 +1658,22 @@ "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/1.3.0" + "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.4.2" }, - "time": "2022-06-24T06:47:20+00:00" + "time": "2022-08-25T15:04:21+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.16", + "version": "9.2.17", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "2593003befdcc10db5e213f9f28814f5aa8ac073" + "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2593003befdcc10db5e213f9f28814f5aa8ac073", - "reference": "2593003befdcc10db5e213f9f28814f5aa8ac073", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa94dc41e8661fe90c7316849907cba3007b10d8", + "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8", "shasum": "" }, "require": { @@ -1729,7 +1729,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.16" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.17" }, "funding": [ { @@ -1737,7 +1737,7 @@ "type": "github" } ], - "time": "2022-08-20T05:26:47+00:00" + "time": "2022-08-30T12:24:04+00:00" }, { "name": "phpunit/php-file-iterator", From 1d253bc8c2761ef9f4472d5a328fc45fd40e21f8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 18:23:49 +0100 Subject: [PATCH 11/32] Utils: remove 32-bit specific code from javaStringHash() this was necessary in the days of 32-bit, but for 64-bit, the 0xffffffff mask is sufficient and produces the exact same result. --- src/utils/Utils.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/utils/Utils.php b/src/utils/Utils.php index 8d27c9861..d5ecae996 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -366,12 +366,6 @@ final class Utils{ $ord -= 0x100; } $hash = 31 * $hash + $ord; - while($hash > 0x7FFFFFFF){ - $hash -= 0x100000000; - } - while($hash < -0x80000000){ - $hash += 0x100000000; - } $hash &= 0xFFFFFFFF; } return $hash; From 85678aa3562921599358789767bb76a6daf4b657 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 18:28:33 +0100 Subject: [PATCH 12/32] phpstan 1.8.3 --- composer.json | 2 +- composer.lock | 36 +++++++-------- src/block/Lever.php | 1 - tests/phpstan/configs/actual-problems.neon | 45 ------------------- .../phpstan/configs/impossible-generics.neon | 5 --- tests/phpstan/configs/php-bugs.neon | 3 +- tests/phpstan/configs/phpstan-bugs.neon | 10 +++++ 7 files changed, 30 insertions(+), 72 deletions(-) diff --git a/composer.json b/composer.json index ef3fdd5c7..220366824 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "webmozart/path-util": "^2.3" }, "require-dev": { - "phpstan/phpstan": "1.8.2", + "phpstan/phpstan": "1.8.3", "phpstan/phpstan-phpunit": "^1.1.0", "phpstan/phpstan-strict-rules": "^1.2.0", "phpunit/phpunit": "^9.2" diff --git a/composer.lock b/composer.lock index b517c33db..cf747f322 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": "72bfad1350c97a3df225577163d702ea", + "content-hash": "5d4f1fe16d8b5bd9f420e30877aa734b", "packages": [ { "name": "adhocore/json-comment", @@ -1505,16 +1505,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.8.2", + "version": "1.8.3", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c" + "reference": "5583623b61caafebd62bc78a99533aa9d769d097" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c53312ecc575caf07b0e90dee43883fdf90ca67c", - "reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/5583623b61caafebd62bc78a99533aa9d769d097", + "reference": "5583623b61caafebd62bc78a99533aa9d769d097", "shasum": "" }, "require": { @@ -1538,9 +1538,13 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.8.2" + "source": "https://github.com/phpstan/phpstan/tree/1.8.3" }, "funding": [ { @@ -1551,16 +1555,12 @@ "url": "https://github.com/phpstan", "type": "github" }, - { - "url": "https://www.patreon.com/phpstan", - "type": "patreon" - }, { "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", "type": "tidelift" } ], - "time": "2022-07-20T09:57:31+00:00" + "time": "2022-09-01T15:27:34+00:00" }, { "name": "phpstan/phpstan-phpunit", @@ -1616,21 +1616,21 @@ }, { "name": "phpstan/phpstan-strict-rules", - "version": "1.4.2", + "version": "1.4.3", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-strict-rules.git", - "reference": "4e57160a710dea304fbd1a177ce38edd9b3848db" + "reference": "431b3d6e8040075de196680cd5bc95735987b4ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/4e57160a710dea304fbd1a177ce38edd9b3848db", - "reference": "4e57160a710dea304fbd1a177ce38edd9b3848db", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/431b3d6e8040075de196680cd5bc95735987b4ae", + "reference": "431b3d6e8040075de196680cd5bc95735987b4ae", "shasum": "" }, "require": { "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.7.15" + "phpstan/phpstan": "^1.8.3" }, "require-dev": { "nikic/php-parser": "^4.13.0", @@ -1658,9 +1658,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/1.4.2" + "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.4.3" }, - "time": "2022-08-25T15:04:21+00:00" + "time": "2022-08-26T15:05:46+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/src/block/Lever.php b/src/block/Lever.php index c9dfe76bb..e45a95345 100644 --- a/src/block/Lever.php +++ b/src/block/Lever.php @@ -69,7 +69,6 @@ class Lever extends Flowable{ 5 => LeverFacing::UP_AXIS_Z(), 6 => LeverFacing::UP_AXIS_X(), 7 => LeverFacing::DOWN_AXIS_Z(), - default => throw new AssumptionFailedError("0x07 mask should make this impossible"), //phpstan doesn't understand :( }; $this->activated = ($stateMeta & BlockLegacyMetadata::LEVER_FLAG_POWERED) !== 0; diff --git a/tests/phpstan/configs/actual-problems.neon b/tests/phpstan/configs/actual-problems.neon index 746c9a792..85b261dca 100644 --- a/tests/phpstan/configs/actual-problems.neon +++ b/tests/phpstan/configs/actual-problems.neon @@ -775,18 +775,8 @@ parameters: count: 1 path: ../../../src/plugin/PluginBase.php - - - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: ../../../src/plugin/PluginDescription.php - - message: "#^Cannot cast mixed to string\\.$#" - count: 5 - path: ../../../src/plugin/PluginDescription.php - - - - message: "#^Parameter \\#1 \\$data of static method pocketmine\\\\permission\\\\PermissionParser\\:\\:loadPermissions\\(\\) expects array\\\\>, mixed given\\.$#" count: 1 path: ../../../src/plugin/PluginDescription.php @@ -795,11 +785,6 @@ parameters: count: 1 path: ../../../src/plugin/PluginDescription.php - - - message: "#^Parameter \\#1 \\$name of static method pocketmine\\\\plugin\\\\PluginEnableOrder\\:\\:fromString\\(\\) expects string, mixed given\\.$#" - count: 1 - path: ../../../src/plugin/PluginDescription.php - - message: "#^Parameter \\#2 \\$subject of function preg_match expects string, mixed given\\.$#" count: 1 @@ -810,26 +795,6 @@ parameters: count: 1 path: ../../../src/plugin/PluginDescription.php - - - message: "#^Property pocketmine\\\\plugin\\\\PluginDescription\\:\\:\\$authors \\(array\\\\) does not accept array\\.$#" - count: 1 - path: ../../../src/plugin/PluginDescription.php - - - - message: "#^Property pocketmine\\\\plugin\\\\PluginDescription\\:\\:\\$authors \\(array\\\\) does not accept array\\\\.$#" - count: 1 - path: ../../../src/plugin/PluginDescription.php - - - - message: "#^Property pocketmine\\\\plugin\\\\PluginDescription\\:\\:\\$depend \\(array\\\\) does not accept array\\.$#" - count: 1 - path: ../../../src/plugin/PluginDescription.php - - - - message: "#^Property pocketmine\\\\plugin\\\\PluginDescription\\:\\:\\$loadBefore \\(array\\\\) does not accept array\\.$#" - count: 1 - path: ../../../src/plugin/PluginDescription.php - - message: "#^Property pocketmine\\\\plugin\\\\PluginDescription\\:\\:\\$main \\(string\\) does not accept mixed\\.$#" count: 1 @@ -840,16 +805,6 @@ parameters: count: 1 path: ../../../src/plugin/PluginDescription.php - - - message: "#^Property pocketmine\\\\plugin\\\\PluginDescription\\:\\:\\$softDepend \\(array\\\\) does not accept array\\.$#" - count: 1 - path: ../../../src/plugin/PluginDescription.php - - - - message: "#^Property pocketmine\\\\plugin\\\\PluginDescription\\:\\:\\$srcNamespacePrefix \\(string\\) does not accept mixed\\.$#" - count: 1 - path: ../../../src/plugin/PluginDescription.php - - message: "#^Cannot call method addChild\\(\\) on pocketmine\\\\permission\\\\Permission\\|null\\.$#" count: 4 diff --git a/tests/phpstan/configs/impossible-generics.neon b/tests/phpstan/configs/impossible-generics.neon index 0281bcd7f..b0e67d294 100644 --- a/tests/phpstan/configs/impossible-generics.neon +++ b/tests/phpstan/configs/impossible-generics.neon @@ -10,8 +10,3 @@ parameters: count: 1 path: ../../../src/event/RegisteredListener.php - - - message: "#^Property pocketmine\\\\event\\\\RegisteredListener\\:\\:\\$handler type has no signature specified for Closure\\.$#" - count: 1 - path: ../../../src/event/RegisteredListener.php - diff --git a/tests/phpstan/configs/php-bugs.neon b/tests/phpstan/configs/php-bugs.neon index f4754087b..c70ef1ecb 100644 --- a/tests/phpstan/configs/php-bugs.neon +++ b/tests/phpstan/configs/php-bugs.neon @@ -1,7 +1,6 @@ parameters: ignoreErrors: - - message: "#^Property pocketmine\\\\network\\\\mcpe\\\\handler\\\\StupidJsonDecodeTest\\:\\:\\$stupidJsonDecodeFunc \\(Closure\\(string, bool\\)\\: mixed\\) does not accept Closure\\|null\\.$#" + message: "#^Property pocketmine\\\\network\\\\mcpe\\\\handler\\\\StupidJsonDecodeTest\\:\\:\\$stupidJsonDecodeFunc \\(Closure\\(string, bool=\\)\\: mixed\\) does not accept Closure\\|null\\.$#" count: 1 path: ../../phpunit/network/mcpe/handler/StupidJsonDecodeTest.php - diff --git a/tests/phpstan/configs/phpstan-bugs.neon b/tests/phpstan/configs/phpstan-bugs.neon index dcfda66bc..b9e3e76b8 100644 --- a/tests/phpstan/configs/phpstan-bugs.neon +++ b/tests/phpstan/configs/phpstan-bugs.neon @@ -55,6 +55,11 @@ parameters: count: 1 path: ../../../src/plugin/PluginManager.php + - + message: "#^Offset \\(int\\|string\\) on non\\-empty\\-array\\ in isset\\(\\) always exists and is not nullable\\.$#" + count: 1 + path: ../../../src/plugin/PluginManager.php + - message: "#^Static property pocketmine\\\\scheduler\\\\AsyncTask\\:\\:\\$threadLocalStorage \\(ArrayObject\\\\>\\|null\\) does not accept non\\-empty\\-array\\\\>\\|ArrayObject\\\\>\\.$#" count: 1 @@ -70,6 +75,11 @@ parameters: count: 1 path: ../../../src/thread/Worker.php + - + message: "#^Offset \\(int\\|string\\) on non\\-empty\\-array\\ in isset\\(\\) always exists and is not nullable\\.$#" + count: 1 + path: ../../../src/world/WorldManager.php + - message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#" count: 2 From 1ee02d7e02e668ed5efe737b1afc5b03775f72c6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 18:43:39 +0100 Subject: [PATCH 13/32] Do not install pocketmine/locale-data 2.8.9 (it's incorrectly versioned) the changes made in 2.8.9 should have been released as a new minor version, not a patch. --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 220366824..284ff4b50 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "pocketmine/classloader": "^0.2.0", "pocketmine/color": "^0.2.0", "pocketmine/errorhandler": "^0.6.0", - "pocketmine/locale-data": "~2.8.0", + "pocketmine/locale-data": "~2.8.0 <2.8.9", "pocketmine/log": "^0.4.0", "pocketmine/log-pthreads": "^0.4.0", "pocketmine/math": "^0.4.0", diff --git a/composer.lock b/composer.lock index cf747f322..b3bae8d04 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": "5d4f1fe16d8b5bd9f420e30877aa734b", + "content-hash": "4f57f22ed042b67eb1c1413aab2ab3bd", "packages": [ { "name": "adhocore/json-comment", @@ -532,16 +532,16 @@ }, { "name": "pocketmine/locale-data", - "version": "2.8.9", + "version": "2.8.7", "source": { "type": "git", "url": "https://github.com/pmmp/Language.git", - "reference": "27637272e5230511e3b6568192d0422e5e97a571" + "reference": "e115d3d64a508065f1cedad1be55528906308456" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/Language/zipball/27637272e5230511e3b6568192d0422e5e97a571", - "reference": "27637272e5230511e3b6568192d0422e5e97a571", + "url": "https://api.github.com/repos/pmmp/Language/zipball/e115d3d64a508065f1cedad1be55528906308456", + "reference": "e115d3d64a508065f1cedad1be55528906308456", "shasum": "" }, "type": "library", @@ -549,9 +549,9 @@ "description": "Language resources used by PocketMine-MP", "support": { "issues": "https://github.com/pmmp/Language/issues", - "source": "https://github.com/pmmp/Language/tree/2.8.9" + "source": "https://github.com/pmmp/Language/tree/2.8.7" }, - "time": "2022-08-25T18:54:39+00:00" + "time": "2022-08-21T20:37:16+00:00" }, { "name": "pocketmine/log", From 033dac3d16bb151fb5afec55adf0c63f1f649d8b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 19:13:16 +0100 Subject: [PATCH 14/32] Server: be explicit about the player promise resolver type since there's no way for phpstan to infer the type of this, it becomes implicit mixed, which can conceal bugs. --- src/Server.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Server.php b/src/Server.php index 3128a7c39..4c6176f24 100644 --- a/src/Server.php +++ b/src/Server.php @@ -570,6 +570,7 @@ class Server{ $playerPos = null; $spawn = $world->getSpawnLocation(); } + /** @phpstan-var PromiseResolver $playerPromiseResolver */ $playerPromiseResolver = new PromiseResolver(); $world->requestChunkPopulation($spawn->getFloorX() >> Chunk::COORD_BIT_SIZE, $spawn->getFloorZ() >> Chunk::COORD_BIT_SIZE, null)->onCompletion( function() use ($playerPromiseResolver, $class, $session, $playerInfo, $authenticated, $world, $playerPos, $spawn, $offlinePlayerData) : void{ From 770cca2efa71c5d8fcf0701f238e6e2fd2369125 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 19:13:54 +0100 Subject: [PATCH 15/32] Server: harden response handling for crash report submission this eliminates some checkImplicitMixed errors in phpstan. --- src/Server.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Server.php b/src/Server.php index 4c6176f24..ac22f74b5 100644 --- a/src/Server.php +++ b/src/Server.php @@ -1651,12 +1651,14 @@ class Server{ ], 10, [], $postUrlError); if($reply !== null && is_object($data = json_decode($reply->getBody()))){ - if(isset($data->crashId) && isset($data->crashUrl)){ + if(isset($data->crashId) && is_int($data->crashId) && isset($data->crashUrl) && is_string($data->crashUrl)){ $reportId = $data->crashId; $reportUrl = $data->crashUrl; $this->logger->emergency($this->getLanguage()->translate(KnownTranslationFactory::pocketmine_crash_archive($reportUrl, (string) $reportId))); - }elseif(isset($data->error)){ + }elseif(isset($data->error) && is_string($data->error)){ $this->logger->emergency("Automatic crash report submission failed: $data->error"); + }else{ + $this->logger->emergency("Invalid JSON response received from crash archive: " . $reply->getBody()); } }else{ $this->logger->emergency("Failed to communicate with crash archive: $postUrlError"); From d72e947d15b9818ad4c9f39b41c7cdcbe79e6437 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 19:14:35 +0100 Subject: [PATCH 16/32] BlockFactory: avoid unnecessary local static variable usage phpstan treats these as always mixed, because it can't be sure what their types will be. --- src/block/BlockFactory.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/block/BlockFactory.php b/src/block/BlockFactory.php index 5f4676584..8aabeb9ca 100644 --- a/src/block/BlockFactory.php +++ b/src/block/BlockFactory.php @@ -523,12 +523,6 @@ class BlockFactory{ $this->registerAllMeta(...$leaves); $this->registerAllMeta(...$allSidedLogs); - static $sandstoneTypes = [ - Meta::SANDSTONE_NORMAL => "", - Meta::SANDSTONE_CHISELED => "Chiseled ", - Meta::SANDSTONE_CUT => "Cut ", - Meta::SANDSTONE_SMOOTH => "Smooth " - ]; $sandstoneBreakInfo = new BreakInfo(0.8, ToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel()); $this->registerAllMeta(new Stair(new BID(Ids::RED_SANDSTONE_STAIRS, 0), "Red Sandstone Stairs", $sandstoneBreakInfo)); $this->registerAllMeta(new Stair(new BID(Ids::SMOOTH_RED_SANDSTONE_STAIRS, 0), "Smooth Red Sandstone Stairs", $sandstoneBreakInfo)); @@ -536,7 +530,12 @@ class BlockFactory{ $this->registerAllMeta(new Stair(new BID(Ids::SMOOTH_SANDSTONE_STAIRS, 0), "Smooth Sandstone Stairs", $sandstoneBreakInfo)); $sandstones = []; $redSandstones = []; - foreach($sandstoneTypes as $variant => $prefix){ + foreach([ + Meta::SANDSTONE_NORMAL => "", + Meta::SANDSTONE_CHISELED => "Chiseled ", + Meta::SANDSTONE_CUT => "Cut ", + Meta::SANDSTONE_SMOOTH => "Smooth " + ] as $variant => $prefix){ $sandstones[] = new Opaque(new BID(Ids::SANDSTONE, $variant), $prefix . "Sandstone", $sandstoneBreakInfo); $redSandstones[] = new Opaque(new BID(Ids::RED_SANDSTONE, $variant), $prefix . "Red Sandstone", $sandstoneBreakInfo); } From 222049927a45057021a15fda0fe2d69d5401d8f3 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 19:15:05 +0100 Subject: [PATCH 17/32] Language: fixed bogus callable reference in array_map for some reason phpstan only reports this under checkImplicitMixed. --- src/lang/Language.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lang/Language.php b/src/lang/Language.php index 0cba6bd21..7e6f6cfcc 100644 --- a/src/lang/Language.php +++ b/src/lang/Language.php @@ -129,7 +129,7 @@ class Language{ protected static function loadLang(string $path, string $languageCode) : array{ $file = Path::join($path, $languageCode . ".ini"); if(file_exists($file)){ - $strings = array_map('\stripcslashes', Utils::assumeNotFalse(parse_ini_file($file, false, INI_SCANNER_RAW), "Missing or inaccessible required resource files")); + $strings = array_map('stripcslashes', Utils::assumeNotFalse(parse_ini_file($file, false, INI_SCANNER_RAW), "Missing or inaccessible required resource files")); if(count($strings) > 0){ return $strings; } From 66cd156d808b7b81b0ff4dd653259c1e6de6bc7b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 19:18:01 +0100 Subject: [PATCH 18/32] Utils: use static property for core count cache, instead of local static variable --- src/utils/Utils.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/utils/Utils.php b/src/utils/Utils.php index d5ecae996..35d6595ca 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -109,6 +109,7 @@ final class Utils{ private static ?string $os = null; private static ?UuidInterface $serverUniqueId = null; + private static ?int $cpuCores = null; /** * Returns a readable identifier for the given Closure, including file and line. @@ -296,14 +297,11 @@ final class Utils{ } public static function getCoreCount(bool $recalculate = false) : int{ - static $processors = 0; - - if($processors > 0 && !$recalculate){ - return $processors; - }else{ - $processors = 0; + if(self::$cpuCores !== null && !$recalculate){ + return self::$cpuCores; } + $processors = 0; switch(Utils::getOS()){ case Utils::OS_LINUX: case Utils::OS_ANDROID: @@ -327,7 +325,7 @@ final class Utils{ $processors = (int) getenv("NUMBER_OF_PROCESSORS"); break; } - return $processors; + return self::$cpuCores = $processors; } /** From f88c4d9a8c711780aa88a25f64a114e38df7c1e0 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 19:19:04 +0100 Subject: [PATCH 19/32] Remove more unnecessary local static variable usages these are never mutated. Local constants would be better, if we had those. --- src/block/Cactus.php | 2 +- src/entity/ExperienceManager.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/block/Cactus.php b/src/block/Cactus.php index 987bea144..11be13086 100644 --- a/src/block/Cactus.php +++ b/src/block/Cactus.php @@ -72,7 +72,7 @@ class Cactus extends Transparent{ * @return AxisAlignedBB[] */ protected function recalculateCollisionBoxes() : array{ - static $shrinkSize = 1 / 16; + $shrinkSize = 1 / 16; return [AxisAlignedBB::one()->contract($shrinkSize, 0, $shrinkSize)->trim(Facing::UP, $shrinkSize)]; } diff --git a/src/entity/ExperienceManager.php b/src/entity/ExperienceManager.php index b74b87192..d6942de82 100644 --- a/src/entity/ExperienceManager.php +++ b/src/entity/ExperienceManager.php @@ -237,8 +237,8 @@ class ExperienceManager{ } public function onPickupXp(int $xpValue) : void{ - static $mainHandIndex = -1; - static $offHandIndex = -2; + $mainHandIndex = -1; + $offHandIndex = -2; //TODO: replace this with a more generic equipment getting/setting interface /** @var Durable[] $equipment */ From ca4b8a5827f9b5b6c87297de7ed6a1cf28009c67 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 19:24:09 +0100 Subject: [PATCH 20/32] World: remove local static recursion guard variable, closes #3125 --- src/world/World.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/world/World.php b/src/world/World.php index 13dc24d1e..549a0f501 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -171,6 +171,8 @@ class World implements ChunkManager{ /** @var Entity[] */ public $updateEntities = []; + + private bool $inDynamicStateRecalculation = false; /** @var Block[][] */ private array $blockCache = []; @@ -1536,17 +1538,15 @@ class World implements ChunkManager{ $block->position($this, $x, $y, $z); - static $dynamicStateRead = false; - - if($dynamicStateRead){ + if($this->inDynamicStateRecalculation){ //this call was generated by a parent getBlock() call calculating dynamic stateinfo //don't calculate dynamic state and don't add to block cache (since it won't have dynamic state calculated). //this ensures that it's impossible for dynamic state properties to recursively depend on each other. $addToCache = false; }else{ - $dynamicStateRead = true; + $this->inDynamicStateRecalculation = true; $block->readStateFromWorld(); - $dynamicStateRead = false; + $this->inDynamicStateRecalculation = false; } if($addToCache && $relativeBlockHash !== null){ From a0ea74c08f05cf93e9beecc7f90d215d50cc1f6e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 19:34:12 +0100 Subject: [PATCH 21/32] Inventory: Improve quality of type info of arrays --- src/inventory/Inventory.php | 10 ++++++++++ src/inventory/SimpleInventory.php | 1 + 2 files changed, 11 insertions(+) diff --git a/src/inventory/Inventory.php b/src/inventory/Inventory.php index fa45d4a78..230f6aa49 100644 --- a/src/inventory/Inventory.php +++ b/src/inventory/Inventory.php @@ -47,12 +47,20 @@ interface Inventory{ public function setItem(int $index, Item $item) : void; /** + * Returns an array of all the itemstacks in the inventory, indexed by their slot number. + * Empty slots are not included unless includeEmpty is true. + * * @return Item[] + * @phpstan-return array */ public function getContents(bool $includeEmpty = false) : array; /** + * Sets the contents of the inventory. Non-numeric offsets or offsets larger than the size of the inventory are + * ignored. + * * @param Item[] $items + * @phpstan-param array $items */ public function setContents(array $items) : void; @@ -85,8 +93,10 @@ interface Inventory{ /** * Will return all the Items that has the same id and metadata (if not null). * Won't check amount + * The returned array is indexed by slot number. * * @return Item[] + * @phpstan-return array */ public function all(Item $item) : array; diff --git a/src/inventory/SimpleInventory.php b/src/inventory/SimpleInventory.php index 95ed29c24..aae11c84c 100644 --- a/src/inventory/SimpleInventory.php +++ b/src/inventory/SimpleInventory.php @@ -58,6 +58,7 @@ class SimpleInventory extends BaseInventory{ /** * @return Item[] + * @phpstan-return array */ public function getContents(bool $includeEmpty = false) : array{ $contents = []; From a735a69870624065867c8ff0221c2638305bfd2a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 19:36:08 +0100 Subject: [PATCH 22/32] BaseInventory: improve type info available to setContents() and internalSetContents() --- src/inventory/BaseInventory.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/inventory/BaseInventory.php b/src/inventory/BaseInventory.php index 4f939c518..d906dbbbd 100644 --- a/src/inventory/BaseInventory.php +++ b/src/inventory/BaseInventory.php @@ -76,11 +76,13 @@ abstract class BaseInventory implements Inventory{ /** * @param Item[] $items + * @phpstan-param array $items */ abstract protected function internalSetContents(array $items) : void; /** * @param Item[] $items + * @phpstan-param array $items */ public function setContents(array $items) : void{ if(count($items) > $this->getSize()){ From 6866c86d3940e655c3bd9bb4f91f8e9ab0a440ed Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 19:36:45 +0100 Subject: [PATCH 23/32] BaseInventory: fix CS --- src/inventory/BaseInventory.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/inventory/BaseInventory.php b/src/inventory/BaseInventory.php index d906dbbbd..3edc52043 100644 --- a/src/inventory/BaseInventory.php +++ b/src/inventory/BaseInventory.php @@ -134,6 +134,7 @@ abstract class BaseInventory implements Inventory{ return $slots; } + public function first(Item $item, bool $exact = false) : int{ $count = $exact ? $item->getCount() : max(1, $item->getCount()); $checkDamage = $exact || !$item->hasAnyDamageValue(); From 6dd5fec4eae35fa710d6518749a433e0002e343c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 19:38:23 +0100 Subject: [PATCH 24/32] ExperienceManager: remove superfluous doc comment --- src/entity/ExperienceManager.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/entity/ExperienceManager.php b/src/entity/ExperienceManager.php index d6942de82..9cff48f33 100644 --- a/src/entity/ExperienceManager.php +++ b/src/entity/ExperienceManager.php @@ -241,7 +241,6 @@ class ExperienceManager{ $offHandIndex = -2; //TODO: replace this with a more generic equipment getting/setting interface - /** @var Durable[] $equipment */ $equipment = []; if(($item = $this->entity->getInventory()->getItemInHand()) instanceof Durable && $item->hasEnchantment(VanillaEnchantments::MENDING())){ From 88eafdd614319e1b676ecc11673ce2c34a08e593 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 19:57:22 +0100 Subject: [PATCH 25/32] Improve type info for RegistryTrait::getAll() and its users --- src/block/VanillaBlocks.php | 1 + src/entity/effect/VanillaEffects.php | 1 + src/item/VanillaItems.php | 1 + src/utils/EnumTrait.php | 1 + src/utils/RegistryTrait.php | 6 +++++- 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/block/VanillaBlocks.php b/src/block/VanillaBlocks.php index ec3c5a494..c2216c5dd 100644 --- a/src/block/VanillaBlocks.php +++ b/src/block/VanillaBlocks.php @@ -585,6 +585,7 @@ final class VanillaBlocks{ /** * @return Block[] + * @phpstan-return array */ public static function getAll() : array{ //phpstan doesn't support generic traits yet :( diff --git a/src/entity/effect/VanillaEffects.php b/src/entity/effect/VanillaEffects.php index 249ce367c..04f7985da 100644 --- a/src/entity/effect/VanillaEffects.php +++ b/src/entity/effect/VanillaEffects.php @@ -101,6 +101,7 @@ final class VanillaEffects{ /** * @return Effect[] + * @phpstan-return array */ public static function getAll() : array{ //phpstan doesn't support generic traits yet :( diff --git a/src/item/VanillaItems.php b/src/item/VanillaItems.php index 98a4ba514..9bc537812 100644 --- a/src/item/VanillaItems.php +++ b/src/item/VanillaItems.php @@ -384,6 +384,7 @@ final class VanillaItems{ /** * @return Item[] + * @phpstan-return array */ public static function getAll() : array{ //phpstan doesn't support generic traits yet :( diff --git a/src/utils/EnumTrait.php b/src/utils/EnumTrait.php index 315561444..c9d24e0fc 100644 --- a/src/utils/EnumTrait.php +++ b/src/utils/EnumTrait.php @@ -48,6 +48,7 @@ trait EnumTrait{ * This is overridden to change the return typehint. * * @return self[] + * @phpstan-return array */ public static function getAll() : array{ //phpstan doesn't support generic traits yet :( diff --git a/src/utils/RegistryTrait.php b/src/utils/RegistryTrait.php index 989800ef0..776980599 100644 --- a/src/utils/RegistryTrait.php +++ b/src/utils/RegistryTrait.php @@ -29,7 +29,10 @@ use function mb_strtoupper; use function preg_match; trait RegistryTrait{ - /** @var object[] */ + /** + * @var object[] + * @phpstan-var array + */ private static $members = null; private static function verifyName(string $name) : void{ @@ -107,6 +110,7 @@ trait RegistryTrait{ /** * @return object[] + * @phpstan-return array */ private static function _registryGetAll() : array{ self::checkInit(); From f3ca6de1eb2d1899ed6fa2cc1b5d2edd245471a9 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 20:00:52 +0100 Subject: [PATCH 26/32] shut --- src/Server.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Server.php b/src/Server.php index ac22f74b5..88888445b 100644 --- a/src/Server.php +++ b/src/Server.php @@ -132,6 +132,7 @@ use function get_class; use function ini_set; use function is_array; use function is_dir; +use function is_int; use function is_object; use function is_resource; use function is_string; From c063198b893c945bc729282eeb4dd6746c61f269 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Sep 2022 20:01:52 +0100 Subject: [PATCH 27/32] Fixed incorrect array key type in BrewingStandTest --- tests/phpunit/block/BrewingStandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/block/BrewingStandTest.php b/tests/phpunit/block/BrewingStandTest.php index 58be37470..f812ffdaf 100644 --- a/tests/phpunit/block/BrewingStandTest.php +++ b/tests/phpunit/block/BrewingStandTest.php @@ -33,7 +33,7 @@ class BrewingStandTest extends TestCase{ * @phpstan-return \Generator}, void, void> */ public function slotsProvider() : \Generator{ - yield [BrewingStandSlot::getAll()]; + yield [array_values(BrewingStandSlot::getAll())]; yield [[BrewingStandSlot::EAST()]]; yield [[BrewingStandSlot::EAST(), BrewingStandSlot::NORTHWEST()]]; } From 3d03bb1301a654bd582bd76b074ed8c00f0b2e66 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 15 Sep 2022 12:01:26 +0100 Subject: [PATCH 28/32] Fix CS --- src/entity/effect/Effect.php | 1 - src/network/mcpe/cache/ChunkCache.php | 2 -- tests/phpunit/block/BrewingStandTest.php | 1 + 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/entity/effect/Effect.php b/src/entity/effect/Effect.php index 442028d4c..cce009733 100644 --- a/src/entity/effect/Effect.php +++ b/src/entity/effect/Effect.php @@ -38,7 +38,6 @@ class Effect{ * @param Translatable|string $name Translation key used for effect name * @param Color $color Color of bubbles given by this effect * @param bool $bad Whether the effect is harmful - * @param int $defaultDuration * @param bool $hasBubbles Whether the effect has potion bubbles. Some do not (e.g. Instant Damage has its own particles instead of bubbles) */ public function __construct( diff --git a/src/network/mcpe/cache/ChunkCache.php b/src/network/mcpe/cache/ChunkCache.php index dae5e27d6..15b696945 100644 --- a/src/network/mcpe/cache/ChunkCache.php +++ b/src/network/mcpe/cache/ChunkCache.php @@ -43,8 +43,6 @@ class ChunkCache implements ChunkListener{ /** * Fetches the ChunkCache instance for the given world. This lazily creates cache systems as needed. - * - * @return ChunkCache */ public static function getInstance(World $world, Compressor $compressor) : self{ $worldId = spl_object_id($world); diff --git a/tests/phpunit/block/BrewingStandTest.php b/tests/phpunit/block/BrewingStandTest.php index f812ffdaf..c61a1db6d 100644 --- a/tests/phpunit/block/BrewingStandTest.php +++ b/tests/phpunit/block/BrewingStandTest.php @@ -25,6 +25,7 @@ namespace pocketmine\block; use PHPUnit\Framework\TestCase; use pocketmine\block\utils\BrewingStandSlot; +use function array_values; use function count; class BrewingStandTest extends TestCase{ From 67887afd6b0cc5d0bbe4b3ec513df101e70c6209 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 15 Sep 2022 12:03:04 +0100 Subject: [PATCH 29/32] Updated php-cs-fixer version for Actions --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d2656d281..ded1c0ee5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -198,7 +198,7 @@ jobs: uses: shivammathur/setup-php@2.21.2 with: php-version: 8.0 - tools: php-cs-fixer:3.8 + tools: php-cs-fixer:3.11 - name: Run PHP-CS-Fixer run: php-cs-fixer fix --dry-run --diff --ansi From a82923acb458d8f8130a1d73761d70ce14c3507b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 15 Sep 2022 12:03:36 +0100 Subject: [PATCH 30/32] Updated Actions PHP versions --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ded1c0ee5..44a672b73 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: image: [ubuntu-20.04] - php: [8.0.22, 8.1.9] + php: [8.0.23, 8.1.10] steps: - name: Build and prepare PHP cache @@ -31,7 +31,7 @@ jobs: fail-fast: false matrix: image: [ubuntu-20.04] - php: [8.0.22, 8.1.9] + php: [8.0.23, 8.1.10] steps: - uses: actions/checkout@v3 @@ -69,7 +69,7 @@ jobs: fail-fast: false matrix: image: [ubuntu-20.04] - php: [8.0.22, 8.1.9] + php: [8.0.23, 8.1.10] steps: - uses: actions/checkout@v3 @@ -107,7 +107,7 @@ jobs: fail-fast: false matrix: image: [ubuntu-20.04] - php: [8.0.22, 8.1.9] + php: [8.0.23, 8.1.10] steps: - uses: actions/checkout@v3 @@ -147,7 +147,7 @@ jobs: fail-fast: false matrix: image: [ubuntu-20.04] - php: [8.0.22, 8.1.9] + php: [8.0.23, 8.1.10] steps: - uses: actions/checkout@v3 From 313850eec4af4cb138c245daab1ab400892f75e3 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 15 Sep 2022 12:08:36 +0100 Subject: [PATCH 31/32] Updated composer dependencies --- composer.lock | 75 ++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/composer.lock b/composer.lock index b3bae8d04..997e72456 100644 --- a/composer.lock +++ b/composer.lock @@ -926,20 +926,20 @@ }, { "name": "ramsey/uuid", - "version": "4.4.0", + "version": "4.5.0", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "373f7bacfcf3de038778ff27dcce5672ddbf4c8a" + "reference": "ef842484ba57f163c6d465ab744bfecb872a11d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/373f7bacfcf3de038778ff27dcce5672ddbf4c8a", - "reference": "373f7bacfcf3de038778ff27dcce5672ddbf4c8a", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/ef842484ba57f163c6d465ab744bfecb872a11d4", + "reference": "ef842484ba57f163c6d465ab744bfecb872a11d4", "shasum": "" }, "require": { - "brick/math": "^0.8 || ^0.9 || ^0.10", + "brick/math": "^0.8.8 || ^0.9 || ^0.10", "ext-ctype": "*", "ext-json": "*", "php": "^8.0", @@ -960,12 +960,13 @@ "php-mock/php-mock-mockery": "^1.3", "php-parallel-lint/php-parallel-lint": "^1.1", "phpbench/phpbench": "^1.0", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-mockery": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-phpunit": "^1.1", "phpunit/phpunit": "^8.5 || ^9", - "slevomat/coding-standard": "^7.0", + "ramsey/composer-repl": "^1.4", + "slevomat/coding-standard": "^8.4", "squizlabs/php_codesniffer": "^3.5", "vimeo/psalm": "^4.9" }, @@ -1003,7 +1004,7 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.4.0" + "source": "https://github.com/ramsey/uuid/tree/4.5.0" }, "funding": [ { @@ -1015,7 +1016,7 @@ "type": "tidelift" } ], - "time": "2022-08-05T17:58:37+00:00" + "time": "2022-09-15T01:44:53+00:00" }, { "name": "symfony/polyfill-php81", @@ -1338,16 +1339,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.14.0", + "version": "v4.15.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "34bea19b6e03d8153165d8f30bba4c3be86184c1" + "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/34bea19b6e03d8153165d8f30bba4c3be86184c1", - "reference": "34bea19b6e03d8153165d8f30bba4c3be86184c1", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", + "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", "shasum": "" }, "require": { @@ -1388,9 +1389,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.14.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.1" }, - "time": "2022-05-31T20:59:12+00:00" + "time": "2022-09-04T07:30:47+00:00" }, { "name": "phar-io/manifest", @@ -2247,16 +2248,16 @@ }, { "name": "sebastian/comparator", - "version": "4.0.6", + "version": "4.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382" + "reference": "fa0f136dd2334583309d32b62544682ee972b51a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a", "shasum": "" }, "require": { @@ -2309,7 +2310,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" }, "funding": [ { @@ -2317,7 +2318,7 @@ "type": "github" } ], - "time": "2020-10-26T15:49:45+00:00" + "time": "2022-09-14T12:41:17+00:00" }, { "name": "sebastian/complexity", @@ -2507,16 +2508,16 @@ }, { "name": "sebastian/exporter", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9" + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", "shasum": "" }, "require": { @@ -2572,7 +2573,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" }, "funding": [ { @@ -2580,7 +2581,7 @@ "type": "github" } ], - "time": "2021-11-11T14:18:36+00:00" + "time": "2022-09-14T06:03:37+00:00" }, { "name": "sebastian/global-state", @@ -2935,16 +2936,16 @@ }, { "name": "sebastian/type", - "version": "3.1.0", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "fb44e1cc6e557418387ad815780360057e40753e" + "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb44e1cc6e557418387ad815780360057e40753e", - "reference": "fb44e1cc6e557418387ad815780360057e40753e", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", + "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", "shasum": "" }, "require": { @@ -2956,7 +2957,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -2979,7 +2980,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.1.0" + "source": "https://github.com/sebastianbergmann/type/tree/3.2.0" }, "funding": [ { @@ -2987,7 +2988,7 @@ "type": "github" } ], - "time": "2022-08-29T06:55:37+00:00" + "time": "2022-09-12T14:47:03+00:00" }, { "name": "sebastian/version", From 112974758ead4e8dd25beed226805e885aa84486 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 15 Sep 2022 12:13:50 +0100 Subject: [PATCH 32/32] Updated PHPStan to 1.8.5 --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 284ff4b50..fa630de86 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "webmozart/path-util": "^2.3" }, "require-dev": { - "phpstan/phpstan": "1.8.3", + "phpstan/phpstan": "1.8.5", "phpstan/phpstan-phpunit": "^1.1.0", "phpstan/phpstan-strict-rules": "^1.2.0", "phpunit/phpunit": "^9.2" diff --git a/composer.lock b/composer.lock index 997e72456..b2e7b44d7 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": "4f57f22ed042b67eb1c1413aab2ab3bd", + "content-hash": "82c3c4f98020c30f8ba31f11211abdc3", "packages": [ { "name": "adhocore/json-comment", @@ -1506,16 +1506,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.8.3", + "version": "1.8.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "5583623b61caafebd62bc78a99533aa9d769d097" + "reference": "f6598a5ff12ca4499a836815e08b4d77a2ddeb20" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/5583623b61caafebd62bc78a99533aa9d769d097", - "reference": "5583623b61caafebd62bc78a99533aa9d769d097", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/f6598a5ff12ca4499a836815e08b4d77a2ddeb20", + "reference": "f6598a5ff12ca4499a836815e08b4d77a2ddeb20", "shasum": "" }, "require": { @@ -1545,7 +1545,7 @@ ], "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.8.3" + "source": "https://github.com/phpstan/phpstan/tree/1.8.5" }, "funding": [ { @@ -1561,7 +1561,7 @@ "type": "tidelift" } ], - "time": "2022-09-01T15:27:34+00:00" + "time": "2022-09-07T16:05:32+00:00" }, { "name": "phpstan/phpstan-phpunit",