Skip to content

Commit 0632615

Browse files
authored
More precise types
1 parent de62851 commit 0632615

14 files changed

+30
-29
lines changed

src/Type/BenevolentUnionType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class BenevolentUnionType extends UnionType
1212

1313
/**
1414
* @api
15-
* @param Type[] $types
15+
* @param list<Type> $types
1616
*/
1717
public function __construct(array $types, bool $normalized = false)
1818
{

src/Type/Constant/ConstantArrayType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class ConstantArrayType implements Type
9595

9696
/**
9797
* @api
98-
* @param array<int, ConstantIntegerType|ConstantStringType> $keyTypes
98+
* @param list<ConstantIntegerType|ConstantStringType> $keyTypes
9999
* @param array<int, Type> $valueTypes
100100
* @param non-empty-list<int> $nextAutoIndexes
101101
* @param int[] $optionalKeys
@@ -280,7 +280,7 @@ private function powerSet(array $in): array
280280
}
281281

282282
/**
283-
* @return array<int, ConstantIntegerType|ConstantStringType>
283+
* @return list<ConstantIntegerType|ConstantStringType>
284284
*/
285285
public function getKeyTypes(): array
286286
{

src/Type/Constant/ConstantArrayTypeBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ final class ConstantArrayTypeBuilder
4040
private bool $oversized = false;
4141

4242
/**
43-
* @param array<int, Type> $keyTypes
43+
* @param list<Type> $keyTypes
4444
* @param array<int, Type> $valueTypes
4545
* @param non-empty-list<int> $nextAutoIndexes
4646
* @param array<int> $optionalKeys
@@ -308,7 +308,7 @@ public function getArray(): Type
308308
}
309309

310310
if (!$this->degradeToGeneralArray) {
311-
/** @var array<int, ConstantIntegerType|ConstantStringType> $keyTypes */
311+
/** @var list<ConstantIntegerType|ConstantStringType> $keyTypes */
312312
$keyTypes = $this->keyTypes;
313313
return new ConstantArrayType($keyTypes, $this->valueTypes, $this->nextAutoIndexes, $this->optionalKeys, $this->isList);
314314
}

src/Type/Generic/TemplateBenevolentUnionType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(
3434
$this->default = $default;
3535
}
3636

37-
/** @param Type[] $types */
37+
/** @param list<Type> $types */
3838
public function withTypes(array $types): self
3939
{
4040
return new self(

src/Type/IntersectionType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class IntersectionType implements CompoundType
7171

7272
/**
7373
* @api
74-
* @param Type[] $types
74+
* @param list<Type> $types
7575
*/
7676
public function __construct(private array $types)
7777
{
@@ -85,15 +85,15 @@ public function __construct(private array $types)
8585
}
8686

8787
/**
88-
* @return Type[]
88+
* @return list<Type>
8989
*/
9090
public function getTypes(): array
9191
{
9292
return $this->types;
9393
}
9494

9595
/**
96-
* @return Type[]
96+
* @return list<Type>
9797
*/
9898
private function getSortedTypes(): array
9999
{

src/Type/OperatorTypeSpecifyingExtensionRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function callOperatorTypeSpecifyingExtensions(Expr\BinaryOp $expr, Type $
3232
$operatorSigil = $expr->getOperatorSigil();
3333
$operatorTypeSpecifyingExtensions = $this->getOperatorTypeSpecifyingExtensions($operatorSigil, $leftType, $rightType);
3434

35-
/** @var Type[] $extensionTypes */
35+
/** @var list<Type> $extensionTypes */
3636
$extensionTypes = [];
3737

3838
foreach ($operatorTypeSpecifyingExtensions as $extension) {

src/Type/Php/ArrayMapFunctionReturnTypeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
180180
}
181181

182182
/**
183-
* @return AccessoryType[]
183+
* @return list<AccessoryType>
184184
*/
185185
private function getAccessoryTypes(Type $arrayType, Type $valueType): array
186186
{

src/Type/Php/MinMaxFunctionReturnTypeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private function processArrayType(string $functionName, Type $argType): Type
150150
}
151151

152152
/**
153-
* @param Type[] $types
153+
* @param list<Type> $types
154154
*/
155155
private function processType(
156156
string $functionName,

src/Type/TypeCombinator.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,14 +399,14 @@ public static function union(Type ...$types): Type
399399

400400
if ($tempTypes === []) {
401401
if ($benevolentUnionObject instanceof TemplateBenevolentUnionType) {
402-
return $benevolentUnionObject->withTypes($types);
402+
return $benevolentUnionObject->withTypes(array_values($types));
403403
}
404404

405-
return new BenevolentUnionType($types, true);
405+
return new BenevolentUnionType(array_values($types), true);
406406
}
407407
}
408408

409-
return new UnionType($types, true);
409+
return new UnionType(array_values($types), true);
410410
}
411411

412412
/**
@@ -564,7 +564,7 @@ private static function compareTypesInUnion(Type $a, Type $b): ?array
564564
}
565565

566566
/**
567-
* @return array<Type>
567+
* @return list<Type>
568568
*/
569569
private static function getAccessoryCaseStringTypes(Type $type): array
570570
{
@@ -704,7 +704,7 @@ private static function intersectWithSubtractedType(
704704

705705
/**
706706
* @param Type[] $arrayTypes
707-
* @return Type[]
707+
* @return list<Type>
708708
*/
709709
private static function processArrayAccessoryTypes(array $arrayTypes): array
710710
{
@@ -1497,7 +1497,7 @@ public static function intersect(Type ...$types): Type
14971497
return $types[0];
14981498
}
14991499

1500-
return new IntersectionType($types);
1500+
return new IntersectionType(array_values($types));
15011501
}
15021502

15031503
public static function removeFalsey(Type $type): Type

src/Type/TypeUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public static function getHasPropertyTypes(Type $type): array
210210
}
211211

212212
/**
213-
* @return AccessoryType[]
213+
* @return list<AccessoryType>
214214
*/
215215
public static function getAccessoryTypes(Type $type): array
216216
{

0 commit comments

Comments
 (0)