dongqixuan3112 2017-02-23 11:00
浏览 72

将PHP样式指南导入PhpStorm以自动构建代码?

We have a really sloppy codebase and I would like to structure it a bit e.g fix all wrongly intended lines and fix such: $sum=1+1 to $sum = 1 + 1.

Is there a way to do this? I have a faint memory that I did something similar with IntelliJ but with googles style guides for java.

  • 写回答

1条回答 默认 最新

  • dsgsgs30201 2017-02-23 13:44
    关注

    Generally speaking: your code will not be reformatted automatically (like Visual Studio may do as you type) -- only with your consent (that's the general idea that devs at JetBrains are sticking to at the moment). Although current formatting rules are used when you insert some elements from Code Completion popup/Live Template.

    You can invoke code formatter manually at any time via Code | Reformat Code.

    To configure formatting rules -- Settings/Preferences | Editor | Code Style | PHP.

    It also allows to use some predefined formatting styles (like PEAR, Zend, WordPress, Symfony 2 etc.) by importing it into your current scheme (useSet from:` clickable link on the right top side of that screen):

    https://www.jetbrains.com/help/phpstorm/2016.3/code-style-php.html#d14191e93

    enter image description here


    PHP language also has support for code re-arrangement (Arrangement tab) -- it allows you to specify how your entities/class elements will be placed in your code (fields first then methods; public methods first and private at the end; etc).

    Code arrangement can be executed without invoking actual code formatting -- use Code | Rearrange Code for that.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?