From 58a95f88366568fea531df30ff898fd881b3d43d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 9 Oct 2021 19:18:32 +0100 Subject: [PATCH 1/2] Updated transitive composer dependencies --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 7cedb4812..34065f3a8 100644 --- a/composer.lock +++ b/composer.lock @@ -893,16 +893,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": { @@ -937,9 +937,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", From e38866c4ba90f8efd5630dbe674fd7ca15f586ff Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 9 Oct 2021 19:33:43 +0100 Subject: [PATCH 2/2] phpstan 0.12.99 --- composer.json | 2 +- composer.lock | 14 +++---- phpstan.neon.dist | 4 +- src/pocketmine/utils/Internet.php | 1 + tests/phpstan/configs/l7-baseline.neon | 5 --- tests/phpstan/configs/l8-baseline.neon | 5 --- tests/phpstan/configs/phpstan-bugs.neon | 50 ++++++++++++++++++++++--- 7 files changed, 56 insertions(+), 25 deletions(-) diff --git a/composer.json b/composer.json index 89758d393..911b036f5 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "pocketmine/spl": "^0.4.0" }, "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 34065f3a8..68576adf1 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": "8fc787ba6d9029fb6daa3e8c112b76c5", + "content-hash": "f3f0ef9944d96c5b71b7e32aac5118cd", "packages": [ { "name": "adhocore/json-comment", @@ -1010,16 +1010,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": { @@ -1050,7 +1050,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": [ { @@ -1070,7 +1070,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 9240471d4..f2fd04b9b 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -49,7 +49,7 @@ 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' PhpSocket: '\Socket' PhpCurlHandle: '\CurlHandle' diff --git a/src/pocketmine/utils/Internet.php b/src/pocketmine/utils/Internet.php index 26b393061..4979aa4e8 100644 --- a/src/pocketmine/utils/Internet.php +++ b/src/pocketmine/utils/Internet.php @@ -233,6 +233,7 @@ class Internet{ } if(!is_string($raw)) throw new AssumptionFailedError("curl_exec() should return string|false when CURLOPT_RETURNTRANSFER is set"); $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/l7-baseline.neon b/tests/phpstan/configs/l7-baseline.neon index 0f6f063c1..52ea0cd26 100644 --- a/tests/phpstan/configs/l7-baseline.neon +++ b/tests/phpstan/configs/l7-baseline.neon @@ -75,11 +75,6 @@ parameters: count: 2 path: ../../../src/pocketmine/PocketMine.php - - - message: "#^Cannot cast array\\\\|string\\|false to int\\.$#" - count: 1 - path: ../../../src/pocketmine/Server.php - - message: "#^Cannot cast array\\\\|string\\|false to string\\.$#" count: 1 diff --git a/tests/phpstan/configs/l8-baseline.neon b/tests/phpstan/configs/l8-baseline.neon index 03641bb01..636f93250 100644 --- a/tests/phpstan/configs/l8-baseline.neon +++ b/tests/phpstan/configs/l8-baseline.neon @@ -260,11 +260,6 @@ parameters: count: 1 path: ../../../src/pocketmine/block/BaseRail.php - - - message: "#^Parameter \\#1 \\$constraint of method pocketmine\\\\block\\\\BaseRail\\:\\:getPossibleConnectionDirectionsOneConstraint\\(\\) expects int, int\\|null given\\.$#" - count: 1 - path: ../../../src/pocketmine/block/BaseRail.php - - message: "#^Only numeric types are allowed in \\-, int\\|null given on the left side\\.$#" count: 1 diff --git a/tests/phpstan/configs/phpstan-bugs.neon b/tests/phpstan/configs/phpstan-bugs.neon index c98712cb1..d538a89ca 100644 --- a/tests/phpstan/configs/phpstan-bugs.neon +++ b/tests/phpstan/configs/phpstan-bugs.neon @@ -1,15 +1,60 @@ parameters: ignoreErrors: + - + message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(pocketmine\\\\Player\\)\\: bool given\\.$#" + count: 1 + path: ../../../src/pocketmine/Server.php + + - + message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(string\\)\\: bool given\\.$#" + count: 1 + path: ../../../src/pocketmine/Server.php + - message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#" count: 3 path: ../../../src/pocketmine/command/CommandReader.php + - + message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(pocketmine\\\\Player\\)\\: bool given\\.$#" + count: 1 + path: ../../../src/pocketmine/command/defaults/ListCommand.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/pocketmine/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/pocketmine/entity/Human.php + - message: "#^Call to function assert\\(\\) with false and 'unknown hit type' will always evaluate to false\\.$#" count: 1 path: ../../../src/pocketmine/entity/projectile/Projectile.php + - + message: "#^Parameter \\#2 \\$callback of function usort expects callable\\(mixed, mixed\\)\\: int, array\\('pocketmine\\\\\\\\inventory\\\\\\\\CraftingManager', 'sort'\\) given\\.$#" + count: 1 + path: ../../../src/pocketmine/inventory/CraftingManager.php + + - + message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(string\\)\\: bool given\\.$#" + count: 1 + path: ../../../src/pocketmine/lang/BaseLang.php + + - + message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(pocketmine\\\\entity\\\\Entity\\)\\: bool given\\.$#" + count: 1 + path: ../../../src/pocketmine/level/format/Chunk.php + + - + message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(string\\)\\: bool given\\.$#" + count: 1 + path: ../../../src/pocketmine/level/format/io/region/McRegion.php + - message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#" count: 2 @@ -25,11 +70,6 @@ parameters: count: 1 path: ../../../src/pocketmine/network/mcpe/protocol/DataPacket.php - - - message: "#^Parameter \\#1 \\$ of closure expects TMemberType, TMemberType given\\.$#" - count: 1 - path: ../../../src/pocketmine/utils/Utils.php - - message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#" count: 1