How to stop curly brace on new line when formatting the code
Asked Answered
C

3

12

I am using VSCode and have installed phpfmt PHP formater extension. When I hit the format code option, the cruly braces of functions and classes are set to new line. I have practice of adding curly brace on the same line and I want the same to be done by the formater.

What I want is:

public function abc () {

}

What PHP formater does is:

public function abc ()
{

}
Countersubject answered 23/11, 2018 at 7:33 Comment(0)
A
0

Tried excluding AllmanStyleBraces, but haven't worked. Then, following answer of @GlebKemarsky that suggest to disable PSR2 style guides, I tried be less aggressive and excluding only PSR2CurlyOpenNextLine worked in VS Code.

"phpfmt.exclude": [
    "PSR2CurlyOpenNextLine"
]
Apgar answered 26/7, 2024 at 3:20 Comment(0)
M
-1

It works for me:

"phpfmt.psr2": false,

This option is enabled by default and and as written in this standard:

Opening braces for methods MUST go on the next line

Muscovado answered 15/2, 2021 at 16:10 Comment(0)
A
-2
"phpfmt.exclude": ["AllmanStyleBraces"]
Ashton answered 3/3, 2020 at 7:53 Comment(1)
I doubt that this helps or even works at all. Please explain how it is supposed to work and why it is supposed to help.Wrac

© 2022 - 2025 — McMap. All rights reserved.