How can I keep PhpStorm from reformatting phpdoc comments?

I am using Swagger annotations in my doc block, which have hierarchical @xxx type comments. Every time the 'reformat code' is used or update the doc blocks from the right-mouse menu, PhpStorm seems to slam all @xxx to the left and do strange indention elsewhere. How can I keep it from doing this?

PhpStorm 6.0 on Ubuntu 12.10

Before

    /**
     *
     * @Api(
     *   path="/pet.{format}/findByStatus",
     *   description="Operations about pets",
     *   @operations(
     *     @operation(
     *       httpMethod="GET",
     *       summary="Finds Pets by status",
     *       notes="Multiple status values can be provided with comma seperated strings",
     *       responseClass="List[Pet]",
     *       nickname="findPetsByStatus",
     *       @parameters(
     *         @parameter(
     *           name="status",
     *           description="Status values that need to be considered for filter",
     *           paramType="query",
     *           defaultValue="available",
     *           @allowableValues(valueType="LIST", values="['available', 'pending', 'sold']"),
     *           required="true",
     *           allowMultiple=true,
     *           dataType="string"
     *         )
     *       ),
     *       @errorResponses(
     *          @errorResponse(
     *            code="400",
     *            reason="Invalid status value"
     *          )
     *       )
     *     )
     *   )
     * )
     */


After

 /**
  *
  * @Api(
  *            path="/pet.{format}/findByStatus",
  *            description="Operations about pets",
  * @operations(
  * @operation(
  *            httpMethod="GET",
  *            summary="Finds Pets by status",
  *            notes="Multiple status values can be provided with comma seperated strings",
  *            responseClass="List[Pet]",
  *            nickname="findPetsByStatus",
  *
  * @parameters(
  * @parameter(
  *           name="status",
  *           description="Status values that need to be considered for filter",
  *           paramType="query",
  *           defaultValue="available",
  *
  * @allowableValues(valueType="LIST", values="['available', 'pending', 'sold']"),
  *            required="true",
  *            allowMultiple=true,
  *            dataType="string"
  *         )
  *       ),
  * @errorResponses(
  * @errorResponse(
  *            code="400",
  *            reason="Invalid status value"
  *          )
  *       )
  *     )
  *   )
  * )
  */

1 comment

Hi there,

AFAIK it is not possible -- PhpStorm will re-align any line in PHPDoc comment that starts with @ (will strip leading spaces .. so it will become *[space]@)

Thing is -- you are using not-standard PHPDoc tags and PhpStorm is simply unaware about such possible formatting / formatting requirement (all PhpStorm knows is that in standard PHPDoc comment formatting tag gets alligned if it is first in the line).

My only suggestion right now is to post a Feature Request / Usability Problem ticket to the Issue Tracker (e.g. "Add an option to PHP code style to not touch PHPDoc comments at all ... or do not strip extra leading spaces") and hopefully it will be implemented in next major version (v7). But please check if similar ticket does not exist already (I did a quick search and found none).

0

Please sign in to leave a comment.