Noise: give PHPStan some help understanding SplFixedArray

This commit is contained in:
Dylan K. Taylor 2023-12-20 14:32:05 +00:00
parent 4d9b97d2bb
commit 74cb0be868
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 17 additions and 0 deletions

View File

@ -208,6 +208,7 @@ abstract class Noise{
throw new \InvalidArgumentException("xSize % samplingRate must return 0");
}
/** @phpstan-var \SplFixedArray<float> $noiseArray */
$noiseArray = new \SplFixedArray($xSize + 1);
for($xx = 0; $xx <= $xSize; $xx += $samplingRate){
@ -240,6 +241,7 @@ abstract class Noise{
assert($xSize % $samplingRate === 0, new \InvalidArgumentException("xSize % samplingRate must return 0"));
assert($zSize % $samplingRate === 0, new \InvalidArgumentException("zSize % samplingRate must return 0"));
/** @phpstan-var \SplFixedArray<\SplFixedArray<float>> $noiseArray */
$noiseArray = new \SplFixedArray($xSize + 1);
for($xx = 0; $xx <= $xSize; $xx += $samplingRate){

View File

@ -1070,6 +1070,21 @@ parameters:
count: 1
path: ../../../src/world/generator/hell/Nether.php
-
message: "#^Offset int does not exist on SplFixedArray\\<float\\>\\|null\\.$#"
count: 4
path: ../../../src/world/generator/noise/Noise.php
-
message: "#^Parameter \\$q0 of static method pocketmine\\\\world\\\\generator\\\\noise\\\\Noise\\:\\:linearLerp\\(\\) expects float, float\\|null given\\.$#"
count: 1
path: ../../../src/world/generator/noise/Noise.php
-
message: "#^Parameter \\$q1 of static method pocketmine\\\\world\\\\generator\\\\noise\\\\Noise\\:\\:linearLerp\\(\\) expects float, float\\|null given\\.$#"
count: 1
path: ../../../src/world/generator/noise/Noise.php
-
message: "#^Cannot call method getBiomeId\\(\\) on pocketmine\\\\world\\\\format\\\\Chunk\\|null\\.$#"
count: 1