diff --git a/src/parser/class.js b/src/parser/class.js index 69216d3ee..fad28269a 100644 --- a/src/parser/class.js +++ b/src/parser/class.js @@ -442,6 +442,10 @@ module.exports = { this.next(); // consume the visibility keyword if (this.version >= 804 && this.token === "(") { // visibility(set) modifier: e.g. private(set) + // For shorthand, default get visibility to public if not already set + if (result[0][0] === -1) { + result[0][0] = 0; + } this.next(); // consume '(' if (this.token !== this.tok.T_STRING || this.text() !== "set") { this.error("set"); diff --git a/test/snapshot/__snapshots__/asymmetric-visibility.test.js.snap b/test/snapshot/__snapshots__/asymmetric-visibility.test.js.snap index 70400417c..b580a07ae 100644 --- a/test/snapshot/__snapshots__/asymmetric-visibility.test.js.snap +++ b/test/snapshot/__snapshots__/asymmetric-visibility.test.js.snap @@ -1207,7 +1207,7 @@ Program { "value": null, }, ], - "visibility": "", + "visibility": "public", "visibilitySet": "private", }, ], @@ -1311,7 +1311,7 @@ Program { "value": null, }, ], - "visibility": "", + "visibility": "public", "visibilitySet": "protected", }, ],