@@ -29,7 +29,7 @@ protected function formatComments(?\phpDocumentor\Reflection\DocBlock $docBlock,
2929
3030 $ container = new \PHPFUI \Container ();
3131
32- $ container ->add ($ this ->parsedown ->text ($ docBlock -> getSummary ( )));
32+ $ container ->add ($ this ->parsedown ->text ($ this -> getInheritedSummary ( $ docBlock , $ reflectionMethod )));
3333 $ desc = $ docBlock ->getDescription ();
3434
3535 if ($ desc )
@@ -57,15 +57,25 @@ protected function formatComments(?\phpDocumentor\Reflection\DocBlock $docBlock,
5757 $ description = \method_exists ($ tag , 'getDescription ' ) ? \trim ($ tag ->getDescription ()) : '' ;
5858 $ body = '' ;
5959 // punt on useless tags
60- if (\in_array ($ name , ['method ' , 'param ' , ' inheritdoc ' ]))
60+ if (\in_array ($ name , ['method ' , 'inheritdoc ' ]))
6161 {
6262 continue ;
6363 }
6464
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 )
6676 {
6777 // useless if no description or type
68- if (! $ description && ! $ tag -> getType () )
78+ if (! $ description && ! $ type )
6979 {
7080 continue ;
7181 }
@@ -91,14 +101,9 @@ protected function formatComments(?\phpDocumentor\Reflection\DocBlock $docBlock,
91101 $ body .= new \PHPFUI \Link ($ tag ->getLink (), '' , false );
92102 }
93103
94- if (\method_exists ( $ tag , ' getType ' ) )
104+ if ($ type )
95105 {
96- $ type = $ tag ->getType ();
97-
98- if ($ type )
99- {
100- $ body .= $ this ->getClassName ($ type ) . ' ' ;
101- }
106+ $ body .= $ this ->getClassName ($ type ) . ' ' ;
102107 }
103108
104109 if (\method_exists ($ tag , 'getVariableName ' ))
@@ -116,6 +121,10 @@ protected function formatComments(?\phpDocumentor\Reflection\DocBlock $docBlock,
116121
117122 $ container ->add ($ ul );
118123 }
124+ else
125+ {
126+ $ container ->add ('no tags<br> ' );
127+ }
119128
120129 return $ container ;
121130 }
@@ -207,6 +216,7 @@ protected function getComments(?\phpDocumentor\Reflection\DocBlock $docBlock, ?\
207216 protected function getDocBlock ($ method ) : ?\phpDocumentor \Reflection \DocBlock
208217 {
209218 $ comments = $ method ->getDocComment ();
219+ $ comments = \str_replace ('{@inheritdoc} ' , '@inheritdoc ' , $ comments );
210220
211221 if (! $ comments )
212222 {
@@ -233,37 +243,72 @@ protected function getHtmlClass(string $class) : string
233243 return \str_replace ('\\' , '- ' , $ class );
234244 }
235245
236- protected function getInheritedDocBlock ( array $ tags , \ReflectionMethod $ reflectionMethod ) : array
246+ protected function getInheritedSummary ( \ phpDocumentor \ Reflection \ DocBlock $ docBlock , ? \ReflectionMethod $ reflectionMethod = null ) : string
237247 {
248+ $ summary = $ docBlock ->getSummary ();
249+ if (! $ reflectionMethod )
250+ {
251+ return $ summary ;
252+ }
253+
254+ $ tags = $ docBlock ->getTags ();
238255 foreach ($ tags as $ index => $ tag )
239256 {
240257 if (0 == \strcasecmp ($ tag ->getName (), 'inheritDoc ' ))
241258 {
242259 $ reflectionClass = $ reflectionMethod ->getDeclaringClass ();
243260 $ parent = $ reflectionClass ->getParentClass ();
244261
245- if (! $ parent )
262+ while ( $ parent )
246263 {
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 );
250268
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 ();
254275 }
255- $ docBlock = $ this ->getDocBlock ($ method );
256276
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 )
258294 {
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 ());
261304
262- return $ this ->getInheritedDocBlock ($ tags , $ method );
305+ return $ this ->getInheritedDocBlock ($ tags , $ method );
306+ }
307+ }
308+ $ parent = $ parent ->getParentClass ();
263309 }
264310
265- // Nothing at this level, but go up one and try the parent method
266- return $ this ->getInheritedDocBlock ($ tags , $ method );
311+ break ;
267312 }
268313 }
269314
0 commit comments