Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
Description
Hello,
I get the following error when using JsonSerializable in a PHP project:
Unknown macro: {className}is not abstract and does not override abstract method jsonSerialize() in \JsonSerializable
The PHP code is the following:
<?php class ClassName implements JsonSerializable { public function jsonSerialize(): array { return []; } }
As of PHP 8 JsonSerializable::jsonSerialize() has the return type mixed defined and Netbeans now defines that return type. But it is perfectly fine to change the return type of an interface method with return type mixed.
From the RFC:
"The mixed return type could be narrowed in a subclass as this is covariant and is allowed in LSP." (https://wiki.php.net/rfc/mixed_type_v2)
The error is very misleading and wrong. So I propose removing `mixed` again from the interface definition in Netbeans.
Thank you!