代码之家  ›  专栏  ›  技术社区  ›  Luiz

不要用phpstorm封装else-if

  •  1
  • Luiz  · 技术社区  · 8 年前

    我试图在phpstorm中使用一些预定义的代码样式,以便使用 Ctrl+Alt+L ,例如zend或codeigniter。

    但是,所有这些都转换为

    if ($a) {
      //
    } else if ($b) {
     //
    } else if ($c) {
      //
    }
    

    进入之内

    if ($a) {
      //
    } else {
      if ($b) {
        //
      } else {
        if ($c) {
          //
        }
      }
    }
    

    我怎样才能摆脱这个?我试着设置一些选项,比如 Group use => do not wrap Special else if treatment => false ,但这些似乎不起作用。

    代码样式XML: https://pastebin.com/Lu5NMys3

    1 回复  |  直到 8 年前
        1
  •  2
  •   LazyOne    8 年前
    1. Settings/Preferences
    2. Editor | Code Style | PHP
    3. Wrapping and Braces 标签
    4. 'if()' statement --> Special 'else if' treatment --确保选中此选项。

      enter image description here

    5. Code Conversion 标签

    6. Convert else if / esleif to: -禁用或选择所需样式。

      enter image description here