VS Code PHP Formatter Intelephense
Asked Answered
M

1

19

I use Visual Studio Code as my editor and Intelephense as my PHP formatter. It works well for the most part, but Intelephense changes my format in several ways that makes it harder for me to read. For example, I like to format my code as follows:

    if( $var ) {
        // Do something.
    }
    elseif( $var ) {
        // Do something.
    }

But! When I save, Intelephense changes the above to:

    if ($var) {
        // Do something.
    } elseif ($var) {
        // Do something.
    }

To me, that's harder to read, especially when dealing with long expressions. How can I configure Intelephense to format my code as in the first example?

Matronize answered 20/7, 2020 at 16:42 Comment(1)
I wrote an answer on a similar question.Thorson
O
29

Extensions > PHP Intelephense > Manage(click the gear) > Find Intelephense › Format: Braces and change or Find Intelephense › Format: Enable and remove tick.

Oviduct answered 20/7, 2020 at 16:53 Comment(4)
Yes, that takes care of the braces going on a new line, thank you. I set my braces to the Allman style, which is what I wanted. But how about spacing, if( $var ) instead of if ($var)?Matronize
Try Spaces Inside Braces ExtensionOviduct
I tried Spaces Inside Braces but when I save, the spaces get deleted by PHP formatter, Intelephense. Is there a setting within Intelephense that'll do it?Matronize
I don't know sorry.Oviduct

© 2022 - 2024 — McMap. All rights reserved.