0

我发现了一个旧库,它使用@type停靠块内的标签,更具体地说是定义类属性,例如

/**
 * 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 ...)中找到对此类标记的任何引用。

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

4

3 回答 3

1

我发现的唯一东西就是这个。在 PHPDoc 标签表中对其进行了描述,这些标签在 WordPress 中常用为:

用于表示参数数组值类型。有关示例语法,请参阅作为数组的钩子或参数部分。

用法:

参数数组值的数据类型描述

所以,它似乎是 PHPDoc 的一部分。更令人惊讶的是,您在列出的链接中找不到任何关于它的信息。

于 2018-01-11T08:43:51.453 回答
1

我发现,在 phpDocumentator 的旧版本中,@type 位于 fig-standards 存储库中。他们在 2014 年将其更改为 @var。

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

于 2018-01-11T08:54:19.953 回答
1

它来自序列化器/反序列化器库(或者至少看起来是,我找不到任何其他远程相关的东西)

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

它也是一个 symfony 包。看这里

可以在属性上定义此注释以指定该属性的类型。对于反序列化,必须定义此注解。@Type 注解可以有参数,并且参数可以被序列化/反序列化处理程序用来增强序列化或反序列化结果;例如,您可能希望强制使用某种格式来序列化 DateTime 类型,并同时指定反序列化时使用的不同格式。

于 2018-01-11T08:47:30.843 回答