From 683da58667706bb5c6071bb708235f838d149168 Mon Sep 17 00:00:00 2001 From: Valentin Udaltsov Date: Tue, 27 Feb 2024 13:07:17 +0300 Subject: [PATCH] Removed constraint from TemplateType --- src/DefaultTypeVisitor.php | 2 +- src/TemplateType.php | 7 ++----- src/TypeVisitor.php | 2 +- src/types.php | 7 ++----- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/DefaultTypeVisitor.php b/src/DefaultTypeVisitor.php index 3d7c772..f6a1b5f 100644 --- a/src/DefaultTypeVisitor.php +++ b/src/DefaultTypeVisitor.php @@ -176,7 +176,7 @@ public function string(Type $self): mixed return $this->default($self); } - public function template(Type $self, string $name, AtClass|AtFunction|AtMethod $declaredAt, Type $constraint): mixed + public function template(Type $self, string $name, AtClass|AtFunction|AtMethod $declaredAt): mixed { return $this->default($self); } diff --git a/src/TemplateType.php b/src/TemplateType.php index e358505..2ba645f 100644 --- a/src/TemplateType.php +++ b/src/TemplateType.php @@ -7,23 +7,20 @@ /** * @internal * @psalm-internal Typhoon\Type - * @template-covariant TType - * @implements Type + * @implements Type */ final class TemplateType implements Type { /** * @param non-empty-string $name - * @param Type $constraint */ public function __construct( private readonly string $name, private readonly AtFunction|AtClass|AtMethod $declaredAt, - private readonly Type $constraint, ) {} public function accept(TypeVisitor $visitor): mixed { - return $visitor->template($this, $this->name, $this->declaredAt, $this->constraint); + return $visitor->template($this, $this->name, $this->declaredAt); } } diff --git a/src/TypeVisitor.php b/src/TypeVisitor.php index 8627eba..035fba1 100644 --- a/src/TypeVisitor.php +++ b/src/TypeVisitor.php @@ -213,7 +213,7 @@ public function string(Type $self): mixed; * @param non-empty-string $name * @return TReturn */ - public function template(Type $self, string $name, AtFunction|AtClass|AtMethod $declaredAt, Type $constraint): mixed; + public function template(Type $self, string $name, AtFunction|AtClass|AtMethod $declaredAt): mixed; /** * @param Type $self diff --git a/src/types.php b/src/types.php index 7cf06c8..7648f1d 100644 --- a/src/types.php +++ b/src/types.php @@ -391,14 +391,11 @@ public static function prop(Type $type, bool $optional = false): Property } /** - * @template TType * @param non-empty-string $name - * @param Type $constraint - * @return Type */ - public static function template(string $name, AtMethod|AtClass|AtFunction $declaredAt, Type $constraint = self::mixed): Type + public static function template(string $name, AtMethod|AtClass|AtFunction $declaredAt): Type { - return new TemplateType($name, $declaredAt, $constraint); + return new TemplateType($name, $declaredAt); } /**