Skip to content

Commit 506184c

Browse files
Simplify
1 parent f149a5c commit 506184c

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

src/PhpDoc/TypeNodeResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ private function resolveArrayShapeNode(ArrayShapeNode $typeNode, NameScope $name
10651065
ArrayShapeNode::KIND_NON_EMPTY_LIST,
10661066
], true);
10671067

1068-
$arrayType = $isList ? $builder->getList() : $builder->getArray();
1068+
$arrayType = $builder->getArray($isList);
10691069

10701070
$accessories = [];
10711071
if ($isList) {

src/Type/Constant/ConstantArrayTypeBuilder.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,16 @@ public function disableArrayDegradation(): void
325325
$this->disableArrayDegradation = true;
326326
}
327327

328-
public function getArray(): Type
328+
public function getArray(bool $forceList = false): Type
329329
{
330+
if ($forceList) {
331+
if ($this->isList->no()) {
332+
return new NeverType();
333+
}
334+
335+
$this->isList = TrinaryLogic::createYes();
336+
}
337+
330338
$keyTypesCount = count($this->keyTypes);
331339
if ($keyTypesCount === 0) {
332340
return new ConstantArrayType([], []);
@@ -376,17 +384,6 @@ public function getArray(): Type
376384
return new IntersectionType([$array, ...$types]);
377385
}
378386

379-
public function getList(): Type
380-
{
381-
if ($this->isList->no()) {
382-
return new NeverType();
383-
}
384-
385-
$this->isList = TrinaryLogic::createYes();
386-
387-
return $this->getArray();
388-
}
389-
390387
public function isList(): bool
391388
{
392389
return $this->isList->yes();

0 commit comments

Comments
 (0)