Prettier 1.14.3
PHP Plugin 0.9.0
// Options (if any):
{
"braceStyle": "1tbs"
}
Input:
$a = "hello "."world";
Output:
$a = 'hello ' . 'world';
Expected behaviour:
Symfony's coding standards require that there are no spaces around concatenation. I can't see anything in accepted PSRs that leans one way or the other. It seems that there's no real consistency across different coding standards:
concat_space which defaults to none).Do you think this is worth an option given the differences of standards?
@aboyton don't think we really need this option, it is normal add space for binary operators. Also for me it is real unreadable. We will have to implement a lot of options if we want to satisfy everyone coding standards and we have philosophy for this https://prettier.io/docs/en/option-philosophy.html
/cc @czosel
I agree that there shouldn't be an option for this. The style we implement in prettier should be the one which is more popular in the community - not sure which one that would be.
Without option with space around concatenation operator.
/cc @czosel i think we need more options to adapt prettier on difference code bases :smile: . Ideally doesn't have many options. Will be great have option: codeStyle with popular code styles, for example PSR (always latest and it is default), WordPress, Symfony and Laravel, it is allow to us increase users and avoid unnecessary options. What do you think?
Hmm, while the idea of "bundling" options sounds interesting, I'd like it if our plugin would motivate the PHP community to converge to a common coding style. Especially with this example (spacing around concatenation operator) I think the community would benefit more from a common standard.
If a specific community/project won't adopt prettier because of this, they should also be able to do something similar to https://github.com/prettier/prettier-eslint using php-cs-fixer?
https://github.com/prettier/plugin-php/tree/master/docs/recipes/php-cs-fixer
@czosel I鈥檓 afraid that the community doesn't want to have a common standard (PSR exists very long time) and we should think more about the ideas above, we don't need support all formats, only popular, also Symfony and Laravel should be very easy to implement. I think we need close this issue and some other and open new issue about this and continue discussion there. What do you think? Right now support php7.3/php7.4/inline/comments are high priority so implementation this feature may be delayed
@evilebottnawi Probably that's also because PSR made some unpopular decisions (brace style) and doesn't specify as much as people need (like this issue). I agree that we should study this after we made the first stable release. I'd start by making a big table that compares the differences between the coding standards, which we could use to decide about what should be implemented. Probably it would also make sense to talk to members of the individual "sub" communities about how important specific decisions are to them. I'll go ahead and close this issue for now.
Most helpful comment
Without option with space around concatenation operator.