neuberoliveira's avatar

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

0 likes
2 replies
neuberoliveira's avatar

hoo ok, forget to mention but the purpose is too autocomplete in IDEs like phpstorm. For now i will stay with phpdoc that solve both issues and will take a look at larastan

thanks

Please or to participate in this conversation.