I'm working with a large number of files that have PHP block docs with Swagger PHP annotations on them, however they are not indented. Is there anyway to automatically format them with spaces?
Turning
/**
* @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"
* )
* )
* )
*/
Into
/**
* @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"
* )
* )
* )
*/
In the editor, select a code fragment you want to reformat. Before reformatting, you can take a look at the code style settings that are applied to the selected code: press Alt+Enter and click Adjust code style settings. From the main menu, select Code | Reformat Code or press Ctrl+Alt+L .
In PHPDoc comments, PhpStorm supports formatting options in compliance with the ZEND, PEAR, and other coding standards. PHPDoc comments in your source code are available for Quick Documentation Lookup, which helps you get quick information for any documented symbol.
PHP annotations are basically metadata which can be included in the source code and also in between classes, functions, properties and methods. They are to be started with the prefix @ wherever they are declared and they indicate something specific.
Looking into this unfortunately there isn't anything built into PHPStorm to do this. I fixed this issue with a bit of node and have open sourced my work if anyone else needs it.
:)
https://github.com/eknowles/grunt-tidy-annotations
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With