L33. Artisan command and signature strings#274
Open
shuvroroy wants to merge 29 commits into
Open
Conversation
…$this->argument/option
…efinition, and diagnostics
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements L33 — Artisan command and signature strings: PHPantom now statically recovers Artisan command names and parses command
$signaturegrammar, bringing completion, go-to-definition, hover, and diagnostics to command-name string literals and to a command's own arguments/options.What it does
Command names — recovered from a command class's
$signature,$name, or#[AsCommand]attribute, scanned across project and vendor command classes into aLaravelCommandIndex(built oninitialized, refreshed incrementally on edits). Wherever a command name appears as a string literal it now:Artisan::call('|'),Artisan::queue('|'),Schedule::command('|'), and$this->call('|')/callSilently('|')inside a command;invalid_laravel_command).Own arguments & options — the
$signaturegrammar ({user},{user?},{--queue=}, arrays*, defaults,shortcut|name,: descriptions) is parsed once so that inside a command class:$this->argument('|')/$this->option('|')complete against the enclosing command's own signature;invalid_command_parameter);Artisan::call('cmd', ['|' => …])completes argument names and--optionkeys.Both diagnostic codes work with the existing
[[diagnostics.ignore]]mechanism; no new config.Scope / limitations
extendsaCommand-suffixed class (or lives underConsole/Commands/, or carries#[AsCommand]). This matches the near-universal Laravel/Symfony convention but would miss a command with an unconventional class name.$this->call/callSilentlyis recognized only inside a syntactic console-command class (so ordinary->call(), e.g.$this->call('GET', '/uri')in HTTP tests, is never touched).initializedhandler, not the headlessanalyzepipeline, so unknown-command flagging is an editor-session feature. Own-parameter validation is offset-based and works in both.configure()/getArguments()rather than$signature/$name/#[AsCommand]are not recovered.Testing
$this->callvs. non-$thisreceivers).tests/integration/laravel_commands.rs) — command-name completion inArtisan::call, go-to-definition to the declaring class, unknown-command diagnostic, own-option completion, and unknown-own-argument diagnostic, all driven through the realinitialized→did_open→ request flow.Example
Added to the
examples/laraveldemo project:app/Console/Commands/SyncBakeryCommand.php—$signaturewith an argument, two options, and inline descriptions;handle()exercises$this->argument/$this->option/$this->call.app/Console/Commands/GenerateReportCommand.php— the#[AsCommand(name: 'reports:generate')]path.Demo::artisanCommands()— command-name completion/navigation/hover, an unknown name, andArtisan::call('bakery:sync', [...])array-key completion, with a numbered "Try:" walkthrough.