Skip to content

Commit 2d5ca16

Browse files
committedApr 27, 2021
update some for tuye
1 parent 896cf8c commit 2d5ca16

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed
 

Diff for: ‎src/Type.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,35 @@ final class Type
4949

5050
// ------ other type names ------
5151

52-
public const CALLABLE = 'callable';
52+
public const CALLABLE = 'callable';
5353

5454
public const MiXED = 'mixed';
5555

5656
public const UNKNOWN = 'unknown type';
5757

58+
/**
59+
* has shorts
60+
*/
61+
public const SHORT_TYPES = [
62+
self::BOOLEAN => self::BOOL,
63+
self::INTEGER => self::INT,
64+
];
65+
5866
/**
5967
* @param mixed $val
68+
* @param bool $toShort
6069
*
6170
* @return string
6271
*/
63-
public static function get($val): string
72+
public static function get($val, bool $toShort = false): string
6473
{
6574
$typName = gettype($val);
6675
if ($typName === self::UNKNOWN) {
6776
$typName = self::MiXED;
6877
} elseif ($typName === self::RESOURCE_CLOSED) {
6978
$typName = self::RESOURCE;
79+
} elseif ($toShort && isset(self::SHORT_TYPES[$typName])) {
80+
$typName = self::SHORT_TYPES[$typName];
7081
}
7182

7283
return $typName;

0 commit comments

Comments
 (0)
Please sign in to comment.