Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-6078

Remove `mixed` type from JsonSerializable

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • php - Code Analysis
    • 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!

      Attachments

        Activity

          People

            Kacer Tomáš Procházka
            crash Fabian Grutschus
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: