sendgrid / sendgrid-php

The Official Twilio SendGrid PHP API Library
https://sendgrid.com
MIT License
1.49k stars 623 forks source link

PHP 8.1 throws Deprecation errors relating to jsonSerialize #1070

Closed madhancock closed 2 years ago

madhancock commented 2 years ago

Issue Summary

PHP 8.1 throws Deprecation errors for this package.

Steps to Reproduce

Use in PHP 8.1

Exception/Log

Example (occurs in all occurrences of jsonSerialize):

Deprecated: Return type of SendGrid\Mail\Content::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Technical details:

Suggested Fix

There is a temporary fix of adding the #[\ReturnTypeWillChange] annotation to the methods.

The long term fix would be to correctly specify the return type. This will require a major release as it will lock out PHP version prior to PHP 8.1.

madhancock commented 2 years ago

1066 applies the temporary backwards compatible fix for the issue.

andreas-aeschlimann commented 2 years ago

The PR has been merged as they saw my comment. I think you can close this issue now.