Skip to content

Commit b45a41b

Browse files
committed
SA fixes
1 parent 6cacffd commit b45a41b

4 files changed

Lines changed: 9 additions & 10 deletions

File tree

src/Parser/RichParser.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ private function parseIdentifiers(string $text, int $ignorePos): array
361361
throw new IgnoreParseException('Missing identifier', 1);
362362
}
363363

364-
/** @phpstan-ignore return.type (return type is correct, not sure why it's being changed from array shape to key-value shape) */
365364
return $identifiers;
366365
}
367366

src/Type/Constant/ConstantArrayType.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ public function accepts(Type $type, bool $strictTypes): AcceptsResult
560560
$result = $result->and($acceptsValue);
561561
}
562562

563-
$otherUnsealed = $constantArray->getUnsealedTypes();
563+
$otherUnsealed = $constantArray->unsealed;
564564
if ($otherUnsealed !== null && !$constantArray->isUnsealed()->no()) {
565565
[$otherUnsealedKeyType, $otherUnsealedValueType] = $otherUnsealed;
566566

@@ -662,7 +662,7 @@ public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
662662
if ($type instanceof self) {
663663
$thisUnsealedness = $this->isUnsealed();
664664
$typeUnsealedness = $type->isUnsealed();
665-
$bothDefinite = !$thisUnsealedness->maybe() && !$typeUnsealedness->maybe();
665+
$bothDefinite = $this->unsealed !== null && $type->unsealed !== null;
666666

667667
if (count($this->keyTypes) === 0) {
668668
if (!$bothDefinite) {
@@ -678,7 +678,7 @@ public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
678678
foreach ($this->keyTypes as $i => $keyType) {
679679
$hasOffset = $type->hasOffsetValueType($keyType);
680680
if ($bothDefinite && $hasOffset->no() && $typeUnsealedness->yes()) {
681-
[$typeUnsealedKey] = $type->getUnsealedTypes();
681+
[$typeUnsealedKey] = $type->unsealed;
682682
if (!$typeUnsealedKey->isSuperTypeOf($keyType)->no()) {
683683
$hasOffset = TrinaryLogic::createMaybe();
684684
}
@@ -696,7 +696,7 @@ public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
696696

697697
$otherValueType = $type->getOffsetValueType($keyType);
698698
if ($otherValueType instanceof ErrorType && $bothDefinite && $typeUnsealedness->yes()) {
699-
[, $typeUnsealedValue] = $type->getUnsealedTypes();
699+
[, $typeUnsealedValue] = $type->unsealed;
700700
$otherValueType = $typeUnsealedValue;
701701
}
702702
$isValueSuperType = $this->valueTypes[$i]->isSuperTypeOf($otherValueType);
@@ -725,7 +725,7 @@ public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
725725
continue;
726726
}
727727

728-
[$thisUnsealedKey, $thisUnsealedValue] = $this->getUnsealedTypes();
728+
[$thisUnsealedKey, $thisUnsealedValue] = $this->unsealed;
729729
$keyCheck = $thisUnsealedKey->isSuperTypeOf($typeKey);
730730
if ($keyCheck->no()) {
731731
if ($type->isOptionalKey($i)) {
@@ -749,8 +749,8 @@ public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
749749
if ($thisUnsealedness->no()) {
750750
$results[] = IsSuperTypeOfResult::createMaybe();
751751
} else {
752-
[$thisUnsealedKey, $thisUnsealedValue] = $this->getUnsealedTypes();
753-
[$typeUnsealedKey, $typeUnsealedValue] = $type->getUnsealedTypes();
752+
[$thisUnsealedKey, $thisUnsealedValue] = $this->unsealed;
753+
[$typeUnsealedKey, $typeUnsealedValue] = $type->unsealed;
754754
$results[] = $thisUnsealedKey->isSuperTypeOf($typeUnsealedKey);
755755
$results[] = $thisUnsealedValue->isSuperTypeOf($typeUnsealedValue);
756756
}

src/Type/TypeCombinator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,7 @@ private static function intersectDefiniteConstantArrays(ConstantArrayType $a, Co
17091709
{
17101710
$aSealed = $a->isUnsealed()->no();
17111711
$bSealed = $b->isUnsealed()->no();
1712-
$bothUnsealed = !$aSealed && !$bSealed;
1712+
$bothUnsealed = !$aSealed && !$bSealed && $a->getUnsealedTypes() !== null && $b->getUnsealedTypes() !== null;
17131713

17141714
$aKeyByValue = [];
17151715
foreach ($a->getKeyTypes() as $k => $keyType) {

tests/PHPStan/Type/TypeCombinatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3197,7 +3197,7 @@ public function testUnion(
31973197
}
31983198

31993199
/**
3200-
* @param list<Type> $types
3200+
* @param list<Type>|list<string> $types
32013201
* @param class-string<Type> $expectedTypeClass
32023202
*/
32033203
#[DataProvider('dataUnion')]

0 commit comments

Comments
 (0)