File tree Expand file tree Collapse file tree 2 files changed +36
-4
lines changed
Expand file tree Collapse file tree 2 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -309,15 +309,20 @@ protected function replaceAnnotationVars($str)
309309 protected function showHelpByMethodAnnotation ($ method , $ action = null )
310310 {
311311 $ ref = new \ReflectionClass ($ this );
312- $ cName = lcfirst ( self :: getName () ?: $ ref -> getShortName () );
312+ $ name = $ this -> input -> getCommand ( );
313313
314- if (!$ ref ->hasMethod ($ method ) || !$ ref ->getMethod ($ method )->isPublic ()) {
315- $ name = $ action ? "$ cName/ $ action " : $ cName ;
316- $ this ->write ("Command [<info> $ name</info>] don't exist or don't allow access in the class. " );
314+ if (!$ ref ->hasMethod ($ method )) {
315+ $ this ->write ("The command [<info> $ name</info>] don't exist in the class. " );
317316
318317 return 0 ;
319318 }
320319
320+ // is a console controller command
321+ if ($ action && !$ ref ->getMethod ($ method )->isPublic ()) {
322+ $ this ->write ("The command [<info> $ name</info>] don't allow access in the class. " );
323+ return 0 ;
324+ }
325+
321326 $ doc = $ ref ->getMethod ($ method )->getDocComment ();
322327 $ tags = Annotation::tagList ($ this ->replaceAnnotationVars ($ doc ));
323328
Original file line number Diff line number Diff line change @@ -216,6 +216,33 @@ public function getInt($key, $default = 0): int
216216 return $ value === null ? (int )$ default : (int )$ value ;
217217 }
218218
219+ /**
220+ * get same args value
221+ * eg: des description
222+ *
223+ * ```php
224+ * $input->sameArg(['des', 'description']);
225+ * ```
226+ *
227+ * @param array $names
228+ * @param mixed $default
229+ * @return bool|mixed|null
230+ */
231+ public function getSameArg (array $ names , $ default = null )
232+ {
233+ return $ this ->sameArg ($ names , $ default );
234+ }
235+ public function sameArg (array $ names , $ default = null )
236+ {
237+ foreach ($ names as $ name ) {
238+ if ($ this ->hasArg ($ name )) {
239+ return $ this ->get ($ name );
240+ }
241+ }
242+
243+ return $ default ;
244+ }
245+
219246 /////////////////////////////////////////////////////////////////////////////////////////
220247 /// long/short options (eg: -d --help)
221248 /////////////////////////////////////////////////////////////////////////////////////////
You can’t perform that action at this time.
0 commit comments