@@ -127,40 +127,7 @@ public function getValueString(mixed $value) : string
127127 break ;
128128
129129 case 'object ' :
130- $ class = $ value ::class;
131-
132- if ('ReflectionNamedType ' == $ class )
133- {
134- $ value = ($ value ->allowsNull () ? '? ' : '' ) . $ this ->getClassName ($ value ->getName ());
135- }
136- elseif ('ReflectionUnionType ' == $ class )
137- {
138- $ types = $ value ->getTypes ();
139- $ value = $ bar = '' ;
140-
141- foreach ($ types as $ type )
142- {
143- $ value .= $ bar ;
144- $ bar = '| ' ;
145- $ value .= $ this ->getClassName ($ type ->getName ());
146- }
147- }
148- elseif ('ReflectionIntersectionType ' == $ class )
149- {
150- $ types = $ value ->getTypes ();
151- $ value = $ bar = '' ;
152-
153- foreach ($ types as $ type )
154- {
155- $ value .= $ bar ;
156- $ bar = '& ' ;
157- $ value .= $ this ->getClassName ($ type ->getName ());
158- }
159- }
160- else
161- {
162- $ value = $ this ->getClassName ($ class );
163- }
130+ $ value = $ this ->getClassName ($ value );
164131
165132 break ;
166133
@@ -302,10 +269,53 @@ protected function formatComments(?\phpDocumentor\Reflection\DocBlock $docBlock,
302269 return $ container ;
303270 }
304271
305- protected function getClassName (string $ class , bool $ asLink = true ) : string
272+ protected function getClassName (string | object $ class , bool $ asLink = true ) : string
306273 {
307274 $ array = '' ;
308275
276+ if (! \is_string ($ class ))
277+ {
278+ $ className = $ class ::class;
279+
280+ if ('ReflectionNamedType ' == $ className )
281+ {
282+ return ($ class ->allowsNull () ? '? ' : '' ) . $ this ->getClassName ($ class ->getName ());
283+ }
284+ elseif ('ReflectionUnionType ' == $ className )
285+ {
286+ $ types = $ class ->getTypes ();
287+ $ value = $ bar = '' ;
288+
289+ foreach ($ types as $ type )
290+ {
291+ $ value .= $ bar ;
292+ $ bar = '| ' ;
293+ $ value .= $ this ->getClassName ($ type );
294+ }
295+
296+ return $ value ;
297+ }
298+ elseif ('ReflectionIntersectionType ' == $ className )
299+ {
300+ $ types = $ class ->getTypes ();
301+ $ value = '( ' ;
302+ $ bar = '' ;
303+
304+ foreach ($ types as $ type )
305+ {
306+ $ value .= $ bar ;
307+ $ bar = '& ' ;
308+ $ value .= $ this ->getClassName ($ type ->getName ());
309+ }
310+
311+ return $ value . ') ' ;
312+ }
313+
314+
315+ return $ this ->getClassName ($ class ::class);
316+
317+ }
318+
309319 if ($ asLink && $ class )
310320 {
311321 // could be mixed, break out by |
0 commit comments