Skip to content

Commit

Permalink
Update PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Feb 17, 2025
1 parent 34f801e commit 77be5f8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 58 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
36 changes: 18 additions & 18 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ public function addOp(string $name) : void{

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);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ public static function validateCallableSignature(callable|CallbackType $signatur
* @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){
Expand Down
32 changes: 1 addition & 31 deletions tests/phpstan/configs/actual-problems.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions tests/phpstan/configs/phpstan-bugs.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 77be5f8

Please sign in to comment.