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

Weird change on "format" that causes syntax error in PHP #130

Open Spriz opened 2 months ago

Spriz commented 2 months ago

When formatting code with this extension it changes this line here: https://github.com/spawnia/sailor/blob/master/src/Codegen/ObjectLikeBuilder.php#L91

to:

        $this->converters->addBody                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       /** @lang PHP */ '];');

(it adds a bunch of whitespaces)

Running phpcbf from terminal doesn't do this

the phpcs error it's showing is from this rule


    <rule ref="Generic.WhiteSpace.ScopeIndent">
        <properties>
            <property name="indent" value="4" />
            <property name="exact" value="true" />
        </properties>
    </rule>
jonathanbossenger commented 2 months ago

Hi @Spriz, I'd like to try and replicate your environment to test this.

Could I confirm with you, is this a package you are developing for, or including as a dependency?

What coding style standard are you applying to phpcs/phpcbf

Spriz commented 2 months ago

@jonathanbossenger It's just a dependency I had opened to make a 1-line PR, but I'm actually worried that it might have been my VSCode setup using an extension that should auto format with phpcbf. It caused other issues for me the past few days, and I ended up uninstalling it.

jonathanbossenger commented 2 months ago

OK, thanks anyway for the feedback.

Spriz commented 2 months ago

Sorry it's not very specific. These are the phpcs settings I use FWIW: https://gist.github.com/Spriz/f5517701dafbe9c1c077458012559a0e

Feel free to close if you don't see any easy reproducible thing here :v: