laravel-mongodb icon indicating copy to clipboard operation
laravel-mongodb copied to clipboard

PHPStan errors after 4.3.0 upgrade

Open promatik opened this issue 2 months ago • 0 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.

promatik avatar May 01 '24 01:05 promatik