You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat!: bump default formatting version to composer version with fallback to latest supported PHP (#2434)
* feat!: bump default formatting version to 8.3
BREAKING CHANGE: If you didn't set the `phpVersion` option explicitly,
the formatting will assume PHP 8.3 now (instead of 7.0).
* added composer version detection
* run all spec.mjs test files, not just jsfmt, remove __tests__ dir as not used
* changed return to null and improved test coverage
- added wildcard major versions
- updated test for null return
- added invalid json test case
* refactor: renamed getComposerPhpVersion func to match config naming more closely
* documentation updaste for PHP default version changes
* reformat: ran prettier on README
* set default phpVersion to auto and added composer setting
* refactored versions after rebasing
- automatically use latest version
- phpVersion is always a number now
- moved isMinVersion to simple number comparison
* update versions to number
* snapshot changes after bumping default version to 8.4
* reformat: prettier
* fix default version
* Update README.md to be clearer about default php version
Co-authored-by: Christian Zosel <christian@zosel.ch>
* Update README.md fix typo
Co-authored-by: Christian Zosel <christian@zosel.ch>
* Update src/options.mjs remove extra else
Co-authored-by: Christian Zosel <christian@zosel.ch>
* make not json example much clearer
---------
Co-authored-by: Chris Seufert <chris@seufert.id.au>
Co-authored-by: Chris Seufert <chris@modd.com.au>
|`phpVersion`|`"7.0"`| Allows specifying the PHP version you're using. If you're using PHP 7.1 or later, setting this option will make use of modern language features in the printed output. If you're using PHP lower than 7.0, you'll have to set this option or Prettier will generate incompatible code. |
182
-
|`printWidth`|`80`| Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#print-width)) |
183
-
|`tabWidth`|`4`| Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tab-width)), The default is `4` based on the `PSR-2` coding standard. |
184
-
|`useTabs`|`false`| Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tabs)) |
185
-
|`singleQuote`|`false`| If set to `"true"`, strings that use double quotes but do not rely on the features they add, will be reformatted. Example: `"foo" -> 'foo'`, `"foo $bar" -> "foo $bar"`. |
186
-
|`trailingCommaPHP`|`true`| If set to `true`, trailing commas will be added wherever possible. <br> If set to `false`, no trailing commas are printed. |
187
-
|`braceStyle`|`"per-cs"`| If set to `"per-cs"`, prettier will move open brace for code blocks (classes, functions and methods) onto new line. <br> If set to `"1tbs"`, prettier will move open brace for code blocks (classes, functions and methods) onto same line. |
188
-
|`requirePragma`|`false`| Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#require-pragma)) |
189
-
|`insertPragma`|`false`| Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#insert-pragma)) |
|`phpVersion`|`"auto"`\*| Allows specifying the PHP version you're using. (See Notes Below) |
182
+
|`printWidth`|`80`| Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#print-width)) |
183
+
|`tabWidth`|`4`| Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tab-width)), The default is `4` based on the `PSR-2` coding standard. |
184
+
|`useTabs`|`false`| Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tabs)) |
185
+
|`singleQuote`|`false`| If set to `"true"`, strings that use double quotes but do not rely on the features they add, will be reformatted. Example: `"foo" -> 'foo'`, `"foo $bar" -> "foo $bar"`. |
186
+
|`trailingCommaPHP`|`true`| If set to `true`, trailing commas will be added wherever possible. <br> If set to `false`, no trailing commas are printed. |
187
+
|`braceStyle`|`"per-cs"`| If set to `"per-cs"`, prettier will move open brace for code blocks (classes, functions and methods) onto new line. <br> If set to `"1tbs"`, prettier will move open brace for code blocks (classes, functions and methods) onto same line. |
188
+
|`requirePragma`|`false`| Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#require-pragma)) |
189
+
|`insertPragma`|`false`| Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#insert-pragma)) |
190
+
191
+
### \*`phpVersion` Configuration Notes :
192
+
193
+
The default setting `auto`, attempts to auto-detect your supported php versions from a `composer.json` with in the
194
+
current directory or any parent directory, the plugin will use a minimum supported php version from
195
+
`{"require":{"php":"..."}}` to set the phpVersion. If not found or not able to be parsed, it will default to latest
196
+
supported PHP version.
197
+
198
+
You set the `phpVersion` to `composer` and this will only use the `composer.json` file to determine the php
199
+
version, prettier will crash if the PHP cannot be determined.
200
+
201
+
You can also set the `phpVersion` to a specific version, such as `7.4`, `8.0`, `8.1`, `8.2`, or `8.3`.
202
+
203
+
**Please Note:** If the phpVersion is not set correctly for your environment, this plugin will produce code that could
204
+
be incompatible with your PHP runtime. For example, if you are using PHP 7.4, but the plugin is set to PHP 8.3, it will
205
+
produce code that uses features not available in PHP 7.4.
0 commit comments