@prettier/plugin-php 0.22.4 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,26 +8,23 @@
8
8
  <h2 align="center">Prettier PHP Plugin</h2>
9
9
 
10
10
  <p align="center">
11
- <a href="https://github.com/prettier/plugin-php/actions">
12
- <img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/prettier/plugin-php/Node CI?style=flat-square">
11
+ <a href="https://github.com/prettier/plugin-php/actions?query=branch%3Amain">
12
+ <img alt="CI Status" src="https://img.shields.io/github/actions/workflow/status/prettier/plugin-php/nodejs.yml?style=flat-square&label=CI&branch=main">
13
13
  </a>
14
14
  <a href="https://www.npmjs.com/package/@prettier/plugin-php">
15
15
  <img alt="npm version" src="https://img.shields.io/npm/v/@prettier/plugin-php.svg?style=flat-square">
16
16
  </a>
17
17
  <a href="https://codecov.io/gh/prettier/plugin-php">
18
- <img alt="Codecov Coverage Status" src="https://img.shields.io/codecov/c/github/prettier/plugin-php.svg?style=flat-square">
18
+ <img alt="Coverage Status" src="https://img.shields.io/codecov/c/github/prettier/plugin-php.svg?style=flat-square">
19
19
  </a>
20
20
  <!-- <a href="https://www.npmjs.com/package/@prettier/plugin-php">
21
21
  <img alt="monthly downloads" src="https://img.shields.io/npm/dm/@prettier/plugin-php.svg?style=flat-square">
22
22
  </a> -->
23
- <a href="#badge">
23
+ <a href="https://github.com/prettier/prettier#badge">
24
24
  <img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square">
25
25
  </a>
26
- <a href="https://gitter.im/jlongster/prettier">
27
- <img alt="Gitter" src="https://img.shields.io/gitter/room/jlongster/prettier.svg?style=flat-square">
28
- </a>
29
- <a href="https://twitter.com/PrettierCode">
30
- <img alt="Follow+Prettier+on+Twitter" src="https://img.shields.io/twitter/follow/prettiercode.svg?label=follow+prettier&style=flat-square">
26
+ <a href="https://x.com/intent/follow?screen_name=PrettierCode">
27
+ <img alt="Follow Prettier on X" src="https://img.shields.io/badge/%40PrettierCode-9f9f9f?style=flat-square&logo=x&labelColor=555">
31
28
  </a>
32
29
  </p>
33
30
 
@@ -179,17 +176,33 @@ await prettier.format(YOUR_CODE, {
179
176
 
180
177
  Prettier for PHP supports the following options. We recommend that all users set the `phpVersion` option.
181
178
 
182
- | Name | Default | Description |
183
- | ------------------ | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
184
- | `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. |
185
- | `printWidth` | `80` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#print-width)) |
186
- | `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. |
187
- | `useTabs` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tabs)) |
188
- | `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"`. |
189
- | `trailingCommaPHP` | `true` | If set to `true`, trailing commas will be added wherever possible. <br> If set to `false`, no trailing commas are printed. |
190
- | `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. |
191
- | `requirePragma` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#require-pragma)) |
192
- | `insertPragma` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#insert-pragma)) |
179
+ | Name | Default | Description |
180
+ | ------------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
181
+ | `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.
193
206
 
194
207
  ## Ignoring code
195
208
 
