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/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=====================================