Skip to content

Commit

Permalink
tmp wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Dec 12, 2023
1 parent 44ec189 commit 7aa327e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -5089,8 +5089,11 @@ private function exactInstantiation(New_ $node, string $className): ?Type
foreach ($resolvedPhpDoc->getTemplateTags() as $tag) {
$templateType = $typeMap->getType($tag->getName());
$bound = $tag->getBound();
if ($templateType !== null) {
if ($templateType->isConstantValue()->yes() && (!$bound->isScalar()->yes() || $bound->describe(VerbosityLevel::precise()) === '(int|string)')) {
if ($templateType !== null && !$tag->getVariance()->covariant()) {
$isArrayKey = $bound->describe(VerbosityLevel::precise()) === '(int|string)';
if ($templateType->isScalar()->yes() && $isArrayKey) {
$templateType = $templateType->generalize(GeneralizePrecision::templateArgument());
} elseif ($templateType->isConstantValue()->yes() && (!$bound->isScalar()->yes() || $isArrayKey)) {
$templateType = $templateType->generalize(GeneralizePrecision::templateArgument());
}
$list[] = $templateType;
Expand Down

0 comments on commit 7aa327e

Please sign in to comment.