PHP Documentor 中的注释关联数组 [英] Comment associative array in PHP Documentor

查看:26
本文介绍了PHP Documentor 中的注释关联数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 PHP 应用程序中使用了几个关联数组,并且我正在使用 PHP 文档器来注释我的源代码.我从来没有真正为数组中的数组指定注释,但现在我需要这样做,但不知道如何做.

I use several associative arrays in my PHP application and I'm using PHP documentor to comment my sources. I never really did specify comments for the arrays in an array, but now I need to do that and don't know how.

$array = array('id' => 'test', 'class' => 'tester', 'options' => array('option1' => 1, 'option2' => 2))

我如何以正确的方式为 @var@param 注释这个数组?我可以这样做,但我不知道这是否正确:

How do I comment this array in the correct way for @var and @param comments? I could do this like this, but I don't know if this is correct:

@param string $array['id']
@param string $array['class']
@param int $array['options']['option1']

但是如何为 @var 部分做到这一点?

But how to do this for the @var part?

推荐答案

你不能记录每个键,但是 你可以告诉 phpDocumentor 它是什么类型.

You can't document each key, but you can tell phpDocumentor what type it is.

你可以这样做:

/**
 * Form the array like this:
 * <code>
 * $array = array(
 *   'id'      => 'foo',          // the id
 *   'class'   => 'myClass',     // the class
 * );
 * 
 * </code>
 *
 * @var array[string]string 
 */
$array;

这篇关于PHP Documentor 中的注释关联数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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