Is there a way for phpDoc to document an array of objects as a parameter?

后端 未结 5 2074
礼貌的吻别
礼貌的吻别 2020-12-17 09:20

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
         


        
5条回答
  •  被撕碎了的回忆
    2020-12-17 10:21

    The best you can do is:

    @param array $variablename an array of {@link CustomType} objects
    

    This should help the reader realize the true datatype of $variablename, while indicating the expectation of what the array contains.

    This won't be enough to help an IDE's autocompletion when it comes to using a member from $variablename and expecting properties/methods of CustomType to appear. There's really no way to get that behavior currently.

提交回复
热议问题