From 879429278857cd9c4f017187ad8d7202aed21f50 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 11 Jan 2020 21:20:55 +0000 Subject: [PATCH] remove &$var reference notations in phpdoc this isn't required by the spec and PHPStan chokes on it. I was previously having it ignore these errors, but it turns out that PHPStan is not making use of extended typeinfo provided if it can't parse the tag, which is problematic on level 6 and also a problem for array-of-type. Therefore, we are going to have to take the hit. --- src/pocketmine/MemoryManager.php | 6 +++--- src/pocketmine/command/SimpleCommandMap.php | 4 ++-- src/pocketmine/level/Level.php | 2 +- .../level/format/io/region/McRegion.php | 4 ++-- .../level/format/io/region/RegionLoader.php | 4 ++-- .../network/mcpe/NetworkBinaryStream.php | 12 ++++++------ src/pocketmine/utils/Config.php | 10 +++++----- src/pocketmine/utils/Git.php | 2 +- src/pocketmine/utils/Internet.php | 12 ++++++------ src/pocketmine/utils/Utils.php | 16 ++++++++-------- tests/phpstan/configs/phpstan-bugs.neon | 4 ---- 11 files changed, 36 insertions(+), 40 deletions(-) diff --git a/src/pocketmine/MemoryManager.php b/src/pocketmine/MemoryManager.php index d6e03a393..52e650a35 100644 --- a/src/pocketmine/MemoryManager.php +++ b/src/pocketmine/MemoryManager.php @@ -472,9 +472,9 @@ class MemoryManager{ /** * @param mixed $from - * @param mixed &$data - * @param object[] &$objects - * @param int[] &$refCounts + * @param mixed $data reference parameter + * @param object[] $objects reference parameter + * @param int[] $refCounts reference parameter * @param int $recursion * @param int $maxNesting * @param int $maxStringSize diff --git a/src/pocketmine/command/SimpleCommandMap.php b/src/pocketmine/command/SimpleCommandMap.php index bac246ec7..9f534ff5a 100644 --- a/src/pocketmine/command/SimpleCommandMap.php +++ b/src/pocketmine/command/SimpleCommandMap.php @@ -226,8 +226,8 @@ class SimpleCommandMap implements CommandMap{ * This method is intended to provide capability for handling commands with spaces in their name. * The referenced parameters will be modified accordingly depending on the resulting matched command. * - * @param string &$commandName - * @param string[] &$args + * @param string $commandName reference parameter + * @param string[] $args reference parameter * * @return Command|null */ diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 7effb72a0..462d4c454 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -1778,7 +1778,7 @@ class Level implements ChunkManager, Metadatable{ * It'll try to lower the durability if Item is a tool, and set it to Air if broken. * * @param Vector3 $vector - * @param Item &$item (if null, can break anything) + * @param Item $item reference parameter (if null, can break anything) * @param Player $player * @param bool $createParticles * diff --git a/src/pocketmine/level/format/io/region/McRegion.php b/src/pocketmine/level/format/io/region/McRegion.php index 51cad2438..3aa089bf6 100644 --- a/src/pocketmine/level/format/io/region/McRegion.php +++ b/src/pocketmine/level/format/io/region/McRegion.php @@ -331,8 +331,8 @@ class McRegion extends BaseLevelProvider{ /** * @param int $chunkX * @param int $chunkZ - * @param int &$regionX - * @param int &$regionZ + * @param int $regionX reference parameter + * @param int $regionZ reference parameter */ public static function getRegionIndex(int $chunkX, int $chunkZ, &$regionX, &$regionZ){ $regionX = $chunkX >> 5; diff --git a/src/pocketmine/level/format/io/region/RegionLoader.php b/src/pocketmine/level/format/io/region/RegionLoader.php index e00fdff44..f4dcce87f 100644 --- a/src/pocketmine/level/format/io/region/RegionLoader.php +++ b/src/pocketmine/level/format/io/region/RegionLoader.php @@ -244,8 +244,8 @@ class RegionLoader{ /** * @param int $offset - * @param int &$x - * @param int &$z + * @param int $x reference parameter + * @param int $z reference parameter */ protected static function getChunkCoords(int $offset, ?int &$x, ?int &$z) : void{ $x = $offset & 0x1f; diff --git a/src/pocketmine/network/mcpe/NetworkBinaryStream.php b/src/pocketmine/network/mcpe/NetworkBinaryStream.php index b8cd85838..71f4fd153 100644 --- a/src/pocketmine/network/mcpe/NetworkBinaryStream.php +++ b/src/pocketmine/network/mcpe/NetworkBinaryStream.php @@ -457,9 +457,9 @@ class NetworkBinaryStream extends BinaryStream{ /** * Reads an block position with unsigned Y coordinate. * - * @param int &$x - * @param int &$y - * @param int &$z + * @param int $x reference parameter + * @param int $y reference parameter + * @param int $z reference parameter */ public function getBlockPosition(&$x, &$y, &$z) : void{ $x = $this->getVarInt(); @@ -483,9 +483,9 @@ class NetworkBinaryStream extends BinaryStream{ /** * Reads a block position with a signed Y coordinate. * - * @param int &$x - * @param int &$y - * @param int &$z + * @param int $x reference parameter + * @param int $y reference parameter + * @param int $z reference parameter */ public function getSignedBlockPosition(&$x, &$y, &$z) : void{ $x = $this->getVarInt(); diff --git a/src/pocketmine/utils/Config.php b/src/pocketmine/utils/Config.php index 6dcaba22b..9f7859ed8 100644 --- a/src/pocketmine/utils/Config.php +++ b/src/pocketmine/utils/Config.php @@ -106,10 +106,10 @@ class Config{ ]; /** - * @param string $file Path of the file to be loaded - * @param int $type Config type to load, -1 by default (detect) - * @param array $default Array with the default values that will be written to the file if it did not exist - * @param null &$correct Sets correct to true if everything has been loaded correctly + * @param string $file Path of the file to be loaded + * @param int $type Config type to load, -1 by default (detect) + * @param array $default Array with the default values that will be written to the file if it did not exist + * @param null $correct reference parameter, Sets correct to true if everything has been loaded correctly */ public function __construct(string $file, int $type = Config::DETECT, array $default = [], &$correct = null){ $this->load($file, $type, $default); @@ -507,7 +507,7 @@ class Config{ /** * @param array $default - * @param array &$data + * @param array $data reference parameter * * @return int */ diff --git a/src/pocketmine/utils/Git.php b/src/pocketmine/utils/Git.php index 549ea97b0..dc6ae4a69 100644 --- a/src/pocketmine/utils/Git.php +++ b/src/pocketmine/utils/Git.php @@ -37,7 +37,7 @@ final class Git{ * Returns the git hash of the currently checked out head of the given repository, or null on failure. * * @param string $dir - * @param bool &$dirty Output, set to whether the repo has local changes + * @param bool $dirty reference parameter, set to whether the repo has local changes * * @return string|null */ diff --git a/src/pocketmine/utils/Internet.php b/src/pocketmine/utils/Internet.php index 8fec39ad5..85b17724f 100644 --- a/src/pocketmine/utils/Internet.php +++ b/src/pocketmine/utils/Internet.php @@ -138,9 +138,9 @@ class Internet{ * @param string $page * @param int $timeout default 10 * @param array $extraHeaders - * @param string &$err Will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation. - * @param array[] &$headers - * @param int &$httpCode + * @param string $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation. + * @param array[] $headers reference parameter + * @param int $httpCode reference parameter * * @return bool|mixed false if an error occurred, mixed data if successful. */ @@ -162,9 +162,9 @@ class Internet{ * @param array|string $args * @param int $timeout * @param array $extraHeaders - * @param string &$err Will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation. - * @param array[] &$headers - * @param int &$httpCode + * @param string $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation. + * @param array[] $headers reference parameter + * @param int $httpCode reference parameter * * @return bool|mixed false if an error occurred, mixed data if successful. */ diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 91b65b465..78e29b41f 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -451,9 +451,9 @@ class Utils{ * @param string $page * @param int $timeout default 10 * @param array $extraHeaders - * @param string &$err Will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation. - * @param array[] &$headers - * @param int &$httpCode + * @param string $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation. + * @param array[] $headers reference parameter + * @param int $httpCode reference parameter * * @return bool|mixed false if an error occurred, mixed data if successful. */ @@ -469,9 +469,9 @@ class Utils{ * @param array|string $args * @param int $timeout * @param array $extraHeaders - * @param string &$err Will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation. - * @param array[] &$headers - * @param int &$httpCode + * @param string $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation. + * @param array[] $headers reference parameter + * @param int $httpCode reference parameter * * @return bool|mixed false if an error occurred, mixed data if successful. */ @@ -519,8 +519,8 @@ class Utils{ /** * @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 + * @param string|null $stdout Reference parameter to write stdout to + * @param string|null $stderr Reference parameter to write stderr to * * @return int process exit code */ diff --git a/tests/phpstan/configs/phpstan-bugs.neon b/tests/phpstan/configs/phpstan-bugs.neon index 8907818ba..562ed05de 100644 --- a/tests/phpstan/configs/phpstan-bugs.neon +++ b/tests/phpstan/configs/phpstan-bugs.neon @@ -1,9 +1,5 @@ parameters: ignoreErrors: - - - message: "#^PHPDoc tag @param has invalid value \\(.+\\)\\: Unexpected token \"&\", expected variable at offset \\d+$#" - path: ../../../src - - message: "#^Default value of the parameter \\#\\d+ \\$[A-Za-z\\d_]+ \\(\\-?\\d+\\) of method .+\\(\\) is incompatible with type float\\.$#" path: ../../../src