diff --git a/rules/CodingStyle/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php b/rules/CodingStyle/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php index 6fc9e4b388..632a94d48a 100644 --- a/rules/CodingStyle/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php +++ b/rules/CodingStyle/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php @@ -151,7 +151,7 @@ private function shouldSkipArrayForInvalidTypeOrKeys(Expr $expr): bool private function isArrayKeyTypeAllowed(ArrayType|ConstantArrayType $arrayType): bool { - if ($arrayType->getKeyType()->isInteger()->yes()) { + if ($arrayType->getIterableKeyType()->isInteger()->yes()) { return true; } diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictNewArrayRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictNewArrayRector.php index b562cdd175..dd4a13067b 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictNewArrayRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictNewArrayRector.php @@ -273,7 +273,7 @@ private function shouldAddReturnArrayDocType(ArrayType|ConstantArrayType $arrayT } // handle only simple arrays - if (! $arrayType->getKeyType()->isInteger()->yes()) { + if (! $arrayType->getIterableKeyType()->isInteger()->yes()) { return false; } } diff --git a/rules/TypeDeclaration/TypeNormalizer.php b/rules/TypeDeclaration/TypeNormalizer.php index f202007c7e..662afd1b36 100644 --- a/rules/TypeDeclaration/TypeNormalizer.php +++ b/rules/TypeDeclaration/TypeNormalizer.php @@ -61,7 +61,7 @@ public function normalizeArrayOfUnionToUnionArray(Type $type, int $arrayNesting $this->collectedNestedArrayTypes[] = new NestedArrayType( $type->getIterableValueType(), $arrayNesting, - $type->getKeyType() + $type->getIterableKeyType() ); } @@ -95,7 +95,7 @@ public function normalizeArrayTypeAndArrayNever(Type $type): Type private function isConstantArrayNever(Type $type): bool { - return $type instanceof ConstantArrayType && $type->getKeyType() instanceof NeverType && $type->getIterableValueType() instanceof NeverType; + return $type instanceof ConstantArrayType && $type->getIterableKeyType() instanceof NeverType && $type->getIterableValueType() instanceof NeverType; } private function collectNestedArrayTypeFromUnionType(UnionType $unionType, int $arrayNesting): void diff --git a/src/NodeTypeResolver/PHPStan/Type/TypeFactory.php b/src/NodeTypeResolver/PHPStan/Type/TypeFactory.php index 680a877ff3..48c90beb6a 100644 --- a/src/NodeTypeResolver/PHPStan/Type/TypeFactory.php +++ b/src/NodeTypeResolver/PHPStan/Type/TypeFactory.php @@ -210,7 +210,7 @@ private function unwrapConstantArrayTypes(ConstantArrayType $constantArrayType): { $unwrappedTypes = []; - $flattenKeyTypes = TypeUtils::flattenTypes($constantArrayType->getKeyType()); + $flattenKeyTypes = TypeUtils::flattenTypes($constantArrayType->getIterableKeyType()); $flattenItemTypes = TypeUtils::flattenTypes($constantArrayType->getIterableValueType()); foreach ($flattenItemTypes as $position => $nestedFlattenItemType) { diff --git a/src/NodeTypeResolver/PHPStan/TypeHasher.php b/src/NodeTypeResolver/PHPStan/TypeHasher.php index 15e1a08b16..7bef62779d 100644 --- a/src/NodeTypeResolver/PHPStan/TypeHasher.php +++ b/src/NodeTypeResolver/PHPStan/TypeHasher.php @@ -30,7 +30,7 @@ public function createTypeHash(Type $type): string } if ($type instanceof ArrayType) { - return $this->createTypeHash($type->getIterableValueType()) . $this->createTypeHash($type->getKeyType()) . '[]'; + return $this->createTypeHash($type->getIterableValueType()) . $this->createTypeHash($type->getIterableKeyType()) . '[]'; } if ($type instanceof GenericObjectType) { diff --git a/src/NodeTypeResolver/TypeComparator/ArrayTypeComparator.php b/src/NodeTypeResolver/TypeComparator/ArrayTypeComparator.php index 1be2c05529..62a96ae36b 100644 --- a/src/NodeTypeResolver/TypeComparator/ArrayTypeComparator.php +++ b/src/NodeTypeResolver/TypeComparator/ArrayTypeComparator.php @@ -20,8 +20,8 @@ public function isSubtype(ArrayType|ConstantArrayType $checkedType, ArrayType|Co ->yes(); } - $checkedKeyType = $checkedType->getKeyType(); - $mainKeyType = $mainType->getKeyType(); + $checkedKeyType = $checkedType->getIterableKeyType(); + $mainKeyType = $mainType->getIterableKeyType(); if (! $mainKeyType instanceof MixedType && $mainKeyType->isSuperTypeOf($checkedKeyType)->yes()) { return true;