{"id":"9c19e286db3c7a5f","repo":"laravel/framework","slug":"unable-to-determine-command-name-from-signature","errorCode":null,"errorMessage":"Unable to determine command name from signature.","messagePattern":"Unable to determine command name from signature\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Console/Parser.php","lineNumber":41,"sourceCode":"        if (preg_match_all('/\\{\\s*(.*?)\\s*\\}/', $expression, $matches) && count($matches[1])) {\n            return array_merge([$name], static::parameters($matches[1]));\n        }\n\n        return [$name, [], []];\n    }\n\n    /**\n     * Extract the name of the command from the expression.\n     *\n     * @param  string  $expression\n     * @return string\n     *\n     * @throws \\InvalidArgumentException\n     */\n    protected static function name(string $expression)\n    {\n        if (! preg_match('/[^\\s]+/', $expression, $matches)) {\n            throw new InvalidArgumentException('Unable to determine command name from signature.');\n        }\n\n        return $matches[0];\n    }\n\n    /**\n     * Extract all parameters from the tokens.\n     *\n     * @param  string[]  $tokens\n     * @return array{\\Symfony\\Component\\Console\\Input\\InputArgument[], \\Symfony\\Component\\Console\\Input\\InputOption[]}\n     */\n    protected static function parameters(array $tokens)\n    {\n        $arguments = [];\n\n        $options = [];\n\n        foreach ($tokens as $token) {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Console/Parser.php#L23-L59","documentation":"Thrown by Parser::name() (src/Illuminate/Console/Parser.php:41) when preg_match('/[^\\s]+/', $expression, $matches) fails — i.e. the command signature contains no non-whitespace token. The parser cannot derive a command name, so it aborts before building InputArgument/InputOption definitions.","triggerScenarios":"Defining a Command with $signature = '' (empty), $signature = '   ' (only spaces), or assigning $signature from a variable/constant that resolves to an empty/whitespace string. Also possible if a typo leaves $signature null-coalesced to ''.","commonSituations":"Copy-paste mistakes where the signature property is left blank, dynamically-built signatures that yield an empty string, or refactoring that removes the command name token.","solutions":["Set a non-empty $signature beginning with the command name, e.g. protected $signature = 'reports:send {user}';.","If using $signature dynamically, validate it is non-empty before the command is parsed.","Use configure() with setName() if the name must be computed at runtime.","Check for stray assignments like $signature = ' '."],"exampleFix":"// before\nclass SendReports extends Command\n{\n    protected $signature = '';\n}\n\n// after\nclass SendReports extends Command\n{\n    protected $signature = 'reports:send {user}';\n}","handlingStrategy":"validation","validationCode":"if (trim((string) $signature) === '') {\n    throw new \\LogicException('Command $signature must start with a name token.');\n}","typeGuard":"function signatureHasName(string $signature): bool\n{\n    return trim($signature) !== '';\n}","tryCatchPattern":"try {\n    [$name, $args, $opts] = \\Illuminate\\Console\\Parser::parse($signature);\n} catch (\\InvalidArgumentException $e) {\n    // fix signature; default to a placeholder name\n}","preventionTips":["Always start $signature with the command name token.","Lint command classes in CI for non-empty signatures.","Use configure()+setName() for dynamically-named commands."],"tags":["console","artisan","command-signature","laravel"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}