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 are 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, Annotating Types via PHP Doc Comments

Related : Attributes

Related packages : php-annotations/php-annotations