@param object                          $object
@param string                          $contentType
@param NormalizerContextInterface|null $context
@param string                          $path

@return string
760510
public function serialize(
        $object,
        string $contentType,
        NormalizerContextInterface $context = null,
        $path = ''
    ): string {
        return $this->encoder->encode($this->normalizer->normalize($object, $context, $path), $contentType);
    }
1361222
protected function resolveType($object, MappingContext $context): string
    {
        $definition = $context->getDefinition();

        if ($definition->hasType()) {
            return $definition->getType();
        }

        return $this->typeHandler->getType($object, $context);
    }
664985
public function normalize($object, $format = null, array $context = []): array
    {
        $links = [];

        if (count($object->getRelations())) {
            $links = array_merge($links, $this->normalizer->normalize($object->getRelations(), $format, $context));
        }

        if (count($object->getActions())) {
            $links = array_merge($links, $this->normalizer->normalize($object->getActions(), $format, $context));
        }

        $data = [
            'message' => $object->getMessage(),
        ];

        if ($object->getPath()) {
            $data['path'] = $object->getPath();
        }

        if ($object->getIdentifier()) {
            $data['logref'] = $object->getIdentifier();
        }

        if (count($links)) {
            $data['_links'] = $links;
        }

        return $data;
    }
120930
public function normalize($object, $format = null, array $context = [])
    {
        $this->maxDepthHandler->handleMaxDepth($context);

        if ($this->byReferenceHandler->isByShortReference($context)) {
            return $this->getShortReference($object, $format, $context);
        }

        if ($this->byReferenceHandler->isByReference($context)) {
            return $this->getReference($object, $format, $context);
        }

        try {
            return parent::normalize($object, $format, $context);
        } catch (CircularReferenceException $e) {
            return $this->getShortReference($object, $format, $context);
        }
    }
688127
private function normalizeObject($object) : Expr\FuncCall
    {
        if ($object instanceof InjectorInterface) {
            return new Expr\FuncCall(new Expr\Variable('injector'));
        }
        $serialize = new Scalar\String_(\serialize($object));

        return new Expr\FuncCall(new Node\Name('unserialize'), [new Arg($serialize)]);
    }
760205
private function createNewObject(
        DenormalizationObjectMappingInterface $objectMapping,
        string $path,
        string $type = null
    ) {
        $factory = $objectMapping->getDenormalizationFactory($path, $type);
        $object = $factory();

        if (is_object($object)) {
            return $object;
        }

        $exception = DeserializerLogicException::createFactoryDoesNotReturnObject($path, gettype($object));

        $this->logger->error('deserialize: {exception}', ['exception' => $exception->getMessage()]);

        throw $exception;
    }
1206959
public function normalizeField(
        string $path,
        $object,
        NormalizerContextInterface $context,
        NormalizerInterface $normalizer = null
    ) {
        if (null === $normalizer) {
            throw SerializerLogicException::createMissingNormalizer($path);
        }

        if (null === $relatedObjects = $this->accessor->getValue($object)) {
            return null;
        }

        $values = [];
        foreach ($relatedObjects as $i => $relatedObject) {
            $subPath = $path.'['.$i.']';
            $values[$i] = $normalizer->normalize($relatedObject, $context, $subPath);
        }

        return $values;
    }
1161918
public function normalize($object, $format = null, array $context = array())
    {
        return $this->getNormalizer($object, $format)->normalize($object, $format, $context);
    }
507263
public function deserializeFieldType(GenericDeserializationVisitor $visitor, $contentAttributeValue, array $type, Context $context)
    {
        $facade = $visitor->getCurrentObject();
        if ($facade instanceof ContentAttributeFacade && null !== $facade->type) {
            if (isset($this->fieldTypes[$facade->type]) &&
                isset($this->fieldTypes[$facade->type]['deserialize_type'])
            ) {
                if ($this->fieldTypes[$facade->type]['deserialize_type'] == 'array' && is_scalar($contentAttributeValue)) {
                    $contentAttributeValue = array($contentAttributeValue);
                }

                return $visitor->getNavigator()->accept($contentAttributeValue, array('name' => $this->fieldTypes[$facade->type]['deserialize_type'], 'params' => array()), $context);
            }
        }

        return null;
    }
988947
public function serializeFieldType(GenericSerializationVisitor $visitor, $contentAttributeValue, array $type, Context $context)
    {
        return $visitor->getNavigator()->accept($contentAttributeValue, null, $context);
    }
711097
public function normalize($object, $format = null, array $context = [])
    {
        if (null !== $outputClass = $this->getOutputClass($this->getObjectClass($object), $context)) {
            return parent::normalize($object, $format, $context);
        }

        // Use resolved resource class instead of given resource class to support multiple inheritance child types
        $resourceClass = $this->resourceClassResolver->getResourceClass($object, $context['resource_class'] ?? null, true);
        $context = $this->initContext($resourceClass, $context);
        $iri = $this->iriConverter->getIriFromItem($object);
        $context['iri'] = $iri;
        $context['api_normalize'] = true;

        $metadata = $this->addJsonLdContext($this->contextBuilder, $resourceClass, $context);

        $data = parent::normalize($object, $format, $context);
        if (!\is_array($data)) {
            return $data;
        }

        $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);

        $metadata['@id'] = $iri;
        $metadata['@type'] = $resourceMetadata->getIri() ?: $resourceMetadata->getShortName();

        return $metadata + $data;
    }
