是否有PHPDoc的一种方式来记录对象的数组作为参数? [英] Is there a way for phpDoc to document an array of objects as a parameter?

查看:386
本文介绍了是否有PHPDoc的一种方式来记录对象的数组作为参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PHPDoc的生成的文档,我可以导致PHPDoc的使用,以产生一个链接到一个自定义的类型定义为给定的参数

In phpDoc-generated documentation I can cause phpDoc to generate a link to a custom type definition for a given param using

@param CustomType $variablename

和伟大工程。然而,code我目前记录需要CustomType []参数,即表示CustomType的数组。我想要的文件,以明确的是一个数组是必需的,但是当我使用

and that works great. However, the code I'm currently documenting requires CustomType[] parameters, i.e. an array of said CustomType. I want the documentation to be clear that an array is required, but when I use

@param CustomType[] $variablename

PHPDoc的不再识别的类型,并且因此不能链接到它的定义。这是pretty在这种情况下,重要的 - 我记录有一些相当复杂的类型需要提供一个API

phpDoc no longer recognizes the type, and thus can't link to it's definition. This is pretty important in this case - I'm documenting an API that has some fairly complex types that need to be provided.

我已经尝试了几种不同的语法,这和所有要么把条目作为独立变量类型或文档中打破类型识别。

I've tried several different syntaxes for this and all either treat the entries as separate variable types or break type recognition in the documentation.

除非这个我就注意到它在参数音符,但似乎更清楚地显示在参数类型数组的烦躁。

Barring this I'll just note it in the parameter note, but it seems more clear to show the array-ness of the parameter in the type.

修改

使用phpDocumentor的2(与DocBlox合并)的

With phpDocumentor 2 (which merged with DocBlox) the

@param CustomType[] $paramName

语法的作品,并按照说明@冥河的回答PhpStorm支持类型,暗示与语法。

syntax works, and as noted in @Styx's answer PhpStorm supports type-hinting with that syntax.

接受的答案适当更新。

推荐答案

的PHP文档支持新版 / ** @var sometype。这时候[] * / 语法。更复杂的: / ** @var(sometype。这时候| OTHERTYPE)[] * / 。 <一href=\"http://www.phpdoc.org/docs/latest/guides/types.html#arrays\">http://www.phpdoc.org/docs/latest/guides/types.html#arrays
PHPStorm也支持此语法。

New version of PHP doc support /** @var sometype[] */ syntax. Even more complicated: /** @var (sometype|othertype)[] */. http://www.phpdoc.org/docs/latest/guides/types.html#arrays PHPStorm also support this syntax.

这篇关于是否有PHPDoc的一种方式来记录对象的数组作为参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