Update PHPStan

This commit is contained in:
Dylan K. Taylor 2025-02-17 17:51:39 +00:00
parent 34f801ee3c
commit 77be5f8e25
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
6 changed files with 22 additions and 58 deletions

View File

@ -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"

36
composer.lock generated
View File

@ -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": "af7547291a131bfac6d7087957601325",
"content-hash": "dcf1176890f95cb24670e69c8c8f1216",
"packages": [
{
"name": "adhocore/json-comment",
@ -1150,16 +1150,16 @@
"packages-dev": [
{
"name": "myclabs/deep-copy",
"version": "1.12.1",
"version": "1.13.0",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "123267b2c49fbf30d78a7b2d333f6be754b94845"
"reference": "024473a478be9df5fdaca2c793f2232fe788e414"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845",
"reference": "123267b2c49fbf30d78a7b2d333f6be754b94845",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/024473a478be9df5fdaca2c793f2232fe788e414",
"reference": "024473a478be9df5fdaca2c793f2232fe788e414",
"shasum": ""
},
"require": {
@ -1198,7 +1198,7 @@
],
"support": {
"issues": "https://github.com/myclabs/DeepCopy/issues",
"source": "https://github.com/myclabs/DeepCopy/tree/1.12.1"
"source": "https://github.com/myclabs/DeepCopy/tree/1.13.0"
},
"funding": [
{
@ -1206,7 +1206,7 @@
"type": "tidelift"
}
],
"time": "2024-11-08T17:47:46+00:00"
"time": "2025-02-12T12:17:51+00:00"
},
{
"name": "nikic/php-parser",
@ -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",
@ -1864,16 +1864,16 @@
},
{
"name": "phpunit/phpunit",
"version": "10.5.44",
"version": "10.5.45",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "1381c62769be4bb88fa4c5aec1366c7c66ca4f36"
"reference": "bd68a781d8e30348bc297449f5234b3458267ae8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1381c62769be4bb88fa4c5aec1366c7c66ca4f36",
"reference": "1381c62769be4bb88fa4c5aec1366c7c66ca4f36",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/bd68a781d8e30348bc297449f5234b3458267ae8",
"reference": "bd68a781d8e30348bc297449f5234b3458267ae8",
"shasum": ""
},
"require": {
@ -1945,7 +1945,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.44"
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.45"
},
"funding": [
{
@ -1961,7 +1961,7 @@
"type": "tidelift"
}
],
"time": "2025-01-31T07:00:38+00:00"
"time": "2025-02-06T16:08:12+00:00"
},
{
"name": "sebastian/cli-parser",

View File

@ -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);

View File

@ -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){

View File

@ -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\>\|string, mixed given\.$#'
identifier: argument.type
count: 1
path: ../../../src/plugin/PluginDescription.php
-
message: '#^Property pocketmine\\plugin\\PluginDescription\:\:\$authors \(array\<string\>\) does not accept list\<mixed\>\.$#'
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\<int\|string, bool\|float\|int\|string\>, array\<int\|string, mixed\> given\.$#'
message: '#^Parameter \#1 \$config of static method pocketmine\\utils\\Config\:\:writeProperties\(\) expects array\<int\|string, bool\|float\|int\|string\>, array\<mixed\> given\.$#'
identifier: argument.type
count: 1
path: ../../../src/utils/Config.php

View File

@ -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\<pocketmine\\item\\WritableBookPage\>\) does not accept non\-empty\-array\<int, pocketmine\\item\\WritableBookPage\>\.$#'
identifier: assign.propertyType