@@ -29,7 +29,7 @@ protected function formatComments(?\phpDocumentor\Reflection\DocBlock $docBlock,
29
29
30
30
$ container = new \PHPFUI \Container ();
31
31
32
- $ container ->add ($ this ->parsedown ->text ($ docBlock -> getSummary ( )));
32
+ $ container ->add ($ this ->parsedown ->text ($ this -> getInheritedSummary ( $ docBlock , $ reflectionMethod )));
33
33
$ desc = $ docBlock ->getDescription ();
34
34
35
35
if ($ desc )
@@ -57,15 +57,25 @@ protected function formatComments(?\phpDocumentor\Reflection\DocBlock $docBlock,
57
57
$ description = \method_exists ($ tag , 'getDescription ' ) ? \trim ($ tag ->getDescription ()) : '' ;
58
58
$ body = '' ;
59
59
// punt on useless tags
60
- if (\in_array ($ name , ['method ' , 'param ' , ' inheritdoc ' ]))
60
+ if (\in_array ($ name , ['method ' , 'inheritdoc ' ]))
61
61
{
62
62
continue ;
63
63
}
64
64
65
- if ('var ' == $ name )
65
+ if (\method_exists ($ tag , 'getType ' ))
66
+ {
67
+ $ type = $ tag ->getType ();
68
+ }
69
+ else
70
+ {
71
+ $ type = '' ;
72
+ }
73
+
74
+
75
+ if ('var ' == $ name || 'param ' == $ name )
66
76
{
67
77
// useless if no description or type
68
- if (! $ description && ! $ tag -> getType () )
78
+ if (! $ description && ! $ type )
69
79
{
70
80
continue ;
71
81
}
@@ -91,14 +101,9 @@ protected function formatComments(?\phpDocumentor\Reflection\DocBlock $docBlock,
91
101
$ body .= new \PHPFUI \Link ($ tag ->getLink (), '' , false );
92
102
}
93
103
94
- if (\method_exists ( $ tag , ' getType ' ) )
104
+ if ($ type )
95
105
{
96
- $ type = $ tag ->getType ();
97
-
98
- if ($ type )
99
- {
100
- $ body .= $ this ->getClassName ($ type ) . ' ' ;
101
- }
106
+ $ body .= $ this ->getClassName ($ type ) . ' ' ;
102
107
}
103
108
104
109
if (\method_exists ($ tag , 'getVariableName ' ))
@@ -116,6 +121,10 @@ protected function formatComments(?\phpDocumentor\Reflection\DocBlock $docBlock,
116
121
117
122
$ container ->add ($ ul );
118
123
}
124
+ else
125
+ {
126
+ $ container ->add ('no tags<br> ' );
127
+ }
119
128
120
129
return $ container ;
121
130
}
@@ -207,6 +216,7 @@ protected function getComments(?\phpDocumentor\Reflection\DocBlock $docBlock, ?\
207
216
protected function getDocBlock ($ method ) : ?\phpDocumentor \Reflection \DocBlock
208
217
{
209
218
$ comments = $ method ->getDocComment ();
219
+ $ comments = \str_replace ('{@inheritdoc} ' , '@inheritdoc ' , $ comments );
210
220
211
221
if (! $ comments )
212
222
{
@@ -233,37 +243,72 @@ protected function getHtmlClass(string $class) : string
233
243
return \str_replace ('\\' , '- ' , $ class );
234
244
}
235
245
236
- protected function getInheritedDocBlock ( array $ tags , \ReflectionMethod $ reflectionMethod ) : array
246
+ protected function getInheritedSummary ( \ phpDocumentor \ Reflection \ DocBlock $ docBlock , ? \ReflectionMethod $ reflectionMethod = null ) : string
237
247
{
248
+ $ summary = $ docBlock ->getSummary ();
249
+ if (! $ reflectionMethod )
250
+ {
251
+ return $ summary ;
252
+ }
253
+
254
+ $ tags = $ docBlock ->getTags ();
238
255
foreach ($ tags as $ index => $ tag )
239
256
{
240
257
if (0 == \strcasecmp ($ tag ->getName (), 'inheritDoc ' ))
241
258
{
242
259
$ reflectionClass = $ reflectionMethod ->getDeclaringClass ();
243
260
$ parent = $ reflectionClass ->getParentClass ();
244
261
245
- if (! $ parent )
262
+ while ( $ parent )
246
263
{
247
- return []; // no parent, at top of tree, and no tags, go figure
248
- }
249
- $ method = $ parent ->getMethod ($ reflectionMethod ->name );
264
+ $ method = $ parent ->getMethod ($ reflectionMethod ->name );
265
+ if ($ method )
266
+ {
267
+ $ docBlock = $ this ->getDocBlock ($ method );
250
268
251
- if (! $ method )
252
- {
253
- return []; // no method here, kinda strange
269
+ if ($ docBlock )
270
+ {
271
+ return $ summary . "\n" . $ this ->getInheritedSummary ($ docBlock , $ method );
272
+ }
273
+ }
274
+ $ parent = $ parent ->getParentClass ();
254
275
}
255
- $ docBlock = $ this ->getDocBlock ($ method );
256
276
257
- if ($ docBlock )
277
+ break ;
278
+ }
279
+ }
280
+
281
+ return $ summary ;
282
+ }
283
+
284
+ protected function getInheritedDocBlock (array $ tags , \ReflectionMethod $ reflectionMethod ) : array
285
+ {
286
+ foreach ($ tags as $ index => $ tag )
287
+ {
288
+ if (0 == \strcasecmp ($ tag ->getName (), 'inheritDoc ' ))
289
+ {
290
+ $ reflectionClass = $ reflectionMethod ->getDeclaringClass ();
291
+ $ parent = $ reflectionClass ->getParentClass ();
292
+
293
+ while ($ parent )
258
294
{
259
- // add in the new tags and check parent
260
- \array_splice ($ tags , $ index , 1 , $ docBlock ->getTags ());
295
+ $ method = $ parent ->getMethod ($ reflectionMethod ->name );
296
+ if ($ method )
297
+ {
298
+ $ docBlock = $ this ->getDocBlock ($ method );
299
+
300
+ if ($ docBlock )
301
+ {
302
+ // add in the new tags and check parent
303
+ \array_splice ($ tags , $ index , 1 , $ docBlock ->getTags ());
261
304
262
- return $ this ->getInheritedDocBlock ($ tags , $ method );
305
+ return $ this ->getInheritedDocBlock ($ tags , $ method );
306
+ }
307
+ }
308
+ $ parent = $ parent ->getParentClass ();
263
309
}
264
310
265
- // Nothing at this level, but go up one and try the parent method
266
- return $ this ->getInheritedDocBlock ($ tags , $ method );
311
+ break ;
267
312
}
268
313
}
269
314
0 commit comments