615125
public function normalize($object, NormalizerContextInterface $context = null, string $path = ''): array
    {
        return $this->normalizer->normalize($object, $context, $path);
    }
40169
function normalizeObject(array $object, $path)
    {
        if (!isset($object['{DAV:}getcontentlength']) or $object['{DAV:}getcontentlength'] == "") {
            return ['type' => 'dir', 'path' => trim($path, '/')];
        }

        $result = Util::map($object, static::$resultMap);

        if (isset($object['{DAV:}getlastmodified'])) {
            $result['timestamp'] = strtotime($object['{DAV:}getlastmodified']);
        }

        $result['type'] = 'file';
        $result['path'] = trim($path, '/');

        return $result;
    }
715987
protected function normalizeRelation(PropertyMetadata $propertyMetadata, $relatedObject, string $resourceClass, ?string $format, array $context)
    {
        if (null === $relatedObject || !empty($context['attributes']) || $propertyMetadata->isReadableLink()) {
            if (null === $relatedObject) {
                unset($context['resource_class']);
            } else {
                $context['resource_class'] = $resourceClass;
            }

            if (!$this->serializer instanceof NormalizerInterface) {
                throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', NormalizerInterface::class));
            }

            return $this->serializer->normalize($relatedObject, $format, $context);
        }

        $iri = $this->iriConverter->getIriFromItem($relatedObject);
        if (isset($context['resources'])) {
            $context['resources'][$iri] = $iri;
        }
        if (isset($context['resources_to_push']) && $propertyMetadata->getAttribute('push', false)) {
            $context['resources_to_push'][$iri] = $iri;
        }

        return $iri;
    }
349118
public static function create($contentType, $content = '', $bodyStream = null)
    {
        /* @var ResponseInterface|MockInterface $response */
        $response = Mockery::mock(ResponseInterface::class);

        $response
            ->shouldReceive('getHeader')
            ->with('content-type')
            ->andReturn([
                $contentType,
            ]);

        $response
            ->shouldReceive('getHeaderLine')
            ->with('content-type')
            ->andReturn($contentType);

        if (empty($bodyStream)) {
            /* @var StreamInterface|Mock $bodyStream */
            $bodyStream = Mockery::mock(StreamInterface::class);
            $bodyStream
                ->shouldReceive('__toString')
                ->andReturn($content);
        }

        $response
            ->shouldReceive('getBody')
            ->andReturn($bodyStream);

        return $response;
    }
1117574
protected function normalizeListingObject($path, array $object)
    {
        $permissions = $this->normalizePermissions($object['permissions']);
        $type = isset($object['type']) && ($object['type'] === 2) ?  'dir' : 'file';

        $timestamp = $object['mtime'];

        if ($type === 'dir') {
            return compact('path', 'timestamp', 'type');
        }

        $visibility = $permissions & 0044 ? AdapterInterface::VISIBILITY_PUBLIC : AdapterInterface::VISIBILITY_PRIVATE;
        $size = (int) $object['size'];

        return compact('path', 'timestamp', 'type', 'visibility', 'size');
    }
242868
public function normalize($object, $format = null, array $context = [])
    {
        if (isset($context['api_sub_level'])) {
            return $this->normalizeRawCollection($object, $format, $context);
        }

        try {
            $resourceClass = $this->resourceClassResolver->getResourceClass($object, $context['resource_class'] ?? null, true);
        } catch (InvalidArgumentException $e) {
            if (!isset($context['resource_class'])) {
                return $this->normalizeRawCollection($object, $format, $context);
            }

            throw $e;
        }
        $data = $this->addJsonLdContext($this->contextBuilder, $resourceClass, $context);
        $context = $this->initContext($resourceClass, $context);

        if (isset($context['operation_type']) && OperationType::SUBRESOURCE === $context['operation_type']) {
            $data['@id'] = $this->iriConverter->getSubresourceIriFromResourceClass($resourceClass, $context);
        } else {
            $data['@id'] = $this->iriConverter->getIriFromResourceClass($resourceClass);
        }

        $data['@type'] = 'hydra:Collection';

        $data['hydra:member'] = [];
        foreach ($object as $obj) {
            $data['hydra:member'][] = $this->normalizer->normalize($obj, $format, $context);
        }

        $paginated = null;
        if (
            \is_array($object) ||
            ($paginated = $object instanceof PaginatorInterface) ||
            $object instanceof \Countable && !$object instanceof PartialPaginatorInterface
        ) {
            $data['hydra:totalItems'] = $paginated ? $object->getTotalItems() : \count($object);
        }

        return $data;
    }