vscode-intelephense icon indicating copy to clipboard operation
vscode-intelephense copied to clipboard

Implementing JsonSerializable::jsonSerialize() on PHP < 8.1 issues non-applicable error

Open ludwig801 opened this issue 5 months ago • 1 comments

Describe the bug When implementing JsonSerializable::jsonSerialize() without return type or using any other return type other than mixed using PHP v7.2.24, an error is issued, but in 7.2 this syntax was fully valid. The mixed return type was only introduced in PHP 8.1.

Possibly related to #3024 (which was considered resolved in v1.12.5).

To Reproduce

class MyClass implements JsonSerializable
{
  public function jsonSerialize() // <-- shows error here
  {
    return [
      "key" => "value"
    ];
  }
}

Expected behavior When having set the PHP version to < 8.1, expect no error, since the syntax is valid.

Screenshots image

Platform and version

  • Windows 11 Version 10.0.22631 Build 22631
  • VSCode v1.93.1
  • Intelephense v1.12.6

ludwig801 avatar Sep 15 '24 08:09 ludwig801