8000 [Serializer] [5.0] Add type-hints to serializer interface · symfony/symfony@9d2699e · GitHub
[go: up one dir, main page]

Skip to content

Commit 9d2699e

Browse files
committed
[Serializer] [5.0] Add type-hints to serializer interface
1 parent c10ad18 commit 9d2699e

12 files changed

+19
-19
lines changed

src/Symfony/Component/Serializer/Encoder/ContextAwareDecoderInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ interface ContextAwareDecoderInterface extends DecoderInterface
2323
*
2424
* @param array $context options that decoders have access to
2525
*/
26-
public function supportsDecoding($format, array $context = []);
26+
public function supportsDecoding(string $format, array $context = []);
2727
}

src/Symfony/Component/Serializer/Encoder/DecoderInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ interface DecoderInterface
3636
*
3737
* @throws UnexpectedValueException
3838
*/
39-
public function decode($data, $format, array $context = []);
39+
public function decode($data, string $format, array $context = []);
4040

4141
/**
4242
* Checks whether the deserializer can decode from given format.
@@ -45,5 +45,5 @@ public function decode($data, $format, array $context = []);
4545
*
4646
* @return bool
4747
*/
48-
public function supportsDecoding($format);
48+
public function supportsDecoding(string $format);
4949
}

src/Symfony/Component/Serializer/Encoder/EncoderInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interface EncoderInterface
3131
*
3232
* @throws UnexpectedValueException
3333
*/
34-
public function encode($data, $format, array $context = []);
34+
public function encode($data, string $format, array $context = []);
3535

3636
/**
3737
* Checks whether the serializer can encode to given format.
@@ -40,5 +40,5 @@ public function encode($data, $format, array $context = []);
4040
*
4141
* @return bool
4242
*/
43-
public function supportsEncoding($format);
43+
public function supportsEncoding(string $format);
4444
}

src/Symfony/Component/Serializer/Mapping/AttributeMetadataInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function getName();
3434
*
3535
* @param string $group
3636
*/
37-
public function addGroup($group);
37+
public function addGroup(string $group);
3838

3939
/**
4040
* Gets groups of this attribute.
@@ -48,7 +48,7 @@ public function getGroups();
4848
*
4949
* @param int|null $maxDepth
5050
*/
51-
public function setMaxDepth($maxDepth);
51+
public function setMaxDepth(?int $maxDepth);
5252

5353
/**
5454
* Gets the serialization max depth for this attribute.

src/Symfony/Component/Serializer/Mapping/ClassDiscriminatorResolverInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ public function getMappingForMappedObject($object): ?ClassDiscriminatorMapping;
3737
*
3838
* @return string|null
3939
*/
40-
public function getTypeForMappedObject($object): ?string;
40+
public function getTypeForMappedObject(?string $object): ?string;
4141
}

src/Symfony/Component/Serializer/NameConverter/NameConverterInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface NameConverterInterface
2525
*
2626
* @return string
2727
*/
28-
public function normalize($propertyName);
28+
public function normalize(string $propertyName);
2929

3030
/**
3131
* Converts a property name to its denormalized value.
@@ -34,5 +34,5 @@ public function normalize($propertyName);
3434
*
3535
* @return string
3636
*/
37-
public function denormalize($propertyName);
37+
public function denormalize(string $propertyName);
3838
}

src/Symfony/Component/Serializer/Normalizer/ContextAwareDenormalizerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ interface ContextAwareDenormalizerInterface extends DenormalizerInterface
2323
*
2424
* @param array $context options that denormalizers have access to
2525
*/
26-
public function supportsDenormalization($data, $type, $format = null, array $context = []);
26+
public function supportsDenormalization($data, string $type, ?string $format = null, array $context = []);
2727
}

src/Symfony/Component/Serializer/Normalizer/ContextAwareNormalizerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ interface ContextAwareNormalizerInterface extends NormalizerInterface
2323
*
2424
* @param array $context options that normalizers have access to
2525
*/
26-
public function supportsNormalization($data, $format = null, array $context = []);
26+
public function supportsNormalization($data, ?string $format = null, array $context = []);
2727
}

src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ interface DenormalizerInterface
4444
* @throws RuntimeException Occurs if the class cannot be instantiated
4545
* @throws ExceptionInterface Occurs for all the other cases of errors
4646
*/
47-
public function denormalize($data, $class, $format = null, array $context = []);
47+
public function denormalize($data, string $class, ?string $format = null, array $context = []);
4848

4949
/**
5050
* Checks whether the given class is supported for denormalization by this normalizer.
@@ -55,5 +55,5 @@ public function denormalize($data, $class, $format = null, array $context = []);
5555
*
5656
* @return bool
5757
*/
58-
public function supportsDenormalization($data, $type, $format = null);
58+
public function supportsDenormalization($data, string $type, ?string $format = null);
5959
}

src/Symfony/Component/Serializer/Normalizer/NormalizableInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ interface NormalizableInterface
3535
*
3636
* @return array|string|int|float|bool
3737
*/
38-
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = []);
38+
public function normalize(NormalizerInterface $normalizer, ?string $format = null, array $context = []);
3939
}

src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ interface NormalizerInterface
3838
* @throws LogicException Occurs when the normalizer is not called in an expected context
3939
* @throws ExceptionInterface Occurs for all the other cases of errors
4040
*/
41-
public function normalize($object, $format = null, array $context = []);
41+
public function normalize($object, ?string $format = null, array $context = []);
4242

4343
/**
4444
* Checks whether the given class is supported for normalization by this normalizer.
@@ -48,5 +48,5 @@ public function normalize($object, $format = null, array $context = []);
4848
*
4949
* @return bool
5050
*/
51-
public function supportsNormalization($data, $format = null);
51+
public function supportsNormalization($data, ?string $format = null);
5252
}

src/Symfony/Component/Serializer/SerializerInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface SerializerInterface
2727
*
2828
* @return string
2929
*/
30-
public function serialize($data, $format, array $context = []);
30+
public function serialize($data, string $format, array $context = []);
3131

3232
/**
3333
* Deserializes data into the given type.
@@ -39,5 +39,5 @@ public function serialize($data, $format, array $context = []);
3939
*
4040
* @return object
4141
*/
42-
public function deserialize($data, $type, $format, array $context = []);
42+
public function deserialize($data, string $type, string $format, array $context = []);
4343
}

0 commit comments

Comments
 (0)
0