public function addAllowedValues($option, $allowedValues)
    {
        if ($this->locked) {
            throw new AccessException('Allowed values cannot be added from a lazy option or normalizer.');
        }

        if (!isset($this->defined[$option])) {
            throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
        }

        if (!\is_array($allowedValues)) {
            $allowedValues = [$allowedValues];
        }

        if (!isset($this->allowedValues[$option])) {
            $this->allowedValues[$option] = $allowedValues;
        } else {
            $this->allowedValues[$option] = array_merge($this->allowedValues[$option], $allowedValues);
        }

        // Make sure the option is processed
        unset($this->resolved[$option]);

        return $this;
    }
public function addAllowedValues($option, $allowedValues)
    {
        if ($this->locked) {
            throw new AccessException('Allowed values cannot be added from a lazy option or normalizer.');
        }

        if (!isset($this->defined[$option])) {
            throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
        }

        if (!\is_array($allowedValues)) {
            $allowedValues = [$allowedValues];
        }

        if (!isset($this->allowedValues[$option])) {
            $this->allowedValues[$option] = $allowedValues;
        } else {
            $this->allowedValues[$option] = array_merge($this->allowedValues[$option], $allowedValues);
        }

        // Make sure the option is processed
        unset($this->resolved[$option]);

        return $this;
    }
public function addAllowedValues ( $ option , $ allowedValues ) { if ( $ this -> locked ) { throw new AccessException ( 'Allowed values cannot be added from a lazy option or normalizer.' ) ; } if ( ! isset ( $ this -> defined [ $ option ] ) ) { throw new UndefinedOptionsException ( sprintf ( 'The option "%s" does not exist. Defined options are: "%s".' , $ option , implode ( '", "' , array_keys ( $ this -> defined ) ) ) ) ; } if ( ! \ is_array ( $ allowedValues ) ) { $ allowedValues = [ $ allowedValues ] ; } if ( ! isset ( $ this -> allowedValues [ $ option ] ) ) { $ this -> allowedValues [ $ option ] = $ allowedValues ; } else { $ this -> allowedValues [ $ option ] = array_merge ( $ this -> allowedValues [ $ option ] , $ allowedValues ) ; } // Make sure the option is processed unset ( $ this -> resolved [ $ option ] ) ; return $ this ; }
Adds allowed values for an option.

The values are merged with the allowed values defined previously.

Instead of passing values, you may also pass a closures with the
following signature:

function ($value) {
// return true or false
}

The closure receives the value as argument and should return true to
accept the value and false to reject the value.

@param string $option        The option name
@param mixed  $allowedValues One or more acceptable values/closures

@return $this

@throws UndefinedOptionsException If the option is undefined
@throws AccessException           If called from a lazy option or normalizer
Adds allowed values for an option .