Skip to content

[Console] Fix undefined offset when formatting namespace suggestions #9624

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

Closed
wants to merge 1 commit into from

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Nov 26, 2013

preg_grep returns an array indexed using the keys from the input array. array_values is used in the method find, but was missing in findNamespace.

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #9614
License MIT
Doc PR n/a

Edit: should be merged to 2.4

@@ -515,8 +515,8 @@ public function findNamespace($namespace)
}

$exact = in_array($namespace, $namespaces, true);
if (1 < count($namespaces) && !$exact) {
throw new \InvalidArgumentException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions($namespaces)));
if (count($namespaces) > 1 && !$exact) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you revert the condition change?

Copy link
Contributor

Choose a reason for hiding this comment

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

@fabpot this change makes the condition consistent with the other one in this class:

        if (count($commands) > 1 && !$exact) {
            $suggestions = $this->getAbbreviationSuggestions(array_values($commands));

            throw new \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions));
        }

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, that was to be coherent with the method find

fabpot added a commit that referenced this pull request Nov 27, 2013
…ggestions (GromNaN)

This PR was submitted for the master branch but it was merged into the 2.4 branch instead (closes #9624).

Discussion
----------

[Console] Fix undefined offset when formatting namespace suggestions

[`preg_grep`](http://www.php.net/manual/en/function.preg-grep.php) returns an array indexed using the keys from the input array. `array_values` is used in the method `find`, but was missing in `findNamespace`.

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

Edit: should be merged to 2.4

Commits
-------

f5c4011 [Console] Fix undefined offset when formatting namespace suggestions
@fabpot fabpot closed this Nov 27, 2013
@GromNaN GromNaN deleted the fix-9614 branch November 27, 2013 09:38
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.

3 participants