spatie / laravel-backup

A package to backup your Laravel app
https://spatie.be/docs/laravel-backup
MIT License
5.65k stars 763 forks source link

Return `Command` constants instead of integers in commands #1706

Closed joshbonnick closed 1 year ago

joshbonnick commented 1 year ago

Summary

This PR converts returning integer exit codes to returning the constants defined in Symfony Commands class, making the code more expressive and easier to understand.

Example

class MyCommand extends Command
{
    public function handle(): int 
    {
        // do something that fails...

        return 1;
    }
}
class MyCommand extends Command 
{
    public function handle(): int 
    {
        // do something that fails...

        return static::FAILURE;
    }
}

Additional Changes

Possible Breaking Changes

If the user is extending one of the commands the package provides and are overriding the handle method without the int return type an exception will be thrown. I can remove the return type declaration added if this is a concern.

freekmurze commented 1 year ago

Thanks!