Normalizes arrays.

@param array $value

@return array|string
508813
protected function normalizeArray($value)
    {
        switch (true) {
            case $this->checkFlag(self::ARRAY_MODE_ARRAY):
            default:
                foreach ($value as &$v) {
                    if (is_array($v)) {
                        throw new RendererException('Multi-dimensional arrays are not supported by this array mode');
                    }

                    $v = $this->normalizeValue($v);
                }

                return $value;

                break;

            case $this->checkFlag(self::ARRAY_MODE_CONCAT):
                foreach ($value as &$v) {
                    $v = trim($this->normalizeValue($v), '"'); // We don't want string normalization here
                }

                return $this->normalizeValue(implode(',', $value));

                break;
        }
    }
1106978
public function normalizeValue($value)
    {
        $value = $this->coerceForExpression($this->reduce($value));

        switch ($value[0]) {
            case Type::T_LIST:
                $value = $this->extractInterpolation($value);

                if ($value[0] !== Type::T_LIST) {
                    return [Type::T_KEYWORD, $this->compileValue($value)];
                }

                foreach ($value[2] as $key => $item) {
                    $value[2][$key] = $this->normalizeValue($item);
                }

                return $value;

            case Type::T_STRING:
                return [$value[0], '"', [$this->compileStringContent($value)]];

            case Type::T_NUMBER:
                return $value->normalize();

            case Type::T_INTERPOLATE:
                return [Type::T_KEYWORD, $this->compileValue($value)];

            default:
                return $value;
        }
    }
812225
private function normalizeValue($value, string $type)
    {
        if (Types::ID === $type && $value) {
            if (\is_array($value)) {
                $idsArray = [];
                foreach ($value as $id) {
                    if ($id) {
                        $idsArray[] = $this->decodeID($id);
                    }
                }
                $value = $idsArray;
            } else {
                $value = $this->decodeID($value);
            }
        }

        return $value;
    }
531257
public function prepend($value)
	{
		$value = $this->normalizeValue($value);

		array_unshift($this->items, $value);

		return $value;
	}
1374732
protected function normalize($value)
    {
        if ($value instanceof Exception) {
            $value = [
                'class'     => get_class($value),
                'message'   => $value->getMessage(),
                'code'      => $value->getCode(),
                'file'      => $value->getFile(),
                'line'      => $value->getLine(),
            ];
        }

        return $value;
    }
697852
protected function generateArrayValue(array $value)
    {
        $value = $this->prepareArrayValue($value);
        $outputMode = count($value) > 1 ? $this->outputMode : self::OUTPUT_SINGLE_LINE;

        $code = 'array(';
        if ($outputMode === self::OUTPUT_MULTI_LINE) {
            $code .= $this->getLineFeed() . $this->getIndentation() . $this->getIndentationString() . $this->getIndentationString();
        }

        $outputParts = array();
        $noKeyIndex = 0;
        foreach ($value as $n => $v) {
            $v->setIndentationLevel($this->getIndentationLevel() + 1);
            $v->setOutputMode($this->outputMode);
            $partV = $v->generate();
            if ($n === $noKeyIndex) {
                $outputParts[] = $partV;
                $noKeyIndex++;
            } else {
                $outputParts[] = (is_int($n) === true ? $n : $this->escapeStringValue($n)) . ' => ' . $partV;
            }
        }

        if ($outputMode === self::OUTPUT_MULTI_LINE) {
            $padding = $this->getLineFeed() . $this->getIndentation() . $this->getIndentationString() . $this->getIndentationString();
        } else {
            $padding = ' ';
        }

        $code .= implode(',' . $padding, $outputParts);
        if ($outputMode === self::OUTPUT_MULTI_LINE) {
            $code .= $this->getLineFeed() . $this->getIndentation() . $this->getIndentationString();
        }
        $code .= ')';

        return $code;
    }
832144
protected function normalizeValue($value)
    {
        if (false === $value) {
            return $value;
        }

        $value = $this->remapXml($value);

        $normalized = [];
        foreach ($value as $name => $val) {
            if (isset($this->children[$name])) {
                try {
                    $normalized[$name] = $this->children[$name]->normalize($val);
                } catch (UnsetKeyException $e) {
                }
                unset($value[$name]);
            } elseif (!$this->removeExtraKeys) {
                $normalized[$name] = $val;
            }
        }

        // if extra fields are present, throw exception
        if (\count($value) && !$this->ignoreExtraKeys) {
            $proposals = array_keys($this->children);
            sort($proposals);
            $guesses = [];

            foreach (array_keys($value) as $subject) {
                $minScore = INF;
                foreach ($proposals as $proposal) {
                    $distance = levenshtein($subject, $proposal);
                    if ($distance <= $minScore && $distance < 3) {
                        $guesses[$proposal] = $distance;
                        $minScore = $distance;
                    }
                }
            }

            $msg = sprintf('Unrecognized option%s "%s" under "%s"', 1 === \count($value) ? '' : 's', implode(', ', array_keys($value)), $this->getPath());

            if (\count($guesses)) {
                asort($guesses);
                $msg .= sprintf('. Did you mean "%s"?', implode('", "', array_keys($guesses)));
            } else {
                $msg .= sprintf('. Available option%s %s "%s".', 1 === \count($proposals) ? '' : 's', 1 === \count($proposals) ? 'is' : 'are', implode('", "', $proposals));
            }

            $ex = new InvalidConfigurationException($msg);
            $ex->setPath($this->getPath());

            throw $ex;
        }

        return $normalized;
    }
