停止PhpStorm在函数声明后添加一个新行,当参数拆分为多行时 [英] Stop PhpStorm from adding a new line after function declaration when arguments split across multiple lines

查看:555
本文介绍了停止PhpStorm在函数声明后添加一个新行,当参数拆分为多行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的PhpStorm 8.0.3代码风格中,我已经设置它在函数声明后添加一个新行,工作正常。



m在 PSR-2标准,它们说明函数的开始括号必须放在与多个行分开时的函数参数的右括号相同的行中,如可以看到 here



当参数拆分为多行时,我想要这样...

  public function myMethod(
MyClass $ arg1,
$ arg2 = null,
){
//方法体
}



...当他们都在同一行...

  public function myMethod(MyClass $ arg1,$ arg2 = null)
{
//方法体
}

我试图搜索该选项,但我找不到 - 我知道我可以决定是否要添加新行

解决方案

文件 - >设置对话框,编辑器 - >代码样式 - > PHP 在右侧选择选项卡。



查找函数声明参数阻塞并检查主控制,在这里你有一堆关于包装参数和几个其他选项控制大括号放置的选项。另请参阅上面的大括号放置块。


In my PhpStorm 8.0.3 code style, I have set it to add a new line after a function declaration, which works fine.

Problem is now I'm in a new project that follows the PSR-2 Standards, which say that the opening brace of a function MUST be placed in the same line that the closing parenthesis of the function arguments when these split across multiple lines, as you can see here.

I want this when arguments split across multiple lines...

public function myMethod(
    MyClass $arg1,
    $arg2 = null,
) {
    // method body
}

...and this when they are all in the same line...

public function myMethod(MyClass $arg1, $arg2 = null)
{
    // method body
}

I was trying to search for that option but I couldn't find it - I know I can decide whether I want to add the new line for all functions, but I need it only in these particular occasions.

解决方案

In the File -> Settings dialogue, under Editor -> Code Style -> PHP select Wrapping and Braces tab on the right hand side.

Find the Function declaration parameters block and check the main control, here you have a bunch of options regarding wrapping parameters and few other options in this block to control braces placement. Also look at the Braces placement block above.

这篇关于停止PhpStorm在函数声明后添加一个新行,当参数拆分为多行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