larastan: Access to an undefined property Illuminate\Database\Eloquent\Model::$id.
- Larastan Version: 2.1.8
8-levelused:
Getting the Issue of Access to undefined property Model::$id
But in local I have created the stub file and added the property id on it but still getting the issue.
Error PhpStan

Model.stub File

About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (5 by maintainers)
Hi,
I checked the repo, and I think this is kinda expected and normal.
First of all, there should be only one stub file for a class as PHPStan does not support stub merging. And for
Modelclass that stub file is in Larastan. By overriding you are also loosing information that Larastan has set.Also I’d argue prior to the change in Larastan, this worked “by accident”. For your specific case, generics also could be a solution.
We are not changing the actual vendor file but using the stub feature of the PHPSTAN. One more thing this model is anything either the Admin, User, StoreManager anything that’s why we need to declare its base model.
Modify the type declaration of the model object to be your own model object instead of the Model base class.
Also, why are you modifying any files inside vendor?