973048
protected function normalizeOptions(array $options, array $value)
    {
        return $options['select2']['enabled']
            ? array_merge($value, [
                'error_bubbling' => false,
                'multiple' => false,
                'select2' => array_merge($options['select2'], [
                    'tags' => $options['allow_add'],
                ]),
            ])
            : $value;
    }
683270
public function makeArrayFieldValue($value)
    {
        $value = $this->_unserializeValue($value);
        if (!$this->_isEncodedArrayFieldValue($value)) {
            $value = $this->_encodeArrayFieldValue($value);
        }

        return $value;
    }
229184
public function normalizeArray(array $array)
    {
        $normal = [];

        foreach ($array as $action => $config) {
            if (is_string($config)) {
                $config = ['className' => $config];
            }

            if (is_int($action)) {
                list(, $action) = pluginSplit($config['className']);
            }

            $action = Inflector::variable($action);
            $normal[$action] = $config;
        }

        return $normal;
    }
1301872
protected function normalizeValue($value)
    {
        if (false === $value) {
            return $value;
        }

        $value = $this->remapXml($value);

        $isAssoc = array_keys($value) !== range(0, \count($value) - 1);
        $normalized = [];
        foreach ($value as $k => $v) {
            if (null !== $this->keyAttribute && \is_array($v)) {
                if (!isset($v[$this->keyAttribute]) && \is_int($k) && !$isAssoc) {
                    $ex = new InvalidConfigurationException(sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath()));
                    $ex->setPath($this->getPath());

                    throw $ex;
                } elseif (isset($v[$this->keyAttribute])) {
                    $k = $v[$this->keyAttribute];

                    // remove the key attribute when required
                    if ($this->removeKeyAttribute) {
                        unset($v[$this->keyAttribute]);
                    }

                    // if only "value" is left
                    if (array_keys($v) === ['value']) {
                        $v = $v['value'];
                        if ($this->prototype instanceof ArrayNode && ($children = $this->prototype->getChildren()) && \array_key_exists('value', $children)) {
                            $valuePrototype = current($this->valuePrototypes) ?: clone $children['value'];
                            $valuePrototype->parent = $this;
                            $originalClosures = $this->prototype->normalizationClosures;
                            if (\is_array($originalClosures)) {
                                $valuePrototypeClosures = $valuePrototype->normalizationClosures;
                                $valuePrototype->normalizationClosures = \is_array($valuePrototypeClosures) ? array_merge($originalClosures, $valuePrototypeClosures) : $originalClosures;
                            }
                            $this->valuePrototypes[$k] = $valuePrototype;
                        }
                    }
                }

                if (\array_key_exists($k, $normalized)) {
                    $ex = new DuplicateKeyException(sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath()));
                    $ex->setPath($this->getPath());

                    throw $ex;
                }
            }

            $prototype = $this->getPrototypeForChild($k);
            if (null !== $this->keyAttribute || $isAssoc) {
                $normalized[$k] = $prototype->normalize($v);
            } else {
                $normalized[] = $prototype->normalize($v);
            }
        }

        return $normalized;
    }
174749
def normalize_value(values)
      Array.wrap(values).map do |value|
        value.is_a?(String) ? value.gsub("\n", "") : value
      end
    end
456465
private function sanitize($value)
    {
        if ($value === null) {
            $value = 'null';
        }

        if (is_array($value)) {
            $value = 'array';
        }

        if (is_bool($value)) {
            $value = $value
                ? 'true'
                : 'false';
        }

        return $value;
    }
334152
protected function serializeArray(array $value)
    {
        if (\array_key_exists(self::MAP_TYPE, $value)) {
            return $value;
        }

        $toArray = [self::MAP_TYPE => 'array', self::SCALAR_VALUE => []];
        foreach ($value as $key => $field) {
            $toArray[self::SCALAR_VALUE][$key] = $this->serializeData($field);
        }

        return $this->serializeData($toArray);
    }
1090192
public function reverseTransform($value)
    {
        return is_array($value) && array_key_exists($this->name, $value) ? $value[$this->name] : array();
    }
336314
protected function serializeObject(array $value)
    {
        $value = $this->transformUnmappedObjectsToArray($value);
        $value = $this->preSerialization($value);
        $data = $this->serialization($value);

        return $this->postSerialization($data);
    }
780458
protected function normalizeStringList($value)
    {
        if (is_string($value)) {
            $strings = preg_split('/\s+/', $value, -1, PREG_SPLIT_NO_EMPTY);
        } elseif (is_array($value)) {
            $strings = array_map('trim', array_map('strval', $value));
        } else {
            $strings = [];
        }

        return array_values(array_unique(array_map('strtolower', $strings)));
    }