// can never be commands.
$commandMethodNames = array_filter(
get_class_methods($classNameOrInstance) ?: [],
- function ($m) {
- return !preg_match('#^_#', $m);
+ function ($m) use ($classNameOrInstance) {
+ $reflectionMethod = new \ReflectionMethod($classNameOrInstance, $m);
+ return !$reflectionMethod->isStatic() && !preg_match('#^_#', $m);
}
);
if ($commandInfo->hasAnnotation('command')) {
return true;
}
+ // Skip anything that has a missing or invalid name.
+ $commandName = $commandInfo->getName();
+ if (empty($commandName) || preg_match('#[^a-zA-Z0-9:_-]#', $commandName)) {
+ return false;
+ }
// Skip anything named like an accessor ('get' or 'set')
if (preg_match('#^(get[A-Z]|set[A-Z])#', $commandInfo->getMethodName())) {
return false;