Reputation: 1476
Assume a PHP function like this:
/**
* Description
*
* @return Namespace\GenericObject
*/
function doSomething() {
if ($some_parameter) {
return new GenericObject;
} else {
return FALSE;
}
}
How should the return
of the function be documented, using PHPDoc standard? As far as I know, a function should only have one return
documented, yet, the function above can return either a new object, or a bool.
Upvotes: 1
Views: 48
Reputation: 5041
Use the or |
operator.
/**
* Description
*
* @return Namespace\GenericObject|null|array|false
*/
function doSomething() {
if ($some_parameter) {
return new GenericObject;
} else {
return FALSE;
}
}
Upvotes: 4