1 | <?php |
||
11 | final class JmsSerializerAdapter implements SerializerInterface, NormalizerInterface, DenormalizerInterface |
||
12 | { |
||
13 | /** @var JmsSerializer */ |
||
14 | private $serializer; |
||
15 | |||
16 | /** |
||
17 | * JmsSerializerAdapter constructor. |
||
18 | * |
||
19 | * @param JmsSerializer $serializer |
||
20 | */ |
||
21 | 13 | public function __construct(JmsSerializer $serializer) |
|
22 | { |
||
23 | 13 | $this->serializer = $serializer; |
|
24 | 13 | } |
|
25 | |||
26 | /** {@inheritdoc} */ |
||
27 | 13 | public function serialize($data, $format, array $context = []) |
|
28 | { |
||
29 | 13 | return $this->serializer->serialize($data, $format, JmsContextFactory::serialization($context)); |
|
30 | } |
||
31 | |||
32 | /** {@inheritdoc} */ |
||
33 | public function deserialize($data, $type, $format, array $context = []) |
||
37 | |||
38 | /** {@inheritdoc} */ |
||
39 | 8 | public function normalize($object, $format = null, array $context = []) |
|
40 | { |
||
41 | 8 | $jmsContext = JmsContextFactory::serialization($context); |
|
42 | |||
43 | 8 | if ($this->serializer instanceof Serializer) { |
|
44 | 8 | return $this->serializer->toArray($object, $jmsContext); |
|
45 | } |
||
46 | |||
47 | return json_decode($this->serializer->serialize($object, 'json', $jmsContext), true); |
||
48 | } |
||
49 | |||
50 | /** {@inheritdoc} */ |
||
51 | public function supportsNormalization($data, $format = null) |
||
55 | |||
56 | /** {@inheritdoc} */ |
||
57 | public function denormalize($data, $class, $format = null, array $context = []) |
||
67 | |||
68 | /** {@inheritdoc} */ |
||
69 | public function supportsDenormalization($data, $type, $format = null) |
||
73 | } |
||
74 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: