Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[13.x] Fix DumpCommand return type.
  • Loading branch information
KentarouTakeda committed Jul 30, 2026
commit 0aeba12109a5e94fe5e49022a183c71fab23d664
4 changes: 3 additions & 1 deletion src/Illuminate/Database/Console/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DumpCommand extends Command
*
* @param \Illuminate\Database\ConnectionResolverInterface $connections
* @param \Illuminate\Contracts\Events\Dispatcher $dispatcher
* @return void
* @return int

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could narrow this further down:

Suggested change
* @return int
* @return self::SUCCESS|self::FAILURE|self::INVALID

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is int not inaccurate if self::INVALID is? That logic escapes me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

*/
public function handle(ConnectionResolverInterface $connections, Dispatcher $dispatcher)
{
Expand Down Expand Up @@ -70,6 +70,8 @@ public function handle(ConnectionResolverInterface $connections, Dispatcher $dis
}

$this->components->info($info.' successfully.');

return Command::SUCCESS;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return Command::SUCCESS;
return self::SUCCESS;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

}

/**
Expand Down
Loading