@deprecated
Keeping this for compatibility reasons with older versions. Remove in next major. Use HalPagination object instead

@param $value

@return array
173687
protected function legacySerializeArray(array $value)
    {
        $data = ['total' => 0];
        unset($value[Serializer::MAP_TYPE]);
        foreach ($value[Serializer::SCALAR_VALUE] as $v) {
            $data[self::EMBEDDED_KEY][] = $this->serializeObject($v);
        }
        $data['total'] = count($data[self::EMBEDDED_KEY]);

        return $data;
    }
1046877
public function csvToArray($value)
    {
        if ($value === null) {
            return [];
        }

        $result = explode(',', $value);
        $result = array_map('trim', $result);
        $result = array_filter($result);

        return array_values($result);
    }
161455
private function deserializeValue($value)
    {
        if (is_array($value) && isset($value['class']) && isset($value['payload'])) {
            return $this->deserializeObjectRecursively($value);
        } elseif (is_array($value)) {
            return $this->deserializeArrayRecursively($value);
        }

        return $value;
    }
1145471
protected function stripAssignmentFlags(&$value)
    {
        $flags = [];

        for ($token = &$value; $token[0] === Type::T_LIST && ($s = count($token[2])); $token = &$lastNode) {
            $lastNode = &$token[2][$s - 1];

            while ($lastNode[0] === Type::T_KEYWORD && in_array($lastNode[1], ['!default', '!global'])) {
                array_pop($token[2]);

                $node = end($token[2]);

                $token = $this->flattenList($token);

                $flags[] = $lastNode[1];

                $lastNode = $node;
            }
        }

        return $flags;
    }
1280563
public function filter($value)
    {
        $list = parent::filter($value);

        $dashToCamelCaseFilter       = new DashToCamelCase();
        $underscoreToCamelCaseFilter = new UnderscoreToCamelCase();

        foreach ($list as $listKey => $listOption) {
            $listOption = $dashToCamelCaseFilter->filter($listOption);
            $listOption = $underscoreToCamelCaseFilter->filter($listOption);

            $list[$listKey] = $listOption;
        }

        return $list;
    }
695888
public function transform($value)
    {
        $sites = array();
        if (!empty($value)) {
            foreach ($value as $associatedSite) {
                $sites[] = $associatedSite['siteId'];
            }
        }
        return $sites;
    }
582302
public static function parseHeaderValue(string $value): array
    {
        $parts = \explode(';', $value);
        $type = \trim($parts[0]);
        unset($parts[0]);

        $parameters = [];
        foreach ($parts as $part) {
            [$k, $v] = \explode('=', $part, 2);

            $key = \strtolower(\trim($k));
            $parameters[$key] = \trim($v, ' "');
        }

        return [$type, $parameters];
    }
1280751
private static function convertToArrayAccess($value)
    {
        if ($value instanceof \ArrayAccess) {
            $array = $value;
        } elseif ($value instanceof \Traversable) {
            $array = SequenceType::convertToRewindable($value);
            if ($array instanceof \Traversable) {
                set_error_handler(function ($severity, $message) {
                    return $severity === E_WARNING
                        ? $message === 'Illegal offset type'
                        : preg_match('/^Resource ID#([0-9]+) used as offset, casting to integer \\(\\1\\)$/', $message);
                }, E_WARNING | (PHP_MAJOR_VERSION === 5 ? E_STRICT : E_NOTICE));
                $array = iterator_to_array($array);
                restore_error_handler();
            }
        } else {
            $array = (array)$value;
        }
        
        return $array;
    }
1162990
public function transform($value)
    {
        foreach ($this->groupRolesConfiguration as $tables) {
            foreach ($tables as $package => $rows) {
                foreach ($rows as $row => $roles) {
                    foreach ($roles as $role => $configuration) {
                        $result[$package][$row][$role] = is_array($value) ? in_array($role, $value) : false;
                    }
                }
            }
        }

        return array('roles_collections' => $result);
    }
