Yeah, if you define the fields as properties in the class you will have problems with some of the "magic". You have a phpstan specific wrapper for laravel, so you don't need to worry about it: https://github.com/nunomaduro/larastan
Model props && Autocomplete tools
In my current project we are using phpstan, and it complains a lot about "properties that are not defined in......"
lets say i have a User Model, and in my table i have a fav_color column, so if i retrive the model and use it like $user->fav_color i got those warnings about property fav_color are not defined
for now iam solving this with phpdoc
/**
* @property string $fav_color
*/
class User extends Model {
.......
}
with that, the warning get away, but is a lot common that comments are not updated, so i was wondering if put properties directly in my classs, instead of phpdoc, can lead me to some issue, something like this
class User extends Model {
public $fav_color;
.......
}
asking because theres a lot of "magic" in models, acessors, mutators etc. etc.
its safe to put properties on models like this? staty with phpdoc? any advices?
thanks
Please or to participate in this conversation.