From d4c8cb8f6159b520a9688d10e30101ad24366956 Mon Sep 17 00:00:00 2001 From: Thomas Genin Date: Mon, 16 Jan 2023 14:16:00 -0800 Subject: [PATCH 1/2] Update php parser --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index e714c4a83..7a5fc263e 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "dependencies": { "linguist-languages": "^7.21.0", "mem": "^8.0.0", - "php-parser": "^3.1.2" + "php-parser": "^3.1.3" }, "devDependencies": { "@babel/preset-env": "^7.19.4", diff --git a/yarn.lock b/yarn.lock index 75431481e..01e4d7835 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4148,10 +4148,10 @@ path-type@^4.0.0: resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== -php-parser@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/php-parser/-/php-parser-3.1.2.tgz#db704c584ea4085142fc5d3c33218b207d5f9a09" - integrity sha512-RRCMK/bCKYPLRhlpfMlVVVsaIesuW+X6UxRqWjm7dTAmTZk8PvD6hCmG/RVeDzse7iqYWJwLJeqEbaGLC+aHeQ== +php-parser@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/php-parser/-/php-parser-3.1.3.tgz#7a2aac2eb88a5a6c5aa75e6170a256bee5a30e6b" + integrity sha512-hPvBmnRYPqWEtMfIFOlyjQv1q75UUtxt4U+YscKIQViGmEE2Xa4BuS1B1/cZdjy7MVcwtnr0WkEsr915LgRKOw== picocolors@^1.0.0: version "1.0.0" From 9e7ff60c33673ea7439972fdc555f54175d1be36 Mon Sep 17 00:00:00 2001 From: Thomas Genin Date: Mon, 16 Jan 2023 14:21:41 -0800 Subject: [PATCH 2/2] Add support for readonly class --- src/printer.js | 4 ++++ tests/class/__snapshots__/jsfmt.spec.js.snap | 10 ++++++++++ tests/class/class.php | 6 +++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/printer.js b/src/printer.js index 1783d28b3..3d6269e1e 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1254,6 +1254,10 @@ function printClass(path, options, print) { const attrs = printAttrs(path, options, print, { inline: isAnonymousClass }); const declaration = isAnonymousClass ? [] : [...attrs]; + if (node.isReadonly) { + declaration.push("readonly "); + } + if (node.isFinal) { declaration.push("final "); } diff --git a/tests/class/__snapshots__/jsfmt.spec.js.snap b/tests/class/__snapshots__/jsfmt.spec.js.snap index 906855210..76457e653 100644 --- a/tests/class/__snapshots__/jsfmt.spec.js.snap +++ b/tests/class/__snapshots__/jsfmt.spec.js.snap @@ -935,6 +935,11 @@ class Promoted { } } + +readonly class ReadOnlyCls { + public string $myValue; +} + =====================================output=====================================