Normalizes input options.
@param array $options the options.
@return array the normalized options.
492407
protected static function normalizeInputOptions($options)
    {
        self::addSpanClass($options);
        self::addTextAlignClass($options);
        $size = TbArray::popValue('size', $options);
        if (TbArray::popValue('block', $options, false)) {
            self::addCssClass('input-block-level', $options);
        } else {
            if (!empty($size)) {
                self::addCssClass('input-' . $size, $options);
            }
        }
        return $options;
    }
1103780
protected function prepareOptions($options)
    {
        $opts = array_change_key_case($options, CASE_UPPER);
        $finalizedOpts = array();

        if (!empty($opts['WITHSCORES'])) {
            $finalizedOpts[] = 'WITHSCORES';
        }

        return $finalizedOpts;
    }
1077917
protected function mergeOptions(array $options)
    {
        $defaults = $options + $this->defaultOptions;
        $defaults['params'] = [];
        if (!$defaults['filter_action'] || $this->application->input->{$defaults['method']}($defaults['action']) === $defaults['filter_action']) {
            //Action filter
            //cleaning post/get data
            foreach ($defaults['filters'] as $params => $column) {
                switch ($defaults['method']) {
                    case 'get':
                        if (isset($_GET[$params])) {
                            if (is_array($_GET[$params])) {
                                $_GET[$params] = array_filter(
                                    $_GET[$params],
                                    function ($value) {
                                        return (trim($value) !== '');
                                    }
                                );
                                if (empty($_GET[$params])) {
                                    unset($_GET[$params]);
                                }
                            } elseif (trim($_GET[$params]) === '') {
                                unset($_GET[$params]);
                            }
                        }
                        break;
                    case 'post':
                        if (isset($_POST[$params]) && trim($_POST[$params]) === '') {
                            if (is_array($_POST[$params])) {
                                $_POST[$params] = array_filter(
                                    $_POST[$params],
                                    function ($value) {
                                        return (trim($value) !== '');
                                    }
                                );
                                if (empty($_POST[$params])) {
                                    unset($_POST[$params]);
                                }
                            } elseif (trim($_POST[$params]) === '') {
                                unset($_POST[$params]);
                            }
                            unset($_POST[$params]);
                        }
                        break;
                }
            }
            $defaults['params'] = array_intersect_key($this->application->input->{$defaults['method']}(), $defaults['filters']);
        } elseif ($this->application->input->{$defaults['method']}($defaults['action']) === $defaults['reset_action']) {
            foreach ($defaults['filters'] as $params => $callback) {
                switch ($defaults['method']) {
                    case 'get':
                        unset($_GET[$params]);
                        break;
                    case 'post':
                        unset($_POST[$params]);
                        break;
                }
            }
            //Reset action
            $defaults['params'] = $defaults['default_filters'];
        } elseif ($defaults['save']) {
            $defaults['params'] = $this->application->session->userdata($options['save']);
        }

        // Si aucun filtre n'a été soumis (session non initialisé, filtre par défaut
        $session_exist = false;
        if ($defaults['save']) {
            $session_exist =  $this->application->session->has_userdata($options['save']);
        }
        if (empty($defaults['params']) && !$session_exist) {
             $defaults['params'] = $defaults['default_filters'];
        }
        return $defaults;
    }
448591
public function getFieldList($options = [])
    {
        $_options = [
            'normalize' => true,
        ];

        $options = Hash::merge($_options, $options);

        $list = [];

        foreach ($this->config() as $key => $value) {
            if (!in_array($key, $this->_presetConfigKeys) || is_integer($key)) {
                if (is_integer($key)) {
                    $field = $value;
                } else {
                    $field = $key;
                }

                if ($options['normalize']) {
                    $fieldConfig = $this->_normalizeField($field);
                } else {
                    $fieldConfig = (($this->config($field) == null) ? [] : $this->config($field));
                }

                $list[$field] = $fieldConfig;
            }
        }
        return $list;
    }
1048122
public function setOptions(array $options)
    {
        if ($options) {
            foreach ($options as $k => $v) {
                $this->options[$k] = $v;
            }
        }
        
        static::formatName();
        
        return $this;
    }
