5
3

More than 1 year has passed since last update.

VSCodeのPHP IntelephenseでPHP8.1の記法記載時にエラーがでる

Posted at

はじめに

ローカル環境にて、PHP8.1 にバージョンアップしたところ、PHP Intelephense 拡張機能でエラーが出るようになってしまいました。
どうやら readonly アクセス修飾子を型と認識しているようです。

php_intelephense_error.png

結論

settings.json に PHP Intelephense の設定で PHP バージョンを指定すれば OK

{
    // ターゲットのPHPバージョンを表すsemver互換の文字列。
    // バージョンに適した提案と診断を提供するために使用されます。 
    // PHP5.3.0以降がサポートされています。
    "intelephense.environment.phpVersion": "8.1.0"
}

バージョン

  • PHP
    • 8.1.0

確認

バッチリ消えました!

php_intelephense_error_resolution.png

おわりに

WSL2 の Ubuntu ディストリビューションに PHP8.1 を公式で apt install できるようにしてほしい・・・

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3