Skip to content

Commit

Permalink
Removed ValueType (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
vudaltsov authored Mar 9, 2024
1 parent 47110d5 commit 1d548a4
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 28 deletions.
1 change: 1 addition & 0 deletions src/Type/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## 0.3.1

- Deprecated calling `types::alias()`, `types::template()` and `types::object()` with named arguments.
- Deprecated `TypeVisitor::value()` and `DefaultVisitor::value()`.
3 changes: 3 additions & 0 deletions src/Type/DefaultTypeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ public function union(Type $self, array $types): mixed
return $this->default($self);
}

/**
* @deprecated will be removed in 0.4.0
*/
public function value(Type $self, Type $type): mixed
{
return $this->default($self);
Expand Down
26 changes: 0 additions & 26 deletions src/Type/Internal/ValueType.php

This file was deleted.

1 change: 1 addition & 0 deletions src/Type/TypeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public function truthyString(Type $self): mixed;
public function union(Type $self, array $types): mixed;

/**
* @deprecated will be removed in 0.4.0
* @return TReturn
*/
public function value(Type $self, Type $type): mixed;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/types.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ public static function union(Type ...$types): Type

public static function value(Type $type): Type
{
return new Internal\ValueType($type);
return self::offset($type, self::key($type));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TypeStringifier/TypeStringifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static function types(): \Generator
yield [types::constant('test'), 'test'];
yield [types::classConstant(types::object(\stdClass::class), 'test'), 'stdClass::test'];
yield [types::key(types::list()), 'key-of<list>'];
yield [types::value(types::list()), 'value-of<list>'];
yield [types::value(types::list()), 'list[key-of<list>]'];
yield [types::conditional(types::arg('a'), if: types::string, then: types::int, else: types::float), '($a is string ? int : float)'];
yield [types::conditional(types::template('T', types::atFunction('trim')), if: types::string, then: types::int, else: types::float), '(T@trim() is string ? int : float)'];
yield [types::array(value: types::varianceAware(types::int, Variance::Covariant)), 'array<covariant int>'];
Expand Down

0 comments on commit 1d548a4

Please sign in to comment.