diff --git a/src/RouteMatcher/DefaultRouteMatcher.php b/src/RouteMatcher/DefaultRouteMatcher.php index 07ffbd5..5654e30 100644 --- a/src/RouteMatcher/DefaultRouteMatcher.php +++ b/src/RouteMatcher/DefaultRouteMatcher.php @@ -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 = [ @@ -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 = [ @@ -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) { @@ -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) { diff --git a/test/RouteMatcher/DefaultRouteMatcherTest.php b/test/RouteMatcher/DefaultRouteMatcherTest.php index 76c3287..fe48d8b 100644 --- a/test/RouteMatcher/DefaultRouteMatcherTest.php +++ b/test/RouteMatcher/DefaultRouteMatcherTest.php @@ -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' => [ @@ -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'],