Fabian Grutschus created NETBEANS-6078:
------------------------------------------

             Summary: Remove `mixed` type from JsonSerializable
                 Key: NETBEANS-6078
                 URL: https://issues.apache.org/jira/browse/NETBEANS-6078
             Project: NetBeans
          Issue Type: Improvement
          Components: php - Code Analysis
            Reporter: Fabian Grutschus


Hello,

I get the following error when using JsonSerializable in a PHP project:
{quote}{className} is not abstract and does not override abstract method 
jsonSerialize() in \JsonSerializable
{quote}
The PHP code is the following:

 
{code:java}
<?php
class ClassName implements JsonSerializable {
    public function jsonSerialize(): array {
        return [];
    }
}
{code}
 

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:
{quote}"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])
{quote}
The error is very misleading and wrong. So I propose removing `mixed` again 
from the interface definition in Netbeans.

Thank you!



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to