@@ -231,39 +231,41 @@ private function getParameterDefaultValue(\ReflectionParameter $param): string
231231
232232 private function getDefaultValueString (\ReflectionParameter $ param ): string
233233 {
234+ $ result = '' ;
235+
234236 try {
235- if (!$ param ->isDefaultValueAvailable ()) {
236- return '' ;
237+ if ($ param ->isDefaultValueAvailable ()) {
238+ /** @psalm-suppress MixedAssignment */
239+ $ defaultValue = $ param ->getDefaultValue ();
240+ $ result = ' = ' . var_export ($ defaultValue , true );
237241 }
238-
239- /** @psalm-suppress MixedAssignment */
240- $ defaultValue = $ param ->getDefaultValue ();
241-
242- return ' = ' . var_export ($ defaultValue , true );
243242 } catch (Throwable ) {
244243 // Default value cannot be determined for internal classes or certain parameter types
245- return '' ;
244+ $ result = '' ;
246245 }
246+
247+ return $ result ;
247248 }
248249
249250 /**
250251 * @return array{0: string, 1: bool}
251252 */
252253 private function getMethodReturnType (ReflectionMethod $ method ): array
253254 {
254- if (!$ method ->hasReturnType ()) {
255- return ['' , false ];
256- }
255+ $ returnType = '' ;
256+ $ isVoid = false ;
257257
258- $ type = $ method ->getReturnType ();
258+ if ($ method ->hasReturnType ()) {
259+ $ type = $ method ->getReturnType ();
259260
260- if ($ type === null ) {
261- return ['' , false ];
261+ if ($ type !== null ) {
262+ $ typeString = (string )$ type ;
263+ $ returnType = ': ' . $ typeString ;
264+ $ isVoid = $ typeString === 'void ' ;
265+ }
262266 }
263267
264- $ typeString = (string )$ type ;
265-
266- return [': ' . $ typeString , $ typeString === 'void ' ];
268+ return [$ returnType , $ isVoid ];
267269 }
268270
269271 private function generateMethodBody (string $ methodName , string $ argsList , bool $ isVoid ): string
0 commit comments