-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues after Laravel 11.15 #1572
Comments
Same here. For example,
From _ide_helper.php:
|
Hello, Same for me, all models are viewed as Illuminate\Database\Eloquent\Builder instead of an instance of App\Models\MODELNAME. Thanks in advance, |
Same issue here. It seems that Laravel changed the DocBlocks for the Eloquent Builder class in Laravel 11. It now has a template tag on the class itself |
What worked for me is that i disabled inteliphense and i only had this php intelisense enabled. Then i added this phpdoc to MyModel: |
I have the same problem |
Same problem here |
I created a draft pull request #1591 to fix this issue. The tests don't pass, but the fix is done. A simple fix would require Laravel to only support versions 11.15 and later, which is a breaking change. For compatibility, we could change the behavior depending on the running Laravel version, but because the Laravel Framework allows type changes even in minor versions, we might need to continue implementing similar version detection in the future. In my opinion, I don't recommend it. After hearing your opinions on the versioning approach, I will complete the pull request. |
After further trial and error, it seemed like maintaining compatibility with versions below Laravel 11.15 would be a tough road to overcome, so I completed a pull request narrowing the supported version. |
great job, thank you :) |
While the changes are really good, one thing is still working incorrectly. Model::create(), Model::find(), Model::make() are still returning the wrong type. This is due the @KentarouTakeda What do you think? |
Yes, I think it would be useful if it were fixed. On the other hand, I prefer to explicitly call the Eloquent Builder with $user = User::query()->create();
// Identified as `\App\Models\User`
$user = User::create();
// Identified as `mixed` In my opinion, By the way, the Eloquent mixin example you showed did not produce the same results in my environment. I don't know if it's Laravel or IDE Helper, but it may be written in a way that is interpreted differently depending on the editor. I use VSCode and PHP Intellephense. |
That might be caused due the I agree that a Model should be a different class than Builder. Although the docs state that ::create, ::where and ::find are valid methods. |
I removed By the way, I noticed a strange output in the DocBlock generated to /**
* @return \Illuminate\Database\Eloquent\TModel
*/
public static function create($attributes = []) As you can see, a class that doesn't actually exist is being output as the return type. This is probably a bug. A reasonable solution would be to make |
Thanks, perhaps the interpretation of generics is different between PhpStorm and VSCode. I'll try to fix this in a PR soonish. |
@pataar Would it make sense to reopen this ticket unit "create returns |
@pataar I second @gyulavoros, and would like to add that it also affects |
Versions:
Description:
Additionally to issues like #1571, Laravel 11.15 also ruined some other _ide_helper.php methods (find, findOrFail, etc)
I think is related to laravel/framework#51851 and laravel/framework#52037
Before 11.15:
After 11.15:
Now for example this is wrong:
$pack = Pack::query()->findOrFail($packId);
Previous to 11.15: $pack: Pack|Pack[]|Builder|Builder[]|Collection|Model|null
After 11.15: $pack: |Collection|Model|null
I don't know if we have to do something to make it work again in our end.
Thanks
The text was updated successfully, but these errors were encountered: