Skip to content

Commit

Permalink
Removed atomic classString type, replaced with classString(object)
Browse files Browse the repository at this point in the history
  • Loading branch information
vudaltsov committed Feb 27, 2024
1 parent 22f9af6 commit f8109c1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/NamedClassStringType.php → src/ClassStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
* @psalm-internal Typhoon\Type
* @implements Type<non-empty-string>
*/
final class NamedClassStringType implements Type
final class ClassStringType implements Type
{
public function __construct(
private readonly Type $object,
) {}

public function accept(TypeVisitor $visitor): mixed
{
return $visitor->namedClassString($this, $this->object);
return $visitor->classString($this, $this->object);
}
}
7 changes: 1 addition & 6 deletions src/DefaultTypeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function classConstant(Type $self, Type $class, string $name): mixed
return $this->default($self);
}

public function classString(Type $self): mixed
public function classString(Type $self, Type $object): mixed
{
return $this->default($self);
}
Expand Down Expand Up @@ -121,11 +121,6 @@ public function mixed(Type $self): mixed
return $this->default($self);
}

public function namedClassString(Type $self, Type $object): mixed
{
return $this->default($self);
}

public function namedObject(Type $self, string $class, array $arguments): mixed
{
return $this->default($self);
Expand Down
10 changes: 2 additions & 8 deletions src/TypeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public function callable(Type $self, array $parameters, Type $return): mixed;
public function classConstant(Type $self, Type $class, string $name): mixed;

/**
* @param Type<class-string> $self
* @param Type<non-empty-string> $self
* @return TReturn
*/
public function classString(Type $self): mixed;
public function classString(Type $self, Type $object): mixed;

/**
* @param Type<non-empty-string> $self
Expand Down Expand Up @@ -143,12 +143,6 @@ public function literalValue(Type $self, bool|int|float|string $value): mixed;
*/
public function mixed(Type $self): mixed;

/**
* @param Type<non-empty-string> $self
* @return TReturn
*/
public function namedClassString(Type $self, Type $object): mixed;

/**
* @param Type<object> $self
* @param non-empty-string $class
Expand Down
4 changes: 2 additions & 2 deletions src/types.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static function classConstant(Type $class, string $name): Type
*/
public static function classString(Type $object): Type
{
return new NamedClassStringType($object);
return new ClassStringType($object);
}

/**
Expand Down Expand Up @@ -435,7 +435,7 @@ public function accept(TypeVisitor $visitor): mixed
self::arrayKey => $visitor->union($this, [self::int, self::string]),
self::bool => $visitor->bool($this),
self::callable => $visitor->callable($this, [], self::mixed),
self::classString => $visitor->classString($this),
self::classString => $visitor->classString($this, types::object),
self::closure => $visitor->closure($this, [], types::mixed),
self::false => $visitor->literalValue($this, false),
self::float => $visitor->float($this),
Expand Down

0 comments on commit f8109c1

Please sign in to comment.