Annotations

PHP annotations are a system to provide meta data about code, in a way that is programmatically processable.

PHP annotations are based on PHPDoc comment’s syntax, and were later partially modernized by PHP attributes.

<?php

/**
 * <description of foo>
 * @param int $a : <description of the parameter>
 * @return int : <description of the returned value>
 */
function foo(int $a) {

    // This annotation cannot be turned into an attribute
    /**
     * @var int $b : <description of the variable>
     */
     $b = $a + 1;

     return $b;
}

?>

Documentation

See also Understanding annotations and Annotating Types via PHP Doc Comments.

Related : Attribute, PHPdoc

Related packages : php-annotations/php-annotations