Skip to content
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

An alternative approach for PHP 8.1 support #340

Merged
merged 4 commits into from Nov 22, 2021

Conversation

chrisdeeming
Copy link
Contributor

@Minishlink I am so sorry seeing as you already (very efficiently!) merged my previous PR.

There is an alternative approach. I'm not exaggerating when I say I've spent the last 24 hours engrossed in various vendor libraries looking at this kind of stuff with a view to supporting all PHP versions from 7.0 to 8.1 in our application and it's starting to affect my ability to make correct decisions!

PHP 8.1 adds a return type of mixed to the JsonSerializable::jsonSerialize method. While the #[\ReturnTypeWillChange] attribute will work, an alternative is to simply add the array return type.

This will work on all PHP versions you support and still work on PHP 8.1 because array is a more specific type than mixed (which is a union type that consists of many types, including array).

So, nothing wrong with the previous approach but this may be preferred. No issue if you decide to close this in favour of sticking with the original approach.

@Minishlink
Copy link
Member

@chrisdeeming Oh right, yes let's merge this if it's more specific than #[\ReturnTypeWillChange] and it keeps working on PHP < 8.1
There seems to be some conflicts though :)

# Conflicts:
#	src/MessageSentReport.php
@chrisdeeming
Copy link
Contributor Author

That should be it @Minishlink :)

Copy link
Member

@Minishlink Minishlink left a comment

Choose a reason for hiding this comment

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

Thanks!

@Minishlink Minishlink merged commit 23a78b8 into web-push-libs:master Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants