Skip to content

Commit c052542

Browse files
minor #39451 [Serializer] Fix EncoderInterface::encode() return type (jeroennoten)
This PR was merged into the 4.4 branch. Discussion ---------- [Serializer] Fix EncoderInterface::encode() return type | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | N.A. | License | MIT | Doc PR | N.A. I might have missed something (in that case, please let me know), but I believe that `EncoderInterface::encode()` will and should always return a `string`. This makes more sense because `DecoderInterface::decode()` only accepts a string as input. Commits ------- ae6f054 Fix EncoderInterface::encode() return type
2 parents 43ab20e + ae6f054 commit c052542

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface EncoderInterface
2525
* @param string $format Format name
2626
* @param array $context Options that normalizers/encoders have access to
2727
*
28-
* @return string|int|float|bool
28+
* @return string
2929
*
3030
* @throws UnexpectedValueException
3131
*/

src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ public function testSupportsEncoding()
6767
public function testEncode()
6868
{
6969
$this->encoder1->expects($this->never())->method('encode');
70-
$this->encoder2->expects($this->once())->method('encode');
70+
$this->encoder2->expects($this->once())->method('encode')->willReturn('foo:123');
7171

72-
$this->chainEncoder->encode(['foo' => 123], self::FORMAT_2);
72+
$this->assertSame('foo:123', $this->chainEncoder->encode(['foo' => 123], self::FORMAT_2));
7373
}
7474

7575
public function testEncodeUnsupportedFormat()

0 commit comments

Comments
 (0)