@@ -127,40 +127,7 @@ public function getValueString(mixed $value) : string
127
127
break ;
128
128
129
129
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 );
164
131
165
132
break ;
166
133
@@ -302,10 +269,53 @@ protected function formatComments(?\phpDocumentor\Reflection\DocBlock $docBlock,
302
269
return $ container ;
303
270
}
304
271
305
- protected function getClassName (string $ class , bool $ asLink = true ) : string
272
+ protected function getClassName (string | object $ class , bool $ asLink = true ) : string
306
273
{
307
274
$ array = '' ;
308
275
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
+
309
319
if ($ asLink && $ class )
310
320
{
311
321
// could be mixed, break out by |
0 commit comments