I wasn't able to find an overview of the types which can be hinted with PHPDoc. I know array or string, but is there also bool? Like:
/**
* @param bo开发者_高级运维ol loadLazy
* @return array Array with objects
*/
public function getObjects($loadLazy=false) {
As a "type hint" is only a "hint", I would say you can use pretty much whatever you like.
Still, I tend to use the types that are found in the official PHP manual -- which means, for a Boolean, I would use boolean
.
According to the documentation, you can use any valid PHP type, class names, or mixed
. You can also list multiple types by separating them with a |
(e.g., @param int|bool $var
)
Yes, bool works.
bool is supported in phpDocumentor and phpXref.
C.
精彩评论