diff --git a/composer.json b/composer.json index ee6bccdcc..05f575214 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "webmozart/path-util": "^2.3" }, "require-dev": { - "phpstan/phpstan": "0.12.98", + "phpstan/phpstan": "0.12.99", "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 e2b12903f..4286906a6 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": "77f899b35819bca38246a665fd0233f3", + "content-hash": "c7a00c5a35d43f307fdba7a588029131", "packages": [ { "name": "adhocore/json-comment", @@ -836,16 +836,16 @@ }, { "name": "ramsey/collection", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/ramsey/collection.git", - "reference": "eaca1dc1054ddd10cbd83c1461907bee6fb528fa" + "reference": "cccc74ee5e328031b15640b51056ee8d3bb66c0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/collection/zipball/eaca1dc1054ddd10cbd83c1461907bee6fb528fa", - "reference": "eaca1dc1054ddd10cbd83c1461907bee6fb528fa", + "url": "https://api.github.com/repos/ramsey/collection/zipball/cccc74ee5e328031b15640b51056ee8d3bb66c0a", + "reference": "cccc74ee5e328031b15640b51056ee8d3bb66c0a", "shasum": "" }, "require": { @@ -899,7 +899,7 @@ ], "support": { "issues": "https://github.com/ramsey/collection/issues", - "source": "https://github.com/ramsey/collection/tree/1.2.1" + "source": "https://github.com/ramsey/collection/tree/1.2.2" }, "funding": [ { @@ -911,7 +911,7 @@ "type": "tidelift" } ], - "time": "2021-08-06T03:41:06+00:00" + "time": "2021-10-10T03:01:02+00:00" }, { "name": "ramsey/uuid", @@ -1971,16 +1971,16 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.5.0", + "version": "1.5.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "30f38bffc6f24293dadd1823936372dfa9e86e2f" + "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/30f38bffc6f24293dadd1823936372dfa9e86e2f", - "reference": "30f38bffc6f24293dadd1823936372dfa9e86e2f", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/a12f7e301eb7258bb68acd89d4aefa05c2906cae", + "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae", "shasum": "" }, "require": { @@ -2015,9 +2015,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.5.0" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.5.1" }, - "time": "2021-09-17T15:28:14+00:00" + "time": "2021-10-02T14:08:47+00:00" }, { "name": "phpspec/prophecy", @@ -2088,16 +2088,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.98", + "version": "0.12.99", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "3bb7cc246c057405dd5e290c3ecc62ab51d57e00" + "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/3bb7cc246c057405dd5e290c3ecc62ab51d57e00", - "reference": "3bb7cc246c057405dd5e290c3ecc62ab51d57e00", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b4d40f1d759942f523be267a1bab6884f46ca3f7", + "reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7", "shasum": "" }, "require": { @@ -2128,7 +2128,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.98" + "source": "https://github.com/phpstan/phpstan/tree/0.12.99" }, "funding": [ { @@ -2148,7 +2148,7 @@ "type": "tidelift" } ], - "time": "2021-09-02T12:33:01+00:00" + "time": "2021-09-12T20:09:55+00:00" }, { "name": "phpstan/phpstan-phpunit", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 8908fecb6..fb0598b8c 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -57,5 +57,5 @@ parameters: #variadics don't work for this - mixed probably shouldn't work either, but for now it does #what we actually need is something that accepts an infinite number of parameters, but in the absence of that, #we'll just fill it with 10 - it's very unlikely to encounter a callable with 10 parameters anyway. - anyCallable: 'callable(mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed) : mixed' - anyClosure: '\Closure(mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed) : mixed' + anyCallable: 'callable(never, never, never, never, never, never, never, never, never, never) : mixed' + anyClosure: '\Closure(never, never, never, never, never, never, never, never, never, never) : mixed' diff --git a/src/utils/Internet.php b/src/utils/Internet.php index 36dc96fc2..d94a85729 100644 --- a/src/utils/Internet.php +++ b/src/utils/Internet.php @@ -218,8 +218,8 @@ class Internet{ throw new InternetException(curl_error($ch)); } if(!is_string($raw)) throw new AssumptionFailedError("curl_exec() should return string|false when CURLOPT_RETURNTRANSFER is set"); - /** @var int $httpCode */ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + if(!is_int($httpCode)) throw new AssumptionFailedError("curl_getinfo(CURLINFO_HTTP_CODE) always returns int"); $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $rawHeaders = substr($raw, 0, $headerSize); $body = substr($raw, $headerSize); diff --git a/tests/phpstan/configs/phpstan-bugs.neon b/tests/phpstan/configs/phpstan-bugs.neon index a46b05a10..c4ebf4338 100644 --- a/tests/phpstan/configs/phpstan-bugs.neon +++ b/tests/phpstan/configs/phpstan-bugs.neon @@ -5,6 +5,16 @@ parameters: count: 1 path: ../../../src/block/BaseBanner.php + - + message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(pocketmine\\\\block\\\\Block\\|null\\)\\: bool given\\.$#" + count: 1 + path: ../../../src/block/BlockFactory.php + + - + message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(pocketmine\\\\player\\\\Player\\)\\: bool given\\.$#" + count: 1 + path: ../../../src/command/defaults/ListCommand.php + - message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#" count: 2 @@ -15,36 +25,56 @@ parameters: count: 1 path: ../../../src/crafting/CraftingManager.php + - + message: "#^Parameter \\#2 \\$callback of function usort expects callable\\(mixed, mixed\\)\\: int, array\\('pocketmine\\\\\\\\crafting\\\\\\\\CraftingManager', 'sort'\\) given\\.$#" + count: 1 + path: ../../../src/crafting/CraftingManager.php + - message: "#^Property pocketmine\\\\crafting\\\\CraftingManager\\:\\:\\$destructorCallbacks \\(pocketmine\\\\utils\\\\ObjectSet\\\\|null\\) does not accept pocketmine\\\\utils\\\\ObjectSet\\\\.$#" count: 1 path: ../../../src/crafting/CraftingManager.php + - + message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(pocketmine\\\\entity\\\\Attribute\\)\\: bool given\\.$#" + count: 1 + path: ../../../src/entity/AttributeMap.php + + - + message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(pocketmine\\\\item\\\\Item\\)\\: bool given\\.$#" + count: 1 + path: ../../../src/entity/Human.php + - message: "#^Call to function assert\\(\\) with false and 'unknown hit type' will always evaluate to false\\.$#" count: 1 path: ../../../src/entity/projectile/Projectile.php - - message: "#^Parameter \\#1 \\$ of closure expects TValue, TValue given\\.$#" - count: 2 - path: ../../../src/utils/Promise.php + message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(string\\)\\: bool given\\.$#" + count: 1 + path: ../../../src/lang/Language.php - - message: "#^Property pocketmine\\\\utils\\\\Promise\\\\:\\:\\$result \\(TValue\\|null\\) does not accept TValue\\.$#" + message: "#^Parameter \\#2 \\$callback of function usort expects callable\\(mixed, mixed\\)\\: int, Closure\\(pocketmine\\\\utils\\\\VersionString, pocketmine\\\\utils\\\\VersionString\\)\\: int given\\.$#" count: 1 - path: ../../../src/utils/Promise.php + path: ../../../src/plugin/ApiVersion.php - - message: "#^Parameter \\#1 \\$ of closure expects TMemberType, TMemberType given\\.$#" + message: "#^Parameter \\#1 \\$closure of static method pocketmine\\\\utils\\\\Utils\\:\\:getNiceClosureName\\(\\) expects Closure\\(\\*NEVER\\*, \\*NEVER\\*, \\*NEVER\\*, \\*NEVER\\*, \\*NEVER\\*, \\*NEVER\\*, \\*NEVER\\*, \\*NEVER\\*, \\*NEVER\\*, \\*NEVER\\*\\)\\: mixed, Closure\\(TEvent of pocketmine\\\\event\\\\Event\\)\\: void given\\.$#" count: 1 - path: ../../../src/utils/Utils.php + path: ../../../src/plugin/PluginManager.php - message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#" count: 1 path: ../../../src/utils/Utils.php + - + message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(pocketmine\\\\entity\\\\Entity\\)\\: bool given\\.$#" + count: 2 + path: ../../../src/world/World.php + - message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#" count: 2 @@ -55,3 +85,8 @@ parameters: count: 2 path: ../../../src/world/generator/noise/Noise.php + - + message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(pocketmine\\\\world\\\\format\\\\io\\\\WorldProviderManagerEntry\\)\\: bool given\\.$#" + count: 1 + path: ../../../tools/convert-world.php +