diff --git a/src/Type/BenevolentUnionType.php b/src/Type/BenevolentUnionType.php index e6d826abdc..2a71b8647c 100644 --- a/src/Type/BenevolentUnionType.php +++ b/src/Type/BenevolentUnionType.php @@ -12,7 +12,7 @@ class BenevolentUnionType extends UnionType /** * @api - * @param Type[] $types + * @param list $types */ public function __construct(array $types, bool $normalized = false) { diff --git a/src/Type/Constant/ConstantArrayType.php b/src/Type/Constant/ConstantArrayType.php index 8f3ad9b3e3..599e5a026a 100644 --- a/src/Type/Constant/ConstantArrayType.php +++ b/src/Type/Constant/ConstantArrayType.php @@ -95,7 +95,7 @@ class ConstantArrayType implements Type /** * @api - * @param array $keyTypes + * @param list $keyTypes * @param array $valueTypes * @param non-empty-list $nextAutoIndexes * @param int[] $optionalKeys @@ -280,7 +280,7 @@ private function powerSet(array $in): array } /** - * @return array + * @return list */ public function getKeyTypes(): array { diff --git a/src/Type/Constant/ConstantArrayTypeBuilder.php b/src/Type/Constant/ConstantArrayTypeBuilder.php index fcefe266fb..9396fec39f 100644 --- a/src/Type/Constant/ConstantArrayTypeBuilder.php +++ b/src/Type/Constant/ConstantArrayTypeBuilder.php @@ -40,7 +40,7 @@ final class ConstantArrayTypeBuilder private bool $oversized = false; /** - * @param array $keyTypes + * @param list $keyTypes * @param array $valueTypes * @param non-empty-list $nextAutoIndexes * @param array $optionalKeys @@ -308,7 +308,7 @@ public function getArray(): Type } if (!$this->degradeToGeneralArray) { - /** @var array $keyTypes */ + /** @var list $keyTypes */ $keyTypes = $this->keyTypes; return new ConstantArrayType($keyTypes, $this->valueTypes, $this->nextAutoIndexes, $this->optionalKeys, $this->isList); } diff --git a/src/Type/Generic/TemplateBenevolentUnionType.php b/src/Type/Generic/TemplateBenevolentUnionType.php index aea8573131..c8c2caaefd 100644 --- a/src/Type/Generic/TemplateBenevolentUnionType.php +++ b/src/Type/Generic/TemplateBenevolentUnionType.php @@ -34,7 +34,7 @@ public function __construct( $this->default = $default; } - /** @param Type[] $types */ + /** @param list $types */ public function withTypes(array $types): self { return new self( diff --git a/src/Type/IntersectionType.php b/src/Type/IntersectionType.php index 5896143ac9..51031bb9dc 100644 --- a/src/Type/IntersectionType.php +++ b/src/Type/IntersectionType.php @@ -71,7 +71,7 @@ class IntersectionType implements CompoundType /** * @api - * @param Type[] $types + * @param list $types */ public function __construct(private array $types) { @@ -85,7 +85,7 @@ public function __construct(private array $types) } /** - * @return Type[] + * @return list */ public function getTypes(): array { @@ -93,7 +93,7 @@ public function getTypes(): array } /** - * @return Type[] + * @return list */ private function getSortedTypes(): array { diff --git a/src/Type/OperatorTypeSpecifyingExtensionRegistry.php b/src/Type/OperatorTypeSpecifyingExtensionRegistry.php index 724956062a..bb830a6944 100644 --- a/src/Type/OperatorTypeSpecifyingExtensionRegistry.php +++ b/src/Type/OperatorTypeSpecifyingExtensionRegistry.php @@ -32,7 +32,7 @@ public function callOperatorTypeSpecifyingExtensions(Expr\BinaryOp $expr, Type $ $operatorSigil = $expr->getOperatorSigil(); $operatorTypeSpecifyingExtensions = $this->getOperatorTypeSpecifyingExtensions($operatorSigil, $leftType, $rightType); - /** @var Type[] $extensionTypes */ + /** @var list $extensionTypes */ $extensionTypes = []; foreach ($operatorTypeSpecifyingExtensions as $extension) { diff --git a/src/Type/Php/ArrayMapFunctionReturnTypeExtension.php b/src/Type/Php/ArrayMapFunctionReturnTypeExtension.php index e1cdeb5e2e..8da098e09c 100644 --- a/src/Type/Php/ArrayMapFunctionReturnTypeExtension.php +++ b/src/Type/Php/ArrayMapFunctionReturnTypeExtension.php @@ -180,7 +180,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection, } /** - * @return AccessoryType[] + * @return list */ private function getAccessoryTypes(Type $arrayType, Type $valueType): array { diff --git a/src/Type/Php/MinMaxFunctionReturnTypeExtension.php b/src/Type/Php/MinMaxFunctionReturnTypeExtension.php index 26864a3054..0c4ea75b0f 100644 --- a/src/Type/Php/MinMaxFunctionReturnTypeExtension.php +++ b/src/Type/Php/MinMaxFunctionReturnTypeExtension.php @@ -150,7 +150,7 @@ private function processArrayType(string $functionName, Type $argType): Type } /** - * @param Type[] $types + * @param list $types */ private function processType( string $functionName, diff --git a/src/Type/TypeCombinator.php b/src/Type/TypeCombinator.php index be48ebe6ff..56f756f797 100644 --- a/src/Type/TypeCombinator.php +++ b/src/Type/TypeCombinator.php @@ -381,14 +381,14 @@ public static function union(Type ...$types): Type if ($tempTypes === []) { if ($benevolentUnionObject instanceof TemplateBenevolentUnionType) { - return $benevolentUnionObject->withTypes($types); + return $benevolentUnionObject->withTypes(array_values($types)); } - return new BenevolentUnionType($types, true); + return new BenevolentUnionType(array_values($types), true); } } - return new UnionType($types, true); + return new UnionType(array_values($types), true); } /** @@ -546,7 +546,7 @@ private static function compareTypesInUnion(Type $a, Type $b): ?array } /** - * @return array + * @return list */ private static function getAccessoryCaseStringTypes(Type $type): array { @@ -686,7 +686,7 @@ private static function intersectWithSubtractedType( /** * @param Type[] $arrayTypes - * @return Type[] + * @return list */ private static function processArrayAccessoryTypes(array $arrayTypes): array { @@ -1473,7 +1473,7 @@ public static function intersect(Type ...$types): Type return $types[0]; } - return new IntersectionType($types); + return new IntersectionType(array_values($types)); } public static function removeFalsey(Type $type): Type diff --git a/src/Type/TypeUtils.php b/src/Type/TypeUtils.php index 17920b85ce..e1f54b8e52 100644 --- a/src/Type/TypeUtils.php +++ b/src/Type/TypeUtils.php @@ -210,7 +210,7 @@ public static function getHasPropertyTypes(Type $type): array } /** - * @return AccessoryType[] + * @return list */ public static function getAccessoryTypes(Type $type): array { diff --git a/src/Type/UnionType.php b/src/Type/UnionType.php index 31da5c4b7c..c5c9f65415 100644 --- a/src/Type/UnionType.php +++ b/src/Type/UnionType.php @@ -63,7 +63,7 @@ class UnionType implements CompoundType /** * @api - * @param Type[] $types + * @param list $types */ public function __construct(private array $types, private bool $normalized = false) { @@ -90,7 +90,7 @@ public function __construct(private array $types, private bool $normalized = fal } /** - * @return Type[] + * @return list */ public function getTypes(): array { @@ -126,7 +126,7 @@ public function isNormalized(): bool } /** - * @return Type[] + * @return list */ protected function getSortedTypes(): array { diff --git a/src/Type/UnionTypeHelper.php b/src/Type/UnionTypeHelper.php index f91ea5cb45..ba9eba259e 100644 --- a/src/Type/UnionTypeHelper.php +++ b/src/Type/UnionTypeHelper.php @@ -16,8 +16,9 @@ final class UnionTypeHelper { /** - * @param Type[] $types - * @return Type[] + * @template T of Type + * @param list $types + * @return list */ public static function sortTypes(array $types): array { diff --git a/tests/PHPStan/Type/TypeCombinatorTest.php b/tests/PHPStan/Type/TypeCombinatorTest.php index 95edb13b3d..a4a098ad02 100644 --- a/tests/PHPStan/Type/TypeCombinatorTest.php +++ b/tests/PHPStan/Type/TypeCombinatorTest.php @@ -2805,7 +2805,7 @@ public static function dataUnion(): iterable } /** - * @param Type[] $types + * @param list $types * @param class-string $expectedTypeClass */ #[DataProvider('dataUnion')] @@ -2861,7 +2861,7 @@ public function testUnion( } /** - * @param Type[] $types + * @param list $types * @param class-string $expectedTypeClass */ #[DataProvider('dataUnion')] @@ -4760,7 +4760,7 @@ public static function dataIntersect(): iterable } /** - * @param Type[] $types + * @param list $types * @param class-string $expectedTypeClass */ #[DataProvider('dataIntersect')] @@ -4803,7 +4803,7 @@ public function testIntersect( } /** - * @param Type[] $types + * @param list $types * @param class-string $expectedTypeClass */ #[DataProvider('dataIntersect')] diff --git a/tests/PHPStan/Type/UnionTypeTest.php b/tests/PHPStan/Type/UnionTypeTest.php index a4940279a4..950c81a74a 100644 --- a/tests/PHPStan/Type/UnionTypeTest.php +++ b/tests/PHPStan/Type/UnionTypeTest.php @@ -1411,7 +1411,7 @@ public function testSorting(): void } /** - * @param Type[] $types + * @param list $types * @param list $expectedDescriptions */ #[DataProvider('dataGetConstantArrays')]