首页 > 解决方案 > 如何对 PhpStorm 中的字段进行排序,包括注释

问题描述

我有一堆领域,比如

/**
 * @var string
 * Some stuff here
 */
private $var3;


/**
 * @var int
 * Some other stuff
 */
private $var2;

// Just a comment
private $var1;

我想让它们按字母顺序排列。最终结果应该是

// Just a comment
private $var1;

/**
 * @var int
 * Some other stuff
 */
private $var2;

/**
 * @var string
 * Some stuff here
 */
private $var3;

我尝试使用一个名为“字符串操作”的插件,但它不会将注释与字段保持在一起,排序会导致像这样的随机

* @var int
* @var string

* Some other stuff
 * Some stuff here
 */
 */
/**

/**
 // Just a comment
 private $var1;
 private $var2;
private $var3;

我还尝试使用 IDE 内置的重新排列代码。我保留了默认规则,但将“字段”之一更改为“按名称排序”。好像什么都没做... 在此处输入图像描述

我对尝试什么没有任何其他想法,并且对于许多大文件,手动执行此操作是一项乏味的工作。

有什么解决办法吗?

标签: phpstormjetbrains-idecode-formatting

解决方案


推荐阅读