mongodb / laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

Home Page:https://www.mongodb.com/compatibility/mongodb-laravel-integration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHPStan errors after 4.3.0 upgrade

promatik opened this issue · comments

  • Laravel-mongodb Version: 4.3.0
  • PHP Version: 8.3.6
  • Database Driver & Version: 6.0

Description:

After upgrade to 4.3.0 there are dozens of phpstan errors, those errors are all similar;

Line   app\Http\Controllers\Admin\MailCrudController.php
:58    Parameter #2 $room expects App\Models\Talk\Room, Illuminate\Database\Eloquent\Model|null given.
Line   app\Listeners\Talk\CallEndedListener.php
:26    Access to an undefined property Illuminate\Database\Eloquent\Collection<int, Illuminate\Database\Eloquent\Model>|Illuminate\Database\Eloquent\Model::$id.

I don't know exactly how phpstan works, but before (v4.2) the models were being correctly interpreted. Now with v4.3.0 all Mongo models are being considered Illuminate\Database\Eloquent\Model|null so we have these errors like Access to an undefined property ID.

Expected behaviour

PHP Stan still working, correctly inferring the model.

Actual behaviour

There are now dozens of phpstan errors. Mongo models are always interpreted as Illuminate\Database\Eloquent\Model.

I'll close this one since this is most probably an issue in Larastan.