0

Assume I have this code where each brace is on a separate line. As soon as I save this code the code is changed by VS code so each brace is no longer on a separate line.

function mainEngine(string &$errmessage): void
{
    if (isFormSent()) 
    {
        if ((new User())->loginUser($_POST['username'], 
           $_POST['password'])) 
        {
            header("Location:admin.php");
        } 
        else 
        {
            $errmessage = "Felaktig användare/password";
        }
    }
}

//Tony

user2658578
  • 365
  • 2
  • 5
  • [Take a quick look at a coding standard](http://www.php-fig.org/psr/psr-12/) – RiggsFolly Mar 09 '20 at 13:17
  • It's much more dificult to read the code when the braces are not on separate line. I have tried with .php_cs located in the root without success which looks like this setRules(array( 'braces' => array( 'position_after_anonymous_constructs' => 'next', 'position_after_control_structures' => 'next', ) )); – user2658578 Mar 09 '20 at 13:22
  • I would disagree, I find it much more anoying when the braces are all on seperate lines. It also means I cannot see as many lines of code on a screen, because half of those I can see are just `{` and `}` – RiggsFolly Mar 09 '20 at 13:24
  • I know that this is highly debated but I just want to know if i can make some settings to keep braces on separate line when I code PHP in VS code – user2658578 Mar 09 '20 at 13:26
  • Is there any way to make VS code to keep braces on separate line when I save the code after having done some coding for PHP – user2658578 Mar 09 '20 at 13:36
  • Does this answer your question? [How do I set up VSCode to put curly braces on a new line?](https://stackoverflow.com/questions/32900921/how-do-i-set-up-vscode-to-put-curly-braces-on-a-new-line) – M. Volf Mar 09 '20 at 16:47

1 Answers1

0

As M. Volf says: This is the specific intelephense braces config (k&r type braces) on your User Settings (JSON), add this line:

    "intelephense.format.braces": "k&r",
helvete
  • 2,455
  • 13
  • 33
  • 37