File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments