diff --git a/src/Plugins/Concerns/HandleArguments.php b/src/Plugins/Concerns/HandleArguments.php index 9cf5e606a..beb80e384 100644 --- a/src/Plugins/Concerns/HandleArguments.php +++ b/src/Plugins/Concerns/HandleArguments.php @@ -44,16 +44,20 @@ public function pushArgument(string $argument, array $arguments): array /** * Pops the given argument from the arguments. + * Pops the given argument from the arguments and returns a re-indexed array. * * @param array $arguments * @return array */ public function popArgument(string $argument, array $arguments): array { - $arguments = array_flip($arguments); + $key = array_search($argument, $arguments, true); - unset($arguments[$argument]); + if ($key !== false) { + unset($arguments[$key]); + } + + return array_values($arguments); - return array_values(array_flip($arguments)); } } diff --git a/src/Plugins/Coverage.php b/src/Plugins/Coverage.php index 712f5de55..5e2999611 100644 --- a/src/Plugins/Coverage.php +++ b/src/Plugins/Coverage.php @@ -17,6 +17,8 @@ */ final class Coverage implements AddsOutput, HandlesArguments { + use Concerns\HandleArguments; + private const string COVERAGE_OPTION = 'coverage'; private const string MIN_OPTION = 'min'; @@ -70,11 +72,9 @@ public function handleArguments(array $originals): array return false; }))]; - $originals = array_flip($originals); foreach ($arguments as $argument) { - unset($originals[$argument]); + $originals = $this->popArgument($argument, $originals); } - $originals = array_flip($originals); $inputs = []; $inputs[] = new InputOption(self::COVERAGE_OPTION, null, InputOption::VALUE_NONE);