开发者

Is there an PHPDoc type hint for an boolean parameter?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