问题描述
在我的PhpStorm 8.0.3代码风格中,我已经设置它在函数声明后添加一个新行,工作正常。
m在,它们说明函数的开始括号必须放在与多个行分开时的函数参数的右括号相同的行中,如可以看到。
当参数拆分为多行时,我想要这样...
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, underEditor -> Code Style -> PHP
selectWrapping 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 theBraces placement
block above.这篇关于停止PhpStorm在函数声明后添加一个新行,当参数拆分为多行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!