File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -49,24 +49,35 @@ final class Type
49
49
50
50
// ------ other type names ------
51
51
52
- public const CALLABLE = 'callable ' ;
52
+ public const CALLABLE = 'callable ' ;
53
53
54
54
public const MiXED = 'mixed ' ;
55
55
56
56
public const UNKNOWN = 'unknown type ' ;
57
57
58
+ /**
59
+ * has shorts
60
+ */
61
+ public const SHORT_TYPES = [
62
+ self ::BOOLEAN => self ::BOOL ,
63
+ self ::INTEGER => self ::INT ,
64
+ ];
65
+
58
66
/**
59
67
* @param mixed $val
68
+ * @param bool $toShort
60
69
*
61
70
* @return string
62
71
*/
63
- public static function get ($ val ): string
72
+ public static function get ($ val, bool $ toShort = false ): string
64
73
{
65
74
$ typName = gettype ($ val );
66
75
if ($ typName === self ::UNKNOWN ) {
67
76
$ typName = self ::MiXED;
68
77
} elseif ($ typName === self ::RESOURCE_CLOSED ) {
69
78
$ typName = self ::RESOURCE ;
79
+ } elseif ($ toShort && isset (self ::SHORT_TYPES [$ typName ])) {
80
+ $ typName = self ::SHORT_TYPES [$ typName ];
70
81
}
71
82
72
83
return $ typName ;
You can’t perform that action at this time.
0 commit comments