-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[WIP][Console] Fix missing return in console documentation on execute function #12703
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
Conversation
@@ -146,6 +146,8 @@ the console:: | |||
// outputs a message without adding a "\n" at the end of the line | |||
$output->write('You are about to '); | |||
$output->write('create a user.'); | |||
|
|||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does your execute()
method looks like?
a) protected function execute(InputInterface $input, OutputInterface $output)
b) protected function execute(InputInterface $input, OutputInterface $output): int
I guess b)
, but then its your return type and not the Symfony one.
Symfony 5.0 does not have a return type:
https://github.com/symfony/symfony/blob/5.0/src/Symfony/Component/Console/Command/Command.php#L159
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say a)
because Symfony throw it self the error : https://github.com/symfony/symfony/blob/5.0/src/Symfony/Component/Console/Command/Command.php#L258
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting... You are right, didn't check it this way 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, @maxhelias is right, it's a)
, just copy past current docs on a fresh 5.0 to reproduce
@OskarStark We can also target a old version because it return 0 by defaults for all that is not numeric and since 4.4 we trigger a deprecation |
What should I do here, just open another PR and target the 4.4 version ? |
Since Symfony 5.0, we have an error if we don't return an int on the `execute` function, I added it in the doc so there will not be an `TypeError` when trying this.
Thanks Jérémie! And congrats on your first Symfony Docs contribution! |
…on on execute function (JeremieSamson) This PR was submitted for the 5.0 branch but it was merged into the 4.4 branch instead (closes #12703). Discussion ---------- [WIP][Console] Fix missing return in console documentation on execute function Since Symfony 5.0, we have an error if we don't return an int on the `execute` function, I added it in the doc so there will not be an `TypeError` when trying this. <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- e2d1c06 Update console.rst
Since Symfony 5.0, we have an error if we don't return an int on the
execute
function, I added it in the doc so there will not be anTypeError
when trying this.