cakephp
cakephp copied to clipboard
Change return type of CommandInterface::run() and Command::execute().
Also make Command class abstract.
The current int|null|void is ugly. Always returning an int from execute() shouldn't be too much trouble. We just need to update the bake template to include return static::CODE_SUCCESS.
We just need to update the bake template to include return static::CODE_SUCCESS.
And update almost every command that exists both for us and in user-land code. I agree the current return type isn't great but this feels like a tedious to fix breaking change that doesn't make user land code safer.
Maybe int|null then only?
Personally I'd generally like to see CakePHP enforcing cleaner / more explicit userland code where possible, hence I'd welcome this change, even though upgrades might be a bit tedious if one has many and/or complex commands.
I gotta admit that I didn't really follow all the type upgrades that happened recently as I was very busy, so I'm not sure about the possible breaking changes that were already introduced... or better yet, not introduced for that matter. If it's a concern in the grand scheme of adding type hints, then at least upgrading the docblock type, the documentation and bake could be a first step, and in 6.x we could add the concrete return type?
The only thing I don't like is the return type cannot be declared since void cannot be in a union type.
Are we going to abandon this for cake5?