valeryan / vscode-phpsab

Php Sniffer and Beautifier for VS Code
https://marketplace.visualstudio.com/items?itemName=ValeryanM.vscode-phpsab
MIT License
58 stars 12 forks source link

Strange indentation behavior #150

Open SirLouen opened 1 week ago

SirLouen commented 1 week ago

This is my settings.json config

{
    "[php]": {
        "editor.defaultFormatter": "valeryanm.vscode-phpsab",
        "editor.formatOnSave": true
    },
    "phpsab.executablePathCBF": "./vendor/bin/phpcbf",
    "phpsab.executablePathCS": "./vendor/bin/phpcs",
    "phpsab.standard": "WordPress",
    "phpsab.snifferArguments": [
        "--ignore=*/wp-admin/*,*/wp-includes/*"
    ]
}

It's using WordPress Coding Standards

When I have for example this code:

if (! empty ( $attributes[''] ) ) {
}

And I save, since there is a WordPress CS rule that says that there should be a space between ( and ! it applies it correctly, but at the same time it applies one indentation to the whole code instead of just applying the space as expected and exiting

I'm assuming this is a bug.

valeryan commented 1 week ago

This extension is a wrapper for the phpcbf tool. If you have issues with the inner working of that you will need to report it to the phpcs/phpcbf devs.

SirLouen commented 1 week ago

Maybe is not getting correctly the Wordpress CS for passing them to phpsab? Are there any debug flags to check for this?

valeryan commented 1 week ago

You can see the commands that the extension is running by turning on debugging in settings and then looking in output in vscode and selecting this extension output.

image