bmewburn / vscode-intelephense

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

laravel-ide-helper broken with laravel 11 #2959

Open Nemesis19 opened 1 month ago

Nemesis19 commented 1 month ago

Describe the bug Last versions of Intelephense are showing errors on model instances. See the screenshot.

Screenshot 2024-07-24 alle 21 34 20

With error Expected type 'App\Models\Vehicle'. Found 'Illuminate\Database\Eloquent\TModel'.intelephense(P1006) @var \Illuminate\Database\Eloquent\TModel $vehicle

and for $section this is the error Expected type 'App\Models\Section'. Found 'Illuminate\Database\Eloquent\Builder|null'.intelephense(P1006) @var \Illuminate\Database\Eloquent\Builder|null $section

The only way to solve it is to put @var annotations like these (and not convenient to be added everywhere)

/** @var Vehicle|null $vehicle **/ /** @var Section|null $section **/ VehicleService::startWithSection($vehicle, $section);

it doesn't seem a problem many people have, so is there any configuration that it's causing this?

Thanks

bmewburn commented 1 month ago

It seems the template type TModel is not resolving to the actual type. To understand why, some more context is needed. What version of intelephense is this? What version of Laravel? Are you using https://github.com/barryvdh/laravel-ide-helper? If so, are you generating model docs?

Nemesis19 commented 1 month ago

Latest Intelephense versionLaravel 11Yes I’m using that package and generating the model docs.Il giorno 24 lug 2024, alle ore 23:45, Ben Mewburn @.***> ha scritto: It seems the template type TModel is not resolving to the actual type. To understand why some more context is needed. What version of intelephense is this? What version of Laravel? Are you using https://github.com/barryvdh/laravel-ide-helper? If so, are you generating model docs?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

bmewburn commented 1 month ago

Latest intelephense version as in the pre-release (1.11) ? Or 1.10.4? When generating model docs is it to a separate file or the actual model file?

bmewburn commented 1 month ago

Could be related to https://github.com/barryvdh/laravel-ide-helper/issues/1572, https://github.com/laravel/framework/pull/51851

Nemesis19 commented 1 month ago

I'm sorry I didn't specify...latest stable v1.10.4. The models are generating inside the Model file. Thanks for pointing me to the right direction. I do agree the problems are probably related!

sebj54 commented 1 month ago

I don't know if it is related but I had a similar problem after upgrading some packages. Laravel was already updated to 11, so I think it works correctly with Laravel 11.

The problem is that the more you install vendor packages, the more you are likely to exceed the maximum file size.

To check if it you have the same problem, go to ViewOutput → select intelephense in the dropdown. You should see this error:

[Warn  - 16:10:12] file:///Users/myuser/projects/myproject/_ide_helper.php is over the maximum file size of 1000000 bytes.

I increased the limit in the settings and it now works as expected!

Nemesis19 commented 1 day ago

I don't know if it is related but I had a similar problem after upgrading some packages. Laravel was already updated to 11, so I think it works correctly with Laravel 11.

The problem is that the more you install vendor packages, the more you are likely to exceed the maximum file size.

To check if it you have the same problem, go to ViewOutput → select intelephense in the dropdown. You should see this error:

[Warn  - 16:10:12] file:///Users/myuser/projects/myproject/_ide_helper.php is over the maximum file size of 1000000 bytes.

I increased the limit in the settings and it now works as expected!

Non this is not my case unfortunately.