src/Ulrichsg/Getopt/Getopt.php
private function mergeOptions(array $options)
    {
        /** @var Option[] $mergedList */
        $mergedList = array_merge($this->optionList, $options);
        $duplicates = array();
        foreach ($mergedList as $option) {
            foreach ($mergedList as $otherOption) {
                if (($option === $otherOption) || in_array($otherOption, $duplicates)) {
                    continue;
                }
                if ($this->optionsConflict($option, $otherOption)) {
                    throw new \InvalidArgumentException('Failed to add options due to conflict');
                }
                if (($option->short() === $otherOption->short()) && ($option->long() === $otherOption->long())) {
                    $duplicates[] = $option;
                }
            }
        }
        foreach ($mergedList as $index => $option) {
            if (in_array($option, $duplicates)) {
                unset($mergedList[$index]);
            }
        }
        $this->optionList = array_values($mergedList);
    }
private function mergeOptions(array $options)
    {
        /** @var Option[] $mergedList */
        $mergedList = array_merge($this->optionList, $options);
        $duplicates = array();
        foreach ($mergedList as $option) {
            foreach ($mergedList as $otherOption) {
                if (($option === $otherOption) || in_array($otherOption, $duplicates)) {
                    continue;
                }
                if ($this->optionsConflict($option, $otherOption)) {
                    throw new \InvalidArgumentException('Failed to add options due to conflict');
                }
                if (($option->short() === $otherOption->short()) && ($option->long() === $otherOption->long())) {
                    $duplicates[] = $option;
                }
            }
        }
        foreach ($mergedList as $index => $option) {
            if (in_array($option, $duplicates)) {
                unset($mergedList[$index]);
            }
        }
        $this->optionList = array_values($mergedList);
    }
private function mergeOptions ( array $ options ) { /** @var Option[] $mergedList */ $ mergedList = array_merge ( $ this -> optionList , $ options ) ; $ duplicates = array ( ) ; foreach ( $ mergedList as $ option ) { foreach ( $ mergedList as $ otherOption ) { if ( ( $ option === $ otherOption ) || in_array ( $ otherOption , $ duplicates ) ) { continue ; } if ( $ this -> optionsConflict ( $ option , $ otherOption ) ) { throw new \ InvalidArgumentException ( 'Failed to add options due to conflict' ) ; } if ( ( $ option -> short ( ) === $ otherOption -> short ( ) ) && ( $ option -> long ( ) === $ otherOption -> long ( ) ) ) { $ duplicates [ ] = $ option ; } } } foreach ( $ mergedList as $ index => $ option ) { if ( in_array ( $ option , $ duplicates ) ) { unset ( $ mergedList [ $ index ] ) ; } } $ this -> optionList = array_values ( $ mergedList ) ; }
Merges new options with the ones already in the Getopt optionList, making sure the resulting list is free of
conflicts.

@param Option[] $options The list of new options
@throws \InvalidArgumentException
Merges new options with the ones already in the Getopt optionList making sure the resulting list is free of conflicts .