@filesource - Includes current file in phpDocumentor parsing results
@link [URI] [<description>] - Link tag helps to define relation or link between structural elements.
"PHPDoc" is a section of documentation which provides information on aspects of a "Structural Element" — PSR-5
PHPDoc annotations are comments that provide metadata about all types of structures in PHP. Many popular IDEs are configured by default to utilize PHPDoc annotations to provide code insights and identify possible problems before they arise.
While PHPDoc annotations are not part of the PHP core, they currently hold draft status with PHP-FIG as PSR-5.
All PHPDoc annotations are contained within DocBlocks that are demonstrated by a multi-line with two asterisks:
File level metadata applies to all the code within the file and should be placed at the top of the file:
Adding metadata to functions
Function level annotations help IDEs identify return values or potentially dangerous code
PSR-5 proposes a form of Generics-style notation for collections.
Values in a Collection MAY even be another array and even another Collection.
Describing a variable
The @var keyword can be used to describe the type and usage of:
a class property
a local or global variable
a class or global constant
The type can be one of the built-in PHP types, or a user-defined class, including namespaces.
The name of the variable should be included, but can be omitted if the docblock applies to only one item.
Inheriting metadata from parent structures
If a class extends another class and would use the same metadata, providing it @inheritDoc is a simple way for use the same documentation. If multiple classes inherit from a base, only the base would need to be changed for the children to be affected.
This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0