-
Notifications
You must be signed in to change notification settings - Fork 1.9k
refactor: Deprecated method of returning `void' in Сommands #9595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
I'm not sure this is the preferred way to do this. Adding the deprecation PHPDoc makes the whole method deprecated in IDEs. We have made that mistake somewhere else in the framework causing users to complain that a method is deprecated but in fact only a part or implementation is deprecated. I'm thinking of finding where the commands are ultimately called. Not sure but I think in |
Yes, I remember the deprecated method in the request. I was hoping that it would be possible to update all commands to 4.7 and remove The logging option is not bad. But you need to find all the call points. In this case, is it possible not to specify phpdoc? And get started. Does it make sense to rewrite what I'm suggesting? |
Will the tests have to be updated with new methods or completely replaced (with public function testUpdateWithIncorrectLocaleOption(): void
{
self::$locale = 'test_locale_incorrect';
$this->makeLocaleDirectory();
$status = service('commands')->run('lang:find', [
'dir' => 'Translation',
'locale' => self::$locale,
]);
$this->assertSame(EXIT_USER_INPUT, $status);
} |
I agree that deprecating the whole method doesn't make sense and would only confuse users, especially when only the return behavior is being reconsidered. For the framework's own commands, we can update them to consistently return Personally, I wouldn't make any enforced changes for userland commands. If developers want to return a status code, they're free to do so. If not, the CLI will evaluate to For tests, going with I'm also wondering... since we allow calling commands from other commands using $params = $this->call('command_one');
$this->call('command_two', $params); So, while technically returning |
Using Although CodeIgniter4/system/CLI/Commands.php Lines 54 to 61 in af68358
|
@neznaika0 I know, and I agree, but I try to put myself in the shoes of other developers. Historically, we used the In v4, we won't change (or actually add) the return type for this method because it would unnecessarily complicate existing applications. Therefore, it seems that we should leave it as it is and not change anything. The But this is only my point of view. If more people think we should change the PHPDoc return type to |
Description
I see that the commands must follow the style in which the numeric status code is returned. Now many commands have an deprecated solution -
int|void
. I suggest gradually rewriting the commands and tests for them.I want to ask which type is preferable to return?
CodeIgniter4/system/Commands/Database/MigrateRefresh.php
Line 70 in af68358
This always applies to
EXIT_ERROR
,EXIT_DATABASE
orEXIT_USER_INPUT
? Because the parameters are set by the user.In all other cases, return
EXIT_SUCCESS
.Checklist: