vscode-phpfmt icon indicating copy to clipboard operation
vscode-phpfmt copied to clipboard

preserve array comma style without spaces

Open vkatochka opened this issue 7 months ago • 2 comments

Hi!

Current phpfmt settings:

"phpfmt.psr2": false,
"phpfmt.indent_with_space": false,
"phpfmt.passes": [
  "AllmanStyleBraces"  
]

Original code:

#
$e = array('a','b','c','d');

#
if (in_array($e,['a','b','c']))
{
  return;
}

After formatting:

#
$e = array('a', 'b', 'c', 'd');

#
if (in_array($e, ['a', 'b', 'c']))
{
  return;
}

❓Question

Is it possible to add a setting that:

  • does not insert spaces after commas in arrays and function arguments
  • preserves the style like array('a','b')
  • and still uses tabs for indentation?

When using:

"phpfmt.psr2": true

— spaces after commas are not added, however, tabs are not allowed in PSR-2 mode, and formatting fails with an error

🙏 Feature Suggestion

Please consider adding a setting to preserve the original formatting style without spaces after commas, while still allowing tab indentation.

Thank you for a great extension and your continued support!

Best regards, Vitalii

vkatochka avatar May 27 '25 19:05 vkatochka

Hi @vkatochka good morning. I'm sorry implementing a rule like this is not currently planed.

driade avatar May 29 '25 09:05 driade

Thanks for the answer.

vkatochka avatar May 31 '25 15:05 vkatochka