Debian Codegraph @

lib/3rdParty/composer/symfony/serializer/SerializerInterface.php

raw symbols SCIP
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Serializer;
13
14 use Symfony\Component\Serializer\Exception\ExceptionInterface;
15 use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
16 use Symfony\Component\Serializer\Exception\UnexpectedValueException;
17
18 /**
19 * @author Jordi Boggiano <[email protected]>
20 */
21 interface SerializerInterface
22 {
23 /**
24 * Serializes data in the appropriate format.
25 *
26 * @param array<string, mixed> $context Options normalizers/encoders have access to
27 *
28 * @throws NotNormalizableValueException Occurs when a value cannot be normalized
29 * @throws UnexpectedValueException Occurs when a value cannot be encoded
30 * @throws ExceptionInterface Occurs for all the other cases of serialization-related errors
31 */
32 public function serialize(mixed $data, string $format, array $context = []): string;
33
34 /**
35 * Deserializes data into the given type.
36 *
37 * @template TObject of object
38 * @template TType of string|class-string<TObject>
39 *
40 * @param TType $type
41 * @param array<string, mixed> $context
42 *
43 * @phpstan-return ($type is class-string<TObject> ? TObject : mixed)
44 *
45 * @psalm-return (TType is class-string<TObject> ? TObject : mixed)
46 *
47 * @throws NotNormalizableValueException Occurs when a value cannot be denormalized
48 * @throws UnexpectedValueException Occurs when a value cannot be decoded
49 * @throws ExceptionInterface Occurs for all the other cases of serialization-related errors
50 */
51 public function deserialize(mixed $data, string $type, string $format, array $context = []): mixed;
52 }