You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在PhpStorm中保留行尾PHPdoc注释不自动换行?

如何让PhpStorm保留行尾的PHPdoc注释不自动换行

你可以通过调整PhpStorm的代码风格设置实现需求,具体步骤如下:

  • 打开PhpStorm设置:使用快捷键Ctrl+Alt+S(Windows/Linux)或Cmd+,(Mac)。
  • 依次进入Editor > Code Style > PHP,切换到Code Generation标签页。
  • 在「Commenting code」区域,勾选Place documentation comment at line end选项。
  • (可选)如果数组内注释仍有问题,切换到Wrapping and Braces标签页,找到Arrays部分,确保未开启强制将注释换行的相关选项。

设置完成后,重新格式化代码(快捷键Ctrl+Alt+L/Cmd+Opt+L),行尾的PHPdoc注释就会保持在代码行末尾,不会被自动换行到新行。

比如你的示例代码,格式化后会保留成期望样式:

[
    'configFoo' => ['some' => true], /** @see Foo::some */
    'configBar' => ['baz' => true] /** @see Bar::baz */
]

//...
$a = 42; /** @link https://fakewikipedia.com/The_Answer_to_the_Ultimate_Question_of_Life */
$b = 1; /** @see ExternalDocumentation */

内容的提问来源于stack exchange,提问作者j. Doe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 23:01:09