Add return types to JsonSerializable implementations

This commit is contained in:
Alexander M. Turek 2021-06-05 22:21:26 +02:00
parent 6eead347b0
commit 9246b53f7c
No known key found for this signature in database
GPG Key ID: 819672F969F5F27C
2 changed files with 5 additions and 10 deletions

View File

@ -224,9 +224,6 @@ class JsonResponseTest extends TestCase
{ {
$this->expectException(\Exception::class); $this->expectException(\Exception::class);
$this->expectExceptionMessage('This error is expected'); $this->expectExceptionMessage('This error is expected');
if (!interface_exists(\JsonSerializable::class, false)) {
$this->markTestSkipped('JsonSerializable is required.');
}
$serializable = new JsonSerializableObject(); $serializable = new JsonSerializableObject();
@ -280,12 +277,10 @@ class JsonResponseTest extends TestCase
} }
} }
if (interface_exists(\JsonSerializable::class, false)) { class JsonSerializableObject implements \JsonSerializable
class JsonSerializableObject implements \JsonSerializable {
public function jsonSerialize(): array
{ {
public function jsonSerialize() throw new \Exception('This error is expected');
{
throw new \Exception('This error is expected');
}
} }
} }

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\Serializer\Tests\Fixtures;
class JsonSerializableDummy implements \JsonSerializable class JsonSerializableDummy implements \JsonSerializable
{ {
public function jsonSerialize() public function jsonSerialize(): array
{ {
return [ return [
'foo' => 'a', 'foo' => 'a',