Skip to content

Add return types to JsonSerializable implementations #41556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

derrabus
Copy link
Member

@derrabus derrabus commented Jun 5, 2021

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.

@derrabus derrabus requested a review from dunglas as a code owner June 5, 2021 20:27
@carsonbot carsonbot added this to the 4.4 milestone Jun 5, 2021
@@ -280,12 +277,10 @@ public function testConstructorWithObjectWithoutToStringMethodThrowsAnException(
}
}

if (interface_exists(\JsonSerializable::class, false)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JsonSerializable has been introduced with PHP 5.4. I'm pretty confident it is always defined. 🙂

@derrabus derrabus mentioned this pull request Jun 5, 2021
@nicolas-grekas
Copy link
Member

Thank you @derrabus.

@nicolas-grekas nicolas-grekas merged commit c127120 into symfony:4.4 Jun 6, 2021
@derrabus derrabus deleted the bugfix/json-serializable-return-type branch June 6, 2021 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants