Php补丁程序正在执行:
function foobar()
{
....
}我想:
function foobar() {
....
}我看不出在配置.php_cs文件中的同一行上保留大括号的配置是什么,在https://github.com/FriendsOfPHP/PHP-CS-Fixer上也是如此。我使用的是php-cs-fixerV2 2。
发布于 2018-11-16 11:07:35
您启用了PSR-2,这需要下一行的大括号。从文献资料看来,您可以将braces.position_after_functions_and_oop_constructs设置为same (默认为next):
position_after_functions_and_oop_constructs ('next', 'same'):在高级构造(非匿名类、接口、特征、方法和非lambda函数)之后,是否应该将开头大括号放在“next”或“相同”行上;默认为'next‘。myconfig.php_cs:
'braces' => array(
'allow_single_line_closure' => true,
'position_after_functions_and_oop_constructs' => 'same',
),发布于 2019-02-26 10:48:49
您在这里描述的样式称为“一个真正的支撑样式((OTBS%29))”(缩写为1TBS或OTBS)。
当我得到同样的问题时,我终于在这里结束了,尽管@Robbie的回答很有帮助,但我仍然需要大量的搜索。
因此,我终于在我的存储库中获得了这个.php_cs:
<?php
$finder = PhpCsFixer\Finder::create()
//->exclude('somedir')
//->notPath('src/Symfony/Component/Translation/Tests/fixtures/resources.php'
->in(__DIR__)
;
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'strict_param' => false,
'array_syntax' => ['syntax' => 'long'],
'braces' => [
'allow_single_line_closure' => true,
'position_after_functions_and_oop_constructs' => 'same'],
])
->setFinder($finder)
;一些解释(来自(自述)):
array()而不是[]。是使用长数组语法,还是使用短数组语法;默认为“long”;在IDE中,php补丁插件将在当前项目的根路径中搜索.php_cs配置文件。也可以指定路径。
https://stackoverflow.com/questions/53336561
复制相似问题