I have got phpcs installed in Visual Studio Code, and I have got the following lines in file settings.json:
{
// PHPCS
"phpcs.enable": true,
"phpcs.standard": "WordPress",
}
This seems to have installed correctly and if I have the following code written in a file.
foreach($array as $a ) {
//Some Code here
}
The following errors are returned in the Problem Tab of the Terminal.
Space after opening control structure is required <br/>
No space before opening parenthesis is prohibited <br/>
No space after opening parenthesis is prohibited
I am able to correct these errors manually and the issues goes away from the Problem Tab. Here is how my code looks after fixing manually.
foreach ( $array as $a ) {
// Some Code here.
}
However, if I select the above code block and click on Format Selection, the IDE formats the code as below and again all the errors come back in the Problem Tab.
foreach ($array as $a) {
// Some Code here.
}
Is there a way to use the Format Selection and have it follow the WordPress standards?