[13.x] Fix DumpCommand return type. - #60934
Conversation
| * @param \Illuminate\Database\ConnectionResolverInterface $connections | ||
| * @param \Illuminate\Contracts\Events\Dispatcher $dispatcher | ||
| * @return void | ||
| * @return int |
There was a problem hiding this comment.
You could narrow this further down:
| * @return int | |
| * @return self::SUCCESS|self::FAILURE|self::INVALID |
There was a problem hiding this comment.
Thanks, but I'd rather keep @return int here: handle() never returns INVALID, so that union would be inaccurate. And narrowing it further would introduce a new incompatible-signature error for subclasses that return any other exit code.
There was a problem hiding this comment.
How is int not inaccurate if self::INVALID is? That logic escapes me.
There was a problem hiding this comment.
Fair — sloppy wording; int is wider than what this method returns today, but not wider than what's allowed. Command::execute() casts whatever handle() returns with (int) and passes it straight through, and Symfony only caps it at 255 — the framework itself already emits other codes via --isolated=<n>. So int is the contract, and the union would document a constraint that isn't there.
|
|
||
| $this->components->info($info.' successfully.'); | ||
|
|
||
| return Command::SUCCESS; |
There was a problem hiding this comment.
| return Command::SUCCESS; | |
| return self::SUCCESS; |
There was a problem hiding this comment.
Thanks! Every command under Database/Console uses Command::, including the Command::FAILURE a few lines above in this same method, so I'll keep it consistent.
This PR changes
DumpCommand::handle()to returnCommand::SUCCESSon success and updates its DocBlock from@return voidto@return int.Since the method already returned
Command::FAILUREin some cases, the previous@return voidannotation was incorrect. No native return type has been added, so this introduces no breaking change.We encountered this while overriding
DumpCommandin our project. The incorrect DocBlock causes PHPStan to report an incompatible method signature, and this change resolves that inconsistency.