コトの発端
Visual Studio CodeにPHP Intelephenseを導入したら、SessionとかDBとかSchemaとかのクラスに赤い波線のエラーが表示されるようになった。
コード自体は間違っておらず、プログラムも正常動作する。


気になるので直したいね。
原因
下記のサイトによると、PHP Intelephense 1.3からの仕様によるものらしい。定義のチェックが厳しくなったのかな。
VSCode拡張機能Intelephenseの更新によるUndefined type 'Route'(他クラス)のエラー
Visual Studio Code PHP Intelephense Keep Showing Not Necessary Error
解決
PHP Intelephenseの設定変更にて解決した。
File > Preferences > Settingsを開く

Undefinedで検索し、intelephenseをクリック

下記項目のチェックを外す。OKボタンとかは特になかったので、そのまま閉じた。
- Intelephense › Diagnostics: Undefined Class Constants
- Intelephense › Diagnostics: Undefined Constants
- Intelephense › Diagnostics: Undefined Functions
- Intelephense › Diagnostics: Undefined Methods
- Intelephense › Diagnostics: Undefined Properties
- Intelephense › Diagnostics: Undefined Types

ファイルを開きなおすとエラー表示が消えていた

いつもの
記事の内容は無保証です。