Adding metadata to functions

suggest change

Function-level annotations help IDEs identify return values or potentially dangerous code.

/**
 * Adds two numbers together.
 *
 * @param int $a First parameter to add
 * @param int $b Second parameter to add
 * @return int
 */
function sum($a, $b)
{
    return (int) $a + $b;
}

/**
 * Don't run me! I will always throw an exception.
 *
 * @throws Exception Always
 */
function dangerousCode()
{
    throw new Exception('Ouch, that was dangerous!');
}

/**
 * Old structures should be deprecated so people know not to use them.
 *
 * @deprecated
 */
function oldCode()
{
    throw new LogicException('This deprecated function must not be used.');
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents