Skip to content

Commit

Permalink
Removed constraint from TemplateType
Browse files Browse the repository at this point in the history
  • Loading branch information
vudaltsov committed Feb 27, 2024
1 parent 15e24fd commit 683da58
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/DefaultTypeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
7 changes: 2 additions & 5 deletions src/TemplateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,20 @@
/**
* @internal
* @psalm-internal Typhoon\Type
* @template-covariant TType
* @implements Type<TType>
* @implements Type<mixed>
*/
final class TemplateType implements Type
{
/**
* @param non-empty-string $name
* @param Type<TType> $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);
}
}
2 changes: 1 addition & 1 deletion src/TypeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<truthy-string> $self
Expand Down
7 changes: 2 additions & 5 deletions src/types.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,14 +391,11 @@ public static function prop(Type $type, bool $optional = false): Property
}

/**
* @template TType
* @param non-empty-string $name
* @param Type<TType> $constraint
* @return Type<TType>
*/
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);
}

/**
Expand Down

0 comments on commit 683da58

Please sign in to comment.