php - 如何在PHPStorm中自动格式化PHP注解

标签 php annotations phpstorm swagger-php

我正在处理大量文件,这些文件具有带有 Swagger PHP 注释的 PHP block 文档,但它们没有缩进。有没有自动用空格格式化它们?

车削

/**
 * @SWG\Api(
 * path="/building/{buildingId}",
 * @SWG\Operation(
 * method="GET",
 * type="Building",
 * summary="Returns a Building object by ID",
 * nickname="building/getBuilding",
 * @SWG\Parameter(
 * name="buildingId",
 * description="ID of the building that needs to be fetched",
 * paramType="path",
 * required=false,
 * type="string",
 * defaultValue="1"
 * )
 * )
 * )
 */

进入

/**
 * @SWG\Api(
 *   path="/building/{buildingId}",
 *   @SWG\Operation(
 *     method="GET",
 *     type="Building",
 *     summary="Returns a Building object by ID",
 *     nickname="building/getBuilding",
 *     @SWG\Parameter(
 *       name="buildingId",
 *       description="ID of the building that needs to be fetched",
 *       paramType="path",
 *       required=false,
 *       type="string",
 *       defaultValue="1"
 *     )
 *   )
 * )
 */

最佳答案

不幸的是,PHPStorm 中没有内置任何东西来执行此操作。我用一些节点解决了这个问题,并在其他人需要时开源了我的工作。

:)

https://github.com/eknowles/grunt-tidy-annotations

关于php - 如何在PHPStorm中自动格式化PHP注解,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30787406/

相关文章:

javascript - PHP 和 Node.JS - 加密 PBKDF2

php - 正则表达式 : How to Express\w Without Underscore

annotations - Prolog 中 'semidet' 的概念解决了吗?

c++ - 有没有一种好方法,可以用 C++ 生成代码以通过网络发送函数参数?

javascript - 是否可以在 PhpStorm 中打开 JSLint 检查 Typescript 文件?

php - TDAmeritrade API 认证错误 : Failed to resolve API Key variable request. header.un

php - 如何连接到另一台服务器上的数据库

emacs - 关于如何对我的ocaml编进行类型注释的幼稚问题。在emacs中

php - 如何安装 php-cgi?我尝试了 MacPort、Package 和其他一切,但都没有用

html - 如何让 Vim HTML 语法突出显示来为整个标签着色?