1141967
public function extract($value)
    {
        if ($this->nullable && $value === null) {
            return null;
        }

        $return = [];
        if (is_array($value) || $value instanceof \Traversable) {
            foreach ($value as $key => $object) {
                $return[$key] = $this->hasOneStrategy->extract($object);
            }
        } else {
            throw new Exception\InvalidArgumentException(sprintf(
                'Value must be null (only if nullable option is enabled), or an array, or a Traversable: "%s" given',
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }

        return $return;
    }
564333
private function objectParam($value)
    {
        if ($value instanceof \stdClass) {
            throw new \InvalidArgumentException(
                'Values of type `\stdClass` are interpreted as structs and must define their types.'
            );
        }

        if ($value instanceof ValueInterface) {
            return [
                $this->typeObject($value->type()),
                $value->formatAsString()
            ];
        }

        if ($value instanceof Int64) {
            return [
                $this->typeObject(self::TYPE_INT64),
                $value->get()
            ];
        }

        throw new \InvalidArgumentException(sprintf(
            'Unrecognized value type %s. ' .
            'Please ensure you are using the latest version of google/cloud or google/cloud-spanner.',
            get_class($value)
        ));
    }
194777
public static function extractFromArray($value)
    {
        /**
         * @param array $filters
         *
         * @return array
         */
        $extractVoters = function (array $filters) {
            $voters = [];
            foreach ($filters as $filter) {
                if (is_array($filter)) {
                    $voters = array_merge($voters, array_keys($filter));
                }
            }

            return array_unique($voters);
        };

        $voters = [];
        if (isset($value['filters'])) {
            $voters = array_merge($voters, $extractVoters($value['filters']));
        }
        if (isset($value['breaker'])) {
            $voters = array_merge($voters, $extractVoters($value['breaker']));
        }
        if (isset($value['values'])) {
            foreach ($value['values'] as $valueValue) {
                if (isset($valueValue['filters'])) {
                    $voters = array_merge($voters, $extractVoters($valueValue['filters']));
                }
            }
        }

        return array_values(array_unique($voters));
    }
1098392
public function filter($value)
    {
        return in_array($value, $this->getList(), $this->getStrict()) ? $value : null;
    }
1311513
public function reverseTransform($value)
    {
        if (trim($value) == '') {
            return null;
        }

        $names = explode(',', $value);
        $class = $this->class;

        $tags = array();
        foreach ($names as $name) {
            $entity = $this->repository->findOneBy(array($this->property => $name));
            if (!$entity) {
                $entity = new $class();
                $this->propertyAccessor->setValue($entity, $this->property, $name);
            }

            $tags[] = $entity;
        }

        return $tags;
    }
974022
public function removeDealerBrandVersion($value)
    {
        $targetArray = array();
        foreach ($this->getDealerBrandVersions() as $element) {
            if ($element != $value) {
                $targetArray []= $element;
            }
        }
        $this->setDealerBrandVersions($targetArray);

        return $this;
    }
659972
private function prepareValues($value): array
    {
        if (!self::hasMultipleValues($this->name)) {
            $values = is_array($value) ? $value : [trim($value)];
        } elseif (!is_array($value)) {
            $values = explode(',', (string) $value);
        } else {
            $values = $value;
        }

        foreach (array_keys($values) as $key) {
            $values[$key] = trim($values[$key]);

            if ($values[$key] == '') {
                unset($values[$key]);
            }
        }

        return array_values(array_unique($values));
    }
1100025
private function getValues($value)
    {
        if (is_array($value)) {
            $newValue = [];

            foreach ($value as $itemValue) {
                $newValue = array_merge($newValue, $this->getValues($itemValue));
            }

            return [$newValue];
        }

        $metadataFactory = $this->em->getMetadataFactory();
        $unitOfWork      = $this->em->getUnitOfWork();

        if (is_object($value) && $metadataFactory->hasMetadataFor(StaticClassNameConverter::getClass($value))) {
            $class     = $metadataFactory->getMetadataFor(get_class($value));
            $persister = $unitOfWork->getEntityPersister($class->getClassName());

            if ($class->isIdentifierComposite()) {
                $newValue = [];

                foreach ($persister->getIdentifier($value) as $innerValue) {
                    $newValue = array_merge($newValue, $this->getValues($innerValue));
                }

                return $newValue;
            }
        }

        return [$this->getIndividualValue($value)];
    }