I use the latest Version of Visual Studio Code (1.52.1) with PHP Intelephense 1.5.4 on Ubuntu. Despite it is the latest Version it seems not to know the new PHP 8 Syntax. For example it shows an error when using the nullsafe operator:
$myobject?->myfunction();
Is there a way to teach VSC PHP 8 or do we have to just wait for an update?
You should point Visual Studio Code to the location of PHP interpreter that you want to use.
You can do it by setting a line in the settings.json
like this:
"php.validate.executablePath": "c:/usr/php8.1/php.exe",
It is a VSCode configuration option but seems to work with Intelephense too.
You can also do it on per project basis using a separate settings.json
file residing in project's .vscode
folder.
You can find more on these options in the VSCode documentation.