bmewburn / vscode-intelephense

PHP intellisense for Visual Studio Code
https://intelephense.com
Other
1.57k stars 93 forks source link

Laravel and Root Types #2861

Closed blondie63 closed 2 months ago

blondie63 commented 2 months ago

Describe the bug In Laravel i can import Classes with Use classname but i can also write \classname Look this example:

Intelephense-issue

This cose works perfectly but Intelephense show this error: Undefined type 'Route'.intelephense(P1009)

Why ?

Platform and version MacOS 14.4.1 (23E224) VS.Code Version: 1.88.1 Commit: e170252f762678dec6ca2cc69aba1570769a5d39 Date: 2024-04-10T17:43:08.196Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Darwin arm64 23.4.0 Intelephense v1.10.4

bmewburn commented 2 months ago

They are defined at runtime, so static analysis cannot discover them.

You can either import the full facade name, eg.

use Illuminate\Support\Facades\Route; 

Or declare them yourself in an ide helper file. eg

class Route extends \Illuminate\Support\Facades\Route {}

Or use https://github.com/barryvdh/laravel-ide-helper . Which can generate an ide helper file for you.