8000 [Console] added a better way to ask questions to the user by romainneutron · Pull Request #10606 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console] added a better way to ask questions to the user #10606

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 2 commits into from
Apr 2, 2014

Conversation

romainneutron
Copy link
Contributor
Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR not yet

This PR replaces #9811

  • add missing phpdocs
  • add unit tests
  • submit doc PR

@cordoval
Copy link
Contributor
cordoval commented Apr 1, 2014

rather than "not yet", maybe add a checkbox list with the TODO items

@romainneutron
Copy link
Contributor Author

@stof I'm working on your comment #9811 (comment)
It does not seem possible to inject the InputInterface in QuestionHelper constructor as it's built in Application constructor.

Do you have an idea about doing something different than what's been done in #8452?

@stof
Copy link
Member
stof commented Apr 1, 2014

given that it is a new class (and so no BC concern), it would make sense to pass the input as an argument along the output IMO. We are already passing the output because we need to display the question. It would make sense to pass the input as well given that we are dealing with asking for input

@romainneutron
Copy link
Contributor Author

Alright, I've passed InputInterface and OutputInterface in the const 8000 ructor (as we do in the latest Table helper)

@stof
Copy link
Member
stof commented Apr 1, 2014

The Table helper is different. This QuestionHelper is designed as a stateless service object (registered in the HelperSet) while the Table object is a stateful one-time object (you create a new Table instance for each table you render). This is why passing them as arguments might be better.
The QuestionHelper is a good fit for the HelperSet because it does not hold configuration and so can be called several times without side-effects. It would be good to keep it this way (the QuestionHelper should be registered in the HelperSet btw).

I think that the concept of HelperSet could be deprecated in 3.0 if we push toward using DI in commands (the HelperSet is just a service locator); However, for this to be useful, we will probably need to change a bit the architecture: the output implementation is currently a service able to output text, not a value object representing the output like the Response is in Symfony. However, it is a scoped service as it is passed to the run() method (or more often created inside the run() method using the default implementation). The input is a value object on the other hand, but it also holds some additional property which would impact other code (the interactive mode, set by options registered by the Application rather than input dedicated to the command, which would actually be seen as scoped parameters as well). This is why we suffer to have helpers depending on the input and output. The console component is not built to help using DI with it.

@stof
Copy link
Member
stof commented Apr 1, 2014

related to my previous comment, if you look at PhpSpec and Behat, which are both complex command-line apps requiring to be able to push output in different places (for instance in event listeners), they are both injecting the output as a synthetic service, which is what it really is (the input is not a service in them either)

@romainneutron romainneutron changed the title [WIP][Console] added a better way to ask questions to the user [Console] added a better way to ask questions to the user Apr 2, 2014
@romainneutron
Copy link
Contributor Author

Hello, I've addressed comments and added unit tests.
This PR is ready for review, only doc PR is missing

@romainneutron
Copy link
Contributor Author

I just added a fix to the question implementation : When using a ChoiceQuestion, the result is not the index of the choice anymore, but its value.

fabpot added a commit that referenced this pull request Apr 2, 2014
…ser (fabpot, romainneutron)

This PR was merged into the 2.5-dev branch.

Discussion
----------

[Console] added a better way to ask questions to the user

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | not yet

This PR replaces #9811

- [x] add missing phpdocs
- [x] add unit tests
- [ ] submit doc PR

Commits
-------

336bba2 [Console] Add docblocks and unit tests to QuestionHelper
c413f89 [Console] added a better way to ask questions to the user
@fabpot fabpot merged commit 336bba2 into symfony:master Apr 2, 2014
@romainneutron romainneutron mentioned this pull request Apr 2, 2014
fabpot added a commit that referenced this pull request Apr 2, 2014
This PR was merged into the 2.5-dev branch.

Discussion
----------

Fix travis build

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT

Since #10287 and #10606 have been merged, errors occur in FrameworkBundle and Console component. This patch solves this. After merging 2.4 in master (that would fix Process suite), everything should be green.

Commits
-------

099e480 Fix travis build
* @param OutputInterface $output
* @param Question $question
*
* @return bool|mixed|null|string
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't mixed imply the others?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes

weaverryan added a commit to symfony/symfony-docs that referenced this pull request Apr 12, 2014
…eutron)

This PR was merged into the master branch.

Discussion
----------

[Console] Add documentation for QuestionHelper

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes (symfony/symfony#10606)
| Applies to    | 2.5+

This is the documentation for the new Question Helper

Commits
-------

f4ee337 [Console] Add documentation for QuestionHelper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0