diff --git a/composer.json b/composer.json index 75784af12..c2442fc4f 100644 --- a/composer.json +++ b/composer.json @@ -52,7 +52,7 @@ "symfony/filesystem": "~6.4.0" }, "require-dev": { - "phpstan/phpstan": "2.1.4", + "phpstan/phpstan": "2.1.5", "phpstan/phpstan-phpunit": "^2.0.0", "phpstan/phpstan-strict-rules": "^2.0.0", "phpunit/phpunit": "^10.5.24" diff --git a/composer.lock b/composer.lock index b0c4ebec3..91ce96fa8 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": "663122b8f03ef5ec6718a419923a0851", + "content-hash": "d63e9f0240056c52c10113b305010130", "packages": [ { "name": "adhocore/json-comment", @@ -1386,16 +1386,16 @@ }, { "name": "phpstan/phpstan", - "version": "2.1.4", + "version": "2.1.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "8f99e18eb775dbaf6460c95fa0b65312da9c746a" + "reference": "451b17f9665481ee502adc39be987cb71067ece2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/8f99e18eb775dbaf6460c95fa0b65312da9c746a", - "reference": "8f99e18eb775dbaf6460c95fa0b65312da9c746a", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/451b17f9665481ee502adc39be987cb71067ece2", + "reference": "451b17f9665481ee502adc39be987cb71067ece2", "shasum": "" }, "require": { @@ -1440,7 +1440,7 @@ "type": "github" } ], - "time": "2025-02-10T08:25:21+00:00" + "time": "2025-02-13T12:49:56+00:00" }, { "name": "phpstan/phpstan-phpunit", diff --git a/src/Server.php b/src/Server.php index 252964a91..679a0ef0b 100644 --- a/src/Server.php +++ b/src/Server.php @@ -699,7 +699,7 @@ class Server{ public function removeOp(string $name) : void{ $lowercaseName = strtolower($name); - foreach($this->operators->getAll() as $operatorName => $_){ + foreach(Utils::promoteKeys($this->operators->getAll()) as $operatorName => $_){ $operatorName = (string) $operatorName; if($lowercaseName === strtolower($operatorName)){ $this->operators->remove($operatorName); diff --git a/src/utils/Utils.php b/src/utils/Utils.php index 46cd49ec4..2a9dd65da 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -587,7 +587,7 @@ final class Utils{ * @phpstan-param \Closure(TMemberType) : void $validator */ public static function validateArrayValueType(array $array, \Closure $validator) : void{ - foreach($array as $k => $v){ + foreach(Utils::promoteKeys($array) as $k => $v){ try{ $validator($v); }catch(\TypeError $e){ diff --git a/tests/phpstan/configs/actual-problems.neon b/tests/phpstan/configs/actual-problems.neon index ef9828b37..73b7a65c1 100644 --- a/tests/phpstan/configs/actual-problems.neon +++ b/tests/phpstan/configs/actual-problems.neon @@ -48,12 +48,6 @@ parameters: count: 1 path: ../../../src/VersionInfo.php - - - message: '#^Method pocketmine\\VersionInfo\:\:GIT_HASH\(\) should return string but returns mixed\.$#' - identifier: return.type - count: 1 - path: ../../../src/VersionInfo.php - - message: '#^Static property pocketmine\\VersionInfo\:\:\$gitHash \(string\|null\) does not accept mixed\.$#' identifier: assign.propertyType @@ -918,24 +912,6 @@ parameters: count: 1 path: ../../../src/plugin/PluginDescription.php - - - message: '#^Parameter \#1 \$haystack of function stripos expects string, mixed given\.$#' - identifier: argument.type - count: 1 - path: ../../../src/plugin/PluginDescription.php - - - - message: '#^Parameter \#2 \$subject of function preg_match expects string, mixed given\.$#' - identifier: argument.type - count: 1 - path: ../../../src/plugin/PluginDescription.php - - - - message: '#^Parameter \#3 \$subject of function str_replace expects array\\|string, mixed given\.$#' - identifier: argument.type - count: 1 - path: ../../../src/plugin/PluginDescription.php - - message: '#^Property pocketmine\\plugin\\PluginDescription\:\:\$authors \(array\\) does not accept list\\.$#' identifier: assign.propertyType @@ -966,12 +942,6 @@ parameters: count: 1 path: ../../../src/resourcepacks/ZippedResourcePack.php - - - message: '#^Method pocketmine\\resourcepacks\\ZippedResourcePack\:\:getSha256\(\) should return string but returns string\|false\.$#' - identifier: return.type - count: 1 - path: ../../../src/resourcepacks/ZippedResourcePack.php - - message: '#^Property pocketmine\\resourcepacks\\ZippedResourcePack\:\:\$fileResource \(resource\) does not accept resource\|false\.$#' identifier: assign.propertyType @@ -1009,7 +979,7 @@ parameters: path: ../../../src/utils/Config.php - - message: '#^Parameter \#1 \$config of static method pocketmine\\utils\\Config\:\:writeProperties\(\) expects array\, array\ given\.$#' + message: '#^Parameter \#1 \$config of static method pocketmine\\utils\\Config\:\:writeProperties\(\) expects array\, array\ given\.$#' identifier: argument.type count: 1 path: ../../../src/utils/Config.php diff --git a/tests/phpstan/configs/phpstan-bugs.neon b/tests/phpstan/configs/phpstan-bugs.neon index 9ab125763..aeb3fae29 100644 --- a/tests/phpstan/configs/phpstan-bugs.neon +++ b/tests/phpstan/configs/phpstan-bugs.neon @@ -114,12 +114,6 @@ parameters: count: 1 path: ../../../src/crash/CrashDump.php - - - message: '#^Call to function assert\(\) with false and ''unknown hit type'' will always evaluate to false\.$#' - identifier: function.impossibleType - count: 1 - path: ../../../src/entity/projectile/Projectile.php - - message: '#^Property pocketmine\\item\\WritableBookBase\:\:\$pages \(list\\) does not accept non\-empty\-array\\.$#' identifier: assign.propertyType