1 | <?php |
||
24 | final class ObjectNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, CacheableSupportsMethodInterface |
||
25 | { |
||
26 | // To not use the current normalizer |
||
27 | const WONT_DENORMALIZE = 'dunglas_normalizer_wont_denormalize'; |
||
28 | const TYPE_FIELD = '#type'; |
||
29 | |||
30 | /** |
||
31 | * @var NormalizerInterface|DenormalizerInterface |
||
32 | */ |
||
33 | private $serializer; |
||
34 | private $objectNormalizer; |
||
35 | |||
36 | public function __construct(NormalizerInterface $objectNormalizer) |
||
44 | |||
45 | /** |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | public function normalize($object, $format = null, array $context = []) |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | public function supportsNormalization($data, $format = null) |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | public function denormalize($data, $class, $format = null, array $context = []) |
||
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | */ |
||
84 | public function supportsDenormalization($data, $type, $format = null) |
||
88 | |||
89 | /** |
||
90 | * {@inheritdoc} |
||
91 | */ |
||
92 | public function setSerializer(SerializerInterface $serializer) |
||
106 | |||
107 | /** |
||
108 | * {@inheritdoc} |
||
109 | */ |
||
110 | public function hasCacheableSupportsMethod(): bool |
||
114 | |||
115 | /** |
||
116 | * Converts data to $class' object if possible. |
||
117 | * |
||
118 | * @param array $data |
||
119 | * @param string $class |
||
120 | * @param null $format |
||
121 | * @param array $context |
||
122 | * |
||
123 | * @return object|null |
||
124 | */ |
||
125 | private function denormalizeObject(array $data, string $class, $format = null, array $context = []) |
||
142 | |||
143 | /** |
||
144 | * Convert raw value to normalized value - object or primitive type. |
||
145 | * |
||
146 | * @param mixed $value |
||
147 | * @param string $class |
||
148 | * @param null $format |
||
149 | * @param array $context |
||
150 | * |
||
151 | * @return object|null |
||
152 | */ |
||
153 | private function denormalizeValue($value, string $class, $format = null, array $context = []) |
||
163 | |||
164 | /** |
||
165 | * Grab class from array. |
||
166 | * |
||
167 | * @param $data |
||
168 | * |
||
169 | * @return string|null |
||
170 | */ |
||
171 | private function extractType(&$data) |
||
182 | } |
||
183 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.