You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the report! Yes, this looks like a wrong assumption in the stub file. Maybe additionally we need to keep track of the child in the relation clasess. I'll take a look into this 👍
I could only find this situation (returning child model) in associate, dissociate, and getChild methods of BelongsTo relation. If you encounter this behavior in different relation methods, let me know 👍
--level
used: 5Description
PHPStan reports the following error:
Method App\Post::setAuthorAttribute() should return App\User but returns App\Post
.The
associate
method of theBelongsTo
relation does not return the related model, but the child model: https://github.com/laravel/framework/blob/7.x/src/Illuminate/Database/Eloquent/Relations/BelongsTo.php#L216But Larastan assumes the opposite: https://github.com/nunomaduro/larastan/blob/master/stubs/BelongsTo.stub#L11
Laravel code where the issue was found
I have no idea how Larastan or PHPstan works, otherwise I would send a PR for this issue.
The text was updated successfully, but these errors were encountered: