8000 minor #41556 Add return types to JsonSerializable implementations (de… · symfony/symfony@c127120 · GitHub
[go: up one dir, main page]

Skip to content

Commit c127120

Browse files
minor #41556 Add return types to JsonSerializable implementations (derrabus)
This PR was merged into the 4.4 branch. Discussion ---------- Add return types to JsonSerializable implementations | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Part of #41552 | License | MIT | Doc PR | N/A PHP 8.1 will trigger a deprecation warning if we implement `JsonSerializable` without a return type. I've added return types to the two mock implementations that were affected. Commits ------- 9246b53 Add return types to JsonSerializable implementations
2 parents 40992f0 + 9246b53 commit c127120

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,6 @@ public function testSetContentJsonSerializeError()
224224
{
225225
$this->expectException(\Exception::class);
226226
$this->expectExceptionMessage('This error is expected');
227-
if (!interface_exists(\JsonSerializable::class, false)) {
228-
$this->markTestSkipped('JsonSerializable is required.');
229-
}
230227

231228
$serializable = new JsonSerializableObject();
232229

@@ -280,12 +277,10 @@ public function testConstructorWithObjectWithoutToStringMethodThrowsAnException(
280277
}
281278
}
282279

283-
if (interface_exists(\JsonSerializable::class, false)) {
284-
class JsonSerializableObject implements \JsonSerializable
280+
class JsonSerializableObject implements \JsonSerializable
281+
{
282+
public function jsonSerialize(): array
285283
{
286-
public function jsonSerialize()
287-
{
288-
throw new \Exception('This error is expected');
289-
}
284+
throw new \Exception('This error is expected');
290285
}
291286
}

src/Symfony/Component/Serializer/Tests/Fixtures/JsonSerializableDummy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class JsonSerializableDummy implements \JsonSerializable
1515
{
16-
public function jsonSerialize()
16+
public function jsonSerialize(): array
1717
{
1818
return [
1919
'foo' => 'a',

0 commit comments

Comments
 (0)
0