Skip to content

[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

Merged
merged 1 commit into from
Dec 9, 2019
Merged

Conversation

JeremieSamson
Copy link
Contributor

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.

@JeremieSamson JeremieSamson changed the title Update console.rst Fix missing return in console documentation on execute function Nov 26, 2019
@JeremieSamson JeremieSamson changed the title Fix missing return in console documentation on execute function [WIP][Console] Fix missing return in console documentation on execute function Nov 26, 2019
@@ -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;
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

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 🤔

Copy link
Contributor Author

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

@maxhelias
Copy link
Contributor

@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

@JeremieSamson
Copy link
Contributor Author

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.
@javiereguiluz javiereguiluz changed the base branch from 5.0 to 4.4 December 9, 2019 14:30
@javiereguiluz
Copy link
Member

Thanks Jérémie! And congrats on your first Symfony Docs contribution!

javiereguiluz added a commit that referenced this pull request Dec 9, 2019
…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
@javiereguiluz javiereguiluz merged commit e2d1c06 into symfony:4.4 Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants