Adding metadata to functions
suggest changeFunction-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.');
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents