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 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教