plugin icon indicating copy to clipboard operation
plugin copied to clipboard

[Bug]: Adding query() triggers warning of Incompatible return type

Open buzkall opened this issue 4 months ago • 8 comments

Bug description

In a Laravel model, when running an Eloquent query, if I add the function query(), I get the warning of incompatible type suggesting that the return type should be the Laravel idea helper file.

Image

Plugin version

11.3.0.252

Operating system

MacOS

Steps to reproduce

Removing the query() from the function eliminates the warning

Relevant log output


buzkall avatar Sep 01 '25 12:09 buzkall

Hello. What is module()? Scope? Could you provide the model code?

adelf avatar Sep 01 '25 12:09 adelf

Yes, module() is a scope.

Here I attach a simpler example with the code of the scope

Image

With the #[Scope] approach I need to add query() or I'll get an error "Non-static method App\Models\Center::installed() cannot be called statically"

The same warning happens if I use the older scope prefix

Image

buzkall avatar Sep 01 '25 15:09 buzkall

Hello. Reproduced. It appeared in the last PhpStorm update. We will try to fix.

adelf avatar Sep 04 '25 21:09 adelf

Fixed in 11.4. It should disappear after helper code generation with 11.4

adelf avatar Sep 15 '25 12:09 adelf

I'm on the Laravel Idea plugin version 11.4.1.252, I've executed the "Generate helper code" function, but I still get the same warning if I set Illuminate\Support\Collection as the return value

Image

Image

buzkall avatar Sep 22 '25 10:09 buzkall

Could you try to run main menu -> FIle > Invalidate Caches... and after that generate helper code again. I got the warning once, but after that, the helper code works ok. Seems, we have a floating bug here... And seems, It's not inside Laravel Idea. It asks PhpStorm about the type of some methods and get dfferent results...

adelf avatar Sep 22 '25 10:09 adelf

I've invalidaded caches and generated code again, but the same warning keeps appearing 😭

buzkall avatar Sep 22 '25 12:09 buzkall

We are sorry about this. We are going to fully rewrite the helper code generation part in 12.0, and probably will fix this there.

adelf avatar Sep 24 '25 12:09 adelf