Deal with a whole lot of PHPStan suppressed key casting errors

closes #6534
This commit is contained in:
Dylan K. Taylor
2024-11-25 14:30:58 +00:00
parent aef4fa7174
commit 5325ecee37
66 changed files with 338 additions and 124 deletions

View File

@ -135,7 +135,7 @@ class BlockTest extends TestCase{
}
$errors = [];
foreach($expected as $typeName => $numStates){
foreach(Utils::promoteKeys($expected) as $typeName => $numStates){
if(!is_string($typeName) || !is_int($numStates)){
throw new AssumptionFailedError("Old table should be array<string, int>");
}

View File

@ -89,7 +89,6 @@ class ItemTest extends TestCase{
}
public function testGetEnchantments() : void{
/** @var EnchantmentInstance[] $enchantments */
$enchantments = [
new EnchantmentInstance(VanillaEnchantments::EFFICIENCY(), 5),
new EnchantmentInstance(VanillaEnchantments::SHARPNESS(), 1)

View File

@ -47,7 +47,7 @@ final class CloningRegistryTraitTest extends TestCase{
public function testGetAllClone() : void{
$list1 = TestCloningRegistry::getAll();
$list2 = TestCloningRegistry::getAll();
foreach($list1 as $k => $member){
foreach(Utils::promoteKeys($list1) as $k => $member){
self::assertNotSame($member, $list2[$k], "VanillaBlocks ought to clone its members");
}
}

View File

@ -37,9 +37,13 @@ final class TestCloningRegistry{
/**
* @return \stdClass[]
* @phpstan-return array<string, \stdClass>
*/
public static function getAll() : array{
/** @var \stdClass[] $result */
/**
* @var \stdClass[] $result
* @phpstan-var array<string, \stdClass> $result
*/
$result = self::_registryGetAll();
return $result;
}