Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Console commands #45

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
lookyman merged 6 commits into master from commands
Apr 16, 2019
Merged

Console commands #45

lookyman merged 6 commits into master from commands
Apr 16, 2019

Conversation

Copy link
Collaborator

@lookyman lookyman commented Apr 9, 2019
edited
Loading

closes #20, closes #36

@mcfedr @Jean85 Can you guys test this?

mhujer reacted with thumbs up emoji mhujer and leongersen reacted with heart emoji
Copy link
Member

❤️ ❤️ ❤️

Copy link
Member

I'd like the symfony.container_xml_path to be nullable - we're using Symfony Console but without the Symfony DIC.

Copy link
Member

Basically the extension related to DIC should not do anything if this parameter is null :)

Copy link
Contributor

mhujer commented Apr 10, 2019

@lookyman Just tested it. Works great 👍

Command "demo:command" does not define argument "foobar".

29,
],
[
'Parameter #5 $default of method Symfony\Component\Console\Command\Command::addOption() expects string|false|null, int given.',
Copy link
Contributor

Choose a reason for hiding this comment

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

This appears to be wrong - the doc is

* @param string|string[]|int|bool|null $default The default value (must be null for InputOption::VALUE_NONE)

so i'm seeing this reported for my calls to to addOption where I'm passing int

Copy link
Contributor

Choose a reason for hiding this comment

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

Although its true that getOption has return type of string|string[]|bool|null - which will likely also be wrong in this case... maybe the symfony docblock needs to be fixed

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
Collaborator Author

Choose a reason for hiding this comment

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

The thing is, if you pass the option from the console, you can only ever get string there (or bool in case of VALUE_NONE, or null if you don't pass the option at all). You can pass a different type as a default, but that is imho wrong (as suggested by the docblock), and there is a rule that should forbid that.

Copy link
Collaborator Author

@lookyman lookyman Apr 11, 2019
edited
Loading

Choose a reason for hiding this comment

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

So there are two options here: 1) go with the docblock and just restrict it's allowed types based on the mode, or 2) union with the default's type, even if it's not allowed by the docblock. I went with the first approach. Do you suggest we should go with the second? I realize that the code does not forbid that, just the docblock, so it should be ok, I just don't think it's the intended behaviour. And I specifically added the Invalid(Argument|Option)DefaultValueRule for these cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interestingly this was just recently changed in Symfony - symfony/symfony#29201 - seems there is a bit of inconsistency here in the docblocks and the code, the ArgvInput, normally used will only ever give you strings, but the ArrayInput, often used for testing, lets you pass int (or whatever else).

I guess given the reality is your going to get strings out for real usage, might be best to stick with what you've done. Might be also be nice to check the args to ArrayInput are also strings([]) so users dont test with different types.

Copy link
Collaborator Author

@lookyman lookyman Apr 12, 2019
edited
Loading

Choose a reason for hiding this comment

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

You know what, I actually for some reason missed that the addOption method allows int in default. I guess I should reflect that after all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mcfedr done

mcfedr reacted with thumbs up emoji
Copy link
Collaborator Author

I'd like the symfony.container_xml_path to be nullable - we're using Symfony Console but without the Symfony DIC.

Basically the extension related to DIC should not do anything if this parameter is null :)

@ondrejmirtes done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
1 more reviewer

@mcfedr mcfedr mcfedr left review comments

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[Command] getOption return types Help getArgument/getOption in Symfony Console InputInterface

AltStyle によって変換されたページ (->オリジナル) /