diff --git a/composer.json b/composer.json index cb0f6d18e..25755413e 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "composer-runtime-api": "^2.0" }, "require-dev": { - "phpstan/phpstan": "0.12.64", + "phpstan/phpstan": "0.12.65", "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 56f6c8bd2..11f824a63 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": "f0cec87ced440a2ea2b189283e9f696c", + "content-hash": "21ef5b68eba33e23b11acde01e8a2f36", "packages": [ { "name": "adhocore/json-comment", @@ -1000,16 +1000,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.64", + "version": "0.12.65", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "23eb1cb7ae125f45f1d0e48051bcf67a9a9b08aa" + "reference": "1c7658668b28f8d647a8b874372acf14c4352688" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/23eb1cb7ae125f45f1d0e48051bcf67a9a9b08aa", - "reference": "23eb1cb7ae125f45f1d0e48051bcf67a9a9b08aa", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1c7658668b28f8d647a8b874372acf14c4352688", + "reference": "1c7658668b28f8d647a8b874372acf14c4352688", "shasum": "" }, "require": { @@ -1040,7 +1040,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.64" + "source": "https://github.com/phpstan/phpstan/tree/0.12.65" }, "funding": [ { @@ -1056,7 +1056,7 @@ "type": "tidelift" } ], - "time": "2020-12-21T11:59:02+00:00" + "time": "2021-01-06T16:51:10+00:00" }, { "name": "phpstan/phpstan-phpunit", diff --git a/src/pocketmine/metadata/MetadataStore.php b/src/pocketmine/metadata/MetadataStore.php index 47e551d8c..5882ea6f4 100644 --- a/src/pocketmine/metadata/MetadataStore.php +++ b/src/pocketmine/metadata/MetadataStore.php @@ -29,7 +29,10 @@ namespace pocketmine\metadata; use pocketmine\plugin\Plugin; abstract class MetadataStore{ - /** @var \SplObjectStorage[]|MetadataValue[][] */ + /** + * @var \SplObjectStorage[]|MetadataValue[][] + * @phpstan-var array> + */ private $metadataMap; /** @@ -41,6 +44,7 @@ abstract class MetadataStore{ $owningPlugin = $newMetadataValue->getOwningPlugin(); if(!isset($this->metadataMap[$key])){ + /** @phpstan-var \SplObjectStorage $entry */ $entry = new \SplObjectStorage(); $this->metadataMap[$key] = $entry; }else{ @@ -92,7 +96,6 @@ abstract class MetadataStore{ * @return void */ public function invalidateAll(Plugin $owningPlugin){ - /** @var \SplObjectStorage|MetadataValue[] $values */ foreach($this->metadataMap as $values){ if(isset($values[$owningPlugin])){ $values[$owningPlugin]->invalidate(); diff --git a/src/pocketmine/scheduler/AsyncTask.php b/src/pocketmine/scheduler/AsyncTask.php index 21be7a736..fbb6d00db 100644 --- a/src/pocketmine/scheduler/AsyncTask.php +++ b/src/pocketmine/scheduler/AsyncTask.php @@ -51,6 +51,7 @@ use function unserialize; abstract class AsyncTask extends Collectable{ /** * @var \SplObjectStorage|null + * @phpstan-var \SplObjectStorage * Used to store objects on the main thread which should not be serialized. */ private static $threadLocalStorage; @@ -258,7 +259,9 @@ abstract class AsyncTask extends Collectable{ } if(self::$threadLocalStorage === null){ - self::$threadLocalStorage = new \SplObjectStorage(); //lazy init + /** @phpstan-var \SplObjectStorage $storage */ + $storage = new \SplObjectStorage(); + self::$threadLocalStorage = $storage; //lazy init } if(isset(self::$threadLocalStorage[$this])){ diff --git a/tests/phpstan/configs/actual-problems.neon b/tests/phpstan/configs/actual-problems.neon index 670d85c03..e6a9617ff 100644 --- a/tests/phpstan/configs/actual-problems.neon +++ b/tests/phpstan/configs/actual-problems.neon @@ -745,6 +745,11 @@ parameters: count: 1 path: ../../../src/pocketmine/level/generator/normal/Normal.php + - + message: "#^Method pocketmine\\\\metadata\\\\MetadataStore\\:\\:getMetadataInternal\\(\\) should return array\\ but returns SplObjectStorage\\\\.$#" + count: 1 + path: ../../../src/pocketmine/metadata/MetadataStore.php + - message: "#^Variable method call on pocketmine\\\\event\\\\Listener\\.$#" count: 1