英文:
Laravel Pint json config not wokring
问题
我一直在尝试使用Laravel Pint,但似乎无法按照我想要的方式使其工作。
我的目标是使大括号与类或函数的定义在同一行,而不是像这样:
function test()
{
}
我想要的格式是这样的:
function test() {
}
我在pint.json
文件中使用了以下配置,但没有改变任何东西:
{
"preset": "laravel",
"braces": {
"position_after_functions_and_oop_constructs": "same",
"position_after_anonymous_constructs": "same"
}
}
我甚至尝试使用psr12
预设,但仍然没有改变任何东西:
{
"preset": "psr12"
}
此外,我想知道如何允许这种格式:
if ( !$num )
return;
运行Pint之后,它会更改为以下格式(它移除了if
条件之间的空格,添加了!
后面的空格,并在状态周围添加了括号):
if (! $num) {
return;
}
英文:
I've been playing around with Laravel Pint and I can't seem to make it work the way I want.
My goal is to have the curly brackets inline with class or function
so instead
function test()
{
}
I want to have a format like this
function test() {
}
I have this on pint.json
but doesn't change anything.
{
"preset": "laravel",
"braces": {
"position_after_functions_and_oop_constructs": "same",
"position_after_anonymous_constructs": "same"
}
}
I event tried using psr12
preset and still does not change anything
{
"preset": "psr12"
}
Additionally, I'd like to know how I can allow this format
if ( !$num )
return;
it changes to this after running pint, (it removes the space between if
condition and added a space after !
and wrap the state with brackets)
if (! $num) {
return;
}
答案1
得分: 3
在 pint.json
文件中的规则将会是:
{
"preset": "laravel",
"rules": {
"not_operator_with_successor_space": false,
"curly_braces_position": {
"functions_opening_brace": "same_line",
"classes_opening_brace": "same_line"
}
}
}
根据 PHP-CS-Fixer 的规则,使用 curly_braces_position。
英文:
The rule in a pint.json
will be
{
"preset": "laravel",
"rules": {
"not_operator_with_successor_space": false,
"curly_braces_position": {
"functions_opening_brace": "same_line",
"classes_opening_brace": "same_line"
}
}
}
As per PHP-CS-Fixer Rule, use curly_braces_position
Ref: How with pint can I remove space after negative “!” symbol?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论