public function resolve(array $options)
    {
        $resolver = new OptionsResolver();

        foreach ($this->options as $option) {
            $name = $option->getName();

            if ($option instanceof AliasedFixerOption) {
                $alias = $option->getAlias();

                if (\array_key_exists($alias, $options)) {
                    // @TODO 2.12 Trigger a deprecation notice and add a test for it
                    if (\array_key_exists($name, $options)) {
                        throw new InvalidOptionsException(sprintf('Aliased option %s/%s is passed multiple times.', $name, $alias));
                    }

                    $options[$name] = $options[$alias];
                    unset($options[$alias]);
                }
            }

            if ($option->hasDefault()) {
                $resolver->setDefault($name, $option->getDefault());
            } else {
                $resolver->setRequired($name);
            }

            $allowedValues = $option->getAllowedValues();
            if (null !== $allowedValues) {
                foreach ($allowedValues as &$allowedValue) {
                    if (\is_object($allowedValue) && \is_callable($allowedValue)) {
                        $allowedValue = function ($values) use ($allowedValue) {
                            return $allowedValue($values);
                        };
                    }
                }

                $resolver->setAllowedValues($name, $allowedValues);
            }

            $allowedTypes = $option->getAllowedTypes();
            if (null !== $allowedTypes) {
                $resolver->setAllowedTypes($name, $allowedTypes);
            }

            $normalizer = $option->getNormalizer();
            if (null !== $normalizer) {
                $resolver->setNormalizer($name, $normalizer);
            }
        }

        return $resolver->resolve($options);
    }
public function resolve(array $options)
    {
        $resolver = new OptionsResolver();

        foreach ($this->options as $option) {
            $name = $option->getName();

            if ($option instanceof AliasedFixerOption) {
                $alias = $option->getAlias();

                if (\array_key_exists($alias, $options)) {
                    
                    if (\array_key_exists($name, $options)) {
                        throw new InvalidOptionsException(sprintf('Aliased option %s/%s is passed multiple times.', $name, $alias));
                    }

                    $options[$name] = $options[$alias];
                    unset($options[$alias]);
                }
            }

            if ($option->hasDefault()) {
                $resolver->setDefault($name, $option->getDefault());
            } else {
                $resolver->setRequired($name);
            }

            $allowedValues = $option->getAllowedValues();
            if (null !== $allowedValues) {
                foreach ($allowedValues as &$allowedValue) {
                    if (\is_object($allowedValue) && \is_callable($allowedValue)) {
                        $allowedValue = function ($values) use ($allowedValue) {
                            return $allowedValue($values);
                        };
                    }
                }

                $resolver->setAllowedValues($name, $allowedValues);
            }

            $allowedTypes = $option->getAllowedTypes();
            if (null !== $allowedTypes) {
                $resolver->setAllowedTypes($name, $allowedTypes);
            }

            $normalizer = $option->getNormalizer();
            if (null !== $normalizer) {
                $resolver->setNormalizer($name, $normalizer);
            }
        }

        return $resolver->resolve($options);
    }
public function resolve ( array $ options ) { $ resolver = new OptionsResolver ( ) ; foreach ( $ this -> options as $ option ) { $ name = $ option -> getName ( ) ; if ( $ option instanceof AliasedFixerOption ) { $ alias = $ option -> getAlias ( ) ; if ( \ array_key_exists ( $ alias , $ options ) ) { // @TODO 2.12 Trigger a deprecation notice and add a test for it if ( \ array_key_exists ( $ name , $ options ) ) { throw new InvalidOptionsException ( sprintf ( 'Aliased option %s/%s is passed multiple times.' , $ name , $ alias ) ) ; } $ options [ $ name ] = $ options [ $ alias ] ; unset ( $ options [ $ alias ] ) ; } } if ( $ option -> hasDefault ( ) ) { $ resolver -> setDefault ( $ name , $ option -> getDefault ( ) ) ; } else { $ resolver -> setRequired ( $ name ) ; } $ allowedValues = $ option -> getAllowedValues ( ) ; if ( null !== $ allowedValues ) { foreach ( $ allowedValues as & $ allowedValue ) { if ( \ is_object ( $ allowedValue ) && \ is_callable ( $ allowedValue ) ) { $ allowedValue = function ( $ values ) use ( $ allowedValue ) { return $ allowedValue ( $ values ) ; } ; } } $ resolver -> setAllowedValues ( $ name , $ allowedValues ) ; } $ allowedTypes = $ option -> getAllowedTypes ( ) ; if ( null !== $ allowedTypes ) { $ resolver -> setAllowedTypes ( $ name , $ allowedTypes ) ; } $ normalizer = $ option -> getNormalizer ( ) ; if ( null !== $ normalizer ) { $ resolver -> setNormalizer ( $ name , $ normalizer ) ; } } return $ resolver -> resolve ( $ options ) ; }
{@inheritdoc}
{