I'm currently using VS Code's latest version 1.41.1 (at the time of writing).
I've installed PHP CS Fixer to auto-format my code. However there's a behavious that I don't like. It always formats the code like this:
if (condition) {
// code...
} else {
// code
}
But this is not giving me good readability.
I'd like to achieve this:
if (condition)
{
// code...
}
else
{
// code
}
Is there any extentsion that supports this code formatting for PHP in VS Code? Or is there any option in PHP CS Fixer to skip formatting these curly brackets? Any other otpions?
Based on @Nicolas's comment I was able to make it work in 2 steps.
.php_cs
Add this block of code to the file:
<?php
return PhpCsFixer\Config::create()
->setRules(array(
'braces' => array(
'position_after_anonymous_constructs' => 'next',
'position_after_control_structures' => 'next',
)
));
All done and works like a charm. Thanks for the help @Nicolas!