I am creating a project based on Laravel framework and I am using PhpStorm for it. By default, Laravel has the following settings if we enable Laravel plugin in PhpStorm.
Now based on these settings if I create a model and try to define all the relations and other properties in the following way
<?php
/**
* Class User
*
* @package App\Http\Entities
* @property int $id
* @property mixed $posts
*/
class User extends Model
{
/**
* The table associated with the model
*
* @var string
*/
protected $table = 'users';
/**
* Indicates if model should be timestampped
*
* @var bool
*/
public $timestamps = false;
/**
* The attributes are not mass assignable
*
* @var array
*/
protected $guarded = ['type'];
/**
* Get all the posts for a user
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function posts()
{
return $this->hasMany('App\Http\Entities\Post');
}
}
Automatically I have to add all the annotations for the class or warning is shown by PhpStorm which is obviously because settings are enabled if I disabled them warnings are gone as well.
But I am curious to know what do they actually represent as it must have some reason if it was set by default. Also when writing other models I noticed that when I defined a function inside a model like this
public function userComments()
{
return $this->hasMany('Some model');
}
In annotation, it gets set to something like this
/**
* @property $user_comments
*/
Now firstly it was a function and also for above cases where I defined a function post(), the annotation was set as @property which is again confusing to me. Secondly, I like to define my variable as well as function to camelCase but because of all this annotation getting set at top of the class as snake_case I somehow don't like that.
So all I want to know is what are they basically and what is the purpose of defining them and what do they represent.
P.S. This is my very first project with Laravel framework and I know that it has to do with PHP Documentation and everything but I have never really documented my code earlier. So any suggestion would be helpful.