Patrique Ouimet
Senior Product Engineer
Thu, Aug 15, 2019 8:33 AM
Work in progress compiling a list of possible php annotations
Used to describe a variable
Parameters:
type
examples: int
, string
, bool
, array
, User
, int|User
, callable
, mixed
variable
examples: $user, $iddescription
example: the id of a userExamples:
class User
{
/** @var string */
protected $name;
/**
* @param string $name the name of a user
*/
public function __construct(string $name)
{
$this->name = $name;
}
/**
* @return Post|null
*/
public function getLatestPost() : ?Post
{
/** @var Post $post */
$post = Post::where('user_id', $this->id)->latest()->first();
return $post;
}
}
Used to describe a function or method argument
Parameters:
type
examples: int
, string
, bool
, array
, User
, int|User
, callable
, mixed
variable
examples: $user, $iddescription
example: the id of a userExamples:
/**
* @param int $id the id of a user
* @return User|null
*/
public static function getUserById(int $id) : ?User
{
return User::find($id);
}
Used to describe a class property
Parameters:
type
examples: int
, string
, bool
, array
, User
, int|User
, callable
, mixed
variable
examples: $user, $iddescription
example: the id of a userExamples:
/**
* @property string $name Selected name of the user
*/
class User
{
//
}