Skip to content

Commit 6c0c49b

Browse files
committed
TypeNodeResolver: Reduce number of intersect() calls
1 parent 1dc7058 commit 6c0c49b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/PhpDoc/TypeNodeResolver.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,18 +1056,24 @@ private function resolveArrayShapeNode(ArrayShapeNode $typeNode, NameScope $name
10561056
}
10571057

10581058
$arrayType = $builder->getArray();
1059+
1060+
$accessories = [];
10591061
if (in_array($typeNode->kind, [
10601062
ArrayShapeNode::KIND_LIST,
10611063
ArrayShapeNode::KIND_NON_EMPTY_LIST,
10621064
], true)) {
1063-
$arrayType = TypeCombinator::intersect($arrayType, new AccessoryArrayListType());
1065+
$accessories[] = new AccessoryArrayListType();
10641066
}
10651067

10661068
if (in_array($typeNode->kind, [
10671069
ArrayShapeNode::KIND_NON_EMPTY_ARRAY,
10681070
ArrayShapeNode::KIND_NON_EMPTY_LIST,
10691071
], true)) {
1070-
$arrayType = TypeCombinator::intersect($arrayType, new NonEmptyArrayType());
1072+
$accessories[] = new NonEmptyArrayType();
1073+
}
1074+
1075+
if (count($accessories) > 0) {
1076+
return TypeCombinator::intersect($arrayType, ...$accessories);
10711077
}
10721078

10731079
return $arrayType;

0 commit comments

Comments
 (0)