是否有布尔参数的 PHPDoc 类型提示?

发布于 2024-08-16 22:43:56 字数 193 浏览 1 评论 0原文

我无法找到可以用 PHPDoc 提示的类型的概述。我知道数组或字符串,但还有布尔值吗?喜欢:

/**
 * @param bool loadLazy
 * @return array Array with objects
 */
public function getObjects($loadLazy=false) {

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 bool loadLazy
 * @return array Array with objects
 */
public function getObjects($loadLazy=false) {

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

白首有我共你 2024-08-23 22:43:56

由于“类型提示”只是一个“提示”,我想说您几乎可以使用您喜欢的任何内容。

尽管如此,我还是倾向于使用官方 PHP 手册中找到的类型——这意味着,对于 布尔值,我会使用布尔值

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.

佞臣 2024-08-23 22:43:56

根据文档,您可以使用任何有效的< a href="http://www.php.net/types" rel="noreferrer">PHP 类型、类名或混合。您还可以通过用 | 分隔来列出多种类型(例如,@param int|bool $var

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)

百合的盛世恋 2024-08-23 22:43:56

是的,布尔有效。

Yes, bool works.

你列表最软的妹 2024-08-23 22:43:56

phpDocumentor 和 phpXref 支持 bool。

C.

bool is supported in phpDocumentor and phpXref.

C.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文