File tree Expand file tree Collapse file tree 1 file changed +46
-1
lines changed
Expand file tree Collapse file tree 1 file changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -167,7 +167,52 @@ public function getTypeName($type)
167167 */
168168 public function getParamDefault (array $ param )
169169 {
170- return '' ;
170+ $ type = $ param ['type ' ] ?? '' ;
171+ $ default = $ param ['default ' ] ?? '' ;
172+ $ required = $ param ['required ' ] ?? '' ;
173+
174+ if ($ required ) {
175+ return '' ;
176+ }
177+
178+ $ output = ' = ' ;
179+
180+ if (empty ($ default ) && $ default !== 0 && $ default !== false ) {
181+ switch ($ type ) {
182+ case self ::TYPE_NUMBER :
183+ case self ::TYPE_INTEGER :
184+ case self ::TYPE_BOOLEAN :
185+ $ output .= 'null ' ;
186+ break ;
187+ case self ::TYPE_STRING :
188+ $ output .= '"" ' ;
189+ break ;
190+ case self ::TYPE_ARRAY :
191+ $ output .= '[] ' ;
192+ break ;
193+ case self ::TYPE_OBJECT :
194+ $ output .= '{} ' ;
195+ break ;
196+ }
197+ }
198+ else {
199+ switch ($ type ) {
200+ case self ::TYPE_NUMBER :
201+ case self ::TYPE_INTEGER :
202+ case self ::TYPE_ARRAY :
203+ case self ::TYPE_OBJECT :
204+ $ output .= $ default ;
205+ break ;
206+ case self ::TYPE_BOOLEAN :
207+ $ output .= ($ default ) ? 'true ' : 'false ' ;
208+ break ;
209+ case self ::TYPE_STRING :
210+ $ output .= "\"{$ default }\"" ;
211+ break ;
212+ }
213+ }
214+
215+ return $ output ;
171216 }
172217
173218 /**
You can’t perform that action at this time.
0 commit comments