1006328
private function _options($options)
    {
        $result = array();

        // certain parameters have to occur first
        if (isset($options->unsigned)) {
            $result []= 'unsigned';
        }

        if (isset($options->zerofill)) {
            $result []= 'zerofill';
        }

        foreach ($options as $key=>$value) {
            switch ($key) {
                case 'primary':
                    $result [] = 'primary key';
                    break;

                case 'required':
                case 'notnull':
                    $result [] = 'not null';
                    break;

                case 'default':
                    $result []= sprintf("default '%s'", $value);
                    break;

                case 'sequence':
                case 'unsigned':
                case 'zerofill':
                case 'allowed':
                    break;

                default:
                    $result []= $key;
                    break;
            }
        }

        return implode(' ', $result);
    }
125508
public function normalizeParameters(array $parameters)
    {
        $normalized = [];

        // [1] Encode both the keys and values.
        // Decode it frist, in case the given data is already encoded.
        foreach ($parameters as $key => $value) {
            $key = rawurlencode(rawurldecode($key));

            if (is_array($value)) {
                $normalized[$key] = $this->normalizeParameters($value);
            } else {
                $normalized[$key] = rawurlencode(rawurldecode($value));
            }
        }

        // [2] Sort by the encoded key.
        ksort($normalized);

        return $normalized;
    }
1172905
static protected function normalizeOptions($options) {
		if ($options instanceof Traversable) {
			$options = iterator_to_array($options);
		}
		
		if (! is_array($options)) {
			throw new InvalidOptions('Options must be an array or a Traversable implementation');
		}
		
		return $options;
	}
333198
protected function resolveOptions(array $options = array())
    {
        $resolver = new OptionsResolver;
        $this->setDefaultOptions($resolver);

        if (!empty($this->options)) {
            $resolver->setDefaults($this->options);
        }

        return $resolver->resolve($options);
    }
551467
private function options(array $options = [])
    {
        $options['query'] = array_merge(
            [
                'protover' => $this->api_protover,
                'clientver' => $this->app_version,
                'client' => $this->app_client,
            ],
            isset($options['query']) ? $options['query'] : []
        );

        $options['headers'] = array_merge(
            [
                'User-Agent' => $this->app_code,
            ],
            isset($options['headers']) ? $options['headers'] : []
        );

        return $options;
    }
231441
private function configure(array $options = []): array
    {
        $resolver = new OptionsResolver();
        $resolver->setDefaults([
            'max_restarts' => 10,
        ]);

        $resolver->setAllowedTypes('max_restarts', 'int');

        return $resolver->resolve($options);
    }
1205418
protected function _mergeOptions($options) {
		if (!is_array($options)) {
			$type = $options;
			if (!$type) {
				$type = 'info';
			}
			$options = [
				'type' => $type,
			];
		}

		$options = $this->_transformCrudOptions($options);

		if (isset($options['element']) && !isset($options['type'])) {
			$options['type'] = $options['element'];
		}

		$options += ['type' => 'info'];
		$options += ['element' => $options['type']];

		$options += (array)$this->getConfig();

		return $options;
	}
490784
public function setOptions(array $options)
    {
        $this->validateOptions($options, $this->type);

        $this->options = $options;

        return $this;
    }
858455
public function setOptions(array $options)
    {
        $defaultOptions = [
            'primary' => false,
            'auto_increment' => false,
            'position' => null,
            'length' => null,
        ];

        $options = array_merge($defaultOptions, $options);

        if ($options['primary']) {
            $options['auto_increment'] = true;

            $this->signed = false;
            $this->allowNull = false;
        }

        $this->autoIncrement = $options['auto_increment'];
        $this->position = $options['position'];
        $this->length = $options['length'];
        $this->primary = $options['primary'];

        return $this;
    }
1250745
public function input($options = [])
    {
        if (is_string($options)) {
            $options = ['class' => $options];
        }

        $input = new Input($this->expression('input'), $options);

        return $input;
    }
1111498
public function setOptions(array $options)
    {
        foreach ($options as $option => $value) {
            $this->setOption($option, $value);
        }

        return $this;
    }
225935
public static function acceptsOptions( array $options )
    {
        $tl = strlen( static::TYPE );

        return isset( $options['type'] ) && (
            static::TYPE == $options['type'] || (
                strlen( $options['type'] ) > $tl &&
                ( static::TYPE . '.' ) == substr( $options['type'], 0, $tl + 1 )
            )
        );
    }