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

Fix notice and warnings: #1

Closed
wants to merge 1 commit into from
Closed

Fix notice and warnings: #1

wants to merge 1 commit into from

Conversation

parap
Copy link

@parap parap commented Mar 22, 2012

(Undefined index:argv; array_shift() expects parameter 1 to be array, null given)

 (Undefined index:argv; array_shift() expects parameter 1 to be array, null given)
@stof
Copy link
Member

stof commented Apr 4, 2012

pull requests should be sent to symfony/symfony. The subtree splits are marked as read-only in their description, which means that only the cron job updating them from the symfony repo writes in them.

there is currently a discussion to see if it could be possible to accept pull requests coming both ways but we haven't set up the needed tools yet (or even figured if it can be done reliably)

@parap parap closed this Apr 4, 2012
fabpot added a commit that referenced this pull request May 20, 2015
…gizanagi)

This PR was merged into the 2.7 branch.

Discussion
----------

[Console] Fix first choice was invalid when using value

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

This PR solves the following issues encountered using question helper and choices questions:
- First choice was not selectable by value.
- ChoiceList with associative choices with mixed string and int keys has same issue with first choice.
- Fix inconsistency by always returning values as strings.

First point exemple:
![screenshot 2015-05-15 a 17 16 12](https://cloud.githubusercontent.com/assets/2211145/7655757/3344b39a-fb26-11e4-9fe7-0775616619bf.PNG)

Last two points are mainly edge cases. Indeed, if a QuestionChoice has something like :
```php
array(
    '0' => 'No environment',
    '1' => 'My environment 1',
    'env_2' => 'My environment 2',
    3 => 'My environment 3',
);
```
as choices, you will not be able to select the first choice and get an `InvalidArgumentException`:

```
There were 2 errors:

1) Symfony\Component\Console\Tests\Helper\QuestionHelperTest::testChoiceFromChoicelistWithMixedKeys with data set #0 ('0', '0')
InvalidArgumentException: Value "0" is invalid

2) Symfony\Component\Console\Tests\Helper\QuestionHelperTest::testChoiceFromChoicelistWithMixedKeys with data set #1 ('No environment', '0')
InvalidArgumentException: Value "No environment" is invalid
```

Moreover, even if you were able to select by value (`No environment`), you'll get an integer instead of a string:
```
Failed asserting that '0' is identical to 0.
```
For more consistency, the solution is to always return a string.

The issue does not exist in 2.6, as the `QuestionChoice::getDefaultValidator` handled things differently.

Commits
-------

03e4ab6 [Console] Fix first choice was invalid when using value
danepowell added a commit to danepowell/console that referenced this pull request Apr 24, 2023
symfony-splitter pushed a commit that referenced this pull request Apr 28, 2023
* 5.4:
  trim(): Argument #1 () must be of type string, bool given
  [Dumper] Trim leading newlines when checking if value begins with a space
  Fix the list of supported shells for completions in a phar
symfony-splitter pushed a commit that referenced this pull request Apr 28, 2023
* 6.2:
  Fix test class name
  trim(): Argument #1 () must be of type string, bool given
  Check if trace.curlCommand is defined in profiler
  [Dumper] Trim leading newlines when checking if value begins with a space
  [FrameworkBundle] Make service edges unique
  Fix the list of supported shells for completions in a phar
  Fix the usage of the zsh completion through the fpath discovery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants