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

为何使用PhpStorm的Reformat Code功能时部分方法格式不一致?

解决PhpStorm中Laravel方法格式不一致的问题

可以实现统一格式,调整以下PhpStorm代码风格设置即可:

  1. 打开设置面板(快捷键Ctrl+Alt+S,或顶部菜单File > Settings)
  2. 进入Editor > Code Style > PHP设置项
  3. 切换到Wrapping and Braces标签页,调整几个关键选项:
    • 在「Method modifiers」区域,勾选Place 'function' keyword on the same line as modifiers,同时设置Wrap modifiers为「Do not wrap」,确保public等修饰符和function在同一行
    • 在「Method declaration parameters」区域,设置Wrap when typing reaches right margin为「Do not wrap」,避免参数单独换行
    • 在「Method return type」区域,勾选Place return type on the same line as method name,让返回类型和方法名保持在同一行

调整完成后点击「Apply」保存设置,再选中文件内容执行Reformat Code(快捷键Ctrl+Alt+L),所有方法就会统一成你想要的第一种紧凑格式。

内容的提问来源于stack exchange,提问作者mstdmstd

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.08 13:55:20