Vscode-intelephense: PHP 7.4 arrow functions not supported?!

Created on 26 Feb 2020  路  5Comments  路  Source: bmewburn/vscode-intelephense

Describe the bug
With PHP 7.4 arrow functions were introduced. Unfortunately arrow functions are shown as wrong code. Even with runnable code.

To Reproduce
Just create a simple arrow function as a callback. The editor will shown that it's wrong. But with it's working with PHP 7.4.

Expected behavior
The editor shouldn't mark it as an error.

I already tried to change the PHP Version in Intelephense > Environment: PHP Version to 7.4.0 and added "fn" to Intelephense: Stubs. Unfortunately both didn't work.

Screenshots

function test() {
  echo 'hello world';
}

call_user_func(fn() => test());

Platform and version

macOS Mojave
Version 10.14.6

Visual Studio Code
Version 1.42.1

PHP Intelephense
Version 1.3.11

needs more info

Most helpful comment

Ahh sorry. You're right.

Was working with PHP 7.4 in Docker but I had an older version installed on my local machine.

Sorry. But I wish you a nice weekend! :)

All 5 comments

I can't reproduce the issue. Please post the error.

Bildschirmfoto 2020-02-26 um 20 49 12

Bildschirmfoto 2020-02-26 um 20 50 35

This might be error from build-in php validator from vscode, can you check if you have path to php7.4 in php.validate.executablePath or set "php.validate.enable": false?

Ahh sorry. You're right.

Was working with PHP 7.4 in Docker but I had an older version installed on my local machine.

Sorry. But I wish you a nice weekend! :)

I can't seem to resolve this, I have these configurements:

{
    "php.validate.enable": false,
    "intelephense.environment.phpVersion": "7.4.5",
}

Yet, my IDE complains on the arrow functions:

image

I've tried to reindex the workspace and restarting VSCode, to no avail. Any ideas?

Was this page helpful?
0 / 5 - 0 ratings