File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,42 @@ public static function get($val, bool $toShort = false): string
83
83
return $ typName ;
84
84
}
85
85
86
+ /**
87
+ * Get type default value.
88
+ *
89
+ * @param string $type
90
+ *
91
+ * @return array|false|float|int|string|null
92
+ */
93
+ public static function getDefault (string $ type )
94
+ {
95
+ $ value = null ;
96
+ switch ($ type ) {
97
+ case self ::INT :
98
+ case self ::INTEGER :
99
+ $ value = 0 ;
100
+ break ;
101
+ case self ::BOOL :
102
+ case self ::BOOLEAN :
103
+ $ value = false ;
104
+ break ;
105
+ case self ::FLOAT :
106
+ $ value = (float )0 ;
107
+ break ;
108
+ case self ::DOUBLE :
109
+ $ value = (double )0 ;
110
+ break ;
111
+ case self ::STRING :
112
+ $ value = '' ;
113
+ break ;
114
+ case self ::ARRAY :
115
+ $ value = [];
116
+ break ;
117
+ }
118
+
119
+ return $ value ;
120
+ }
121
+
86
122
/**
87
123
* @return array
88
124
* @see \gettype()
You can’t perform that action at this time.
0 commit comments