diff --git a/README.md b/README.md index e33bb4b03..da9c51d3f 100644 --- a/README.md +++ b/README.md @@ -176,17 +176,33 @@ await prettier.format(YOUR_CODE, { Prettier for PHP supports the following options. We recommend that all users set the `phpVersion` option. -| Name | Default | Description | -| ------------------ | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `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. | -| `printWidth` | `80` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#print-width)) | -| `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. | -| `useTabs` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tabs)) | -| `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"`. | -| `trailingCommaPHP` | `true` | If set to `true`, trailing commas will be added wherever possible.
If set to `false`, no trailing commas are printed. | -| `braceStyle` | `"per-cs"` | If set to `"per-cs"`, prettier will move open brace for code blocks (classes, functions and methods) onto new line.
If set to `"1tbs"`, prettier will move open brace for code blocks (classes, functions and methods) onto same line. | -| `requirePragma` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#require-pragma)) | -| `insertPragma` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#insert-pragma)) | +| Name | Default | Description | +| ------------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `phpVersion` | `"auto"` \* | Allows specifying the PHP version you're using. (See Notes Below) | +| `printWidth` | `80` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#print-width)) | +| `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. | +| `useTabs` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#tabs)) | +| `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"`. | +| `trailingCommaPHP` | `true` | If set to `true`, trailing commas will be added wherever possible.
If set to `false`, no trailing commas are printed. | +| `braceStyle` | `"per-cs"` | If set to `"per-cs"`, prettier will move open brace for code blocks (classes, functions and methods) onto new line.
If set to `"1tbs"`, prettier will move open brace for code blocks (classes, functions and methods) onto same line. | +| `requirePragma` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#require-pragma)) | +| `insertPragma` | `false` | Same as in Prettier ([see prettier docs](https://prettier.io/docs/en/options.html#insert-pragma)) | + +### \* `phpVersion` Configuration Notes : + +The default setting `auto`, attempts to auto-detect your supported php versions from a `composer.json` with in the +current directory or any parent directory, the plugin will use a minimum supported php version from +`{"require":{"php":"..."}}` to set the phpVersion. If not found or not able to be parsed, it will default to latest +supported PHP version. + +You set the `phpVersion` to `composer` and this will only use the `composer.json` file to determine the php +version, prettier will crash if the PHP cannot be determined. + +You can also set the `phpVersion` to a specific version, such as `7.4`, `8.0`, `8.1`, `8.2`, or `8.3`. + +**Please Note:** If the phpVersion is not set correctly for your environment, this plugin will produce code that could +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 +produce code that uses features not available in PHP 7.4. ## Ignoring code diff --git a/jest.config.mjs b/jest.config.mjs index 41902fa1a..0170dafb7 100644 --- a/jest.config.mjs +++ b/jest.config.mjs @@ -14,7 +14,7 @@ export default { transform: {}, setupFiles: ["/tests_config/run_spec.mjs"], // Matches `.js` file to prevent files use `.js` extension by mistake, https://github.com/prettier/plugin-php/pull/2247#discussion_r1331847801 - testRegex: "jsfmt\\.spec\\.m?js$|__tests__/.*\\.m?js$", + testRegex: ".*\\.spec\\.m?js$", snapshotSerializers: ["jest-snapshot-serializer-raw"], globals: { STANDALONE: RUN_STANDALONE_TESTS, diff --git a/src/needs-parens.mjs b/src/needs-parens.mjs index 3f1be4adf..c234c8da7 100644 --- a/src/needs-parens.mjs +++ b/src/needs-parens.mjs @@ -1,9 +1,4 @@ -import { - getPrecedence, - shouldFlatten, - isBitwiseOperator, - isMinVersion, -} from "./util.mjs"; +import { getPrecedence, shouldFlatten, isBitwiseOperator } from "./util.mjs"; function needsParens(path, options) { const { parent } = path; @@ -135,7 +130,7 @@ function needsParens(path, options) { case "new": { const requiresParens = node.kind === "clone" || - (node.kind === "new" && !isMinVersion(options.phpVersion, "8.4")); + (node.kind === "new" && options.phpVersion < 8.4); switch (parent.kind) { case "propertylookup": case "nullsafepropertylookup": diff --git a/src/options.mjs b/src/options.mjs index 3a67fff3d..e7444d804 100644 --- a/src/options.mjs +++ b/src/options.mjs @@ -1,30 +1,124 @@ +import fs from "fs"; +import path from "path"; + const CATEGORY_PHP = "PHP"; +// prettier-ignore +const SUPPORTED_PHP_VERSIONS = [ + 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, + 7.0, 7.1, 7.2, 7.3, 7.4, + 8.0, 8.1, 8.2, 8.3, 8.4, +]; + +export const LATEST_SUPPORTED_PHP_VERSION = Math.max(...SUPPORTED_PHP_VERSIONS); + +let getComposerError = ""; + +/** + * Detect the minimum PHP version from the composer.json file + * @return {number|null} The PHP version to use in the composer.json file, null when not found + */ +function getComposerPhpVersion() { + // Try to find composer.json + const currentDir = process.cwd(); + let composerPath = null; + + const directComposerPath = path.join(currentDir, "composer.json"); + if (fs.existsSync(directComposerPath)) { + composerPath = directComposerPath; + } + + if (!composerPath) { + let searchDir = path.dirname(currentDir); + while (searchDir !== path.parse(searchDir).root) { + const potentialComposerPath = path.join(searchDir, "composer.json"); + if (fs.existsSync(potentialComposerPath)) { + composerPath = potentialComposerPath; + break; + } + searchDir = path.dirname(searchDir); + } + } + + if (composerPath) { + try { + const fileContent = fs.readFileSync(composerPath, "utf8"); + const composerJson = JSON.parse(fileContent); + + if (composerJson.require && composerJson.require.php) { + // Check for a wildcard pattern like "7.*" + const wildcardMatch = composerJson.require.php.match( + /^(?:[^0-9]*)?([0-9]+)\.\*/ + ); + if (wildcardMatch) { + return parseFloat(`${wildcardMatch[1]}.0`); + } + + // Extract version from composer semver format + const versionMatch = composerJson.require.php.match( + /^(?:[^0-9]*)?([0-9]+)\.([0-9]+)/ + ); + + if (versionMatch) { + return parseFloat(`${versionMatch[1]}.${versionMatch[2]}`); + } else { + getComposerError = `Could not decode PHP version (${composerJson.require.php}})`; + return null; + } + } + } catch (e) { + getComposerError = `Error reading composer.json: ${e.message}`; + } + } else { + getComposerError = "Could not find composer.json"; + } + + return null; +} + +export { getComposerPhpVersion }; + +/** + * Resolve the PHP version to a number based on the provided options. + * + */ +export function resolvePhpVersion(options) { + if (!options) { + return; + } + if (options.phpVersion === "auto") { + options.phpVersion = + getComposerPhpVersion() ?? LATEST_SUPPORTED_PHP_VERSION; + } else if (options.phpVersion === "composer") { + const v = getComposerPhpVersion(); + if (v === null) { + throw new Error( + `Could not determine PHP version from composer; ${getComposerError}` + ); + } + options.phpVersion = v; + } else { + options.phpVersion = parseFloat(options.phpVersion); + } +} + export default { phpVersion: { since: "0.13.0", category: CATEGORY_PHP, type: "choice", - default: "7.0", + default: "auto", description: "Minimum target PHP version.", choices: [ - { value: "5.0" }, - { value: "5.1" }, - { value: "5.2" }, - { value: "5.3" }, - { value: "5.4" }, - { value: "5.5" }, - { value: "5.6" }, - { value: "7.0" }, - { value: "7.1" }, - { value: "7.2" }, - { value: "7.3" }, - { value: "7.4" }, - { value: "8.0" }, - { value: "8.1" }, - { value: "8.2" }, - { value: "8.3" }, - { value: "8.4" }, + ...SUPPORTED_PHP_VERSIONS.map((v) => ({ value: v.toFixed(1) })), + { + value: "composer", + description: "Use the PHP version defined in composer.json", + }, + { + value: "auto", + description: `Try composer.json, else latest PHP Version (${LATEST_SUPPORTED_PHP_VERSION})`, + }, ], }, trailingCommaPHP: { diff --git a/src/parser.mjs b/src/parser.mjs index 80b61bb45..8df49870d 100644 --- a/src/parser.mjs +++ b/src/parser.mjs @@ -1,5 +1,6 @@ import engine from "php-parser"; -import options from "./options.mjs"; +import { LATEST_SUPPORTED_PHP_VERSION } from "./options.mjs"; +import { resolvePhpVersion } from "./options.mjs"; function parse(text, opts) { const inMarkdown = opts && opts.parentParser === "markdown"; @@ -7,19 +8,16 @@ function parse(text, opts) { if (!text && inMarkdown) { return ""; } + resolvePhpVersion(opts); // Todo https://github.com/glayzzle/php-parser/issues/170 text = text.replace(/\?>\n<\?/g, "?>\n___PSEUDO_INLINE_PLACEHOLDER___ parseFloat(c.value)) - ); - // initialize a new parser instance const parser = new engine({ parser: { extractDoc: true, - version: `${latestSupportedPhpVersion}`, + version: `${LATEST_SUPPORTED_PHP_VERSION}`, }, ast: { withPositions: true, diff --git a/src/printer.mjs b/src/printer.mjs index d8e21e832..c3cf11cd0 100644 --- a/src/printer.mjs +++ b/src/printer.mjs @@ -37,7 +37,6 @@ import { isReferenceLikeNode, normalizeMagicMethodName, isSimpleCallArgument, - isMinVersion, } from "./util.mjs"; const { @@ -66,12 +65,19 @@ const { isPreviousLineEmpty, } = prettierUtil; +/** + * Determine if we should print a trailing comma based on the config & php version + * + * @param options {object} Prettier Options + * @param requiredVersion {number} + * @returns {boolean} + */ function shouldPrintComma(options, requiredVersion) { if (!options.trailingCommaPHP) { return false; } - return isMinVersion(options.phpVersion, requiredVersion); + return options.phpVersion >= requiredVersion; } function shouldPrintHardlineForOpenBrace(options) { @@ -612,9 +618,9 @@ function printArgumentsList(path, options, print, argumentsKey = "arguments") { const lastArg = getLast(args); const maybeTrailingComma = - (shouldPrintComma(options, "7.3") && + (shouldPrintComma(options, 7.3) && ["call", "new", "unset", "isset"].includes(node.kind)) || - (shouldPrintComma(options, "8.0") && + (shouldPrintComma(options, 8.0) && ["function", "closure", "method", "arrowfunc", "attribute"].includes( node.kind )) @@ -1186,7 +1192,7 @@ function printAttrs(path, options, print, { inline = false } = {}) { allAttrs.push( group([ indent(attrGroup), - ifBreak(shouldPrintComma(options, "8.0") ? "," : ""), + ifBreak(shouldPrintComma(options, 8.0) ? "," : ""), softline, "]", inline ? ifBreak(softline, " ") : "", @@ -1658,11 +1664,7 @@ function printNode(path, options, print) { join([",", line], path.map(print, "items")), ]), node.name - ? [ - ifBreak(shouldPrintComma(options, "7.2") ? "," : ""), - softline, - "}", - ] + ? [ifBreak(shouldPrintComma(options, 7.2) ? "," : ""), softline, "}"] : "", ]); case "useitem": @@ -2356,9 +2358,8 @@ function printNode(path, options, print) { case "list": case "array": { const useShortForm = - (node.kind === "array" && isMinVersion(options.phpVersion, "5.4")) || - (node.kind === "list" && - (node.shortForm || isMinVersion(options.phpVersion, "7.1"))); + (node.kind === "array" && options.phpVersion >= 5.4) || + (node.kind === "list" && (node.shortForm || options.phpVersion >= 7.1)); const open = useShortForm ? "[" : [node.kind, "("]; const close = useShortForm ? "]" : ")"; @@ -2408,7 +2409,7 @@ function printNode(path, options, print) { indent([softline, printArrayItems(path, options, print)]), needsForcedTrailingComma ? "," : "", ifBreak( - !needsForcedTrailingComma && shouldPrintComma(options, "5.0") + !needsForcedTrailingComma && shouldPrintComma(options, 5.0) ? [ lastElem && shouldPrintHardlineBeforeTrailingComma(lastElem) ? hardline @@ -2675,7 +2676,7 @@ function printNode(path, options, print) { if (parent.kind === "encapsedpart") { const parentParent = path.grandparent; let closingTagIndentation = 0; - const flexible = isMinVersion(options.phpVersion, "7.3"); + const flexible = options.phpVersion >= 7.3; let linebreak = literalline; if (parentParent.type === "heredoc") { linebreak = flexible ? hardline : literalline; @@ -2744,7 +2745,7 @@ function printNode(path, options, print) { case "string": case "shell": case "heredoc": { - const flexible = isMinVersion(options.phpVersion, "7.3"); + const flexible = options.phpVersion >= 7.3; const linebreak = flexible ? hardline : literalline; return [ getEncapsedQuotes(node), @@ -2769,7 +2770,7 @@ function printNode(path, options, print) { case "magic": return node.value; case "nowdoc": { - const flexible = isMinVersion(options.phpVersion, "7.3"); + const flexible = options.phpVersion >= 7.3; const linebreak = flexible ? hardline : literalline; return [ "<<<'", diff --git a/src/util.mjs b/src/util.mjs index 03428ca48..b4bf9e473 100644 --- a/src/util.mjs +++ b/src/util.mjs @@ -709,10 +709,6 @@ function memoize(fn) { }; } -function isMinVersion(actualVersion, requiredVersion) { - return parseFloat(actualVersion) >= parseFloat(requiredVersion); -} - export { printNumber, getPrecedence, @@ -744,5 +740,4 @@ export { normalizeMagicMethodName, isSimpleCallArgument, memoize, - isMinVersion, }; diff --git a/tests/assign/__snapshots__/jsfmt.spec.mjs.snap b/tests/assign/__snapshots__/jsfmt.spec.mjs.snap index 27dfa6187..78d9bd542 100644 --- a/tests/assign/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/assign/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`assign.php 1`] = ` ====================================options===================================== @@ -233,14 +233,14 @@ $veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongVariable = $veryVeryVeryVeryVer $obj->property = $obj->oneProperty = $obj->twoPeroperty = 0; $obj->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty = $obj->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty = $obj->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty = 0; $obj->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty = $obj->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty = $obj->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty = $veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongValue; -$obj->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty = (new MyClass())->call( - $arg +$obj->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty = new MyClass()->call( + $arg, ); $obj->loooooooooooong->lookup = $this->getRequest()->getParam( - "instance-resource-id" + "instance-resource-id", ); $obj->loooooooooooong->lookup = (int) $this->getRequest()->getParam( - "instance-resource-id" + "instance-resource-id", ); $component = @@ -251,7 +251,7 @@ $component = Foo::$insertReallyReallyReallyReallyReallyReallyReallyReallyLongName; $component = $a::$insertReallyReallyReallyReallyReallyReallyReallyReallyLongName; -$component = (new Foo()) +$component = new Foo() ->insertReallyReallyReallyReallyReallyReallyReallyReallyLongName; $component = (clone $a) ->insertReallyReallyReallyReallyReallyReallyReallyReallyLongName; @@ -266,7 +266,7 @@ $component = Foo::$insertReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongName; $component = $a::$insertReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongName; -$component = (new Foo()) +$component = new Foo() ->insertReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongName; $component = (clone $a) ->insertReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongName; diff --git a/tests/attributes/__snapshots__/jsfmt.spec.mjs.snap b/tests/attributes/__snapshots__/jsfmt.spec.mjs.snap index 7d30d00a9..c2b776223 100644 --- a/tests/attributes/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/attributes/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`attributes.php 1`] = ` ====================================options===================================== @@ -158,25 +158,25 @@ class D "aaaaaaaaaaaaa", "vvvvvvvvvvvv", "cccccccccc", - "eeeeeeeeeee" + "eeeeeeeeeee", ), - X + X, ] function Y( #[ ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ( 12345678, - 1234578 - ) + 1234578, + ), ] - string $_ + string $_, ): string { return new #[NON, Anon] class {}; } #[ IA("interface"), - \\Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\\Namespace\\WithStuff\\IB + \\Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\\Namespace\\WithStuff\\IB, ] interface IC { @@ -209,7 +209,7 @@ class ValueModel { #[ Assert\\NotBlank(allowNull: false, groups: ["foo"]), - Assert\\Length(max: 255, groups: ["foo"]) + Assert\\Length(max: 255, groups: ["foo"]), ] public ?string $value = null; } @@ -233,7 +233,7 @@ class ParamCommentFunctionAnnotation #[Foo] function bar( int $a, // parameter comment - int $b + int $b, ) { return $a + $b; } @@ -242,7 +242,7 @@ class ParamCommentFunctionAnnotation function bar2( int $a, int $middle, // parameter comment - int $b + int $b, ) { return $a + $middle + $b; } diff --git a/tests/bin/__snapshots__/jsfmt.spec.mjs.snap b/tests/bin/__snapshots__/jsfmt.spec.mjs.snap index cd784e8db..787a4f6d2 100644 --- a/tests/bin/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/bin/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`bin.php 1`] = ` ====================================options===================================== @@ -455,7 +455,7 @@ function f() { if ( get_option( - "woocommerce_product_cart_actions_notification_more_cart" + "woocommerce_product_cart_actions_notification_more_cart", ) === "yes" && count($cartItems) > 0 ) { @@ -490,7 +490,7 @@ call( "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVery" ? 1 : 2, - "arg" + "arg", ); $var = @@ -660,13 +660,13 @@ $var = call($var > $someOtherReallyReallyLongVariable ? true : false); $var = call( $someOtherReallyReallyLongVariable > $someOtherReallyReallyLongVariable ? true - : false + : false, ); $var = call( $someOtherReallyReallyReallyReallyReallyReallyLongVariable > $someOtherReallyReallyReallyReallyReallyReallyLongVariable ? true - : false + : false, ); return $var > $var ? true : false; @@ -686,7 +686,7 @@ func( $glimseGlyphsHazardNoopsTieTie === averredBathersBoxroomBuggyNurl && $anodyneCondosMalateOverateRetinol ? $annularCooeedSplicesWalksWayWay - : $kochabCooieGameOnOboleUnweave + : $kochabCooieGameOnOboleUnweave, ); $var = $a ?? $b; @@ -714,7 +714,7 @@ $var = call( $someOtherReallyReallyLongVariable, $someOtherReallyReallyLongVariable, - $someOtherReallyReallyLongVariable + $someOtherReallyReallyLongVariable, )))); $var = $someOtherReallyReallyLongVariable ?? diff --git a/tests/brace-style/__snapshots__/jsfmt.spec.mjs.snap b/tests/brace-style/__snapshots__/jsfmt.spec.mjs.snap index 4db4b933b..389ba6b8e 100644 --- a/tests/brace-style/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/brace-style/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`classes.php 1`] = ` ====================================options===================================== @@ -486,7 +486,7 @@ function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVer function reeeeeeeeeeaaaaaaaallllllllyyyyyy_llloooooooonnnnnnggggg( $soooooooooooo_looooooooonnnng, - $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr + $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr, ) { return $soooooooooooo_looooooooonnnng; } @@ -498,7 +498,7 @@ function type_hinting_test( float $float_test, iterable $iterable_test, int $int_test, - string $string_test = "" + string $string_test = "", ) { return $int_test; } @@ -511,7 +511,7 @@ $anonymousLongVariableName = function ( $name, $more, $params, - $looooooooooooooooooooooooooooooooong + $looooooooooooooooooooooooooooooooong, ) use ($all, $kinds, $of, $stuff) { printf("Hello %s", $name); }; @@ -579,7 +579,7 @@ function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVer function reeeeeeeeeeaaaaaaaallllllllyyyyyy_llloooooooonnnnnnggggg( $soooooooooooo_looooooooonnnng, - $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr + $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr, ) { return $soooooooooooo_looooooooonnnng; } @@ -591,7 +591,7 @@ function type_hinting_test( float $float_test, iterable $iterable_test, int $int_test, - string $string_test = "" + string $string_test = "", ) { return $int_test; } @@ -604,7 +604,7 @@ $anonymousLongVariableName = function ( $name, $more, $params, - $looooooooooooooooooooooooooooooooong + $looooooooooooooooooooooooooooooooong, ) use ($all, $kinds, $of, $stuff) { printf("Hello %s", $name); }; @@ -672,7 +672,7 @@ function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVer function reeeeeeeeeeaaaaaaaallllllllyyyyyy_llloooooooonnnnnnggggg( $soooooooooooo_looooooooonnnng, - $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr + $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr, ) { return $soooooooooooo_looooooooonnnng; } @@ -684,7 +684,7 @@ function type_hinting_test( float $float_test, iterable $iterable_test, int $int_test, - string $string_test = "" + string $string_test = "", ) { return $int_test; } @@ -697,7 +697,7 @@ $anonymousLongVariableName = function ( $name, $more, $params, - $looooooooooooooooooooooooooooooooong + $looooooooooooooooooooooooooooooooong, ) use ($all, $kinds, $of, $stuff) { printf("Hello %s", $name); }; @@ -762,7 +762,7 @@ function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVer function reeeeeeeeeeaaaaaaaallllllllyyyyyy_llloooooooonnnnnnggggg( $soooooooooooo_looooooooonnnng, - $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr + $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr, ) { return $soooooooooooo_looooooooonnnng; } @@ -774,7 +774,7 @@ function type_hinting_test( float $float_test, iterable $iterable_test, int $int_test, - string $string_test = "" + string $string_test = "", ) { return $int_test; } @@ -787,7 +787,7 @@ $anonymousLongVariableName = function ( $name, $more, $params, - $looooooooooooooooooooooooooooooooong + $looooooooooooooooooooooooooooooooong, ) use ($all, $kinds, $of, $stuff) { printf("Hello %s", $name); }; @@ -942,7 +942,7 @@ class Foo function reeeeeeeeeeaaaaaaaallllllllyyyyyy_llloooooooonnnnnnggggg( $soooooooooooo_looooooooonnnng, - $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr + $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr, ) { return $soooooooooooo_looooooooonnnng; } @@ -954,7 +954,7 @@ class Foo float $float_test, iterable $iterable_test, int $int_test, - string $string_test = "" + string $string_test = "", ) { return $int_test; } @@ -964,7 +964,7 @@ class Foo $max_length, // @codingStandardsIgnoreLine $ellipses = " … ", // the spaces are non-breaking spaces - &$flag = null + &$flag = null, ) { return "hello"; } @@ -976,7 +976,7 @@ class Foo $max_length, // @codingStandardsIgnoreLine $ellipses = " … ", // the spaces are non-breaking spaces - &$flag = null + &$flag = null, ) { $string = trim($string); } @@ -988,43 +988,43 @@ class Foo public static function hello_4( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ) {} public static function hello_5( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ): ?string {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName() {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( - $var = 1 + $var = 1, ) {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ) {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ): ?string {} public static function newlines( $var = 1, - $other_var = 2 + $other_var = 2, ) {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( $var = 1, - $other_var = 2 + $other_var = 2, ) {} } @@ -1179,7 +1179,7 @@ class Foo function reeeeeeeeeeaaaaaaaallllllllyyyyyy_llloooooooonnnnnnggggg( $soooooooooooo_looooooooonnnng, - $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr + $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr, ) { return $soooooooooooo_looooooooonnnng; } @@ -1191,7 +1191,7 @@ class Foo float $float_test, iterable $iterable_test, int $int_test, - string $string_test = "" + string $string_test = "", ) { return $int_test; } @@ -1201,7 +1201,7 @@ class Foo $max_length, // @codingStandardsIgnoreLine $ellipses = " … ", // the spaces are non-breaking spaces - &$flag = null + &$flag = null, ) { return "hello"; } @@ -1213,7 +1213,7 @@ class Foo $max_length, // @codingStandardsIgnoreLine $ellipses = " … ", // the spaces are non-breaking spaces - &$flag = null + &$flag = null, ) { $string = trim($string); } @@ -1225,43 +1225,43 @@ class Foo public static function hello_4( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ) {} public static function hello_5( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ): ?string {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName() {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( - $var = 1 + $var = 1, ) {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ) {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ): ?string {} public static function newlines( $var = 1, - $other_var = 2 + $other_var = 2, ) {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( $var = 1, - $other_var = 2 + $other_var = 2, ) {} } @@ -1416,7 +1416,7 @@ class Foo function reeeeeeeeeeaaaaaaaallllllllyyyyyy_llloooooooonnnnnnggggg( $soooooooooooo_looooooooonnnng, - $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr + $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr, ) { return $soooooooooooo_looooooooonnnng; } @@ -1428,7 +1428,7 @@ class Foo float $float_test, iterable $iterable_test, int $int_test, - string $string_test = "" + string $string_test = "", ) { return $int_test; } @@ -1438,7 +1438,7 @@ class Foo $max_length, // @codingStandardsIgnoreLine $ellipses = " … ", // the spaces are non-breaking spaces - &$flag = null + &$flag = null, ) { return "hello"; } @@ -1450,7 +1450,7 @@ class Foo $max_length, // @codingStandardsIgnoreLine $ellipses = " … ", // the spaces are non-breaking spaces - &$flag = null + &$flag = null, ) { $string = trim($string); } @@ -1462,43 +1462,43 @@ class Foo public static function hello_4( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ) {} public static function hello_5( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ): ?string {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName() {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( - $var = 1 + $var = 1, ) {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ) {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ): ?string {} public static function newlines( $var = 1, - $other_var = 2 + $other_var = 2, ) {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( $var = 1, - $other_var = 2 + $other_var = 2, ) {} } @@ -1645,7 +1645,7 @@ class Foo { function reeeeeeeeeeaaaaaaaallllllllyyyyyy_llloooooooonnnnnnggggg( $soooooooooooo_looooooooonnnng, - $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr + $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr, ) { return $soooooooooooo_looooooooonnnng; } @@ -1657,7 +1657,7 @@ class Foo { float $float_test, iterable $iterable_test, int $int_test, - string $string_test = "" + string $string_test = "", ) { return $int_test; } @@ -1667,7 +1667,7 @@ class Foo { $max_length, // @codingStandardsIgnoreLine $ellipses = " … ", // the spaces are non-breaking spaces - &$flag = null + &$flag = null, ) { return "hello"; } @@ -1679,7 +1679,7 @@ class Foo { $max_length, // @codingStandardsIgnoreLine $ellipses = " … ", // the spaces are non-breaking spaces - &$flag = null + &$flag = null, ) { $string = trim($string); } @@ -1691,43 +1691,43 @@ class Foo { public static function hello_4( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ) {} public static function hello_5( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ): ?string {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName() {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( - $var = 1 + $var = 1, ) {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ) {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( $var = 1, $other_var = 2, - $other_other_other_var = 3 + $other_other_other_var = 3, ): ?string {} public static function newlines( $var = 1, - $other_var = 2 + $other_var = 2, ) {} public static function veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName( $var = 1, - $other_var = 2 + $other_var = 2, ) {} } diff --git a/tests/call/__snapshots__/jsfmt.spec.mjs.snap b/tests/call/__snapshots__/jsfmt.spec.mjs.snap index 94fbc34ed..be49c6300 100644 --- a/tests/call/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/call/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`call.php 1`] = ` ====================================options===================================== @@ -386,7 +386,7 @@ $db->Execute( $somewhatLongParameterX, $somewhatLongParameterXYZ, ], - $sql + $sql, ); $app->get("/hello/{name}", function ($name) use ($app) { @@ -395,19 +395,19 @@ $app->get("/hello/{name}", function ($name) use ($app) { $this->something->method( $argument, - $this->more->stuff($this->even->more->things->complicatedMethod()) + $this->more->stuff($this->even->more->things->complicatedMethod()), ); $this->something->method( $this->more->stuff($this->even->more->things->complicatedMethod()), - $argument + $argument, ); $this->something->method( $argument, $otherArgument, ["foo" => "bar", "baz" => "buzz"], - $this->even->more->things->complicatedMethod() + $this->even->more->things->complicatedMethod(), ); $this->files->put($path, $this->expiration($minutes) . serialize($value), true); @@ -432,7 +432,7 @@ $this->filter([ $this->assertEquals( ["First", "Second", "Taylor", "Mohamed", "Jeffrey", "Abigail", "Lydia"], - $results + $results, ); $this->assertEquals(["First"], $results); @@ -451,7 +451,7 @@ $some->other->thing( "foo" => "bar", "buzz" => $this->is->nested([12, 34, 45, 67, 89]), ], - [11323123, 1231, 13231233243, 324234234] + [11323123, 1231, 13231233243, 324234234], ); $foo->bar( @@ -459,12 +459,12 @@ $foo->bar( function ($arg2) use ($var1) { // body }, - $arg3 + $arg3, ); $packages = array_merge( idx($composer, "require", []), - idx($composer, "require-dev", []) + idx($composer, "require-dev", []), ); if ( @@ -474,7 +474,7 @@ if ( function ($acc, $tmp) { return $acc ^ $tmp; }, - 0 + 0, ) ) { return []; @@ -484,21 +484,21 @@ implode( ", ", array_map(function ($f) { return $f; - }, array_merge($arr1, $arr2, $arr3)) + }, array_merge($arr1, $arr2, $arr3)), ); call( function () { return thing(); }, - 1 ? 2 : 3 + 1 ? 2 : 3, ); call( function () { return thing(); }, - something() ? someOtherThing() : somethingElse(true, 0) + something() ? someOtherThing() : somethingElse(true, 0), ); call( @@ -507,7 +507,7 @@ call( }, something($longArgumentName, $anotherLongArgumentName) ? someOtherThing() - : somethingElse(true, 0) + : somethingElse(true, 0), ); call( @@ -518,10 +518,10 @@ call( $longArgumentName, $anotherLongArgumentName, $anotherLongArgumentName, - $anotherLongArgumentName + $anotherLongArgumentName, ) ? someOtherThing() - : somethingElse(true, 0) + : somethingElse(true, 0), ); array_map( @@ -530,7 +530,7 @@ array_map( }, is_array($attributes["alignment"]) ? $attributes["alignment"] - : explode(" ", $attributes["alignment"]) + : explode(" ", $attributes["alignment"]), ); call(' @@ -542,7 +542,7 @@ call( ' string string -string' +string', ); call( @@ -550,7 +550,7 @@ call( string string string', - $a + $a, ); call( @@ -558,7 +558,7 @@ call( ' string string -string' +string', ); call(" @@ -570,7 +570,7 @@ call( " string string -string" +string", ); call( @@ -578,7 +578,7 @@ call( string string string", - $a + $a, ); call( @@ -586,7 +586,7 @@ call( " string string -string" +string", ); $a->call(' @@ -598,7 +598,7 @@ $a->bar->call( ' string string -string' +string', ); $a->call(' @@ -615,14 +615,14 @@ $a->call( string string string', - $c + $c, )->call( $a, ' string string string', - $c + $c, ); call("string $var string"); @@ -636,7 +636,7 @@ call( "string string string -$var" +$var", ); call(\`string $var string\`); @@ -650,54 +650,58 @@ call( \`string string string -$var\` +$var\`, ); call( <<foo)(); diff --git a/tests/case/__snapshots__/jsfmt.spec.mjs.snap b/tests/case/__snapshots__/jsfmt.spec.mjs.snap index f254aafbd..8b25cbdaf 100644 --- a/tests/case/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/case/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`case.php 1`] = ` ====================================options===================================== @@ -332,7 +332,7 @@ final class MyClass extends Bar implements iTemplate break; } - while (list($key, $value) = foo($arr)) { + while ([$key, $value] = foo($arr)) { if (!($key % 2)) { continue; } @@ -363,7 +363,7 @@ final class MyClass extends Bar implements iTemplate $noArgs_longVars = function () use ( $longVar1, $longerVar2, - $muchLongerVar3 + $muchLongerVar3, ) { // Body }; @@ -484,7 +484,7 @@ final class MyClass extends Bar implements iTemplate object $param6, ClassA $param7, self $param8, - Name\\Space\\ClassA $param8 + Name\\Space\\ClassA $param8, ): void { // Nothing } diff --git a/tests/class/__snapshots__/jsfmt.spec.mjs.snap b/tests/class/__snapshots__/jsfmt.spec.mjs.snap index cf60d29d6..6fff7326e 100644 --- a/tests/class/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/class/__snapshots__/jsfmt.spec.mjs.snap @@ -303,7 +303,7 @@ $app->setLogger( { echo $msg; } - } + }, ); $app->setLogger( new class { @@ -311,7 +311,7 @@ $app->setLogger( { echo $msg; } - } + }, ); var_dump( @@ -324,7 +324,7 @@ var_dump( } use SomeTrait; - } + }, ); class Outer @@ -427,7 +427,7 @@ $class = new class ( $other_arg, function () { return 1; - } + }, ) {}; $class = new class ( @@ -438,7 +438,7 @@ $class = new class ( $other_arg, function () { return 1; - } + }, ) implements MyOtherClass {}; $class = new class ( @@ -449,7 +449,7 @@ $class = new class ( $other_arg, function () { return 1; - } + }, ) implements MyOtherClass, MyOtherClass1, MyOtherClass2 {}; $class = new class ( @@ -460,7 +460,7 @@ $class = new class ( $other_arg, function () { return 1; - } + }, ) implements VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongMyOtherClass {}; @@ -472,7 +472,7 @@ $class = new class ( $other_arg, function () { return 1; - } + }, ) implements MyOtherClass, MyOtherClass, @@ -487,7 +487,7 @@ $class = new class ( $other_arg, function () { return 1; - } + }, ) extends MyOtherClass {}; $class = new class ( @@ -498,7 +498,7 @@ $class = new class ( $other_arg, function () { return 1; - } + }, ) extends VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongMyClass {}; @@ -510,7 +510,7 @@ $class = new class ( $other_arg, function () { return 1; - } + }, ) extends MyOtherClass implements MyI {}; $class = new class ( @@ -521,7 +521,7 @@ $class = new class ( $other_arg, function () { return 1; - } + }, ) extends MyOtherClass implements MyI, MyII, MyIII {}; $class = new class ( @@ -532,7 +532,7 @@ $class = new class ( $other_arg, function () { return 1; - } + }, ) extends MyOtherClass implements VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongMyClass {}; @@ -544,7 +544,7 @@ $class = new class ( $other_arg, function () { return 1; - } + }, ) extends MyOtherClass implements MyInterface, MyOtherInterface, @@ -558,7 +558,7 @@ $class = new class ( $other_arg, function () { return 1; - } + }, ) extends VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongMyClass implements MyI {}; @@ -571,7 +571,7 @@ $class = new class ( $other_arg, function () { return 1; - } + }, ) extends VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongMyClass implements @@ -587,7 +587,7 @@ $class = new class ( $other_arg, function () { return 1; - } + }, ) extends VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongMyClass implements VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongMyClass {}; @@ -1004,7 +1004,7 @@ abstract class ReallyReallyReallyLongClassName $test_int = null, $test_string = "hi", readonly int $test_readonly, - public readonly string $test_promoted_readonly + public readonly string $test_promoted_readonly, ) { parent::__construct($test_int ?: 1); $this->other = $test_string; @@ -1016,13 +1016,13 @@ abstract class ReallyReallyReallyLongClassName public static function test_static_constructor( $test, $test_int, - $test_string + $test_string, ) { $model = new self($test, $test_int, $test_string); $model = new self( $really_really_really_really_really_really_really_really_long_array, $test_int, - $test_string + $test_string, ); return $model; } @@ -1048,7 +1048,7 @@ abstract class ReallyReallyReallyLongClassName public function reallyReallyReallyReallyReallyReallyReallyLongMethodName( $input, - $otherInput = 1 + $otherInput = 1, ) { return true; } @@ -1115,7 +1115,7 @@ abstract class ReallyReallyReallyLongClassName public function longLongAnotherFunction( string $foo, string $bar, - int $baz + int $baz, ): string { return "foo"; } @@ -1123,7 +1123,7 @@ abstract class ReallyReallyReallyLongClassName public function longLongAnotherFunctionOther( string $foo, string $bar, - int $baz + int $baz, ) { return "foo"; } @@ -1141,7 +1141,7 @@ abstract class ReallyReallyReallyLongClassName $this->something->method( $argument, - $this->more->stuff($this->even->more->things->complicatedMethod()) + $this->more->stuff($this->even->more->things->complicatedMethod()), ); class A {} @@ -1224,9 +1224,9 @@ class field extends \\models\\base array_merge( $configs, $field_type->process_field_config_from_user( - $input["definition"] - ) - ) + $input["definition"], + ), + ), ); unset($input["definition"]); } @@ -1379,7 +1379,7 @@ class Promoted public function __construct( public int $a, private float $b, - protected string $d + protected string $d, ) {} } diff --git a/tests/classconstant/__snapshots__/jsfmt.spec.mjs.snap b/tests/classconstant/__snapshots__/jsfmt.spec.mjs.snap index fa8ee35e7..9a66f8297 100644 --- a/tests/classconstant/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/classconstant/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`classconstant.php 1`] = ` ====================================options===================================== @@ -125,15 +125,15 @@ class ConstDemo 1200 + 1300; const CONST_9 = <<veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLeadDeveloper; $OneSecAgo = (clone $Now)->veryVeryVeryVeryVeryVeryVeryVeryLongMethod( - new \\DateInterval("PT1S") + new \\DateInterval("PT1S"), ); ================================================================================ diff --git a/tests/closure/__snapshots__/jsfmt.spec.mjs.snap b/tests/closure/__snapshots__/jsfmt.spec.mjs.snap index 2917294b0..f9e4e1129 100644 --- a/tests/closure/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/closure/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`closure.php 1`] = ` ====================================options===================================== @@ -158,7 +158,7 @@ $closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2) { $longArgs_noVars = function ( $longArgument, $longerArgument, - $muchLongerArgument + $muchLongerArgument, ) { // body }; @@ -166,7 +166,7 @@ $longArgs_noVars = function ( $noArgs_longVars = function () use ( $longLongLongLongVar1, $longerLongerVar2, - $muchLongerVar3 + $muchLongerVar3, ) { // body }; @@ -174,11 +174,11 @@ $noArgs_longVars = function () use ( $longArgs_longVars = function ( $longArgument, $longerArgument, - $muchLongerArgument + $muchLongerArgument, ) use ( $longLongLongLongLongLongLongVar1, $longerLongerLongerLongerVar2, - $muchLongerVar3 + $muchLongerVar3, ) { // body }; @@ -186,7 +186,7 @@ $longArgs_longVars = function ( $longArgs_shortVars = function ( $longArgument, $longerArgument, - $muchLongerArgument + $muchLongerArgument, ) use ($var1) { // body }; @@ -194,7 +194,7 @@ $longArgs_shortVars = function ( $shortArgs_longVars = function ($arg) use ( $longVar1, $longerVar2, - $muchLongerVar3 + $muchLongerVar3, ) { // body }; @@ -204,7 +204,7 @@ $foo->bar( function ($arg2) use ($var1) { // body }, - $longLongLongLongLongLongLongLongLongLongArg3 + $longLongLongLongLongLongLongLongLongLongArg3, ); $emptyFunc = function () {}; @@ -216,7 +216,7 @@ $emptyFuncWithComment = function () { $longArgs_noVars = function ( $longArgument, $longerArgument, - $muchLongerArgument + $muchLongerArgument, ) { // body }; @@ -228,7 +228,7 @@ $noArgs_longVars = function () use ($longVar1, $longerVar2, $muchLongerVar3) { $longArgs_longVars = function ( $longArgument, $longerArgument, - $muchLongerArgument + $muchLongerArgument, ) use ($longVar1, $longerVar2, $muchLongerVar3) { // body }; @@ -236,7 +236,7 @@ $longArgs_longVars = function ( $longArgs_shortVars = function ( $longArgument, $longerArgument, - $muchLongerArgument + $muchLongerArgument, ) use ($var1) { // body }; @@ -244,7 +244,7 @@ $longArgs_shortVars = function ( $shortArgs_longVars = function ($arg) use ( $longVar1, $longerVar2, - $muchLongerVar3 + $muchLongerVar3, ) { // body }; @@ -264,7 +264,7 @@ $rTDWU = function (array $array) use ($var1, $var2): int { $rTDWLU = function (array $array) use ( $longLongLongLongLongLongLongVar1, $longerLongerLongerLongerVar2, - $muchLongerVar3 + $muchLongerVar3, ): int { return array_sum($array); }; diff --git a/tests/comments/__snapshots__/jsfmt.spec.mjs.snap b/tests/comments/__snapshots__/jsfmt.spec.mjs.snap index a01c42f14..2d311f8a6 100644 --- a/tests/comments/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/comments/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`array.php 1`] = ` ====================================options===================================== @@ -204,7 +204,7 @@ $array = [ ]; call( - [] // Comment + [], // Comment ); call([ @@ -588,7 +588,7 @@ $var->render( foo( /* Comment */ $a /* Comment */, /* Comment */ [] /* Comment */, - /* Comment */ $a + 2 /* Comment */ + /* Comment */ $a + 2 /* Comment */, ); foo(/* A */); $foo->bar(/* B */); @@ -596,24 +596,24 @@ $foo->bar(/* B */); render( // Comment "string", - $container + $container, ); $var->render( // Comment "string", - $var + $var, ); render( "string", - $container + $container, // Comment ); $var->render( "string", - $var + $var, // Comment ); @@ -621,7 +621,7 @@ $var->render( // Comment "string", // Comment - $var + $var, // Comment ); @@ -2745,22 +2745,22 @@ echo // Comment call( $veryVeryVeryVeryVeryVeryVeryLongArg, $veryVeryVeryVeryVeryVeryVeryLongArg, - $veryVeryVeryVeryVeryVeryVeryLongArg + $veryVeryVeryVeryVeryVeryVeryLongArg, ); echo // Comment <<city, // city $vendor->state, // state - $vendor->zip // state + $vendor->zip, // state ); } } @@ -5883,7 +5883,7 @@ $a = new class ( // Comment $a, $b, - $c + $c, ) {}; $a = new class ( @@ -5892,7 +5892,7 @@ $a = new class ( // Comment $b, // Comment - $c + $c, ) {}; $a = new class { @@ -6221,28 +6221,28 @@ class MyClass { function foo( /* Comment */ $a, - /* Comment */ array /* Comment2 */ $b /* Comment */ = /* Comment */ [] /* Comment */ + /* Comment */ array /* Comment2 */ $b /* Comment */ = /* Comment */ [] /* Comment */, ) {} function bar(/* Comment */ &$a /* Comment */) {} function baz( /* Comment */ $a, - /* Comment */ array /* Comment3 */ &$b /* Comment */ = /* Comment */ [] /* Comment */ + /* Comment */ array /* Comment3 */ &$b /* Comment */ = /* Comment */ [] /* Comment */, ) {} class MyClass { public function foo( /* Comment */ $a, - /* Comment */ array /* Comment2 */ $b /* Comment */ = /* Comment */ [] /* Comment */ + /* Comment */ array /* Comment2 */ $b /* Comment */ = /* Comment */ [] /* Comment */, ) {} public function bar(/* Comment */ &$a /* Comment */) {} public function baz( /* Comment */ $a, - /* Comment */ array /* Comment3 */ &$b /* Comment */ = /* Comment */ [] /* Comment */ + /* Comment */ array /* Comment3 */ &$b /* Comment */ = /* Comment */ [] /* Comment */, ) {} } @@ -6333,7 +6333,7 @@ print // Comment print call( // Comment - $a + $a, ); print // Comment @@ -6471,14 +6471,14 @@ class Foo public $bar = // Comment 1 // Comment 2 <<<'EOT' -bar -EOT; + bar + EOT; public $baz = // Comment 1 // Comment 2 << (new Foo($cssFilename->split("/")->length))->join("../")] + ["publicPath" => new Foo($cssFilename->split("/")->length)->join("../")] : []; $extractTextPluginOptions = $shouldUseRelativeAssetPaths ? // Making sure that the publicPath goes back to to build folder. - ["publicPath" => (new Foo($cssFilename->split("/")->length))->join("../")] + ["publicPath" => new Foo($cssFilename->split("/")->length)->join("../")] : []; $extractTextPluginOptions = $shouldUseRelativeAssetPaths // Making sure that the publicPath goes back to to build folder. - ? ["publicPath" => (new Foo($cssFilename->split("/")->length))->join("../")] + ? ["publicPath" => new Foo($cssFilename->split("/")->length)->join("../")] : []; $var = @@ -6915,14 +6915,14 @@ throw /* Comment */ new Foo() /* Comment */; // Comment throw new ClassName( // Comment 1, // Comment // Comment - 2 // Comment + 2, // Comment ); // Comment /* Comment */ throw new ClassName /* Comment */( /* Comment */ 1 /* Comment */, /* Comment */ - /* Comment */ 2 /* Comment */ + /* Comment */ 2 /* Comment */, /* Comment */ ); /* Comment */ @@ -7230,12 +7230,12 @@ unset(/* Comment */ $foo /* Comment */); unset( // Comment - $var + $var, ); unset( // Comment - $var + $var, ); ================================================================================ @@ -7264,7 +7264,7 @@ use // Comment use some\\namespaces\\{ /* Comment */ /* Comment */ /* Comment */ ClassA /* Comment */, /* Comment */ ClassB /* Comment */, - /* Comment */ ClassC as /* Comment */ /* Comment */ C + /* Comment */ ClassC as /* Comment */ /* Comment */ C, }; use // Comment diff --git a/tests/composer-version/composer-version.spec.mjs b/tests/composer-version/composer-version.spec.mjs new file mode 100644 index 000000000..30e6afd69 --- /dev/null +++ b/tests/composer-version/composer-version.spec.mjs @@ -0,0 +1,215 @@ +import { getComposerPhpVersion, resolvePhpVersion } from "../../src/options.mjs"; +import fs from "fs"; +import path from "path"; +import os from "os"; + +describe("getComposerPhpVer", () => { + // Create a unique temporary directory for our tests + const tempDir = path.join(os.tmpdir(), `composer-version-test-${Date.now()}`); + const tempComposerPath = path.join(tempDir, "composer.json"); + const originalCwd = process.cwd(); + + beforeEach(() => { + // Create temp directory if it doesn't exist + if (!fs.existsSync(tempDir)) { + fs.mkdirSync(tempDir, { recursive: true }); + } + }); + + afterEach(() => { + process.chdir(originalCwd); + + // Clean up temp files and directories + if (fs.existsSync(tempComposerPath)) { + fs.unlinkSync(tempComposerPath); + } + + // Remove any nested directories we created + if (fs.existsSync(tempDir)) { + const deleteFolderRecursive = function(dirPath) { + if (fs.existsSync(dirPath)) { + fs.readdirSync(dirPath).forEach((file) => { + const curPath = path.join(dirPath, file); + if (fs.lstatSync(curPath).isDirectory()) { + deleteFolderRecursive(curPath); + } else { + fs.unlinkSync(curPath); + } + }); + fs.rmdirSync(dirPath); + } + }; + + deleteFolderRecursive(tempDir); + } + }); + + test("returns null when no composer.json is found", () => { + // Create a directory with no composer.json + const emptyDir = path.join(tempDir, "empty-dir"); + fs.mkdirSync(emptyDir, { recursive: true }); + + process.chdir(emptyDir); + + expect(getComposerPhpVersion()).toBe(null); + }); + + test.each([ + {ver:">=7.1.0",expected: 7.1}, + {ver:"^8.0",expected: 8.0}, + {ver:"~7.4",expected: 7.4}, + {ver:">=5.6.0 <8.0.0",expected: 5.6}, + {ver:"7.3.*",expected: 7.3}, + {ver:"7.* || 8.*",expected: 7.0} + ])("extracts correct version from $ver ba changing cwd", ({ver, expected}) => { + const composerContent = JSON.stringify( + { + require: { + php: ver, + }, + }, + null, + 2 + ); + + process.chdir(tempDir); + fs.writeFileSync(tempComposerPath, composerContent); + + + expect(getComposerPhpVersion()).toBe(expected); + }); + + test("phpVersion=composer reads composer.json", () => { + + const composerContent = JSON.stringify( + { + require: { + php: ">=5.4", + }, + }, + null, + 2 + ); + + process.chdir(tempDir); + fs.writeFileSync(tempComposerPath, composerContent); + + + const options = { phpVersion: "composer" }; + resolvePhpVersion(options); + expect(options.phpVersion).toBe(5.4); + }) + + test("returns null when composer.json has no PHP requirement", () => { + const composerContent = JSON.stringify( + { + require: { + // No PHP requirement + "some/package": "^1.0" + }, + }, + null, + 2 + ); + + fs.writeFileSync(tempComposerPath, composerContent); + + process.chdir(tempDir); + + expect(getComposerPhpVersion()).toBe(null); + }); + + + test("returns error when no composer.json and phpVersion set to composer", () => { + + process.chdir(tempDir); + + expect(() =>resolvePhpVersion({phpVersion:"composer"})).toThrow(); + }); + + test("returns null when composer.json has invalid PHP requirement", () => { + const composerContent = JSON.stringify( + { + require: { + php: "invalid-version" + }, + }, + null, + 2 + ); + + fs.writeFileSync(tempComposerPath, composerContent); + + process.chdir(tempDir); + + expect(getComposerPhpVersion()).toBe(null); + }); + + test("finds composer.json in parent directory when in nested child folder", () => { + // Create a nested directory structure + const nestedDir1 = path.join(tempDir, "level1"); + const nestedDir2 = path.join(nestedDir1, "level2"); + const nestedDir3 = path.join(nestedDir2, "level3"); + + fs.mkdirSync(nestedDir1, { recursive: true }); + fs.mkdirSync(nestedDir2, { recursive: true }); + fs.mkdirSync(nestedDir3, { recursive: true }); + + // Create composer.json in the root temp directory + const composerContent = JSON.stringify( + { + require: { + php: "^8.1" + }, + }, + null, + 2 + ); + + fs.writeFileSync(tempComposerPath, composerContent); + + process.chdir(nestedDir3); + + expect(getComposerPhpVersion()).toBe(8.1); + }); + + test("finds composer.json in intermediate parent directory", () => { + // Create a nested directory structure + const nestedDir1 = path.join(tempDir, "folder1"); + const nestedDir2 = path.join(nestedDir1, "folder2"); + const nestedDir3 = path.join(nestedDir2, "folder3"); + + fs.mkdirSync(nestedDir1, { recursive: true }); + fs.mkdirSync(nestedDir2, { recursive: true }); + fs.mkdirSync(nestedDir3, { recursive: true }); + + // Create composer.json in the middle level directory + const intermediateComposerPath = path.join(nestedDir2, "composer.json"); + const composerContent = JSON.stringify( + { + require: { + php: "~7.2" + }, + }, + null, + 2 + ); + + fs.writeFileSync(intermediateComposerPath, composerContent); + + process.chdir(nestedDir3); + + expect(getComposerPhpVersion()).toBe(7.2); + }); + + test("returns null when composer.json is malformed", () => { + // Create a malformed JSON file (invalid syntax) + const malformedContent = `{This is not JSON}`; + + fs.writeFileSync(tempComposerPath, malformedContent); + + process.chdir(tempDir); + + expect(getComposerPhpVersion()).toBe(null); + }); +}); diff --git a/tests/echo/__snapshots__/jsfmt.spec.mjs.snap b/tests/echo/__snapshots__/jsfmt.spec.mjs.snap index 40c6016b9..455ac56e9 100644 --- a/tests/echo/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/echo/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`echo.php 1`] = ` ====================================options===================================== @@ -319,30 +319,30 @@ echo esc_html( __( "Hi there. Your recent order on %s has been completed. " . "Your order details are shown below for your reference:", - "woocommerce" + "woocommerce", ), - get_option("blogname") - ) + get_option("blogname"), + ), ); echo esc_html( sprintf( __( "Hi there. Your recent order on %s has been completed. " . "Your order details are shown below for your reference:", - "woocommerce" + "woocommerce", ), - get_option("blogname") - ) + get_option("blogname"), + ), ) . "\\n\\n"; echo esc_html( sprintf( __( "Hi there. Your recent order on %s has been completed. " . "Your order details are shown below for your reference:", - "woocommerce" + "woocommerce", ), - get_option("blogname") - ) + get_option("blogname"), + ), ) . "\\n\\n", "string"; echo esc_html( @@ -350,10 +350,10 @@ echo esc_html( __( "Hi there. Your recent order on %s has been completed. " . "Your order details are shown below for your reference:", - "woocommerce" + "woocommerce", ), - get_option("blogname") - ) + get_option("blogname"), + ), ) . "\\n\\n", "string" . "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString"; @@ -362,10 +362,10 @@ echo esc_html( __( "Hi there. Your recent order on %s has been completed. " . "Your order details are shown below for your reference:", - "woocommerce" + "woocommerce", ), - get_option("blogname") - ) + get_option("blogname"), + ), ), "string", "string"; @@ -374,30 +374,30 @@ echo esc_html( __( "Hi there. Your recent order on %s has been completed. " . "Your order details are shown below for your reference:", - "woocommerce" + "woocommerce", ), - get_option("blogname") - ) + get_option("blogname"), + ), ), esc_html( sprintf( __( "Hi there. Your recent order on %s has been completed. " . "Your order details are shown below for your reference:", - "woocommerce" + "woocommerce", ), - get_option("blogname") - ) + get_option("blogname"), + ), ); echo esc_html( sprintf( __( "Hi there. Your recent order on %s has been completed. " . "Your order details are shown below for your reference:", - "woocommerce" + "woocommerce", ), - get_option("blogname") - ) + get_option("blogname"), + ), ), "string", esc_html( @@ -405,10 +405,10 @@ echo esc_html( __( "Hi there. Your recent order on %s has been completed. " . "Your order details are shown below for your reference:", - "woocommerce" + "woocommerce", ), - get_option("blogname") - ) + get_option("blogname"), + ), ); echo << "foo", "barfoo" => "foobar", "foobar" => "barfoo", - ] + ], ); ?>
element( @@ -1183,7 +1183,7 @@ printWidth: 80 "bar" => "foo", "barfoo" => "foobar", "foobar" => "barfoo", - ] + ], ); ?>
@@ -1803,7 +1803,7 @@ printWidth: 80 value="id); ?>" chosen, true); ?> data-text="order_button_text + $gateway->order_button_text, ); ?>" @@ -1874,7 +1874,7 @@ func( @@ -1882,7 +1882,7 @@ func( @@ -1890,7 +1890,7 @@ func( @@ -1898,7 +1898,7 @@ func( @@ -1906,7 +1906,7 @@ func( @@ -1914,7 +1914,7 @@ func( @@ -1922,7 +1922,7 @@ func( diff --git a/tests/isset/__snapshots__/jsfmt.spec.mjs.snap b/tests/isset/__snapshots__/jsfmt.spec.mjs.snap index f94ba9377..88f261c05 100644 --- a/tests/isset/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/isset/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`isset.php 1`] = ` ====================================options===================================== @@ -60,14 +60,14 @@ class T a->b); isset( $veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongVariable ->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty - ->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty + ->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty, ); if (isset($var)) { diff --git a/tests/kitchen_sink/__snapshots__/jsfmt.spec.mjs.snap b/tests/kitchen_sink/__snapshots__/jsfmt.spec.mjs.snap index ea8553b76..b468e90a5 100644 --- a/tests/kitchen_sink/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/kitchen_sink/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`kitchen_sink.php 1`] = ` ====================================options===================================== @@ -77,7 +77,7 @@ if ($test == 1) { function really_long_function( $test2 = 1, $long_parameter_name, - $even_longer_longer_longer_longer_longer_parameter_name + $even_longer_longer_longer_longer_longer_parameter_name, ) { return $test2; } diff --git a/tests/list/__snapshots__/jsfmt.spec.mjs.snap b/tests/list/__snapshots__/jsfmt.spec.mjs.snap index 027a6c996..c21e367f4 100644 --- a/tests/list/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/list/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`list.php 1`] = ` ====================================options===================================== @@ -159,110 +159,110 @@ list( $info = ["coffee", "brown", "caffeine"]; // Listing all the variables -list($drink, $color, $power) = $info; +[$drink, $color, $power] = $info; echo "$drink is $color and $power makes it special.\\n"; // Listing some of them -list($drink, , $power) = $info; +[$drink, , $power] = $info; echo "$drink has $power.\\n"; // Or let's skip to only the third one -list(, , $power) = $info; +[, , $power] = $info; echo "I need $power!\\n"; // list() doesn't work with strings -list($bar) = "abcde"; +[$bar] = "abcde"; var_dump($bar); // NULL -while (list($id, $name, $salary) = $result->fetch(PDO::FETCH_NUM)) { +while ([$id, $name, $salary] = $result->fetch(PDO::FETCH_NUM)) { } -list($a, list($b, $c)) = [1, [2, 3]]; +[$a, [$b, $c]] = [1, [2, 3]]; $info = ["coffee", "brown", "caffeine"]; -list($a[0], $a[1], $a[2]) = $info; +[$a[0], $a[1], $a[2]] = $info; -list("id" => $id1, "name" => $name1) = $data[0]; -list( +["id" => $id1, "name" => $name1] = $data[0]; +[ "veryVeryVeryVeryVeryLongKey" => $veryVeryVeryVeryVeryLongValue, "veryVeryVeryVeryVeryLongKey" => $veryVeryVeryVeryVeryLongValue, -) = $data[0]; -list( +] = $data[0]; +[ "veryVeryVeryVeryVeryVeryVeryVeryVeryLongKey" => $veryVeryVeryVeryVeryVeryVeryVeryVeryLongValue, "veryVeryVeryVeryVeryVeryVeryVeryVeryLongKey" => $veryVeryVeryVeryVeryVeryVeryVeryVeryLongValue, -) = $data[0]; +] = $data[0]; -foreach ($data as list("id" => $id, "name" => $name)) { +foreach ($data as ["id" => $id, "name" => $name]) { // logic here with $id and $name } foreach ( $data - as list( + as [ "veryVeryVeryVeryVeryLongKey" => $veryVeryVeryVeryVeryLongValue, "veryVeryVeryVeryVeryLongKey" => $veryVeryVeryVeryVeryLongValue, - ) + ] ) { // logic here with $id and $name } foreach ( $data - as list( + as [ "veryVeryVeryVeryVeryVeryVeryVeryVeryLongKey" => $veryVeryVeryVeryVeryVeryVeryVeryVeryLongValue, "veryVeryVeryVeryVeryVeryVeryVeryVeryLongKey" => $veryVeryVeryVeryVeryVeryVeryVeryVeryLongValue, - ) + ] ) { // logic here with $id and $name } -list(, $b) = ["a", "b"]; -list(, , $c) = ["a", "b", "c"]; +[, $b] = ["a", "b"]; +[, , $c] = ["a", "b", "c"]; -while (list($id, $name, $salary) = $result->fetch(PDO::FETCH_NUM)) { +while ([$id, $name, $salary] = $result->fetch(PDO::FETCH_NUM)) { echo " \\n" . " $name\\n" . " $salary\\n" . " \\n"; } -list($a, list($b, $c)) = [1, [2, 3]]; +[$a, [$b, $c]] = [1, [2, 3]]; -list($a[0], $a[1], $a[2]) = $info; +[$a[0], $a[1], $a[2]] = $info; foreach ($data as ["id" => $id, "name" => $name]) { echo "id: $id, name: $name\\n"; } -list(0 => $first, 1 => $second, 2 => $three, 3 => $fourth) = $arr; -list( +[0 => $first, 1 => $second, 2 => $three, 3 => $fourth] = $arr; +[ 0 => $first, 1 => $second, 2 => $three, 3 => $fourth, -) = $arr; +] = $arr; -list($first, $second, $three, $fourth) = $arr; -list(, $first, $second, $three, $fourth) = $arr; -list(, , $first, $second, $three, $fourth, ,) = $arr; -list(, , $first, , $second, , $three, , $fourth, ,) = $arr; -list(, , , $first, $second, $three, $fourth, , ,) = $arr; -list(, , , $first, , , $second, , , $three, , , $fourth, , ,) = $arr; +[$first, $second, $three, $fourth] = $arr; +[, $first, $second, $three, $fourth] = $arr; +[, , $first, $second, $three, $fourth, ,] = $arr; +[, , $first, , $second, , $three, , $fourth, ,] = $arr; +[, , , $first, $second, $three, $fourth, , ,] = $arr; +[, , , $first, , , $second, , , $three, , , $fourth, , ,] = $arr; -list( +[ 0 => $firstVeryVeryVeryVeryLong, 1 => $secondVeryVeryVeryVeryLong, 2 => $threeVeryVeryVeryVeryLong, 3 => $fourthVeryVeryVeryVeryLong, -) = $arr; -list( +] = $arr; +[ , 0 => $firstVeryVeryVeryVeryLong, 1 => $secondVeryVeryVeryVeryLong, 2 => $threeVeryVeryVeryVeryLong, 3 => $fourthVeryVeryVeryVeryLong, -) = $arr; -list( +] = $arr; +[ , , 0 => $firstVeryVeryVeryVeryLong, @@ -270,8 +270,8 @@ list( 2 => $threeVeryVeryVeryVeryLong, 3 => $fourthVeryVeryVeryVeryLong, , -) = $arr; -list( +] = $arr; +[ , , 0 => $firstVeryVeryVeryVeryLong, @@ -282,8 +282,8 @@ list( , 3 => $fourthVeryVeryVeryVeryLong, , -) = $arr; -list( +] = $arr; +[ , , , @@ -293,8 +293,8 @@ list( 3 => $fourthVeryVeryVeryVeryLong, , , -) = $arr; -list( +] = $arr; +[ , , , @@ -310,9 +310,9 @@ list( 3 => $fourthVeryVeryVeryVeryLong, , , -) = $arr; +] = $arr; -list( +[ 0 => $firstVeryVeryVeryVeryLong, 1 => $secondVeryVeryVeryVeryLong, @@ -320,12 +320,12 @@ list( 2 => $threeVeryVeryVeryVeryLong, 3 => $fourthVeryVeryVeryVeryLong, -) = $arr; +] = $arr; -list("id" => $id1, "name" => $name1) = $data[0]; +["id" => $id1, "name" => $name1] = $data[0]; ["id" => $id1, "name" => $name1] = $data[0]; -foreach ($data as list("id" => $id, "name" => $name)) { +foreach ($data as ["id" => $id, "name" => $name]) { // logic here with $id and $name } @@ -339,60 +339,60 @@ function swap(&$a, &$b): void } $array = [1, 2]; -list($a, &$b) = $array; [$a, &$b] = $array; -list(&$a, $b, , list(&$c, $d)) = $array; +[$a, &$b] = $array; +[&$a, $b, , [&$c, $d]] = $array; [&$a, $b, , [&$c, $d]] = $array; -foreach ($array as list(&$a, $b)) { +foreach ($array as [&$a, $b]) { } foreach ($array as [&$a, $b]) { } -list(0 => $var) = $arr; -list(0 => $var) = $arr; -list(, 0 => $var) = $arr; -list(0 => $var) = $arr; -list( +[0 => $var] = $arr; +[0 => $var] = $arr; +[, 0 => $var] = $arr; +[0 => $var] = $arr; +[ 0 => $var, -) = $arr; -list( +] = $arr; +[ , 0 => $var, -) = $arr; -list( +] = $arr; +[ , 0 => $var, -) = $arr; -list( +] = $arr; +[ , 0 => $var, , -) = $arr; -list( +] = $arr; +[ 0 => $var, 1 => $other_var, -) = $arr; -list( +] = $arr; +[ , 0 => $var, 1 => $other_var, -) = $arr; -list( +] = $arr; +[ , 0 => $var, 1 => $other_var, -) = $arr; -list( +] = $arr; +[ , 0 => $var, 1 => $other_var, , -) = $arr; -list(0 => $var) = $arr; -list( +] = $arr; +[0 => $var] = $arr; +[ 0 => $var, -) = $arr; +] = $arr; ================================================================================ `; diff --git a/tests/member_chain/__snapshots__/jsfmt.spec.mjs.snap b/tests/member_chain/__snapshots__/jsfmt.spec.mjs.snap index 283177c24..4d8631650 100644 --- a/tests/member_chain/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/member_chain/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`break-last-call.php 1`] = ` ====================================options===================================== @@ -34,7 +34,7 @@ function call($store) actionWith([ "response" => $response, "type" => $successType, - ]) + ]), ); }, function ($error) { @@ -42,9 +42,9 @@ function call($store) actionWith([ "type" => $failureType, "error" => $error->message || "Something bad happened", - ]) + ]), ); - } + }, ); } @@ -87,10 +87,10 @@ $superSupersuperSupersuperSupersuperSupersuperSuperLong->{$exampleOfOrderOfGette $superSupersuperSupersuperSupersuperSupersuperSuperLong::$exampleOfOrderOfGetterAndSetterReordered; $superSupersuperSupersuperSupersuperSupersuperSuperLong ::$exampleOfOrderOfGetterAndSetterReordered[0]; -$superSupersuperSupersuperSupersuperSupersuperSuperLong = (new SuperSuperSuperSuperSuperSuperLongClassName()) +$superSupersuperSupersuperSupersuperSupersuperSuperLong = new SuperSuperSuperSuperSuperSuperLongClassName() ->some_very_long_member_expression; new $superSupersuperSupersuperSupersuperSupersuperSuperLong->superSupersuperSupersuperSupersuperSupersuperSuperLong->superSupersuperSupersuperSupersuperSupersuperSuperLong(); -(new $superSupersuperSupersuperSupersuperSupersuperSuperLong->superSupersuperSupersuperSupersuperSupersuperSuperLong->superSupersuperSupersuperSupersuperSupersuperSuperLong()) +new $superSupersuperSupersuperSupersuperSupersuperSuperLong->superSupersuperSupersuperSupersuperSupersuperSuperLong->superSupersuperSupersuperSupersuperSupersuperSuperLong() ->superSupersuperSupersuperSupersuperSupersuperSuperLong; $test = $superSupersuperSupersuperSupersuperSupersuperSuperLong->exampleOfOrderOfGetterAndSetterReordered; @@ -241,7 +241,7 @@ $object[ : $helper->responseBody($defaultUser) ]->map(); -(new TestClassWithReallyReallyReallyReallyReallyReallyReallyReallyReallyLongName()) +new TestClassWithReallyReallyReallyReallyReallyReallyReallyReallyReallyLongName() ->map() ->filter(); @@ -470,7 +470,7 @@ return tap( $this->forceFill([ "approver_id" => $user instanceof User ? $user->id : $user, "approved_at" => $this->freshTimestamp(), - ]) + ]), )->save(); return collect(parent::jsonSerialize()) @@ -518,7 +518,7 @@ $a = $t ->once(); $this->loooooooooooong->lookup = (int) $this->getRequest()->getParam( - "some-param" + "some-param", ); $this->loooooooooooong->lookup = (int) $variable @@ -541,38 +541,38 @@ $aVariable = $theThing bar()(); bar( - "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong" + "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong", )(); bar()( - "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong" + "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong", ); bar( - "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong" + "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong", )()()()()(); $foo->bar()(); $foo->bar( - "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong" + "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong", )(); $foo->bar()( - "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong" + "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong", ); $foo->bar( - "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong" + "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong", )()()()()(); $brian->hotel->orders()->ordered()->with("smith")->get(); $brian::$hotel->orders()->ordered()->with("smith")->get(); $brian["hotel"]->orders()->ordered()->with("smith")->get(); Foo::$hotel->orders()->ordered()->with("smith")->get(); -(new Foo())->hotel->orders()->ordered()->with("smith")->get(); +new Foo()->hotel->orders()->ordered()->with("smith")->get(); (clone $a)->hotel->orders()->ordered()->with("smith")->get(); $var = $brian->hotel->orders()->ordered()->with("smith")->get(); $var = $brian::$hotel->orders()->ordered()->with("smith")->get(); $var = $brian["hotel"]->orders()->ordered()->with("smith")->get(); $var = Foo::$hotel->orders()->ordered()->with("smith")->get(); -$var = (new Foo())->hotel->orders()->ordered()->with("smith")->get(); +$var = new Foo()->hotel->orders()->ordered()->with("smith")->get(); $var = (clone $a)->hotel->orders()->ordered()->with("smith")->get(); $var = Foo::keys($items) @@ -583,10 +583,10 @@ $var = Foo::keys($items) return $x * 2; }); -(new static(func_get_args()))->push($this)->each(function ($item) { +new static(func_get_args())->push($this)->each(function ($item) { VarDumper::dump($item); }); -(new static(func_get_args())) +new static(func_get_args()) ->offset(10) ->push($this) ->each(function ($item) { @@ -641,7 +641,7 @@ $wrapper ->find("SomewhatLongNodeName") ->prop( "longPropFunctionName", - "second argument that pushes this group past 80 characters" + "second argument that pushes this group past 80 characters", ) ->then(function () { doSomething(); @@ -812,8 +812,8 @@ $window ->first() ->second(); -(new Foo())->call($foo->bar->baz)->first()->second(); -(new Foo()) +new Foo()->call($foo->bar->baz)->first()->second(); +new Foo() ->call($foo->bar->baz->foo()) ->first() ->second(); @@ -971,7 +971,7 @@ DB::table("identity")->insert([ ]); DB::table( - "identity" + "identity", )->insertReallyReallyReallyReallyReallyReallyReallyReallyReallyLongName([ "ref" => $ref, "handle" => $handle, @@ -991,7 +991,7 @@ Logger::use_logger("albus")->info( [ "uuid" => $uuid, "requested_date" => $date, - ] + ], ); DBwithlongname::table("identity") @@ -1031,7 +1031,7 @@ $page = TableRegistry::insertReallyReallyReallyReallyReallyReallyReallyReallyRea $page = TableRegistry::insertReallyReallyReallyLongName("Pages")[0]; $page = TableRegistry::insertReallyReallyReallyReallyReallyReallyReallyReallyReallyLongName( - "Pages" + "Pages", )[0]; $component = find(".org-lclp-edit-copy-url-banner__link")[0] @@ -1053,7 +1053,7 @@ static::viewFactory() $view ?: static::$defaultSimpleView, array_merge($data, [ "paginator" => $this, - ]) + ]), ) ->render(); static::viewFactory() @@ -1061,7 +1061,7 @@ static::viewFactory() $view ?: static::$defaultSimpleView, array_merge($data, [ "paginator" => $this, - ]) + ]), ) ->render(); self::viewFactory() @@ -1069,7 +1069,7 @@ self::viewFactory() $view ?: static::$defaultSimpleView, array_merge($data, [ "paginator" => $this, - ]) + ]), ) ->render(); parent::viewFactory() @@ -1077,7 +1077,7 @@ parent::viewFactory() $view ?: static::$defaultSimpleView, array_merge($data, [ "paginator" => $this, - ]) + ]), ) ->render(); @@ -1086,7 +1086,7 @@ Foo::viewFactory() $view ?: static::$defaultSimpleView, array_merge($data, [ "paginator" => $this, - ]) + ]), ) ->render(); diff --git a/tests/new/__snapshots__/jsfmt.spec.mjs.snap b/tests/new/__snapshots__/jsfmt.spec.mjs.snap index d29025a20..177c147da 100644 --- a/tests/new/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/new/__snapshots__/jsfmt.spec.mjs.snap @@ -1,8 +1,9 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`new.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -225,7 +226,7 @@ $class = (new Foo([ "VeryVeryVeryVeryVeryVeryVeryVeryVeryLongValue", ]))->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongMethod(); $class = (new PendingDispatch(new $this->class(...func_get_args())))->chain( - $this->chain + $this->chain, ); $dumper = in_array(PHP_SAPI, ["cli", "phpdbg"]) ? new CliDumper() @@ -236,10 +237,10 @@ $class = new static( "] with ID [" . $model->getKey() . "] to JSON: " . - $message + $message, ); $response = new \\Illuminate\\Http\\JsonResponse( - new JsonResponseTestJsonSerializeObject() + new JsonResponseTestJsonSerializeObject(), ); $result = (new Pipeline(new \\Illuminate\\Container\\Container())) ->send("foo") @@ -250,62 +251,64 @@ $result = (new Pipeline(new \\Illuminate\\Container\\Container())) $var = new Foo( <<<'EOD' -Example of string -spanning multiple lines -using nowdoc syntax. -EOD + Example of string + spanning multiple lines + using nowdoc syntax. + EOD , - $arg + $arg, ); $var = new Foo( $arg, <<<'EOD' -Example of string -spanning multiple lines -using nowdoc syntax. -EOD + Example of string + spanning multiple lines + using nowdoc syntax. + EOD + , ); $var = new Foo( $arg, <<<'EOD' -Example of string -spanning multiple lines -using nowdoc syntax. -EOD + Example of string + spanning multiple lines + using nowdoc syntax. + EOD , - $arg + $arg, ); $var = new Foo( << "veryVeryVeryVeryVeryVeryVeryVeryVeryLongString", "key3" => "veryVeryVeryVeryVeryVeryVeryVeryVeryLongString", - ] + ], ) { return $arg; } @@ -211,7 +211,7 @@ function bar2( $arg = "veryVeryVeryVeryVeryVeryVeryVeryVeryLongString" . "veryVeryVeryVeryVeryVeryVeryVeryVeryLongString" . - "veryVeryVeryVeryVeryVeryVeryVeryVeryLongString" + "veryVeryVeryVeryVeryVeryVeryVeryVeryLongString", ) { return $arg; } @@ -219,7 +219,7 @@ function bar2( function bar3( $arg = "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString" ? "1" - : "2" + : "2", ) { return $arg; } @@ -227,7 +227,7 @@ function bar3( function bar4( string $arg = "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString" ? "1" - : "2" + : "2", ) { return $arg; } @@ -237,7 +237,7 @@ function bar5( "veryVeryVeryVeryVeryVeryVeryVeryVeryLongString" === "veryVeryVeryVeryVeryVeryVeryVeryVeryLongString" ? "1" - : "2" + : "2", ) { return $arg; } @@ -245,7 +245,7 @@ function bar5( function foo( $arg = 'string string -string' +string', ) {} function foo( @@ -254,7 +254,7 @@ string string', $arg = 'string string -string' +string', ) {} function foo( @@ -262,7 +262,7 @@ function foo( $b = 'string string string', - $c + $c, ) {} ================================================================================ diff --git a/tests/parens/__snapshots__/jsfmt.spec.mjs.snap b/tests/parens/__snapshots__/jsfmt.spec.mjs.snap index ed2b205ba..ccb74dd00 100644 --- a/tests/parens/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/parens/__snapshots__/jsfmt.spec.mjs.snap @@ -1,8 +1,9 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`array.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -107,7 +108,6 @@ $var = [new stdClass()][0]; exports[`array.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -212,6 +212,7 @@ $var = [new stdClass()][0]; exports[`assign.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -426,7 +427,6 @@ switch ($i = 1) { exports[`assign.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -641,6 +641,7 @@ switch ($i = 1) { exports[`assignref.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -689,7 +690,6 @@ call($a = &$b); exports[`assignref.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -738,6 +738,7 @@ call($a = &$b); exports[`bin.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -1505,7 +1506,6 @@ $result = 2 ** ($number - 1); exports[`bin.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -2273,6 +2273,7 @@ $result = 2 ** ($number - 1); exports[`block.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -2296,7 +2297,6 @@ function foo() exports[`block.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -2320,6 +2320,7 @@ function foo() exports[`break.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -2354,7 +2355,6 @@ break 2; exports[`break.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -2389,6 +2389,7 @@ break 2; exports[`call.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -2507,7 +2508,6 @@ Foo::call($a = new Foo()); exports[`call.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -2626,6 +2626,7 @@ Foo::call($a = new Foo()); exports[`cast.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -2827,7 +2828,6 @@ $timeout = exports[`cast.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -3029,6 +3029,7 @@ $timeout = exports[`clone.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -3107,7 +3108,6 @@ $var = (clone $var->foo)->foo; exports[`clone.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -3186,6 +3186,7 @@ $var = (clone $var->foo)->foo; exports[`closure.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -3239,7 +3240,6 @@ var_dump(...(function () use ($type) {})()); exports[`closure.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -3293,6 +3293,7 @@ var_dump(...(function () use ($type) {})()); exports[`continue.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -3327,7 +3328,6 @@ continue 2; exports[`continue.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -3362,6 +3362,7 @@ continue 2; exports[`control-structures.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -3567,7 +3568,7 @@ switch ($var = 1) { switch ($var = 1) { } -while (list($id, $name, $salary) = $result->fetch(PDO::FETCH_NUM)) { +while ([$id, $name, $salary] = $result->fetch(PDO::FETCH_NUM)) { } while ([$id, $name, $salary] = $result->fetch(PDO::FETCH_NUM)) { } @@ -3589,7 +3590,6 @@ do { exports[`control-structures.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -3817,6 +3817,7 @@ do { exports[`declare.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -3839,7 +3840,6 @@ $a->c(); exports[`declare.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -3862,6 +3862,7 @@ $a->c(); exports[`echo.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -3953,7 +3954,6 @@ echo (function () { exports[`echo.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -4045,6 +4045,7 @@ echo (function () { exports[`empty.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -4076,7 +4077,6 @@ if (empty($var)) { exports[`empty.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -4108,6 +4108,7 @@ if (empty($var)) { exports[`eval.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -4151,7 +4152,6 @@ if (eval("return 1;") === 1) { exports[`eval.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -4195,6 +4195,7 @@ if (eval("return 1;") === 1) { exports[`exit.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -4235,7 +4236,6 @@ call(exit(1)); exports[`exit.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -4276,6 +4276,7 @@ call(exit(1)); exports[`include.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -4359,7 +4360,6 @@ include $_GET["id"] . ".php"; exports[`include.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -4443,6 +4443,7 @@ include $_GET["id"] . ".php"; exports[`isset.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -4478,7 +4479,6 @@ if (isset($var)) { exports[`isset.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -4514,6 +4514,7 @@ if (isset($var)) { exports[`lookups.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -4706,7 +4707,6 @@ $var = (function () { exports[`lookups.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -4899,6 +4899,7 @@ $var = (function () { exports[`namespace.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -4921,7 +4922,6 @@ $a->c(); exports[`namespace.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -4944,6 +4944,7 @@ $a->c(); exports[`new.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -5027,7 +5028,7 @@ new Translator( new MessageFormatter(), "en", [], - ["foo" => "bar"] + ["foo" => "bar"], ); ?> "bar", @@ -5086,7 +5087,6 @@ $var = (new class {})->foo; exports[`new.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -5229,6 +5229,7 @@ $var = new class {}->foo; exports[`parens.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -5247,7 +5248,6 @@ include $test ? "foo" : "bar"; exports[`parens.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -5266,6 +5266,7 @@ include $test ? "foo" : "bar"; exports[`pre-post.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -5394,7 +5395,6 @@ $var = call(--$var->_uuidCounter); exports[`pre-post.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -5523,6 +5523,7 @@ $var = call(--$var->_uuidCounter); exports[`print.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -5622,7 +5623,6 @@ print ($var || $var) && $var; exports[`print.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -5722,6 +5722,7 @@ print ($var || $var) && $var; exports[`program.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -5740,7 +5741,6 @@ $a->c(); exports[`program.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -5759,6 +5759,7 @@ $a->c(); exports[`retif.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -5904,7 +5905,6 @@ $var = new $foo() ? true : false; exports[`retif.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -6050,6 +6050,7 @@ $var = new $foo() ? true : false; exports[`return.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -6090,7 +6091,6 @@ return $this->customer->paymentService ?? null; exports[`return.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -6131,6 +6131,7 @@ return $this->customer->paymentService ?? null; exports[`silent.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -6225,7 +6226,7 @@ try { handle_exception(); } -@list($width, $height) = getimagesize($file); +@[$width, $height] = getimagesize($file); // Todo https://github.com/glayzzle/php-parser/issues/356 // @(list($width, $height) = getimagesize($file)); @@ -6244,7 +6245,6 @@ echo @(1 / 0); exports[`silent.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -6358,6 +6358,7 @@ echo @(1 / 0); exports[`throw.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -6411,7 +6412,6 @@ $value = $a ? $a : throw new \\InvalidArgumentException("In ternary"); exports[`throw.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -6465,6 +6465,7 @@ $value = $a ? $a : throw new \\InvalidArgumentException("In ternary"); exports[`unary.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -6609,7 +6610,6 @@ if (!($token = $this->getToken())) { exports[`unary.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -6754,6 +6754,7 @@ if (!($token = $this->getToken())) { exports[`unnecessary.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -6876,7 +6877,6 @@ function foo($a = 1, $b = "string", $c = true, $d = __LINE__) exports[`unnecessary.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== @@ -6999,6 +6999,7 @@ function foo($a = 1, $b = "string", $c = true, $d = __LINE__) exports[`yield.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "8.3" printWidth: 80 | printWidth =====================================input====================================== @@ -7096,7 +7097,6 @@ function gen_one_to_three() exports[`yield.php 2`] = ` ====================================options===================================== parsers: ["php"] -phpVersion: "8.4" printWidth: 80 | printWidth =====================================input====================================== diff --git a/tests/parens/jsfmt.spec.mjs b/tests/parens/jsfmt.spec.mjs index a2c158328..354bc7ea5 100644 --- a/tests/parens/jsfmt.spec.mjs +++ b/tests/parens/jsfmt.spec.mjs @@ -1,2 +1,2 @@ +run_spec(import.meta, ["php"], {phpVersion:"8.3"}); run_spec(import.meta, ["php"]); -run_spec(import.meta, ["php"], { phpVersion: "8.4" }); diff --git a/tests/preserve_line/__snapshots__/jsfmt.spec.mjs.snap b/tests/preserve_line/__snapshots__/jsfmt.spec.mjs.snap index 45c50c6ef..5a67bb15a 100644 --- a/tests/preserve_line/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/preserve_line/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`argument-list.php 1`] = ` ====================================options===================================== @@ -209,14 +209,14 @@ longArgNamesWithComments( $longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong2, /* Hello World */ - $longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong3 + $longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong3, ); shortArgNames( $short, $short2, - $short3 + $short3, ); comments( @@ -235,7 +235,7 @@ comments( /* Long Long Long Long Long Comment */ // Long Long Long Long Long Comment - $short3 + $short3, // More comments ); @@ -244,7 +244,7 @@ differentArgTypes( return true; }, - isTrue ? doSomething() : 12 + isTrue ? doSomething() : 12, ); moreArgTypes( @@ -261,31 +261,31 @@ moreArgTypes( // Hello world again ["name" => "Hello World", "age" => 34], - $oneThing + $anotherThing + $oneThing + $anotherThing, // Comment - ) + ), ); evenMoreArgTypes( doSomething( ["name" => "Hello World", "age" => 34], - true + true, ), 14, 1 + 2 - 90 / 80, - !98 * 60 - 90 + !98 * 60 - 90, ); $foo->apply( null, // Array here - [1, 2] + [1, 2], ); $bar->on( @@ -293,7 +293,7 @@ $bar->on( function () { doStuff(); - } + }, ); foo( @@ -302,7 +302,7 @@ foo( /* function here */ function () { return true; - } + }, ); $doSomething->apply( @@ -310,13 +310,13 @@ $doSomething->apply( // Comment - ["Hello world 1", "Hello world 2", "Hello world 3"] + ["Hello world 1", "Hello world 2", "Hello world 3"], ); doAnotherThing( "node", - [$solution_type, $time_frame] + [$solution_type, $time_frame], ); $stuff->doThing( @@ -327,7 +327,7 @@ $stuff->doThing( "accept" => function ($node) { doSomething($node); }, - ] + ], ); doThing( @@ -339,7 +339,7 @@ doThing( "decline" => function ($creditCard) { takeMoney($creditCard); }, - ] + ], ); func( @@ -347,7 +347,7 @@ func( thing(); }, - ["yes" => true, "no" => 5] + ["yes" => true, "no" => 5], ); doSomething( @@ -358,7 +358,7 @@ doSomething( /* Comment */ // This is important - [$helloWorld, $someImportantStuff] + [$helloWorld, $someImportantStuff], ); ================================================================================ diff --git a/tests/print/__snapshots__/jsfmt.spec.mjs.snap b/tests/print/__snapshots__/jsfmt.spec.mjs.snap index d93a2e400..922788033 100644 --- a/tests/print/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/print/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`print.php 1`] = ` ====================================options===================================== @@ -229,10 +229,10 @@ print esc_html( __( "Hi there. Your recent order on %s has been completed. " . "Your order details are shown below for your reference:", - "woocommerce" + "woocommerce", ), - get_option("blogname") - ) + get_option("blogname"), + ), ); print << "very_very_very_long_other_value", ]; public $var8 = <<<'EOD' -hello world -EOD; + hello world + EOD; public $var9 = 11111111111111111111111111111111111111111111111111111111111111111111; public $var10 = "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString"; public $var11 = true; diff --git a/tests/propertylookup/__snapshots__/jsfmt.spec.mjs.snap b/tests/propertylookup/__snapshots__/jsfmt.spec.mjs.snap index e0378115a..bbd1aa97f 100644 --- a/tests/propertylookup/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/propertylookup/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`offsets.php 1`] = ` ====================================options===================================== @@ -115,7 +115,7 @@ $this->loooooooooooong->loooooooooooong->loooooooooooong->lookup = $this->loooooooooooong->loooooooooooong->loooooooooooong->lookup = $other->looooooooooong->stuff; $this->loooooooooooong->lookup = (int) $this->getRequest()->getParam( - "instance-resource-id" + "instance-resource-id", ); $obj->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty; diff --git a/tests/retif/__snapshots__/jsfmt.spec.mjs.snap b/tests/retif/__snapshots__/jsfmt.spec.mjs.snap index 94fc73a9f..49603a8d0 100644 --- a/tests/retif/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/retif/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`retif.php 1`] = ` ====================================options===================================== @@ -259,7 +259,7 @@ $test = bar( $someOtherReallyReallyLongVariable, $someOtherReallyReallyLongVariable, - $someOtherReallyReallyLongVariable + $someOtherReallyReallyLongVariable, ); $test = $testReallyReallyReallyReallyReallyReallyLong >= 1 ?: @@ -445,7 +445,7 @@ call( function () { return 1; }, - $var ? 1 : 2 + $var ? 1 : 2, ); call( @@ -454,7 +454,7 @@ call( }, $someOtherReallyReallyLongVariable ? $someOtherReallyReallyLongVariable - : $someOtherReallyReallyLongVariable + : $someOtherReallyReallyLongVariable, ); call( @@ -464,7 +464,7 @@ call( $someOtherReallyReallyLongVariable ?: $someOtherReallyReallyLongVariable ?: $someOtherReallyReallyLongVariable ?: - "test" + "test", ); $var = [ @@ -553,13 +553,13 @@ call($var ?: $var ?: $var ?: "string"); call( $someOtherReallyReallyLongVariable ? $someOtherReallyReallyLongVariable - : $someOtherReallyReallyLongVariable + : $someOtherReallyReallyLongVariable, ); call( $someOtherReallyReallyLongVariable ?: $someOtherReallyReallyLongVariable ?: $someOtherReallyReallyLongVariable ?: - "string" + "string", ); exit($var ? "string" : "other-string"); diff --git a/tests/return/__snapshots__/jsfmt.spec.mjs.snap b/tests/return/__snapshots__/jsfmt.spec.mjs.snap index c1c416e4a..45146d195 100644 --- a/tests/return/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/return/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`return.php 1`] = ` ====================================options===================================== @@ -425,7 +425,7 @@ return new Foo( 1024, $veryVeryVeryVeryVeryVeryLongLine, true, - false + false, ); return new Foo( $arg, @@ -433,7 +433,7 @@ return new Foo( 1024, $veryVeryVeryVeryVeryVeryLongLine, true, - false + false, ) . "string"; return "string" . new Foo( @@ -442,7 +442,7 @@ return "string" . 1024, $veryVeryVeryVeryVeryVeryLongLine, true, - false + false, ); return []; @@ -469,12 +469,12 @@ return $packages || [ ]; return $this->events->until( - new Events\\NotificationSending($notifiable, $notification, $channel) + new Events\\NotificationSending($notifiable, $notification, $channel), ) !== false; return false !== $this->events->until( - new Events\\NotificationSending($notifiable, $notification, $channel) + new Events\\NotificationSending($notifiable, $notification, $channel), ); return $this->getOptions()["endpoint"] ?? @@ -488,7 +488,7 @@ return $this->channels[$name] ?? with($this->resolve($name), function ($logger) use ($name) { return $this->channels[$name] = $this->tap( $name, - new Logger($logger, $this->app["events"]) + new Logger($logger, $this->app["events"]), ); }); @@ -530,7 +530,7 @@ return $this->guards[$name] ?? ($this->guards[$name] = $this->resolve($veryVeryVeryLongVariable)); return $this->guards[$veryVeryVeryLongVariable] ?? ($this->guards[$veryVeryVeryLongVariable] = $this->resolve( - $veryVeryVeryLongVariable + $veryVeryVeryLongVariable, )); return call_user_func($this->passwordValidator, $credentials) && diff --git a/tests/silent/__snapshots__/jsfmt.spec.mjs.snap b/tests/silent/__snapshots__/jsfmt.spec.mjs.snap index 77637a202..523f38a29 100644 --- a/tests/silent/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/silent/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`silent.php 1`] = ` ====================================options===================================== @@ -41,7 +41,7 @@ $variable = @foo() $variable = @foo( "VeryVeryVeryVeryVeryVeryLongArgument", "VeryVeryVeryVeryVeryVeryLongArgument", - "VeryVeryVeryVeryVeryVeryLongArgument" + "VeryVeryVeryVeryVeryVeryLongArgument", ); @trigger_error($error, E_USER_DEPRECATED); $value = @$cache[$key]; diff --git a/tests/single-quote-api/jsfmt.spec.mjs b/tests/single-quote-api/jsfmt.spec.mjs index c95b4ab03..bb9db6fb7 100644 --- a/tests/single-quote-api/jsfmt.spec.mjs +++ b/tests/single-quote-api/jsfmt.spec.mjs @@ -13,7 +13,7 @@ test(`singleQuote option on format api`, async () => { const expected = ` `; diff --git a/tests/staticlookup/__snapshots__/jsfmt.spec.mjs.snap b/tests/staticlookup/__snapshots__/jsfmt.spec.mjs.snap index 101adee06..121cb5059 100644 --- a/tests/staticlookup/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/staticlookup/__snapshots__/jsfmt.spec.mjs.snap @@ -344,7 +344,7 @@ $var = $var[0]::foo; $var = $var[0][1]::foo; $var = $var[0][1]::foo; $var = $var[0][1]::foo; -$var = (new Foo())::bar; +$var = new Foo()::bar; $var = Foo::$bar["baz"](); $var = Foo::$bar["baz"](); $var = Foo::{$bar["baz"]}(); diff --git a/tests/string/__snapshots__/jsfmt.spec.mjs.snap b/tests/string/__snapshots__/jsfmt.spec.mjs.snap index edef47687..a166868aa 100644 --- a/tests/string/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/string/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`multiline.php 1`] = ` ====================================options===================================== @@ -308,7 +308,7 @@ $string = "This is the value of the var named by the return value of getName(): $string = "This is the value of the var named by the return value of getName(): {\${getName( $arg1, $arg2, - $arg3 + $arg3, )}}"; $string = "This is the value of the var named by the return value of \\$object->getName(): {\${$object->getName()}}"; $string = "I'd like an {\${beers::softdrink}}\\n"; diff --git a/tests/sys/__snapshots__/jsfmt.spec.mjs.snap b/tests/sys/__snapshots__/jsfmt.spec.mjs.snap index 25eefe8ec..6cbfb3562 100644 --- a/tests/sys/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/sys/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`sys.php 1`] = ` ====================================options===================================== @@ -40,12 +40,12 @@ echo "test echo"; echo $test, $other; $info = ["coffee", "brown", "caffeine"]; -list($drink, $color, $power) = $info; -list( +[$drink, $color, $power] = $info; +[ $reallyReallyReallyReallyLongName, $otherReallyReallyReallyLongName, $lastOne, -) = $info; +] = $info; print "test print"; print "parens test"; @@ -68,7 +68,7 @@ isset( $test, $test, $test, - $test + $test, ); isset($test["foo"]); diff --git a/tests/trailing_commas/__snapshots__/jsfmt.spec.mjs.snap b/tests/trailing_commas/__snapshots__/jsfmt.spec.mjs.snap index 6650f4f14..c570a1a63 100644 --- a/tests/trailing_commas/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/trailing_commas/__snapshots__/jsfmt.spec.mjs.snap @@ -1,8 +1,9 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`array.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "7.0" printWidth: 80 | printWidth =====================================input====================================== @@ -1753,6 +1754,7 @@ $expected = [ exports[`array.php 5`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "7.0" printWidth: 80 trailingComma: "all" trailingCommaPHP: false @@ -2179,6 +2181,7 @@ EOT exports[`call.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "7.0" printWidth: 80 | printWidth =====================================input====================================== @@ -3359,6 +3362,7 @@ $sel = $this->connections exports[`call.php 5`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "7.0" printWidth: 80 trailingComma: "all" trailingCommaPHP: false @@ -3654,6 +3658,7 @@ $sel = $this->connections exports[`isset.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "7.0" printWidth: 80 | printWidth =====================================input====================================== @@ -3756,6 +3761,7 @@ var_dump( exports[`isset.php 5`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "7.0" printWidth: 80 trailingComma: "all" trailingCommaPHP: false @@ -3782,6 +3788,7 @@ var_dump( exports[`list.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "7.0" printWidth: 80 | printWidth =====================================input====================================== @@ -4180,6 +4187,7 @@ list(,,,0 => $firstVeryVeryVeryVeryLong,,, 1 => $secondVeryVeryVeryVeryLong,,, 2 exports[`list.php 5`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "7.0" printWidth: 80 trailingComma: "all" trailingCommaPHP: false @@ -4280,6 +4288,7 @@ list( exports[`unset.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "7.0" printWidth: 80 | printWidth =====================================input====================================== @@ -4378,6 +4387,7 @@ unset( exports[`unset.php 5`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "7.0" printWidth: 80 trailingComma: "all" trailingCommaPHP: false @@ -4403,6 +4413,7 @@ unset( exports[`use.php 1`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "7.0" printWidth: 80 | printWidth =====================================input====================================== @@ -4609,6 +4620,7 @@ use other_foo\\bar\\{ exports[`use.php 5`] = ` ====================================options===================================== parsers: ["php"] +phpVersion: "7.0" printWidth: 80 trailingComma: "all" trailingCommaPHP: false diff --git a/tests/trailing_commas/jsfmt.spec.mjs b/tests/trailing_commas/jsfmt.spec.mjs index 695bbbc83..a9c95d350 100644 --- a/tests/trailing_commas/jsfmt.spec.mjs +++ b/tests/trailing_commas/jsfmt.spec.mjs @@ -1,8 +1,9 @@ -run_spec(import.meta, ["php"]); +run_spec(import.meta, ["php"], { phpVersion: "7.0" }); run_spec(import.meta, ["php"], { trailingCommaPHP: true, phpVersion: "5.0" }); run_spec(import.meta, ["php"], { trailingCommaPHP: true, phpVersion: "7.2" }); run_spec(import.meta, ["php"], { trailingCommaPHP: true, phpVersion: "7.3" }); run_spec(import.meta, ["php"], { trailingCommaPHP: false, + phpVersion: "7.0", trailingComma: "all", }); diff --git a/tests/unset/__snapshots__/jsfmt.spec.mjs.snap b/tests/unset/__snapshots__/jsfmt.spec.mjs.snap index 949971bb3..3384bb48a 100644 --- a/tests/unset/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/unset/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`unset.php 1`] = ` ====================================options===================================== @@ -22,14 +22,14 @@ unset($veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryL a->b); unset( $veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongVariable ->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty - ->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty + ->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty, ); ================================================================================ diff --git a/tests/use/__snapshots__/jsfmt.spec.mjs.snap b/tests/use/__snapshots__/jsfmt.spec.mjs.snap index f3b09702d..dca64bca2 100644 --- a/tests/use/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/use/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`use.php 1`] = ` ====================================options===================================== @@ -64,7 +64,7 @@ use Vendor\\Package\\SomeNamespace\\{ SubnamespaceOne\\ClassA, SubnamespaceOne\\ClassB, SubnamespaceTwo\\ClassY, - ClassZ + ClassZ, }; use Mizo\\Web\\{ Php\\WebSite, @@ -74,7 +74,7 @@ use Mizo\\Web\\{ function JS\\printTotal, function JS\\printList, const JS\\BUAIKUM, - const JS\\MAUTAM + const JS\\MAUTAM, }; use Illuminate\\Foundation\\Bootstrap\\BootProviders; use function some\\Full\\fn_a; diff --git a/tests/variadic/__snapshots__/jsfmt.spec.mjs.snap b/tests/variadic/__snapshots__/jsfmt.spec.mjs.snap index 4f7205633..64025ce9f 100644 --- a/tests/variadic/__snapshots__/jsfmt.spec.mjs.snap +++ b/tests/variadic/__snapshots__/jsfmt.spec.mjs.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`variadic.php 1`] = ` ====================================options===================================== @@ -41,7 +41,7 @@ function f($req, $opt = null, ...$params) '$req: %d; $opt: %d; number of params: %d' . "\\n", $req, $opt, - count($params) + count($params), ); }