8000 [Serializer] update implementation · symfony/symfony@dcbf8c6 · GitHub
[go: up one dir, main page]

Skip to content

Commit dcbf8c6

Browse files
committed
[Serializer] update implementation
1 parent 9d2699e commit dcbf8c6

21 files changed

+66
-68
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ public function __construct(array $decoders = [])
3535
/**
3636
* {@inheritdoc}
3737
*/
38-
final public function decode($data, $format, array $context = [])
38+
final public function decode($data, string $format, array $context = [])
3939
{
4040
return $this->getDecoder($format, $context)->decode($data, $format, $context);
4141
}
4242

4343
/**
4444
* {@inheritdoc}
4545
*/
46-
public function supportsDecoding($format, array $context = []): bool
46+
public function supportsDecoding(string $format, array $context = []): bool
4747
{
4848
try {
4949
$this->getDecoder($format, $context);

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ public function __construct(array $encoders = [])
3535
/**
3636
* {@inheritdoc}
3737
*/
38-
final public function encode($data, $format, array $context = [])
38+
final public function encode($data, string $format, array $context = [])
3939
{
4040
return $this->getEncoder($format, $context)->encode($data, $format, $context);
4141
}
4242

4343
/**
4444
* {@inheritdoc}
4545
*/
46-
public function supportsEncoding($format, array $context = []): bool
46+
public function supportsEncoding(string $format, array $context = []): bool
4747
{
4848
try {
4949
$this->getEncoder($format, $context);
@@ -57,10 +57,8 @@ public function supportsEncoding($format, array $context = []): bool
5757
/**
5858
* Checks whether the normalization is needed for the given format.
5959
*
60-
* @param string $format
61-
* @param array $context
6260
*/
63-
public function needsNormalization($format, array $context = []): bool
61+
public function needsNormalization(string $format, array $context = []): bool
6462
{
6563
$encoder = $this->getEncoder($format, $context);
6664

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

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(array $defaultContext = [])
5151
/**
5252
* {@inheritdoc}
5353
*/
54-
public function encode($data, $format, array $context = [])
54+
public function encode($data, string $format, array $context = [])
5555
{
5656
$handle = fopen('php://temp,', 'w+');
5757

@@ -110,7 +110,7 @@ public function supportsEncoding($format)
110110
/**
111111
* {@inheritdoc}
112112
*/
113-
public function decode($data, $format, array $context = [])
113+
public function decode($data, string $format, array $context = [])
114114
{
115115
$handle = fopen('php://temp', 'r+');
116116
fwrite($handle, $data);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function __construct(array $defaultContext = [])
7272
*
7373
* @see http://php.net/json_decode json_decode
7474
*/
75-
public function decode($data, $format, array $context = [])
75+
public function decode($data, string $format, array $context = [])
7676
{
7777
$associative = $context[self::ASSOCIATIVE] ?? $this->defaultContext[self::ASSOCIATIVE];
7878
$recursionDepth = $context[self::RECURSION_DEPTH] ?? $this->defaultContext[self::RECURSION_DEPTH];
@@ -98,7 +98,7 @@ public function decode($data, $format, array $context = [])
9898
/**
9999
* {@inheritdoc}
100100
*/
101-
public function supportsDecoding($format)
101+
public function supportsDecoding(string $format)
102102
{
103103
return JsonEncoder::FORMAT === $format;
104104
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(array $defaultContext = [])
3636
*
3737
* {@inheritdoc}
3838
*/
39-
public function encode($data, $format, array $context = [])
39+
public function encode($data, string $format, array $context = [])
4040
{
4141
$jsonEncodeOptions = $context[self::OPTIONS] ?? $this->defaultContext[self::OPTIONS];
4242
$encodedJson = json_encode($data, $jsonEncodeOptions);
@@ -55,7 +55,7 @@ public function encode($data, $format, array $context = [])
5555
/**
5656
* {@inheritdoc}
5757
*/
58-
public function supportsEncoding($format)
58+
public function supportsEncoding(string $format)
5959
{
6060
return JsonEncoder::FORMAT === $format;
6161
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,31 @@ public function __construct(JsonEncode $encodingImpl = null, JsonDecode $decodin
3232
/**
3333
* {@inheritdoc}
3434
*/
35-
public function encode($data, $format, array $context = [])
35+
public function encode($data, string $format, array $context = [])
3636
{
3737
return $this->encodingImpl->encode($data, self::FORMAT, $context);
3838
}
3939

4040
/**
4141
* {@inheritdoc}
4242
*/
43-
public function decode($data, $format, array $context = [])
43+
public function decode($data, string $format, array $context = [])
4444
{
4545
return $this->decodingImpl->decode($data, self::FORMAT, $context);
4646
}
4747

4848
/**
4949
* {@inheritdoc}
5050
*/
51-
public function supportsEncoding($format)
51+
public function supportsEncoding(string $format)
5252
{
5353
return self::FORMAT === $format;
5454
}
5555

5656
/**
5757
* {@inheritdoc}
5858
*/
59-
public function supportsDecoding($format)
59+
public function supportsDecoding(string $format)
6060
{
6161
return self::FORMAT === $format;
6262
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function __construct(array $defaultContext = [])
7979
/**
8080
* {@inheritdoc}
8181
*/
82-
public function encode($data, $format, array $context = [])
82+
public function encode($data, string $format, array $context = [])
8383
{
8484
$encoderIgnoredNodeTypes = $context[self::ENCODER_IGNORED_NODE_TYPES] ?? $this->defaultContext[self::ENCODER_IGNORED_NODE_TYPES];
8585
$ignorePiNode = \in_array(XML_PI_NODE, $encoderIgnoredNodeTypes, true);
@@ -107,7 +107,7 @@ public function encode($data, $format, array $context = [])
107107
/**
108108
* {@inheritdoc}
109109
*/
110-
public function decode($data, $format, array $context = [])
110+
public function decode($data, string $format, array $context = [])
111111
{
112112
if ('' === trim($data)) {
113113
throw new NotEncodableValueException('Invalid XML data, it can not be empty.');
@@ -176,15 +176,15 @@ public function decode($data, $format, array $context = [])
176176
/**
177177
* {@inheritdoc}
178178
*/
179-
public function supportsEncoding($format)
179+
public function supportsEncoding(string $format)
180180
{
181181
return self::FORMAT === $format;
182182
}
183183

184184
/**
185185
* {@inheritdoc}
186186
*/
187-
public function supportsDecoding($format)
187+
public function supportsDecoding(string $format)
188188
{
189189
return self::FORMAT === $format;
190190
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(Dumper $dumper = null, Parser $parser = null, array
4343
/**
4444
* {@inheritdoc}
4545
*/
46-
public function encode($data, $format, array $context = [])
46+
public function encode($data, string $format, array $context = [])
4747
{
4848
$context = array_merge($this->defaultContext, $context);
4949

@@ -53,15 +53,15 @@ public function encode($data, $format, array $context = [])
5353
/**
5454
* {@inheritdoc}
5555
*/
56-
public function supportsEncoding($format)
56+
public function supportsEncoding(string $format)
5757
{
5858
return self::FORMAT === $format || self::ALTERNATIVE_FORMAT === $format;
5959
}
6060

6161
/**
6262
* {@inheritdoc}
6363
*/
64-
public function decode($data, $format, array $context = [])
64+
public function decode($data, string $format, array $context = [])
6565
{
6666
$context = array_merge($this->defaultContext, $context);
6767

@@ -71,7 +71,7 @@ public function decode($data, $format, array $context = [])
7171
/**
7272
* {@inheritdoc}
7373
*/
74-
public function supportsDecoding($format)
74+
public function supportsDecoding(string $format)
7575
{
7676
return self::FORMAT === $format || self::ALTERNATIVE_FORMAT === $format;
7777
}

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(?string $object): ?string;
40+
public function getTypeForMappedObject($object): ?string;
4141
}

0 commit comments

Comments
 (0)
0