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

Conversation

Projects
None yet
4 participants
@ro0NL
Contributor

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)));

This comment has been minimized.

@ro0NL

ro0NL Nov 11, 2017

Contributor

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 ;)

@ro0NL

ro0NL Nov 11, 2017

Contributor

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

fabpot approved these changes Nov 12, 2017

@fabpot

This comment has been minimized.

Show comment
Hide comment
@fabpot

fabpot Nov 12, 2017

Member

Thank you @ro0NL.

Member

fabpot commented Nov 12, 2017

Thank you @ro0NL.

@fabpot fabpot merged commit 965b5b5 into symfony:2.7 Nov 12, 2017

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
fabbot.io Your code looks good.
Details

fabpot added a commit that referenced this pull request Nov 12, 2017

bug #24929 [Console] Fix traversable autocomplete values (ro0NL)
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 ro0NL:console/traversable-autocomplete branch Nov 12, 2017

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