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:
我无法找到可以使用PHPDoc提示的类型的概述。我知道数组或字符串,但是还有bool吗?喜欢:
/**
* @param bool loadLazy
* @return array Array with objects
*/
public function getObjects($loadLazy=false) {
4 个解决方案
#1
10
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
.
不过,我倾向于使用官方PHP手册中的类型 - 这意味着,对于布尔值,我会使用布尔值。
#2
6
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
)
根据文档,您可以使用任何有效的PHP类型,类名称或混合。您还可以通过用|分隔多个类型来列出它们(例如,@ param int | bool $ var)
#3
0
Yes, bool works.
是的,布尔工作。
#4
0
bool is supported in phpDocumentor and phpXref.
phpDocumentor和phpXref支持bool。
C.
C。
#1
10
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
.
不过,我倾向于使用官方PHP手册中的类型 - 这意味着,对于布尔值,我会使用布尔值。
#2
6
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
)
根据文档,您可以使用任何有效的PHP类型,类名称或混合。您还可以通过用|分隔多个类型来列出它们(例如,@ param int | bool $ var)
#3
0
Yes, bool works.
是的,布尔工作。
#4
0
bool is supported in phpDocumentor and phpXref.
phpDocumentor和phpXref支持bool。
C.
C。