Skip to content

Commit 4f267e8

Browse files
committed
Update typhoon/type and templates parsing
1 parent f66c69b commit 4f267e8

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

composer.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Internal/ContextualParser.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,19 +355,20 @@ private function const(array $genericNodes): ConstantT
355355

356356
private function callable(CallableTypeNode $node): CallableT
357357
{
358+
$templates = [];
359+
358360
foreach ($node->templateTypes as $templateNode) {
359-
$this->templateTypes[$templateNode->name] = new TemplateT();
361+
$template = new Template($templateNode->name);
362+
$templates[$templateNode->name] = $template;
363+
$this->templateTypes[$templateNode->name] = $template->type;
360364
}
361365

362366
return new CallableT(
363367
templates: array_map(
364-
fn(TemplateTagValueNode $node): Template => new Template(
365-
name: $node->name,
366-
lowerBound: $node->lowerBound === null ? neverT : $this->parse($node->lowerBound),
367-
upperBound: $node->bound === null ? mixedT : $this->parse($node->bound),
368-
default: $node->default === null ? null : $this->parse($node->default),
369-
type: $this->templateTypes[$node->name],
370-
),
368+
fn(TemplateTagValueNode $node): Template => $templates[$node->name]
369+
->withLowerBound($node->lowerBound === null ? neverT : $this->parse($node->lowerBound))
370+
->withUpperBound($node->bound === null ? mixedT : $this->parse($node->bound))
371+
->withDefault($node->default === null ? null : $this->parse($node->default)),
371372
$node->templateTypes,
372373
),
373374
parameters: array_map(

0 commit comments

Comments
 (0)