Skip to content
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

[Console] Fix traversable autocomplete values #24929

Merged
merged 1 commit into from Nov 12, 2017
Merged

[Console] Fix traversable autocomplete values #24929

merged 1 commit into from Nov 12, 2017

Conversation

ro0NL
Copy link
Contributor

@ro0NL ro0NL commented Nov 11, 2017

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #...
License MIT
Doc PR symfony/symfony-docs#...

Question::setAutocompleterValues implies passing a \Traversable value is allowed, yet it doesnt work :) It also restricts the traversable to be countable, which is not really needed (blocking pure API / iterable type as of 4.0).

@@ -134,7 +134,7 @@ public function doAsk(OutputInterface $output, Question $question)
$ret = trim($ret);
}
} else {
$ret = trim($this->autocomplete($output, $question, $inputStream));
$ret = trim($this->autocomplete($output, $question, $inputStream, is_array($autocomplete) ? $autocomplete : iterator_to_array($autocomplete, false)));
Copy link
Contributor Author

@ro0NL ro0NL Nov 11, 2017

Choose a reason for hiding this comment

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

passing false to iterator_to_array fixes

1) Symfony\Component\Console\Tests\Helper\QuestionHelperTest::testTraversableAutocomplete
Undefined offset: 3

src/Symfony/Component/Console/Helper/QuestionHelper.php:294

in case of assoc array keys (which we dont really care about)

of course using iterator_to_array fixes the offset access in the first place ;)

@fabpot
Copy link
Member

fabpot commented Nov 12, 2017

Thank you @ro0NL.

@fabpot fabpot merged commit 965b5b5 into symfony:2.7 Nov 12, 2017
fabpot added a commit that referenced this pull request Nov 12, 2017
This PR was merged into the 2.7 branch.

Discussion
----------

[Console] Fix traversable autocomplete values

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

`Question::setAutocompleterValues` implies passing a `\Traversable` value is allowed, yet it doesnt work :) It also restricts the traversable to be countable, which is not really needed (blocking pure API / iterable type as of 4.0).

Commits
-------

965b5b5 [Console] Fix traversable autocomplete values
@ro0NL ro0NL deleted the console/traversable-autocomplete branch November 12, 2017 16:13
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.

None yet

4 participants