Debian Codegraph @

lib/3rdParty/composer/symfony/serializer/Normalizer/NormalizerInterface.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\Normalizer;
13
14 use Symfony\Component\Serializer\Exception\CircularReferenceException;
15 use Symfony\Component\Serializer\Exception\ExceptionInterface;
16 use Symfony\Component\Serializer\Exception\InvalidArgumentException;
17 use Symfony\Component\Serializer\Exception\LogicException;
18
19 /**
20 * @author Jordi Boggiano <[email protected]>
21 */
22 interface NormalizerInterface
23 {
24 /**
25 * Normalizes data into a set of arrays/scalars.
26 *
27 * @param mixed $data Data to normalize
28 * @param string|null $format Format the normalization result will be encoded as
29 * @param array<string, mixed> $context Context options for the normalizer
30 *
31 * @return array|string|int|float|bool|\ArrayObject|null \ArrayObject is used to make sure an empty object is encoded as an object not an array
32 *
33 * @throws InvalidArgumentException Occurs when the object given is not a supported type for the normalizer
34 * @throws CircularReferenceException Occurs when the normalizer detects a circular reference when no circular
35 * reference handler can fix it
36 * @throws LogicException Occurs when the normalizer is not called in an expected context
37 * @throws ExceptionInterface Occurs for all the other cases of errors
38 */
39 public function normalize(mixed $data, ?string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null;
40
41 /**
42 * Checks whether the given class is supported for normalization by this normalizer.
43 *
44 * @param mixed $data Data to normalize
45 * @param string|null $format The format being (de-)serialized from or into
46 * @param array<string, mixed> $context Context options for the normalizer
47 */
48 public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool;
49
50 /**
51 * Returns the types potentially supported by this normalizer.
52 *
53 * For each supported formats (if applicable), the supported types should be
54 * returned as keys, and each type should be mapped to a boolean indicating
55 * if the result of supportsNormalization() can be cached or not
56 * (a result cannot be cached when it depends on the context or on the data.)
57 * A null value means that the normalizer does not support the corresponding
58 * type.
59 *
60 * Use type "object" to match any classes or interfaces,
61 * and type "*" to match any types.
62 *
63 * @return array<class-string|'*'|'object'|string, bool|null>
64 */
65 public function getSupportedTypes(?string $format): array;
66 }