-
-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: New option phpVersion
#1280
Comments
Could an implementation of this also support presets? @czosel mentioned config presets in #1274 (comment) and I could see those being equally useful. (eg. WordPress vs. Symfony) Maybe they could be pluggable with separate packages providing the definitions, similar to how eslint and stylelint work with their config packages. |
Hmm, I think that would contradict prettiers option philisophy (you probably know the text, but I find it helps to re-read it sometimes 🙂). I used the preset analogy because |
👍 On roadmap |
This makes perfect sense to me. it makes config simpler. that's exactly what I don't want to have to care about. |
Is there a specific option to force the old behavior of using 'array()' instead of shorthand notation without using the generic "phpVersion": "5.3" ? |
@sparcbr Please open a new issue |
From the discussion in #1274 the idea to introduce a new option
phpVersion
emerged. Since this affects a few other ongoing discussions we'd like to share the plan and ask for feedback! If you agree to the proposal and have nothing to add, feel free to post a 👍 reaction!The basic issue we'd like to solve is that in some cases we need to know the PHP version in use to achieve optimal formatting. For example, starting with PHP 7.3, heredoc/nowdoc can be formatted in a more readable (indented) way, which doesn't work in previous versions.
The following table summarizes the areas where we'd currently benefit from knowing the PHP Version:
array(...)
as shorthand[...]
We propose to do the following changes:
Introduce new option
phpVersion
As the name says, this options allows you to specify the PHP version you're using. Any valid PHP version numer can be specified as value, but they fall in different categories:
7.1
,7.0
,5.6
,5.5
,5.4
: Since our formatting doesn't change between these versions, all of them are equivalent. Since most users are using one of these versions, this category would be the default.7.2
: Print trailing commas in "use"7.3
,7.4
: Print trailing commas in function calls5.3
,5.2
,5.1
,5.0
and older: Don't force array shorthand notationtrailing commas
none
andall
, make it a Boolean (none
=>false
,all
=>true
)true
(which checks thephpVersion
setting to determine which trailing commas can be printed) (see Behavior change: Add trailing commas to array items #493 (comment))array shorthand
Print
array(...)
as shorthand[...]
except whenphpVersion < 5.4
flexible heredoc/nowdoc
Print heredoc/nowdoc in "classic" (non-flexible) style except when
phpVersion >= 7.3
If you'd like to read more about the reasoning behind this, alternatives and trade-offs please see #1274. Thanks!
The text was updated successfully, but these errors were encountered: