diff --git a/composer.json b/composer.json index 0e8035186..d32b966ad 100644 --- a/composer.json +++ b/composer.json @@ -50,7 +50,7 @@ "respect/validation": "^2.0" }, "require-dev": { - "phpstan/phpstan": "^0.12.25", + "phpstan/phpstan": "^0.12.29", "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 df010e048..84725eb77 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": "fb110ec33e506f610d1cb2ca9447597a", + "content-hash": "b8160d3c44bfbc1212084957a8ed3731", "packages": [ { "name": "adhocore/json-comment", @@ -1369,16 +1369,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.25", + "version": "0.12.29", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "9619551d68b2d4c0d681a8df73f3c847c798ee64" + "reference": "9771daaf6b95c6313b908d0bcdee0afcd51f838a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9619551d68b2d4c0d681a8df73f3c847c798ee64", - "reference": "9619551d68b2d4c0d681a8df73f3c847c798ee64", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9771daaf6b95c6313b908d0bcdee0afcd51f838a", + "reference": "9771daaf6b95c6313b908d0bcdee0afcd51f838a", "shasum": "" }, "require": { @@ -1407,7 +1407,21 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", - "time": "2020-05-10T20:36:16+00:00" + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2020-06-14T14:10:59+00:00" }, { "name": "phpstan/phpstan-phpunit", diff --git a/src/network/mcpe/NetworkSession.php b/src/network/mcpe/NetworkSession.php index 0ac489802..b08c8cddd 100644 --- a/src/network/mcpe/NetworkSession.php +++ b/src/network/mcpe/NetworkSession.php @@ -154,7 +154,10 @@ class NetworkSession{ /** @var PacketBatch|null */ private $sendBuffer; - /** @var \SplQueue|CompressBatchPromise[] */ + /** + * @var \SplQueue|CompressBatchPromise[] + * @phpstan-var \SplQueue + */ private $compressedQueue; /** @var Compressor */ private $compressor; diff --git a/src/scheduler/AsyncPool.php b/src/scheduler/AsyncPool.php index 1eedb3e2e..73f0c991d 100644 --- a/src/scheduler/AsyncPool.php +++ b/src/scheduler/AsyncPool.php @@ -49,7 +49,10 @@ class AsyncPool{ /** @var int */ private $workerMemoryLimit; - /** @var \SplQueue[]|AsyncTask[][] */ + /** + * @var \SplQueue[]|AsyncTask[][] + * @phpstan-var array> + */ private $taskQueues = []; /** diff --git a/src/scheduler/TaskScheduler.php b/src/scheduler/TaskScheduler.php index 59a484da2..41fd9d1e4 100644 --- a/src/scheduler/TaskScheduler.php +++ b/src/scheduler/TaskScheduler.php @@ -36,7 +36,10 @@ class TaskScheduler{ /** @var bool */ private $enabled = true; - /** @var ReversePriorityQueue */ + /** + * @var ReversePriorityQueue + * @phpstan-var ReversePriorityQueue + */ protected $queue; /** @var TaskHandler[] */ diff --git a/src/utils/ReversePriorityQueue.php b/src/utils/ReversePriorityQueue.php index d9fa2d0e0..fc8588a13 100644 --- a/src/utils/ReversePriorityQueue.php +++ b/src/utils/ReversePriorityQueue.php @@ -23,11 +23,18 @@ declare(strict_types=1); namespace pocketmine\utils; +/** + * @phpstan-template TPriority + * @phpstan-template TValue + * @phpstan-extends \SplPriorityQueue + */ class ReversePriorityQueue extends \SplPriorityQueue{ /** * @param mixed $priority1 * @param mixed $priority2 + * @phpstan-param TPriority $priority1 + * @phpstan-param TPriority $priority2 * * @return int */ diff --git a/src/world/World.php b/src/world/World.php index bb080773d..540047836 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -197,12 +197,18 @@ class World implements ChunkManager{ /** @var Vector3[][] */ private $changedBlocks = []; - /** @var ReversePriorityQueue */ + /** + * @var ReversePriorityQueue + * @phpstan-var ReversePriorityQueue + */ private $scheduledBlockUpdateQueue; /** @var int[] */ private $scheduledBlockUpdateQueueIndex = []; - /** @var \SplQueue */ + /** + * @var \SplQueue + * @phpstan-var \SplQueue + */ private $neighbourBlockUpdateQueue; /** @var bool[] blockhash => dummy */ private $neighbourBlockUpdateQueueIndex = []; diff --git a/src/world/light/LightUpdate.php b/src/world/light/LightUpdate.php index 41bb468de..5bba96bf3 100644 --- a/src/world/light/LightUpdate.php +++ b/src/world/light/LightUpdate.php @@ -42,7 +42,10 @@ abstract class LightUpdate{ */ protected $updateNodes = []; - /** @var \SplQueue */ + /** + * @var \SplQueue + * @phpstan-var \SplQueue + */ protected $spreadQueue; /** * @var true[] @@ -50,7 +53,10 @@ abstract class LightUpdate{ */ protected $spreadVisited = []; - /** @var \SplQueue */ + /** + * @var \SplQueue + * @phpstan-var \SplQueue + */ protected $removalQueue; /** * @var true[] diff --git a/tests/phpstan/configs/l7-baseline.neon b/tests/phpstan/configs/l7-baseline.neon index 95708b84c..5b4ba2a74 100644 --- a/tests/phpstan/configs/l7-baseline.neon +++ b/tests/phpstan/configs/l7-baseline.neon @@ -751,34 +751,9 @@ parameters: path: ../../../src/resourcepacks/ZippedResourcePack.php - - message: "#^Cannot call method enqueue\\(\\) on array\\\\|SplQueue\\.$#" + message: "#^Cannot call method getNextRun\\(\\) on array\\\\|int\\|pocketmine\\\\scheduler\\\\TaskHandler\\.$#" count: 1 - path: ../../../src/scheduler/AsyncPool.php - - - - message: "#^Cannot call method count\\(\\) on array\\\\|SplQueue\\.$#" - count: 1 - path: ../../../src/scheduler/AsyncPool.php - - - - message: "#^Method pocketmine\\\\scheduler\\\\AsyncPool\\:\\:selectWorker\\(\\) should return int but returns int\\|string\\.$#" - count: 1 - path: ../../../src/scheduler/AsyncPool.php - - - - message: "#^Cannot call method isEmpty\\(\\) on array\\\\|SplQueue\\.$#" - count: 3 - path: ../../../src/scheduler/AsyncPool.php - - - - message: "#^Cannot call method bottom\\(\\) on array\\\\|SplQueue\\.$#" - count: 1 - path: ../../../src/scheduler/AsyncPool.php - - - - message: "#^Cannot call method dequeue\\(\\) on array\\\\|SplQueue\\.$#" - count: 2 - path: ../../../src/scheduler/AsyncPool.php + path: ../../../src/scheduler/TaskScheduler.php - message: "#^Parameter \\#2 \\$subject of function preg_match expects string, string\\|false given\\.$#" @@ -895,6 +870,16 @@ parameters: count: 1 path: ../../../src/world/World.php + - + message: "#^Cannot access offset 'priority' on array\\('priority' \\=\\> int, 'data' \\=\\> pocketmine\\\\math\\\\Vector3\\)\\|int\\|pocketmine\\\\math\\\\Vector3\\.$#" + count: 1 + path: ../../../src/world/World.php + + - + message: "#^Cannot access offset 'data' on array\\('priority' \\=\\> int, 'data' \\=\\> pocketmine\\\\math\\\\Vector3\\)\\|int\\|pocketmine\\\\math\\\\Vector3\\.$#" + count: 1 + path: ../../../src/world/World.php + - message: "#^Parameter \\#1 \\$x of static method pocketmine\\\\world\\\\World\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#" count: 3