Open browner12 opened 5 days ago
Thank you for reporting this issue!
As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.
If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.
Thank you!
Laravel Version
11.29.0
PHP Version
8.3.12
Database Driver & Version
Sqlite 3.43.2
Description
The
partition()
method of theIlluminate\Database\Eloquent\Collection
, as defined in theIlluminate\Support\Traits\EnumeratesValues
class possibly does not have the correct generic return types.https://github.com/laravel/framework/blob/11.x/src/Illuminate/Collections/Traits/EnumeratesValues.php#L501
The issue goes away when I disable and remove the cache of the LaravelIdea plugin. However, I'm not sure if it's an issue with Laravel's definition of the generics, or with how the plugin is parsing the generics. If it's deemed that Laravel is correct, I'll go open this issue in the plugin repo.
Steps To Reproduce
Given the following user table:
and the following code:
all 4 dumped variables will be of type
Illuminate\Database\Eloquent\Collection
. However, the IDE is currently thinking$men
,$women
, and$menGroupedByAge
are all of typeApp\Models\User
.Both our
Collection
andUser
classes also have agroupBy()
method available to them, but with different signatures. Because the IDE believes$men
is aUser
, it's also warning that it is unacceptable to pass a closure togroupBy()
.