docblock中@type标记的来源

时间:2018-01-11 08:21:24

标签: php docblocks

我找到了一个旧的库,它使用了dockblocks中的@type标记,更具体地来说是定义类属性e.g.

/**
 * Mapping of database columns to attachment fields.
 *
 * @type array
 */
protected $_columns = array();
/**
 * Default transform settings.
 *
 * @type array {
 *      @type string $class         The transform method / class to use
 *      @type string $nameCallback  Method to format filename with
 *      @type string $append        What to append to the end of the filename
 *      @type string $prepend       What to prepend to the beginning of the filename
 *      @type string $uploadDir     Directory to move file to after upload to make it publicly accessible
 *      @type string $transportDir  Directory to place files in after transporting
 *      @type string $finalPath     The final path to prepend to file names (like a domain)
 *      @type string $dbColumn      Database column to write file path to
 *      @type string $defaultPath   Default image if no file is uploaded
 *      @type bool $overwrite       Overwrite a file with the same name if it exists
 *      @type bool $self            Should the transforms apply to the uploaded file instead of creating new images
 * }
 */
protected $_transformSettings = array(
    'class' => '',
    'nameCallback' => '',
    'append' => '',
    'prepend' => '',
    'uploadDir' => '',
    'transportDir' => '',
    'finalPath' => '',
    'dbColumn' => '',
    'defaultPath' => '',
    'overwrite' => false,
    'self' => false
);

我无法在任何常用工具(phpDocumentor/1phpDocumentor/2DocBlox ...)中找到对此类代码的引用。

你知道这个标签可能来自哪个工具/文件吗?

3 个答案:

答案 0 :(得分:1)

The only thing, which I found is this. Where it is described in a table of PHPDoc Tags, which are commonly used in WordPress as:

Used to denote argument array value types. See the Hooks or Parameters That Are Arrays sections for example syntax.

with the usage:

datatype description for an argument array value

So, it seems to be part of PHPDoc. Which makes it more surprising, that you couldn't find anything about it in your listed links.

答案 1 :(得分:1)

它来自串行器/解串器库(或者至少它似乎是,我找不到任何其他远程相关的东西)

https://jmsyst.com/libs/serializer/master/reference/annotations#type

这也是一个symfony包。见here

  

可以在属性上定义此注释以指定其类型   那个财产。对于反序列化,必须定义此注释。   @Type注释可以使用参数和参数   序列化/反序列化处理程序,以增强序列化或   反序列化结果;例如,您可能想要强行确定   格式用于序列化DateTime类型并在   同时在反序列化时使用不同的格式。

答案 2 :(得分:1)

我发现,在早期版本的phpDocumentator @type中,在fig-standards repo中。 他们在2014年将其改为@var。

这是git pull请求的链接: https://github.com/phpDocumentor/fig-standards/pull/55

相关问题