@@ -365,13 +365,13 @@ protected function parseAnnotationVars($str)
365365 }
366366
367367 /**
368- * show help by parse method annotation
368+ * show help by parse method annotations
369369 * @param string $method
370370 * @param null|string $action
371371 * @param array $aliases
372372 * @return int
373373 */
374- protected function showHelpByMethodAnnotation ($ method , $ action = null , array $ aliases = [])
374+ protected function showHelpByMethodAnnotations ($ method , $ action = null , array $ aliases = [])
375375 {
376376 $ ref = new \ReflectionClass ($ this );
377377 $ name = $ this ->input ->getCommand ();
@@ -391,36 +391,23 @@ protected function showHelpByMethodAnnotation($method, $action = null, array $al
391391
392392 $ doc = $ ref ->getMethod ($ method )->getDocComment ();
393393 $ tags = Annotation::getTags ($ this ->parseAnnotationVars ($ doc ));
394- $ comments = [];
394+ $ help = [];
395395
396396 if ($ aliases ) {
397- $ comments [] = sprintf ("<comment>Alias Name:</comment> %s \n" , implode (', ' , $ aliases ));
397+ $ help [] = sprintf ("<comment>Alias Name:</comment> %s \n" , implode (', ' , $ aliases ));
398398 }
399399
400- foreach ($ tags as $ tag => $ msg ) {
401- if (! $ msg || !\is_string ($ msg )) {
400+ foreach (array_keys ( self :: $ annotationTags ) as $ tag ) {
401+ if (empty ( $ tags [ $ tag ]) || !\is_string ($ tags [ $ tag ] )) {
402402 continue ;
403403 }
404404
405- if (isset (self ::$ annotationTags [$ tag ])) {
406- $ msg = $ this ->parseAnnotationVars (trim ($ msg ));
407-
408- // need multi align
409- // if (self::$annotationTags[$tag]) {
410- // $lines = array_map(function ($line) {
411- // // return trim($line);
412- // return $line;
413- // }, explode("\n", $msg));
414-
415- // $msg = implode("\n", array_filter($lines, 'trim'));
416- // }
417-
418- $ tag = ucfirst ($ tag );
419- $ comments [] = "<comment> $ tag:</comment> \n $ msg \n" ;
420- }
405+ $ msg = trim ($ tags [$ tag ]);
406+ $ tag = ucfirst ($ tag );
407+ $ help [] = "<comment> $ tag:</comment> \n $ msg \n" ;
421408 }
422409
423- $ this ->output ->write (implode ("\n" , $ comments ), false );
410+ $ this ->output ->write (implode ("\n" , $ help ), false );
424411
425412 return 0 ;
426413 }
@@ -469,6 +456,16 @@ public static function getAnnotationTags(): array
469456 return self ::$ annotationTags ;
470457 }
471458
459+ /**
460+ * @param string $name
461+ */
462+ public static function addAnnotationTag (string $ name )
463+ {
464+ if (!isset (self ::$ annotationTags [$ name ])) {
465+ self ::$ annotationTags [$ name ] = true ;
466+ }
467+ }
468+
472469 /**
473470 * @param array $annotationTags
474471 * @param bool $replace
0 commit comments