From c13170a00b672ac36b5d5fe649df628433fc4431 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 20 Aug 2022 17:16:38 +0100 Subject: [PATCH] Avoid implicit integer cast in Normal::pickBiome() this throws deprecation warnings on PHP 8.1. --- src/world/generator/normal/Normal.php | 1 + tests/phpstan/configs/phpstan-bugs.neon | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/world/generator/normal/Normal.php b/src/world/generator/normal/Normal.php index 2a89d1e61..0e520c8ae 100644 --- a/src/world/generator/normal/Normal.php +++ b/src/world/generator/normal/Normal.php @@ -123,6 +123,7 @@ class Normal extends Generator{ private function pickBiome(int $x, int $z) : Biome{ $hash = $x * 2345803 ^ $z * 9236449 ^ $this->seed; $hash *= $hash + 223; + $hash = (int) $hash; $xNoise = $hash >> 20 & 3; $zNoise = $hash >> 22 & 3; if($xNoise == 3){ diff --git a/tests/phpstan/configs/phpstan-bugs.neon b/tests/phpstan/configs/phpstan-bugs.neon index a1c53d2a4..bfb3b1734 100644 --- a/tests/phpstan/configs/phpstan-bugs.neon +++ b/tests/phpstan/configs/phpstan-bugs.neon @@ -80,3 +80,8 @@ parameters: count: 2 path: ../../../src/world/format/io/region/RegionLoader.php + - + message: "#^Casting to int something that's already int\\.$#" + count: 1 + path: ../../../src/world/generator/normal/Normal.php +