nextcloud / files_antivirus

👾 Antivirus app for Nextcloud Files
https://apps.nextcloud.com/apps/files_antivirus
GNU Affero General Public License v3.0
81 stars 33 forks source link

Fix deprecated "jsonSerialize()" return type in PHP 8.1 #259

Closed danxuliu closed 1 year ago

danxuliu commented 1 year ago

Fixes #258

In PHP 8.1 the return type of jsonSerialize() was set to mixed, and a "deprecated" notice is raised if subclasses do not declare any return type. mixed was added in PHP 8.0, but the return type of a method can have a more specific type in a subclass than in the parent class (https://wiki.php.net/rfc/mixed_type_v2), so array can be used to solve the deprecated notice while also being compatible with PHP 7.4.

How to test

Result with this pull request

No errors are shown in Nextcloud log

Result without this pull request

Return type of OCA\Files_Antivirus\Db\Rule::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice is shown in Nextcloud log