Merge branch 'stable' into next-minor

This commit is contained in:
Dylan K. Taylor 2022-11-04 20:44:28 +00:00
commit cdbdcb5d67
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
19 changed files with 55 additions and 13 deletions

View File

@ -54,7 +54,7 @@
"webmozart/path-util": "^2.3"
},
"require-dev": {
"phpstan/phpstan": "1.8.11",
"phpstan/phpstan": "1.9.1",
"phpstan/phpstan-phpunit": "^1.1.0",
"phpstan/phpstan-strict-rules": "^1.2.0",
"phpunit/phpunit": "^9.2"

14
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": "3e2cf54647dd0587771b2539e42392d6",
"content-hash": "b535dc262141936698680b92902f8e28",
"packages": [
{
"name": "adhocore/json-comment",
@ -1822,16 +1822,16 @@
},
{
"name": "phpstan/phpstan",
"version": "1.8.11",
"version": "1.9.1",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "46e223dd68a620da18855c23046ddb00940b4014"
"reference": "a59c8b5bfd4a236f27efc8b5ce72c313c2b54b5f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/46e223dd68a620da18855c23046ddb00940b4014",
"reference": "46e223dd68a620da18855c23046ddb00940b4014",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/a59c8b5bfd4a236f27efc8b5ce72c313c2b54b5f",
"reference": "a59c8b5bfd4a236f27efc8b5ce72c313c2b54b5f",
"shasum": ""
},
"require": {
@ -1861,7 +1861,7 @@
],
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.8.11"
"source": "https://github.com/phpstan/phpstan/tree/1.9.1"
},
"funding": [
{
@ -1877,7 +1877,7 @@
"type": "tidelift"
}
],
"time": "2022-10-24T15:45:13+00:00"
"time": "2022-11-04T13:35:59+00:00"
},
{
"name": "phpstan/phpstan-phpunit",

View File

@ -398,7 +398,7 @@ class MemoryManager{
do{
$continue = false;
foreach($objects as $hash => $object){
foreach(Utils::stringifyKeys($objects) as $hash => $object){
if(!is_object($object)){
continue;
}
@ -483,6 +483,11 @@ class MemoryManager{
* @param object[] $objects reference parameter
* @param int[] $refCounts reference parameter
*
* @phpstan-param array<string, object> $objects
* @phpstan-param array<string, int> $refCounts
* @phpstan-param-out array<string, object> $objects
* @phpstan-param-out array<string, int> $refCounts
*
* @return mixed
*/
private static function continueDump($from, array &$objects, array &$refCounts, int $recursion, int $maxNesting, int $maxStringSize){

View File

@ -84,6 +84,7 @@ class Leaves extends Transparent{
/**
* @param true[] $visited reference parameter
* @phpstan-param array<int, true> $visited
* @phpstan-param-out array<int, true> $visited
*/
protected function findLog(Vector3 $pos, array &$visited = [], int $distance = 0) : bool{
$index = World::blockHash($pos->x, $pos->y, $pos->z);

View File

@ -76,7 +76,6 @@ class HelpCommand extends VanillaCommand{
$pageHeight = $sender->getScreenLineHeight();
if($commandName === ""){
/** @var Command[][] $commands */
$commands = [];
foreach($sender->getServer()->getCommandMap()->getCommands() as $command){
if($command->testPermissionSilent($sender)){

View File

@ -134,6 +134,8 @@ class InventoryTransaction{
/**
* @param Item[] $needItems
* @param Item[] $haveItems
* @phpstan-param-out Item[] $needItems
* @phpstan-param-out Item[] $haveItems
*
* @throws TransactionValidationException
*/

View File

@ -169,6 +169,7 @@ final class ItemTranslator{
}
/**
* @phpstan-param-out bool $isComplexMapping
* @return int[]
* @phpstan-return array{int, int}
* @throws TypeConversionException

View File

@ -150,6 +150,7 @@ class UPnP{
throw new UPnPException("Failed to recognize the port number from the router's url: {$location}");
}
$urlPort = $url['port'];
$err = "";
$response = Internet::getURL($location, 3, [], $err);
if($response === null){
throw new UPnPException("Unable to access XML: {$err}");

View File

@ -70,8 +70,7 @@ class PluginGraylist{
}
$isWhitelist = match($array["mode"]){
"whitelist" => true,
"blacklist" => false,
default => throw new \InvalidArgumentException("\"mode\" must be either \"whitelist\" or \"blacklist\"")
"blacklist" => false
};
$plugins = [];
if(isset($array["plugins"])){

View File

@ -319,6 +319,9 @@ class PluginManager{
/**
* @param string[][] $dependencyLists
* @param Plugin[] $loadedPlugins
*
* @phpstan-param array<string, list<string>> $dependencyLists
* @phpstan-param-out array<string, list<string>> $dependencyLists
*/
private function checkDepsForTriage(string $pluginName, string $dependencyType, array &$dependencyLists, array $loadedPlugins, PluginLoadTriage $triage) : void{
if(isset($dependencyLists[$pluginName])){

View File

@ -496,6 +496,7 @@ class Config{
* @param mixed[] $data reference parameter
* @phpstan-param array<string, mixed> $default
* @phpstan-param array<string, mixed> $data
* @phpstan-param-out array<string, mixed> $data
*/
private function fillDefaults(array $default, &$data) : int{
$changed = 0;

View File

@ -139,10 +139,14 @@ class Internet{
* GETs an URL using cURL
* NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.
*
* @phpstan-template TErrorVar of mixed
*
* @param int $timeout default 10
* @param string[] $extraHeaders
* @param string|null $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation.
* @phpstan-param list<string> $extraHeaders
* @phpstan-param TErrorVar $err
* @phpstan-param-out TErrorVar|string $err
*/
public static function getURL(string $page, int $timeout = 10, array $extraHeaders = [], &$err = null) : ?InternetRequestResult{
try{
@ -157,11 +161,15 @@ class Internet{
* POSTs data to an URL
* NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.
*
* @phpstan-template TErrorVar of mixed
*
* @param string[]|string $args
* @param string[] $extraHeaders
* @param string|null $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occurred during the operation.
* @phpstan-param string|array<string, string> $args
* @phpstan-param list<string> $extraHeaders
* @phpstan-param TErrorVar $err
* @phpstan-param-out TErrorVar|string $err
*/
public static function postURL(string $page, $args, int $timeout = 10, array $extraHeaders = [], &$err = null) : ?InternetRequestResult{
try{

View File

@ -152,6 +152,8 @@ final class Process{
* @param string $command Command to execute
* @param string|null $stdout Reference parameter to write stdout to
* @param string|null $stderr Reference parameter to write stderr to
* @phpstan-param-out string $stdout
* @phpstan-param-out string $stderr
*
* @return int process exit code
*/

View File

@ -313,7 +313,7 @@ final class Utils{
}
}elseif(($cpuPresent = @file_get_contents("/sys/devices/system/cpu/present")) !== false){
if(preg_match("/^([0-9]+)\\-([0-9]+)$/", trim($cpuPresent), $matches) > 0){
$processors = (int) ($matches[2] - $matches[1]);
$processors = ((int) $matches[2]) - ((int) $matches[1]);
}
}
break;

View File

@ -396,6 +396,9 @@ class World implements ChunkManager{
/**
* @phpstan-param BlockPosHash $hash
* @phpstan-param-out int $x
* @phpstan-param-out int $y
* @phpstan-param-out int $z
*/
public static function getBlockXYZ(int $hash, ?int &$x, ?int &$y, ?int &$z) : void{
[$baseX, $baseY, $baseZ] = morton3d_decode($hash);
@ -410,6 +413,8 @@ class World implements ChunkManager{
/**
* @phpstan-param ChunkPosHash $hash
* @phpstan-param-out int $x
* @phpstan-param-out int $z
*/
public static function getXZ(int $hash, ?int &$x, ?int &$z) : void{
[$x, $z] = morton2d_decode($hash);
@ -1764,6 +1769,7 @@ class World implements ChunkManager{
* It'll try to lower the durability if Item is a tool, and set it to Air if broken.
*
* @param Item $item reference parameter (if null, can break anything)
* @phpstan-param-out Item $item
*/
public function useBreakOn(Vector3 $vector, Item &$item = null, ?Player $player = null, bool $createParticles = false) : bool{
$vector = $vector->floor();

View File

@ -191,6 +191,11 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
return PalettedBlockArray::fromData($bitsPerBlock, $words, $palette);
}
/**
* @phpstan-param-out int $x
* @phpstan-param-out int $y
* @phpstan-param-out int $z
*/
protected static function deserializeExtraDataKey(int $chunkVersion, int $key, ?int &$x, ?int &$y, ?int &$z) : void{
if($chunkVersion >= ChunkVersion::v1_0_0){
$x = ($key >> 12) & 0xf;

View File

@ -276,6 +276,8 @@ class RegionLoader{
/**
* @param int $x reference parameter
* @param int $z reference parameter
* @phpstan-param-out int $x
* @phpstan-param-out int $z
*/
protected static function getChunkCoords(int $offset, ?int &$x, ?int &$z) : void{
$x = $offset & 0x1f;

View File

@ -92,6 +92,8 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
/**
* @param int $regionX reference parameter
* @param int $regionZ reference parameter
* @phpstan-param-out int $regionX
* @phpstan-param-out int $regionZ
*/
public static function getRegionIndex(int $chunkX, int $chunkZ, &$regionX, &$regionZ) : void{
$regionX = $chunkX >> 5;

View File

@ -15,6 +15,11 @@ parameters:
count: 1
path: ../../../src/entity/projectile/Projectile.php
-
message: "#^Empty array passed to foreach\\.$#"
count: 1
path: ../../../src/network/mcpe/cache/ChunkCache.php
-
message: "#^Match arm comparison between 4 and 4 is always true\\.$#"
count: 1