@@ -139,6 +139,7 @@ public function run($command = '')
139139 return $ this ->showHelp ();
140140 }
141141
142+ // some prepare check
142143 if (true !== $ this ->prepare ()) {
143144 return -1 ;
144145 }
@@ -183,8 +184,7 @@ protected function afterExecute()
183184 */
184185 protected function showHelp ()
185186 {
186- // 创建了 InputDefinition , 则使用它的信息。
187- // 不会再解析和使用命令的注释。
187+ // 创建了 InputDefinition , 则使用它的信息。此时不会再解析和使用命令的注释。
188188 if ($ def = $ this ->getDefinition ()) {
189189 $ cmd = $ this ->input ->getCommand ();
190190 $ spt = $ this ->input ->getScript ();
@@ -202,17 +202,17 @@ protected function showHelp()
202202
203203 /**
204204 * prepare run
205+ * @throws \RuntimeException
205206 */
206207 protected function prepare ()
207208 {
208209 if ($ this ->processTitle ) {
209210 if (\function_exists ('cli_set_process_title ' )) {
210211 if (false === @cli_set_process_title ($ this ->processTitle )) {
211- if ('Darwin ' === PHP_OS ) {
212- $ this ->output ->writeln ('<comment>Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.</comment> ' );
213- } else {
214- $ error = error_get_last ();
215- trigger_error ($ error ['message ' ], E_USER_WARNING );
212+ $ error = error_get_last ();
213+
214+ if ($ error && 'Darwin ' !== PHP_OS ) {
215+ throw new \RuntimeException ($ error ['message ' ]);
216216 }
217217 }
218218 } elseif (\function_exists ('setproctitle ' )) {
@@ -326,9 +326,10 @@ protected function handleAnnotationVars($str)
326326 * show help by parse method annotation
327327 * @param string $method
328328 * @param null|string $action
329+ * @param array $aliases
329330 * @return int
330331 */
331- protected function showHelpByMethodAnnotation ($ method , $ action = null )
332+ protected function showHelpByMethodAnnotation ($ method , $ action = null , array $ aliases = [] )
332333 {
333334 $ ref = new \ReflectionClass ($ this );
334335 $ name = $ this ->input ->getCommand ();
@@ -342,12 +343,15 @@ protected function showHelpByMethodAnnotation($method, $action = null)
342343 // is a console controller command
343344 if ($ action && !$ ref ->getMethod ($ method )->isPublic ()) {
344345 $ this ->write ("The command [<info> $ name</info>] don't allow access in the class. " );
346+
345347 return 0 ;
346348 }
347349
348350 $ doc = $ ref ->getMethod ($ method )->getDocComment ();
349351 $ tags = Annotation::tagList ($ this ->handleAnnotationVars ($ doc ));
350352
353+ $ this ->output ->startBuffer ();
354+
351355 foreach ($ tags as $ tag => $ msg ) {
352356 if (!$ msg || !\is_string ($ msg )) {
353357 continue ;
@@ -371,6 +375,8 @@ protected function showHelpByMethodAnnotation($method, $action = null)
371375 }
372376 }
373377
378+ $ this ->output ->flush ();
379+
374380 return 0 ;
375381 }
376382
0 commit comments