Skip to content

Commit

Permalink
[Type] remove redundant scalar type assertation.
Browse files Browse the repository at this point in the history
  • Loading branch information
azjezz committed May 15, 2021
1 parent 6263250 commit 1e1831e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
2 changes: 1 addition & 1 deletion docs/component/type.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
- [is_scalar](./../../src/Psl/Type/is_scalar.php#L18) ( deprecated )
- [is_string](./../../src/Psl/Type/is_string.php#L18) ( deprecated )
- [iterable](./../../src/Psl/Type/iterable.php#L20)
- [literal_scalar](./../../src/Psl/Type/literal_scalar.php#L18)
- [literal_scalar](./../../src/Psl/Type/literal_scalar.php#L14)
- [map](./../../src/Psl/Type/map.php#L21)
- [mixed](./../../src/Psl/Type/mixed.php#L10)
- [mutable_map](./../../src/Psl/Type/mutable_map.php#L21)
Expand Down
7 changes: 0 additions & 7 deletions src/Psl/Type/literal_scalar.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,14 @@

namespace Psl\Type;

use Psl;

/**
* @template T of string|int|float|bool
*
* @param T $value
*
* @throws Psl\Type\Exception\AssertException If $value is not scalar.
*
* @return TypeInterface<T>
*/
function literal_scalar(string|int|float|bool $value): TypeInterface
{
/** @psalm-suppress MissingThrowsDocblock */
union(string(), bool(), num())->assert($value);

return new Internal\LiteralScalarType($value);
}

0 comments on commit 1e1831e

Please sign in to comment.