相关疑难解决方法(0)

在PHPDoc中记录数组选项的最佳方法?

我正在努力编写可读且易于理解的文档,该文档描述了传递给函数的Array选项的多树结构.

这是一个示例数组结构.

$arr = [
   'fields' => [
       'title' => [
           'name'     => 'Document.title',
           'format'   => 'string',
           'readonly' => true
       ]
   ]
];
Run Code Online (Sandbox Code Playgroud)

上述数组有许多可能的选项,但这用作理解该结构的函数的参数.

function doSomething(array $arr) { ... }
Run Code Online (Sandbox Code Playgroud)

我想记录如何在PHPDoc中构建数组,但我不确定正确的方法是什么.

这就是我现在拥有的.

/**
 * Holds configuration settings for each field in a model.
 * Defining the field options
 *
 * array['fields'] array Defines the feilds to be shown by scaffolding.
 * array['fields'][fieldName] array Defines the options for a field, or just enables the field if array is not applied.
 * …
Run Code Online (Sandbox Code Playgroud)

php cakephp phpdoc

49
推荐指数
6
解决办法
5万
查看次数

PHP Documentor中的注释关联数组

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

$array = array('id' => 'test', 'class' => 'tester', 'options' => array('option1' => 1, 'option2' => 2))
Run Code Online (Sandbox Code Playgroud)

如何以正确的方式@var@param评论对此数组进行注释?我可以这样做,但我不知道这是否正确:

@param string $array['id']
@param string $array['class']
@param int $array['options']['option1']
Run Code Online (Sandbox Code Playgroud)

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

php arrays associative-array phpdoc

19
推荐指数
4
解决办法
2万
查看次数

标签 统计

php ×2

phpdoc ×2

arrays ×1

associative-array ×1

cakephp ×1