Skip to content

Commit

Permalink
no need to union AccessoryTypes because classified by `$innerType->de…
Browse files Browse the repository at this point in the history
…scribe(VerbosityLevel::cache())` and they should be same (except HasOffsetValueType)
  • Loading branch information
rajyan committed Dec 17, 2022
1 parent fa878ab commit 8e5b564
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/Type/TypeCombinator.php
Expand Up @@ -513,14 +513,7 @@ private static function processArrayAccessoryTypes(array $arrayTypes): array
break;
}
if ($innerType instanceof HasOffsetValueType) {
$key = sprintf('hasOffsetValue(%s)', $innerType->getOffsetType()->describe(VerbosityLevel::cache()));
$type = isset($accessoryTypes[$key][$i])
? new HasOffsetValueType(
$innerType->getOffsetType(),
self::union($innerType->getValueType(), $accessoryTypes[$key][$i]->getValueType()),
)
: $innerType;
$accessoryTypes[$key][$i] = $type;
$accessoryTypes[sprintf('hasOffsetValue(%s)', $innerType->getOffsetType()->describe(VerbosityLevel::cache()))][$i] = $innerType;
continue;
}
if (!($innerType instanceof AccessoryType) && !($innerType instanceof CallableType)) {
Expand Down Expand Up @@ -558,7 +551,12 @@ private static function processArrayAccessoryTypes(array $arrayTypes): array
continue;
}

$commonAccessoryTypes[] = self::union(...$accessoryType);
if ($accessoryType[0] instanceof HasOffsetValueType) {
$commonAccessoryTypes[] = TypeCombinator::union(...$accessoryType);
continue;
}

$commonAccessoryTypes[] = $accessoryType[0];
}

return $commonAccessoryTypes;
Expand Down

0 comments on commit 8e5b564

Please sign in to comment.