integral-learning / moodle-auth_mumie

0 stars 3 forks source link

Deprecated warnings in jsonSerialize functions #27

Open voegii opened 11 months ago

voegii commented 11 months ago

After installing the plugin following warnings appears on Moodle administration page:

Deprecated: Return type of auth_mumie\mumie_tag::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /path/to/moodle/auth/mumie/classes/mumie_tag.php on line 65

Deprecated: Return type of auth_mumie\mumie_problem::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /path/to/moodle/auth/mumie/classes/mumie_problem.php on line 142

Deprecated: Return type of auth_mumie\mumie_course::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /path/to/moodle/auth/mumie/classes/mumie_course.php on line 197

Deprecated: Return type of auth_mumie\mumie_server::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /path/to/moodle/auth/mumie/classes/mumie_server.php on line 306

We have solved it temporarily with the #[\ReturnTypeWillChange] hint.

Moodle 4.2 with PHP 8.1 (Test server with enabled error reporting and debug display)

Lyannic commented 9 months ago

I'm sorry for the delay in responding. Thank you for poiting out this issue.

Concerning the deprecation notices from PHP 8.1, you're right. PHP has updated the JsonSerializable interface's jsonSerialize method to expect a mixed return type. Your implementation of the #[\ReturnTypeWillChange] attribute is a suitable workaround for the time being, as you’ve rightly pointed out. In terms of our ongoing support for PHP 7, which doesn't recognize the mixed return type, we're unable to incorporate it at the moment. So, using the #[\ReturnTypeWillChange] attribute is our best maneuver until we no longer need to support PHP 7.

We're fully aware that these are deprecation warnings, not errors, and while they need to be addressed eventually, they're not a high priority at the moment. Our focus is on maintaining the quality and stability of the existing codebase, which we’re actively doing. Also, being an open-source project, we greatly value contributions from our user community. We’d be more than happy to look at any pull requests.