kokororin / vscode-phpfmt

Integrates phpfmt into VS Code
https://marketplace.visualstudio.com/items?itemName=kokororin.vscode-phpfmt
BSD 3-Clause "New" or "Revised" License
129 stars 30 forks source link

Issues with formatting of Arrays and Array Access in vscode-phpfmt for WordPress Coding Standards #111

Closed nisarul-dev closed 1 year ago

nisarul-dev commented 1 year ago

Issues:

  1. As per WordPress Coding Standard, an array should be defined like this: (space at the beginning and closing of parentheses or square brackets) Screenshot 2023-05-30 at 10 09 59 AM Source: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#declaring-arrays

  2. As per WordPress Coding Standard, spaces while accessing array items will be like this: Screenshot 2023-05-30 at 10 06 16 AM Source: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#space-usage

Please, solve this issue by introducing some configurations regarding "[]" (Square brackets) so that WordPress Developers can write PHP and use the vscode-phpfmt with more ease.

Thank you.

driade commented 1 year ago

Hello, good morning.

@kokororin has indicated I could directly help with this issue. Under the hood, vscode-phpfmt uses the package https://github.com/driade/phpfmt8 that I currently maintain.

Please feel free to open and issue there so we can discuss this update you need. There's nothing like this at this moment (WP special formatters) but I think we could handle it.

Thanks.

nisarul-dev commented 1 year ago

Thank you for the kind information and valuable suggestion. I am opening an issue under https://github.com/driade/phpfmt8

Thanks.

driade commented 1 year ago

Hello, good morning.

This issue has been solved in https://github.com/driade/phpfmt8/issues/33

I've added a new option in the config, "--wp", which works like PSR2 but adding the formatting for the spaces you asked for.

I don't know much about WP coding standards, please indicate if there's any other update I should make.

Thanks.

kokororin commented 1 year ago

Hello,

You can upgrade fmt by using such vscode command: F1 -> phpfmt: Upgrade fmt.phar or fmt.stub.php

Then add "--wp" to settings.json.