@@ -227,10 +240,6 @@ matrix(
227
240
 
228
241
  ## Editor integration
229
242
 
230
- ### Atom
231
-
232
- The official [prettier plugin for atom](https://github.com/prettier/prettier-atom) supports plugins.
233
-
234
243
  ### Visual Studio Code
235
244
 
236
245
  The official [prettier plugin for vscode](https://github.com/prettier/prettier-vscode) supports plugins since Version 1.10.0. To enable it, install the extension and make sure the plugin is installed _locally_ (in your project folder).
@@ -276,6 +285,10 @@ Sublime Text support is available through Package Control and the [JsPrettier](h
276
285
 
277
286
  The official [prettier plugin for vim](https://github.com/prettier/vim-prettier) has built-in support for plugin-php since 1.0.
278
287
 
288
+ ### Nova
289
+
290
+ The [Prettier⁺ Extension](https://extensions.panic.com/extensions/stonerl/stonerl.prettier/) has built-in support for plugin-php.
291
+
279
292
  #### ALE
280
293
 
281
294
  The linting plugin ALE has built-in support for prettier and its plugins. Just add prettier to your [list of fixers](https://github.com/w0rp/ale#2ii-fixing). For example:
package/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import type { Plugin } from "prettier";
2
+
3
+ declare const plugin: Plugin;
4
+ export default plugin;
package/package.json CHANGED
@@ -1,30 +1,36 @@
1
1
  {
2
2
  "name": "@prettier/plugin-php",
3
- "version": "0.22.4",
3
+ "version": "0.24.0",
4
4
  "description": "Prettier PHP Plugin",
5
5
  "repository": "prettier/prettier-php",
6
6
  "author": "Lucas Azzola <@azz>",
7
7
  "license": "MIT",
8
8
  "unpkg": "./standalone.js",
9
9
  "browser": "./standalone.js",
10
+ "types": "./index.d.ts",
10
11
  "exports": {
11
12
  ".": {
13
+ "types": "./index.d.ts",
12
14
  "browser": "./standalone.js",
13
15
  "default": "./src/index.mjs"
14
16
  },
15
- "./standalone": "./standalone.js",
17
+ "./standalone": {
18
+ "types": "./index.d.ts",
19
+ "default": "./standalone.js"
20
+ },
16
21
  "./package.json": "./package.json"
17
22
  },
18
23
  "files": [
19
24
  "src",
20
- "standalone.js"
25
+ "standalone.js",
26
+ "index.d.ts"
21
27
  ],
22
28
  "dependencies": {
23
- "linguist-languages": "^7.27.0",
24
- "php-parser": "^3.1.5"
29
+ "linguist-languages": "^8.0.0",
30
+ "php-parser": "^3.2.5"
25
31
  },
26
32
  "devDependencies": {
27
- "@babel/preset-env": "^7.23.6",
33
+ "@babel/preset-env": "^7.27.2",
28
34
  "@rollup/plugin-alias": "^5.1.0",
29
35
  "@rollup/plugin-babel": "^6.0.3",
30
36
  "@rollup/plugin-commonjs": "^25.0.7",
@@ -33,7 +39,7 @@
33
39
  "@rollup/plugin-node-resolve": "^15.2.1",
34
40
  "@rollup/plugin-replace": "^5.0.5",
35
41
  "@rollup/plugin-terser": "^0.4.3",
36
- "c8": "^9.1.0",
42
+ "c8": "^10.1.3",
37
43
  "cross-env": "^7.0.2",
38
44
  "eslint": "8.57.0",
39
45
  "eslint-config-prettier": "9.1.0",
@@ -41,11 +47,11 @@
41
47
  "eslint-plugin-jest": "27.6.3",
42
48
  "eslint-plugin-prettier": "5.1.3",
43
49
  "eslint-plugin-prettier-doc": "^1.1.0",
44
- "jest": "29.7.0",
45
- "jest-environment-jsdom": "29.7.0",
46
- "jest-light-runner": "^0.6.0",
50
+ "jest": "30.0.3",
51
+ "jest-environment-jsdom": "30.0.2",
52
+ "jest-light-runner": "^0.7.9",
47
53
  "jest-snapshot-serializer-raw": "^2.0.0",
48
- "prettier": "^3.0.1",
54
+ "prettier": "^3.6.1",
49
55
  "rollup": "^3.28.1",
50
56
  "strip-ansi": "^7.1.0"
51
57
  },
package/src/index.mjs CHANGED
@@ -1,8 +1,6 @@
1
1
  import { doc } from "prettier";
2
- import {
3
- LINGUIST_LANGUAGES_PHP,
4
- LINGUIST_LANGUAGES_HTML_PHP,
5
- } from "./linguist-languages.cjs";
2
+ import LINGUIST_LANGUAGES_PHP from "linguist-languages/data/PHP";
3
+ import LINGUIST_LANGUAGES_HTML_PHP from "linguist-languages/data/HTML_2b_PHP";
6
4
  import parse from "./parser.mjs";
7
5
  import print from "./printer.mjs";
8
6
  import clean from "./clean.mjs";
@@ -1,6 +1,6 @@
1
1
  import { getPrecedence, shouldFlatten, isBitwiseOperator } from "./util.mjs";
2
2
 
3
- function needsParens(path) {
3
+ function needsParens(path, options) {
4
4
  const { parent } = path;
5
5
 
6
6
  if (!parent) {
@@ -128,13 +128,16 @@ function needsParens(path) {
128
128
  }
129
129
  case "clone":
130
130
  case "new": {
131
+ const requiresParens =
132
+ node.kind === "clone" ||
133
+ (node.kind === "new" && options.phpVersion < 8.4);
131
134
  switch (parent.kind) {
132
135
  case "propertylookup":
133
136
  case "nullsafepropertylookup":
134
137
  case "staticlookup":
135
138
  case "offsetlookup":
136
139
  case "call":
137
- return key === "what";
140
+ return key === "what" && requiresParens;
138
141
  default:
139
142
  return false;
140
143
  }
package/src/options.mjs CHANGED
@@ -1,28 +1,124 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
1
4
  const CATEGORY_PHP = "PHP";
2
5
 
6
+ // prettier-ignore
7
+ const SUPPORTED_PHP_VERSIONS = [
8
+ 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6,
9
+ 7.0, 7.1, 7.2, 7.3, 7.4,
10
+ 8.0, 8.1, 8.2, 8.3, 8.4,
11
+ ];
12
+
13
+ export const LATEST_SUPPORTED_PHP_VERSION = Math.max(...SUPPORTED_PHP_VERSIONS);
14
+
15
+ let getComposerError = "";
16
+
17
+ /**
18
+ * Detect the minimum PHP version from the composer.json file
19
+ * @return {number|null} The PHP version to use in the composer.json file, null when not found
20
+ */
21
+ function getComposerPhpVersion() {
22
+ // Try to find composer.json
23
+ const currentDir = process.cwd();
24
+ let composerPath = null;
25
+
26
+ const directComposerPath = path.join(currentDir, "composer.json");
27
+ if (fs.existsSync(directComposerPath)) {
28
+ composerPath = directComposerPath;
29
+ }
30
+
31
+ if (!composerPath) {
32
+ let searchDir = path.dirname(currentDir);
33
+ while (searchDir !== path.parse(searchDir).root) {
34
+ const potentialComposerPath = path.join(searchDir, "composer.json");
35
+ if (fs.existsSync(potentialComposerPath)) {
36
+ composerPath = potentialComposerPath;
37
+ break;
38
+ }
39
+ searchDir = path.dirname(searchDir);
40
+ }
41
+ }
42
+
43
+ if (composerPath) {
44
+ try {
45
+ const fileContent = fs.readFileSync(composerPath, "utf8");
46
+ const composerJson = JSON.parse(fileContent);
47
+
48
+ if (composerJson.require && composerJson.require.php) {
49
+ // Check for a wildcard pattern like "7.*"
50
+ const wildcardMatch = composerJson.require.php.match(
51
+ /^(?:[^0-9]*)?([0-9]+)\.\*/
52
+ );
53
+ if (wildcardMatch) {
54
+ return parseFloat(`${wildcardMatch[1]}.0`);
55
+ }
56
+
57
+ // Extract version from composer semver format
58
+ const versionMatch = composerJson.require.php.match(
59
+ /^(?:[^0-9]*)?([0-9]+)\.([0-9]+)/
60
+ );
61
+
62
+ if (versionMatch) {
63
+ return parseFloat(`${versionMatch[1]}.${versionMatch[2]}`);
64
+ } else {
65
+ getComposerError = `Could not decode PHP version (${composerJson.require.php}})`;
66
+ return null;
67
+ }
68
+ }
69
+ } catch (e) {
70
+ getComposerError = `Error reading composer.json: ${e.message}`;
71
+ }
72
+ } else {
73
+ getComposerError = "Could not find composer.json";
74
+ }
75
+
76
+ return null;
77
+ }
78
+
79
+ export { getComposerPhpVersion };
80
+
81
+ /**
82
+ * Resolve the PHP version to a number based on the provided options.
83
+ *
84
+ */
85
+ export function resolvePhpVersion(options) {
86
+ if (!options) {
87
+ return;
88
+ }
89
+ if (options.phpVersion === "auto") {
90
+ options.phpVersion =
91
+ getComposerPhpVersion() ?? LATEST_SUPPORTED_PHP_VERSION;
92
+ } else if (options.phpVersion === "composer") {
93
+ const v = getComposerPhpVersion();
94
+ if (v === null) {
95
+ throw new Error(
96
+ `Could not determine PHP version from composer; ${getComposerError}`
97
+ );
98
+ }
99
+ options.phpVersion = v;
100
+ } else {
101
+ options.phpVersion = parseFloat(options.phpVersion);
102
+ }
103
+ }
104
+
3
105
  export default {
4
106
  phpVersion: {
5
107
  since: "0.13.0",
6
108
  category: CATEGORY_PHP,
7
109
  type: "choice",
8
- default: "7.0",
110
+ default: "auto",
9
111
  description: "Minimum target PHP version.",
10
112
  choices: [
11
- { value: "5.0" },
12
- { value: "5.1" },
13
- { value: "5.2" },
14
- { value: "5.3" },
15
- { value: "5.4" },
16
- { value: "5.5" },
17
- { value: "5.6" },
18
- { value: "7.0" },
19
- { value: "7.1" },
20
- { value: "7.2" },
21
- { value: "7.3" },
22
- { value: "7.4" },
23
- { value: "8.0" },
24
- { value: "8.1" },
25
- { value: "8.2" },
113
+ ...SUPPORTED_PHP_VERSIONS.map((v) => ({ value: v.toFixed(1) })),
114
+ {
115
+ value: "composer",
116
+ description: "Use the PHP version defined in composer.json",
117
+ },
118
+ {
119
+ value: "auto",
120
+ description: `Try composer.json, else latest PHP Version (${LATEST_SUPPORTED_PHP_VERSION})`,
121
+ },
26
122
  ],
27
123
  },
28
124
  trailingCommaPHP: {
package/src/parser.mjs CHANGED
@@ -1,4 +1,6 @@
1
1
  import engine from "php-parser";
2
+ import { LATEST_SUPPORTED_PHP_VERSION } from "./options.mjs";
3
+ import { resolvePhpVersion } from "./options.mjs";
2
4
 
3
5
  function parse(text, opts) {
4
6
  const inMarkdown = opts && opts.parentParser === "markdown";
@@ -6,6 +8,7 @@ function parse(text, opts) {
6
8
  if (!text && inMarkdown) {
7
9
  return "";
8
10
  }
11
+ resolvePhpVersion(opts);
9
12
 
10
13
  // Todo https://github.com/glayzzle/php-parser/issues/170
11
14
  text = text.replace(/\?>\n<\?/g, "?>\n___PSEUDO_INLINE_PLACEHOLDER___<?");
@@ -14,6 +17,7 @@ function parse(text, opts) {
14
17
  const parser = new engine({
15
18
  parser: {
16
19
  extractDoc: true,
20
+ version: `${LATEST_SUPPORTED_PHP_VERSION}`,
17
21
  },
18
22
  ast: {
19
23
  withPositions: true,
package/src/printer.mjs CHANGED
@@ -65,16 +65,19 @@ const {
65
65
  isPreviousLineEmpty,
66
66
  } = prettierUtil;
67
67
 
68
- function isMinVersion(actualVersion, requiredVersion) {
69
- return parseFloat(actualVersion) >= parseFloat(requiredVersion);
70
- }
71
-
68
+ /**
69
+ * Determine if we should print a trailing comma based on the config & php version
70
+ *
71
+ * @param options {object} Prettier Options
72
+ * @param requiredVersion {number}
73
+ * @returns {boolean}
74
+ */
72
75
  function shouldPrintComma(options, requiredVersion) {
73
76
  if (!options.trailingCommaPHP) {
74
77
  return false;
75
78
  }
76
79
 
77
- return isMinVersion(options.phpVersion, requiredVersion);
80
+ return options.phpVersion >= requiredVersion;
78
81
  }
79
82
 
80
83
  function shouldPrintHardlineForOpenBrace(options) {
@@ -615,9 +618,9 @@ function printArgumentsList(path, options, print, argumentsKey = "arguments") {
615
618
  const lastArg = getLast(args);
616
619
 
617
620
  const maybeTrailingComma =
618
- (shouldPrintComma(options, "7.3") &&
621
+ (shouldPrintComma(options, 7.3) &&
619
622
  ["call", "new", "unset", "isset"].includes(node.kind)) ||
620
- (shouldPrintComma(options, "8.0") &&
623
+ (shouldPrintComma(options, 8.0) &&
621
624
  ["function", "closure", "method", "arrowfunc", "attribute"].includes(
622
625
  node.kind
623
626
  ))
@@ -1189,7 +1192,7 @@ function printAttrs(path, options, print, { inline = false } = {}) {
1189
1192
  allAttrs.push(
1190
1193
  group([
1191
1194
  indent(attrGroup),
1192
- ifBreak(shouldPrintComma(options, "8.0") ? "," : ""),
1195
+ ifBreak(shouldPrintComma(options, 8.0) ? "," : ""),
1193
1196
  softline,
1194
1197
  "]",
1195
1198
  inline ? ifBreak(softline, " ") : "",
@@ -1661,11 +1664,7 @@ function printNode(path, options, print) {
1661
1664
  join([",", line], path.map(print, "items")),
1662
1665
  ]),
1663
1666
  node.name
1664
- ? [
1665
- ifBreak(shouldPrintComma(options, "7.2") ? "," : ""),
1666
- softline,
1667
- "}",
1668
- ]
1667
+ ? [ifBreak(shouldPrintComma(options, 7.2) ? "," : ""), softline, "}"]
1669
1668
  : "",
1670
1669
  ]);
1671
1670
  case "useitem":
@@ -2308,6 +2307,7 @@ function printNode(path, options, print) {
2308
2307
  node.final ? "final " : "",
2309
2308
  node.visibility ? [node.visibility, " "] : "",
2310
2309
  "const",
2310
+ node.type ? [node.nullable ? " ?" : " ", print("type")] : "",
2311
2311
  firstVariable ? [" ", firstVariable] : "",
2312
2312
  indent(printed.slice(1).map((p) => [",", hardline, p])),
2313
2313
  ]);
@@ -2358,9 +2358,8 @@ function printNode(path, options, print) {
2358
2358
  case "list":
2359
2359
  case "array": {
2360
2360
  const useShortForm =
2361
- (node.kind === "array" && isMinVersion(options.phpVersion, "5.4")) ||
2362
- (node.kind === "list" &&
2363
- (node.shortForm || isMinVersion(options.phpVersion, "7.1")));
2361
+ (node.kind === "array" && options.phpVersion >= 5.4) ||
2362
+ (node.kind === "list" && (node.shortForm || options.phpVersion >= 7.1));
2364
2363
  const open = useShortForm ? "[" : [node.kind, "("];
2365
2364
  const close = useShortForm ? "]" : ")";
2366
2365
 
@@ -2410,7 +2409,7 @@ function printNode(path, options, print) {
2410
2409
  indent([softline, printArrayItems(path, options, print)]),
2411
2410
  needsForcedTrailingComma ? "," : "",
2412
2411
  ifBreak(
2413
- !needsForcedTrailingComma && shouldPrintComma(options, "5.0")
2412
+ !needsForcedTrailingComma && shouldPrintComma(options, 5.0)
2414
2413
  ? [
2415
2414
  lastElem && shouldPrintHardlineBeforeTrailingComma(lastElem)
2416
2415
  ? hardline
@@ -2677,7 +2676,7 @@ function printNode(path, options, print) {
2677
2676
  if (parent.kind === "encapsedpart") {
2678
2677
  const parentParent = path.grandparent;
2679
2678
  let closingTagIndentation = 0;
2680
- const flexible = isMinVersion(options.phpVersion, "7.3");
2679
+ const flexible = options.phpVersion >= 7.3;
2681
2680
  let linebreak = literalline;
2682
2681
  if (parentParent.type === "heredoc") {
2683
2682
  linebreak = flexible ? hardline : literalline;
@@ -2746,7 +2745,7 @@ function printNode(path, options, print) {
2746
2745
  case "string":
2747
2746
  case "shell":
2748
2747
  case "heredoc": {
2749
- const flexible = isMinVersion(options.phpVersion, "7.3");
2748
+ const flexible = options.phpVersion >= 7.3;
2750
2749
  const linebreak = flexible ? hardline : literalline;
2751
2750
  return [
2752
2751
  getEncapsedQuotes(node),
@@ -2771,7 +2770,7 @@ function printNode(path, options, print) {
2771
2770
  case "magic":
2772
2771
  return node.value;
2773
2772
  case "nowdoc": {
2774
- const flexible = isMinVersion(options.phpVersion, "7.3");
2773
+ const flexible = options.phpVersion >= 7.3;
2775
2774
  const linebreak = flexible ? hardline : literalline;
2776
2775
  return [
2777
2776
  "<<<'",