'VS Code - does not recognize php 8 syntax

I have recently set up vsCode with PHP. However, it shows errors on following lines.

public static function myFunction(): bool|string

error : syntax error, unexpected '|', expecting ';' or '{'

$app->options('/{routes:.+}', fn (ResponseInterface $response) => $response);

error : syntax error, unexpected '$response' (T_VARIABLE), expecting ')'

How can I make it recognize that this is the correct syntax.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source