Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/44' into develop
Browse files Browse the repository at this point in the history
Close #44
Fixes #43
  • Loading branch information
weierophinney committed Feb 4, 2019
2 parents 0a2bd8e + ae45d9a commit dc2167e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed

- Nothing.
- [#44](https://github.com/zendframework/zend-console/pull/44) fixes usage of `array_unique()` within the `DefaultRouteMatcher` to
properly re-assign the array when invoked.

## 2.7.1 - TBD

Expand Down
8 changes: 4 additions & 4 deletions src/RouteMatcher/DefaultRouteMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ protected function parseDefinition($def)
$options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY);

// remove dupes
array_unique($options);
$options = array_unique($options);

// prepare item
$item = [
Expand Down Expand Up @@ -343,7 +343,7 @@ protected function parseDefinition($def)
$options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY);

// remove dupes
array_unique($options);
$options = array_unique($options);

// prepare item
$item = [
Expand Down Expand Up @@ -381,7 +381,7 @@ protected function parseDefinition($def)
$options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY);

// remove dupes
array_unique($options);
$options = array_unique($options);

// remove prefix
array_walk($options, function (&$val) {
Expand Down Expand Up @@ -424,7 +424,7 @@ protected function parseDefinition($def)
$options = preg_split('/ *\| */', trim($m['options']), 0, PREG_SPLIT_NO_EMPTY);

// remove dupes
array_unique($options);
$options = array_unique($options);

// remove prefix
array_walk($options, function (&$val) {
Expand Down
14 changes: 14 additions & 0 deletions test/RouteMatcher/DefaultRouteMatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ public static function routeProvider()
['--baz'],
null
],
'mandatory-long-flag-alternative-duplicates' => [
'(--foo | --foo | --bar)',
['--foo'],
[
'foo' => true,
'bar' => false,
'baz' => null,
]
],

// -- mandatory short flags
'mandatory-short-flag-no-match' => [
Expand Down Expand Up @@ -375,6 +384,11 @@ public static function routeProvider()
['foo','bar'],
['foo' => null, 'altGroup' => 'bar', 'bar' => true, 'baz' => false]
],
'mandatory-literal-namedAlternative-match-1-duplicates' => [
'foo ( bar | bar | baz ):altGroup',
['foo','bar'],
['foo' => null, 'altGroup' => 'bar', 'bar' => true, 'baz' => false]
],
'mandatory-literal-namedAlternative-match-2' => [
'foo ( bar | baz ):altGroup9',
['foo','baz'],
Expand Down

0 comments on commit dc2167e

Please sign in to comment.