while trying phpstan with laravel to learn strict rules for the model
class Feature extends Model
{
protected $guarded = [];
/**
* @return BelongsToMany<Plan, Feature>
*/
public function plans(): BelongsToMany
{
return $this->belongsToMany(Plan::class);
}
}
on level 6
Method App\Models\Feature::plans() should return
Illuminate\Database\Eloquent\Relations\BelongsToMany<App\Models\Plan,
App\Models\Feature> but returns
Illuminate\Database\Eloquent\Relations\BelongsToMany<App\Models\Plan,
$this(App\Models\Feature)>.
š” Template type TDeclaringModel on class
Illuminate\Database\Eloquent\Relations\BelongsToMany is not
covariant.
how to solve this
Note: I dont wanna use larastan , i want to focus php