diff --git a/src/ast/classconstant.js b/src/ast/classconstant.js index bea667188..33f246901 100644 --- a/src/ast/classconstant.js +++ b/src/ast/classconstant.js @@ -53,16 +53,17 @@ const ClassConstant = ConstantStatement.extends( * @return {void} */ ClassConstant.prototype.parseFlags = function (flags) { - if (flags[0] === -1) { + const getVis = flags[0][0]; + if (getVis === -1) { this.visibility = IS_UNDEFINED; - } else if (flags[0] === null) { + } else if (getVis === null) { /* istanbul ignore next */ this.visibility = null; - } else if (flags[0] === 0) { + } else if (getVis === 0) { this.visibility = IS_PUBLIC; - } else if (flags[0] === 1) { + } else if (getVis === 1) { this.visibility = IS_PROTECTED; - } else if (flags[0] === 2) { + } else if (getVis === 2) { this.visibility = IS_PRIVATE; } this.final = flags[2] === 2; diff --git a/src/ast/declaration.js b/src/ast/declaration.js index 33ffbf5e0..4334e0bac 100644 --- a/src/ast/declaration.js +++ b/src/ast/declaration.js @@ -13,12 +13,15 @@ const IS_PUBLIC = "public"; const IS_PROTECTED = "protected"; const IS_PRIVATE = "private"; +const VISIBILITY_MAP = [IS_PUBLIC, IS_PROTECTED, IS_PRIVATE]; + /** * A declaration statement (function, class, interface...) * @constructor Declaration * @memberOf module:php-parser * @extends {Statement} * @property {Identifier|string} name + * @property {string|null} visibilitySet */ const Declaration = Statement.extends( KIND, @@ -41,19 +44,17 @@ Declaration.prototype.parseFlags = function (flags) { this.isFinal = flags[2] === 2; this.isReadonly = flags[3] === 1; if (this.kind !== "class") { - if (flags[0] === -1) { + const [getVis, setVis] = flags[0]; + if (getVis === -1) { this.visibility = IS_UNDEFINED; - } else if (flags[0] === null) { + } else if (getVis === null) { /* istanbul ignore next */ this.visibility = null; - } else if (flags[0] === 0) { - this.visibility = IS_PUBLIC; - } else if (flags[0] === 1) { - this.visibility = IS_PROTECTED; - } else if (flags[0] === 2) { - this.visibility = IS_PRIVATE; + } else { + this.visibility = VISIBILITY_MAP[getVis]; } this.isStatic = flags[1] === 1; + this.visibilitySet = setVis !== -1 ? VISIBILITY_MAP[setVis] : null; } }; diff --git a/src/ast/parameter.js b/src/ast/parameter.js index 9011a5ce7..0a1aa6d5e 100644 --- a/src/ast/parameter.js +++ b/src/ast/parameter.js @@ -34,6 +34,7 @@ const KIND = "parameter"; * @property {AttrGroup[]} attrGroups * @property {MODIFIER_PUBLIC|MODIFIER_PROTECTED|MODIFIER_PRIVATE} flags * @property {PropertyHook[]} hooks + * @property {MODIFIER_PUBLIC|MODIFIER_PROTECTED|MODIFIER_PRIVATE} flagsSet */ module.exports = Declaration.extends( KIND, @@ -47,6 +48,7 @@ module.exports = Declaration.extends( nullable, flags, hooks, + flagsSet, docs, location, ) { @@ -59,6 +61,7 @@ module.exports = Declaration.extends( this.nullable = nullable; this.flags = flags || 0; this.hooks = hooks || []; + this.flagsSet = flagsSet || 0; this.attrGroups = []; }, ); diff --git a/src/ast/propertystatement.js b/src/ast/propertystatement.js index b8016de55..0508b2793 100644 --- a/src/ast/propertystatement.js +++ b/src/ast/propertystatement.js @@ -13,6 +13,8 @@ const IS_PUBLIC = "public"; const IS_PROTECTED = "protected"; const IS_PRIVATE = "private"; +const VISIBILITY_MAP = [IS_PUBLIC, IS_PROTECTED, IS_PRIVATE]; + /** * Declares a properties into the current scope * @constructor PropertyStatement @@ -20,6 +22,7 @@ const IS_PRIVATE = "private"; * @extends {Statement} * @property {Property[]} properties * @property {string|null} visibility + * @property {string|null} visibilitySet * @property {boolean} isStatic * @property {boolean} isAbstract * @property {boolean} isFinal @@ -41,21 +44,19 @@ const PropertyStatement = Statement.extends( * @return {void} */ PropertyStatement.prototype.parseFlags = function (flags) { - if (flags[0] === -1) { + const [getVis, setVis] = flags[0]; + if (getVis === -1) { this.visibility = IS_UNDEFINED; - } else if (flags[0] === null) { + } else if (getVis === null) { this.visibility = null; - } else if (flags[0] === 0) { - this.visibility = IS_PUBLIC; - } else if (flags[0] === 1) { - this.visibility = IS_PROTECTED; - } else if (flags[0] === 2) { - this.visibility = IS_PRIVATE; + } else { + this.visibility = VISIBILITY_MAP[getVis]; } this.isStatic = flags[1] === 1; this.isAbstract = flags[2] === 1; this.isFinal = flags[2] === 2; + this.visibilitySet = setVis !== -1 ? VISIBILITY_MAP[setVis] : null; }; module.exports = PropertyStatement; diff --git a/src/ast/traitalias.js b/src/ast/traitalias.js index d6a9ecdf0..c20001856 100644 --- a/src/ast/traitalias.js +++ b/src/ast/traitalias.js @@ -32,11 +32,12 @@ module.exports = Node.extends( this.as = as; this.visibility = IS_UNDEFINED; if (flags) { - if (flags[0] === 0) { + const getVis = flags[0][0]; + if (getVis === 0) { this.visibility = IS_PUBLIC; - } else if (flags[0] === 1) { + } else if (getVis === 1) { this.visibility = IS_PROTECTED; - } else if (flags[0] === 2) { + } else if (getVis === 2) { this.visibility = IS_PRIVATE; } } diff --git a/src/parser/class.js b/src/parser/class.js index be8824482..66a068803 100644 --- a/src/parser/class.js +++ b/src/parser/class.js @@ -115,6 +115,9 @@ module.exports = { // check constant if (this.token === this.tok.T_CONST) { + if (flags[0][1] !== -1) { + this.raiseError("Cannot use asymmetric visibility on constants"); + } const constants = this.read_constant_list(flags, attrs); if (this.expect(";")) { this.next(); @@ -126,7 +129,7 @@ module.exports = { // jump over T_VAR then land on T_VARIABLE if (allow_variables && this.token === this.tok.T_VAR) { this.next().expect(this.tok.T_VARIABLE); - flags[0] = null; // public (as null) + flags[0][0] = null; // public (as null) flags[1] = 0; // non static var } @@ -388,69 +391,94 @@ module.exports = { /* * Read member flags * @return array - * 1st index : 0 => public, 1 => protected, 2 => private + * 1st index : [get, set] visibility tuple + * get/set: -1 => no visibility, 0 => public, 1 => protected, 2 => private * 2nd index : 0 => instance member, 1 => static member * 3rd index : 0 => normal, 1 => abstract member, 2 => final member + * 4th index : 0 => no readonly, 1 => readonly */ read_member_flags(asInterface) { - const result = [-1, -1, -1, -1]; - if (this.is("T_MEMBER_FLAGS")) { - let idx = 0, - val = 0; - do { - switch (this.token) { - case this.tok.T_PUBLIC: - idx = 0; - val = 0; - break; - case this.tok.T_PROTECTED: - idx = 0; - val = 1; - break; - case this.tok.T_PRIVATE: - idx = 0; - val = 2; - break; - case this.tok.T_STATIC: - idx = 1; - val = 1; - break; - case this.tok.T_ABSTRACT: - idx = 2; - val = 1; - break; - case this.tok.T_FINAL: - idx = 2; - val = 2; - break; - case this.tok.T_READ_ONLY: - idx = 3; - val = 1; - break; - } - if (asInterface) { - if (idx === 0 && val === 2) { + const result = [[-1, -1], 0, 0, 0]; + const seen = new Set(); + while (this.is("T_MEMBER_FLAGS")) { + let idx = -1, + val = -1; + switch (this.token) { + case this.tok.T_PUBLIC: + case this.tok.T_PROTECTED: + case this.tok.T_PRIVATE: { + idx = 0; + val = + this.token === this.tok.T_PUBLIC + ? 0 + : this.token === this.tok.T_PROTECTED + ? 1 + : 2; + if (asInterface && val === 2) { // an interface can't be private this.expect([this.tok.T_PUBLIC, this.tok.T_PROTECTED]); val = -1; - } else if (idx === 2 && val === 1) { - // an interface cant be abstract + } + this.next(); // consume the visibility keyword + if (this.version >= 804 && this.token === "(") { + // visibility(set) modifier: e.g. private(set) + this.next(); // consume '(' + if (this.token !== this.tok.T_STRING || this.text() !== "set") { + this.error("set"); + } else { + this.next(); // consume 'set' + } + if (this.expect(")")) { + this.next(); // consume ')' + } + if (seen.has("set")) { + this.error(); // set modifier already defined + } else if (val !== -1) { + seen.add("set"); + result[0][1] = val; + } + continue; + } + if (seen.has(idx)) { this.error(); - val = -1; + } else if (val !== -1) { + seen.add(idx); + result[0][0] = val; } + continue; } - if (result[idx] !== -1) { - // already defined flag - this.error(); - } else if (val !== -1) { - result[idx] = val; - } - } while (this.next().is("T_MEMBER_FLAGS")); + case this.tok.T_STATIC: + idx = 1; + val = 1; + break; + case this.tok.T_ABSTRACT: + idx = 2; + val = 1; + break; + case this.tok.T_FINAL: + idx = 2; + val = 2; + break; + case this.tok.T_READ_ONLY: + idx = 3; + val = 1; + break; + } + if (asInterface && idx === 2 && val === 1) { + // an interface can't be abstract + this.error(); + val = -1; + } + if (seen.has(idx)) { + // already defined flag + this.error(); + } else if (val !== -1) { + seen.add(idx); + result[idx] = val; + } + this.next(); } - if (result[1] === -1) result[1] = 0; - if (result[2] === -1) result[2] = 0; - if (result[3] === -1) result[3] = 0; return result; }, @@ -581,6 +609,9 @@ module.exports = { // check constant if (this.token === this.tok.T_CONST) { + if (flags[0][1] !== -1) { + this.raiseError("Cannot use asymmetric visibility on constants"); + } const constants = this.read_constant_list(flags, attrs); if (this.expect(";")) { this.next(); diff --git a/src/parser/function.js b/src/parser/function.js index 5adebe8ca..eb5faaedc 100644 --- a/src/parser/function.js +++ b/src/parser/function.js @@ -268,7 +268,7 @@ module.exports = { } } - const flags = this.read_promoted(); + const [flags, flagsSet] = this.read_promoted(); if ( !readonly && @@ -320,6 +320,7 @@ module.exports = { nullable, flags, hooks, + flagsSet, ); if (attrs) result.attrGroups = attrs; return result; @@ -387,17 +388,67 @@ module.exports = { const MODIFIER_PUBLIC = 1; const MODIFIER_PROTECTED = 2; const MODIFIER_PRIVATE = 4; + + let firstModifier; if (this.token === this.tok.T_PUBLIC) { this.next(); - return MODIFIER_PUBLIC; + firstModifier = MODIFIER_PUBLIC; } else if (this.token === this.tok.T_PROTECTED) { this.next(); - return MODIFIER_PROTECTED; + firstModifier = MODIFIER_PROTECTED; } else if (this.token === this.tok.T_PRIVATE) { this.next(); - return MODIFIER_PRIVATE; + firstModifier = MODIFIER_PRIVATE; + } else { + return [0, 0]; + } + + // PHP 8.4+ asymmetric visibility + if (this.version >= 804) { + if (this.token === "(") { + // shorthand: visibility(set) — firstModifier is the set modifier, read visibility is implicit + this.next(); // consume '(' + if (this.token !== this.tok.T_STRING || this.text() !== "set") { + this.error("set"); + } else { + this.next(); // consume 'set' + } + if (this.expect(")")) { + this.next(); // consume ')' + } + return [0, firstModifier]; // no explicit read visibility, set = firstModifier + } + + // Check for explicit form: readVisibility setVisibility(set) + let setModifier = 0; + if (this.token === this.tok.T_PUBLIC) { + this.next(); + setModifier = MODIFIER_PUBLIC; + } else if (this.token === this.tok.T_PROTECTED) { + this.next(); + setModifier = MODIFIER_PROTECTED; + } else if (this.token === this.tok.T_PRIVATE) { + this.next(); + setModifier = MODIFIER_PRIVATE; + } + + if (setModifier > 0) { + if (this.expect("(")) { + this.next(); // consume '(' + } + if (this.token !== this.tok.T_STRING || this.text() !== "set") { + this.error("set"); + } else { + this.next(); // consume 'set' + } + if (this.expect(")")) { + this.next(); // consume ')' + } + return [firstModifier, setModifier]; + } } - return 0; + + return [firstModifier, 0]; }, /* * Reads a list of arguments diff --git a/test/snapshot/__snapshots__/acid.test.js.snap b/test/snapshot/__snapshots__/acid.test.js.snap index dcf6bf98c..d5be12a4d 100644 --- a/test/snapshot/__snapshots__/acid.test.js.snap +++ b/test/snapshot/__snapshots__/acid.test.js.snap @@ -1033,6 +1033,7 @@ Program { }, ], "visibility": "protected", + "visibilitySet": null, }, Method { "arguments": [], @@ -1606,6 +1607,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1774,6 +1776,7 @@ Program { "raw": "bool", }, "visibility": "public", + "visibilitySet": null, }, Method { "arguments": [], @@ -1835,6 +1838,7 @@ Program { "raw": "bool", }, "visibility": "protected", + "visibilitySet": null, }, Method { "arguments": [], @@ -1896,6 +1900,7 @@ Program { "raw": "bool", }, "visibility": "protected", + "visibilitySet": null, }, ], "extends": [ @@ -2177,6 +2182,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "loc": Location { @@ -2889,6 +2895,7 @@ Program { "raw": "string", }, "visibility": "public", + "visibilitySet": null, }, Method { "arguments": [], @@ -2986,6 +2993,7 @@ Program { "nullable": false, "type": null, "visibility": "private", + "visibilitySet": null, }, ], "kind": "trait", @@ -4140,6 +4148,7 @@ next: "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "loc": Location { @@ -5336,6 +5345,7 @@ next: "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, ], "extends": Name { diff --git a/test/snapshot/__snapshots__/arrowfunc.test.js.snap b/test/snapshot/__snapshots__/arrowfunc.test.js.snap index f79447509..a7ba01d30 100644 --- a/test/snapshot/__snapshots__/arrowfunc.test.js.snap +++ b/test/snapshot/__snapshots__/arrowfunc.test.js.snap @@ -18,6 +18,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -72,6 +73,7 @@ Program { "attrGroups": [], "byref": true, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -126,6 +128,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -142,6 +145,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -158,6 +162,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -321,6 +326,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -380,6 +386,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -434,6 +441,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { diff --git a/test/snapshot/__snapshots__/asymmetric-visibility.test.js.snap b/test/snapshot/__snapshots__/asymmetric-visibility.test.js.snap new file mode 100644 index 000000000..70400417c --- /dev/null +++ b/test/snapshot/__snapshots__/asymmetric-visibility.test.js.snap @@ -0,0 +1,1490 @@ +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing + +exports[`asymmetric visibility asymmetric visibility on constant 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + ClassConstant { + "attrGroups": [], + "constants": [ + Constant { + "kind": "constant", + "name": Identifier { + "kind": "identifier", + "name": "BAR", + }, + "value": Number { + "kind": "number", + "value": "1", + }, + }, + ], + "final": false, + "kind": "classconstant", + "nullable": false, + "type": null, + "visibility": "public", + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [ + Error { + "expected": undefined, + "kind": "error", + "line": 1, + "message": "Cannot use asymmetric visibility on constants on line 1", + "token": undefined, + }, + ], + "kind": "program", +} +`; + +exports[`asymmetric visibility constructor promotion malformed set keyword explicit 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + Method { + "arguments": [ + Parameter { + "attrGroups": [], + "byref": false, + "flags": 1, + "flagsSet": 4, + "hooks": [], + "kind": "parameter", + "name": null, + "nullable": false, + "readonly": false, + "type": Name { + "kind": "name", + "name": "foo", + "resolution": "uqn", + }, + "value": null, + "variadic": false, + }, + ], + "attrGroups": [], + "body": null, + "byref": false, + "isAbstract": false, + "isFinal": false, + "isReadonly": false, + "isStatic": false, + "kind": "method", + "name": Identifier { + "kind": "identifier", + "name": "__construct", + }, + "nullable": false, + "type": null, + "visibility": "public", + "visibilitySet": null, + }, + PropertyStatement { + "isAbstract": false, + "isFinal": false, + "isStatic": false, + "kind": "propertystatement", + "properties": [ + Property { + "attrGroups": [], + "hooks": [], + "kind": "property", + "name": Identifier { + "kind": "identifier", + "name": "name", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "string", + "raw": "string", + }, + "value": null, + }, + ], + "visibility": "", + "visibilitySet": null, + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ExpressionStatement { + "expression": undefined, + "kind": "expressionstatement", + }, + ], + "errors": [ + Error { + "expected": "set", + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected 'foo' (T_STRING) on line 1", + "token": "'foo' (T_STRING)", + }, + Error { + "expected": ")", + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected 'foo' (T_STRING), expecting ')' on line 1", + "token": "'foo' (T_STRING)", + }, + Error { + "expected": 222, + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected ')', expecting T_VARIABLE on line 1", + "token": "')'", + }, + Error { + "expected": "{", + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected 'string' (T_STRING), expecting '{' on line 1", + "token": "'string' (T_STRING)", + }, + Error { + "expected": [ + ",", + ";", + "=", + "{", + ], + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected ')' on line 1", + "token": "')'", + }, + Error { + "expected": [ + ";", + ",", + ], + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected ')' on line 1", + "token": "')'", + }, + Error { + "expected": [ + 198, + 222, + 182, + ], + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected ')' on line 1", + "token": "')'", + }, + Error { + "expected": [ + 198, + 222, + 182, + ], + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected '{' on line 1", + "token": "'{'", + }, + Error { + "expected": "EXPR", + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected '}' on line 1", + "token": "'}'", + }, + ], + "kind": "program", +} +`; + +exports[`asymmetric visibility constructor promotion malformed set keyword shorthand 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + Method { + "arguments": [ + Parameter { + "attrGroups": [], + "byref": false, + "flags": 0, + "flagsSet": 4, + "hooks": [], + "kind": "parameter", + "name": null, + "nullable": false, + "readonly": false, + "type": Name { + "kind": "name", + "name": "foo", + "resolution": "uqn", + }, + "value": null, + "variadic": false, + }, + ], + "attrGroups": [], + "body": null, + "byref": false, + "isAbstract": false, + "isFinal": false, + "isReadonly": false, + "isStatic": false, + "kind": "method", + "name": Identifier { + "kind": "identifier", + "name": "__construct", + }, + "nullable": false, + "type": null, + "visibility": "public", + "visibilitySet": null, + }, + PropertyStatement { + "isAbstract": false, + "isFinal": false, + "isStatic": false, + "kind": "propertystatement", + "properties": [ + Property { + "attrGroups": [], + "hooks": [], + "kind": "property", + "name": Identifier { + "kind": "identifier", + "name": "name", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "string", + "raw": "string", + }, + "value": null, + }, + ], + "visibility": "", + "visibilitySet": null, + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ExpressionStatement { + "expression": undefined, + "kind": "expressionstatement", + }, + ], + "errors": [ + Error { + "expected": "set", + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected 'foo' (T_STRING) on line 1", + "token": "'foo' (T_STRING)", + }, + Error { + "expected": ")", + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected 'foo' (T_STRING), expecting ')' on line 1", + "token": "'foo' (T_STRING)", + }, + Error { + "expected": 222, + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected ')', expecting T_VARIABLE on line 1", + "token": "')'", + }, + Error { + "expected": "{", + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected 'string' (T_STRING), expecting '{' on line 1", + "token": "'string' (T_STRING)", + }, + Error { + "expected": [ + ",", + ";", + "=", + "{", + ], + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected ')' on line 1", + "token": "')'", + }, + Error { + "expected": [ + ";", + ",", + ], + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected ')' on line 1", + "token": "')'", + }, + Error { + "expected": [ + 198, + 222, + 182, + ], + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected ')' on line 1", + "token": "')'", + }, + Error { + "expected": [ + 198, + 222, + 182, + ], + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected '{' on line 1", + "token": "'{'", + }, + Error { + "expected": "EXPR", + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected '}' on line 1", + "token": "'}'", + }, + ], + "kind": "program", +} +`; + +exports[`asymmetric visibility constructor promotion private(set) shorthand 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + Method { + "arguments": [ + Parameter { + "attrGroups": [], + "byref": false, + "flags": 0, + "flagsSet": 4, + "hooks": [], + "kind": "parameter", + "name": Identifier { + "kind": "identifier", + "name": "name", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "string", + "raw": "string", + }, + "value": null, + "variadic": false, + }, + ], + "attrGroups": [], + "body": Block { + "children": [], + "kind": "block", + }, + "byref": false, + "isAbstract": false, + "isFinal": false, + "isReadonly": false, + "isStatic": false, + "kind": "method", + "name": Identifier { + "kind": "identifier", + "name": "__construct", + }, + "nullable": false, + "type": null, + "visibility": "public", + "visibilitySet": null, + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [], + "kind": "program", +} +`; + +exports[`asymmetric visibility constructor promotion protected(set) shorthand 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + Method { + "arguments": [ + Parameter { + "attrGroups": [], + "byref": false, + "flags": 0, + "flagsSet": 2, + "hooks": [], + "kind": "parameter", + "name": Identifier { + "kind": "identifier", + "name": "count", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "int", + "raw": "int", + }, + "value": null, + "variadic": false, + }, + ], + "attrGroups": [], + "body": Block { + "children": [], + "kind": "block", + }, + "byref": false, + "isAbstract": false, + "isFinal": false, + "isReadonly": false, + "isStatic": false, + "kind": "method", + "name": Identifier { + "kind": "identifier", + "name": "__construct", + }, + "nullable": false, + "type": null, + "visibility": "public", + "visibilitySet": null, + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [], + "kind": "program", +} +`; + +exports[`asymmetric visibility constructor promotion public private(set) 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + Method { + "arguments": [ + Parameter { + "attrGroups": [], + "byref": false, + "flags": 1, + "flagsSet": 4, + "hooks": [], + "kind": "parameter", + "name": Identifier { + "kind": "identifier", + "name": "name", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "string", + "raw": "string", + }, + "value": null, + "variadic": false, + }, + ], + "attrGroups": [], + "body": Block { + "children": [], + "kind": "block", + }, + "byref": false, + "isAbstract": false, + "isFinal": false, + "isReadonly": false, + "isStatic": false, + "kind": "method", + "name": Identifier { + "kind": "identifier", + "name": "__construct", + }, + "nullable": false, + "type": null, + "visibility": "public", + "visibilitySet": null, + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [], + "kind": "program", +} +`; + +exports[`asymmetric visibility constructor promotion public protected(set) 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + Method { + "arguments": [ + Parameter { + "attrGroups": [], + "byref": false, + "flags": 1, + "flagsSet": 2, + "hooks": [], + "kind": "parameter", + "name": Identifier { + "kind": "identifier", + "name": "url", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "string", + "raw": "string", + }, + "value": null, + "variadic": false, + }, + ], + "attrGroups": [], + "body": Block { + "children": [], + "kind": "block", + }, + "byref": false, + "isAbstract": false, + "isFinal": false, + "isReadonly": false, + "isStatic": false, + "kind": "method", + "name": Identifier { + "kind": "identifier", + "name": "__construct", + }, + "nullable": false, + "type": null, + "visibility": "public", + "visibilitySet": null, + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [], + "kind": "program", +} +`; + +exports[`asymmetric visibility constructor promotion public public(set) 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + Method { + "arguments": [ + Parameter { + "attrGroups": [], + "byref": false, + "flags": 1, + "flagsSet": 1, + "hooks": [], + "kind": "parameter", + "name": Identifier { + "kind": "identifier", + "name": "name", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "string", + "raw": "string", + }, + "value": null, + "variadic": false, + }, + ], + "attrGroups": [], + "body": Block { + "children": [], + "kind": "block", + }, + "byref": false, + "isAbstract": false, + "isFinal": false, + "isReadonly": false, + "isStatic": false, + "kind": "method", + "name": Identifier { + "kind": "identifier", + "name": "__construct", + }, + "nullable": false, + "type": null, + "visibility": "public", + "visibilitySet": null, + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [], + "kind": "program", +} +`; + +exports[`asymmetric visibility duplicate set modifier 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + PropertyStatement { + "isAbstract": false, + "isFinal": false, + "isStatic": false, + "kind": "propertystatement", + "properties": [ + Property { + "attrGroups": [], + "hooks": [], + "kind": "property", + "name": Identifier { + "kind": "identifier", + "name": "name", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "string", + "raw": "string", + }, + "value": null, + }, + ], + "visibility": "public", + "visibilitySet": "private", + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [ + Error { + "expected": undefined, + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected 'string' (T_STRING) on line 1", + "token": "'string' (T_STRING)", + }, + ], + "kind": "program", +} +`; + +exports[`asymmetric visibility duplicate static flag 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + PropertyStatement { + "isAbstract": false, + "isFinal": false, + "isStatic": true, + "kind": "propertystatement", + "properties": [ + Property { + "attrGroups": [], + "hooks": [], + "kind": "property", + "name": Identifier { + "kind": "identifier", + "name": "name", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "string", + "raw": "string", + }, + "value": null, + }, + ], + "visibility": "", + "visibilitySet": null, + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [ + Error { + "expected": undefined, + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected 'static' (T_STATIC) on line 1", + "token": "'static' (T_STATIC)", + }, + ], + "kind": "program", +} +`; + +exports[`asymmetric visibility duplicate visibility 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + PropertyStatement { + "isAbstract": false, + "isFinal": false, + "isStatic": false, + "kind": "propertystatement", + "properties": [ + Property { + "attrGroups": [], + "hooks": [], + "kind": "property", + "name": Identifier { + "kind": "identifier", + "name": "name", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "string", + "raw": "string", + }, + "value": null, + }, + ], + "visibility": "public", + "visibilitySet": null, + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [ + Error { + "expected": undefined, + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected 'string' (T_STRING) on line 1", + "token": "'string' (T_STRING)", + }, + ], + "kind": "program", +} +`; + +exports[`asymmetric visibility ignored below PHP 8.4 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + PropertyStatement { + "isAbstract": false, + "isFinal": false, + "isStatic": false, + "kind": "propertystatement", + "properties": [ + Property { + "attrGroups": [], + "hooks": [], + "kind": "property", + "name": Identifier { + "kind": "identifier", + "name": "", + }, + "nullable": false, + "readonly": false, + "type": Name { + "kind": "name", + "name": "set", + "resolution": "uqn", + }, + "value": null, + }, + ], + "visibility": "", + "visibilitySet": null, + }, + PropertyStatement { + "isAbstract": false, + "isFinal": false, + "isStatic": false, + "kind": "propertystatement", + "properties": [ + Property { + "attrGroups": [], + "hooks": [], + "kind": "property", + "name": Identifier { + "kind": "identifier", + "name": "name", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "string", + "raw": "string", + }, + "value": null, + }, + ], + "visibility": "", + "visibilitySet": null, + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [ + Error { + "expected": undefined, + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected '(' on line 1", + "token": "'('", + }, + Error { + "expected": [ + 198, + 222, + 182, + ], + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected '(' on line 1", + "token": "'('", + }, + Error { + "expected": 222, + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected ')', expecting T_VARIABLE on line 1", + "token": "')'", + }, + Error { + "expected": [ + ",", + ";", + "=", + "{", + ], + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected 'string' (T_STRING) on line 1", + "token": "'string' (T_STRING)", + }, + Error { + "expected": [ + ";", + ",", + ], + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected 'string' (T_STRING) on line 1", + "token": "'string' (T_STRING)", + }, + ], + "kind": "program", +} +`; + +exports[`asymmetric visibility malformed set keyword in property 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + PropertyStatement { + "isAbstract": false, + "isFinal": false, + "isStatic": false, + "kind": "propertystatement", + "properties": [ + Property { + "attrGroups": [], + "hooks": [], + "kind": "property", + "name": Identifier { + "kind": "identifier", + "name": "", + }, + "nullable": false, + "readonly": false, + "type": Name { + "kind": "name", + "name": "foo", + "resolution": "uqn", + }, + "value": null, + }, + ], + "visibility": "public", + "visibilitySet": "private", + }, + PropertyStatement { + "isAbstract": false, + "isFinal": false, + "isStatic": false, + "kind": "propertystatement", + "properties": [ + Property { + "attrGroups": [], + "hooks": [], + "kind": "property", + "name": Identifier { + "kind": "identifier", + "name": "name", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "string", + "raw": "string", + }, + "value": null, + }, + ], + "visibility": "", + "visibilitySet": null, + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [ + Error { + "expected": "set", + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected 'foo' (T_STRING) on line 1", + "token": "'foo' (T_STRING)", + }, + Error { + "expected": ")", + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected 'foo' (T_STRING), expecting ')' on line 1", + "token": "'foo' (T_STRING)", + }, + Error { + "expected": 222, + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected ')', expecting T_VARIABLE on line 1", + "token": "')'", + }, + Error { + "expected": [ + ",", + ";", + "=", + "{", + ], + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected 'string' (T_STRING) on line 1", + "token": "'string' (T_STRING)", + }, + Error { + "expected": [ + ";", + ",", + ], + "kind": "error", + "line": 1, + "message": "Parse Error : syntax error, unexpected 'string' (T_STRING) on line 1", + "token": "'string' (T_STRING)", + }, + ], + "kind": "program", +} +`; + +exports[`asymmetric visibility private(set) shorthand 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + PropertyStatement { + "isAbstract": false, + "isFinal": false, + "isStatic": false, + "kind": "propertystatement", + "properties": [ + Property { + "attrGroups": [], + "hooks": [], + "kind": "property", + "name": Identifier { + "kind": "identifier", + "name": "label", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "string", + "raw": "string", + }, + "value": null, + }, + ], + "visibility": "", + "visibilitySet": "private", + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [], + "kind": "program", +} +`; + +exports[`asymmetric visibility protected private(set) 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + PropertyStatement { + "isAbstract": false, + "isFinal": false, + "isStatic": false, + "kind": "propertystatement", + "properties": [ + Property { + "attrGroups": [], + "hooks": [], + "kind": "property", + "name": Identifier { + "kind": "identifier", + "name": "count", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "int", + "raw": "int", + }, + "value": null, + }, + ], + "visibility": "protected", + "visibilitySet": "private", + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [], + "kind": "program", +} +`; + +exports[`asymmetric visibility protected(set) shorthand 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + PropertyStatement { + "isAbstract": false, + "isFinal": false, + "isStatic": false, + "kind": "propertystatement", + "properties": [ + Property { + "attrGroups": [], + "hooks": [], + "kind": "property", + "name": Identifier { + "kind": "identifier", + "name": "value", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "int", + "raw": "int", + }, + "value": null, + }, + ], + "visibility": "", + "visibilitySet": "protected", + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [], + "kind": "program", +} +`; + +exports[`asymmetric visibility public private(set) 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + PropertyStatement { + "isAbstract": false, + "isFinal": false, + "isStatic": false, + "kind": "propertystatement", + "properties": [ + Property { + "attrGroups": [], + "hooks": [], + "kind": "property", + "name": Identifier { + "kind": "identifier", + "name": "name", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "string", + "raw": "string", + }, + "value": null, + }, + ], + "visibility": "public", + "visibilitySet": "private", + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [], + "kind": "program", +} +`; + +exports[`asymmetric visibility public protected(set) 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + PropertyStatement { + "isAbstract": false, + "isFinal": false, + "isStatic": false, + "kind": "propertystatement", + "properties": [ + Property { + "attrGroups": [], + "hooks": [], + "kind": "property", + "name": Identifier { + "kind": "identifier", + "name": "url", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "string", + "raw": "string", + }, + "value": null, + }, + ], + "visibility": "public", + "visibilitySet": "protected", + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [], + "kind": "program", +} +`; + +exports[`asymmetric visibility public static private(set) 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + PropertyStatement { + "isAbstract": false, + "isFinal": false, + "isStatic": true, + "kind": "propertystatement", + "properties": [ + Property { + "attrGroups": [], + "hooks": [], + "kind": "property", + "name": Identifier { + "kind": "identifier", + "name": "name", + }, + "nullable": false, + "readonly": false, + "type": TypeReference { + "kind": "typereference", + "name": "string", + "raw": "string", + }, + "value": null, + }, + ], + "visibility": "public", + "visibilitySet": "private", + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "Foo", + }, + }, + ], + "errors": [], + "kind": "program", +} +`; diff --git a/test/snapshot/__snapshots__/attributes.test.js.snap b/test/snapshot/__snapshots__/attributes.test.js.snap index a109100ae..74f1d1968 100644 --- a/test/snapshot/__snapshots__/attributes.test.js.snap +++ b/test/snapshot/__snapshots__/attributes.test.js.snap @@ -400,6 +400,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, PropertyStatement { "isAbstract": false, @@ -437,6 +438,7 @@ Program { }, ], "visibility": "private", + "visibilitySet": null, }, PropertyStatement { "isAbstract": false, @@ -470,6 +472,7 @@ Program { }, ], "visibility": "protected", + "visibilitySet": null, }, ], "extends": null, @@ -688,6 +691,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -740,6 +744,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, ], "extends": null, @@ -835,6 +840,7 @@ Program { ], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1169,6 +1175,7 @@ Program { ], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -2566,6 +2573,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, Method { "arguments": [], @@ -2587,6 +2595,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, Method { "arguments": [], @@ -2608,6 +2617,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, ], "extends": null, @@ -2662,6 +2672,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, ], "extends": null, @@ -2835,6 +2846,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, diff --git a/test/snapshot/__snapshots__/block.test.js.snap b/test/snapshot/__snapshots__/block.test.js.snap index d1cf5abb3..801c54305 100644 --- a/test/snapshot/__snapshots__/block.test.js.snap +++ b/test/snapshot/__snapshots__/block.test.js.snap @@ -686,6 +686,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, ], "extends": null, diff --git a/test/snapshot/__snapshots__/byref.test.js.snap b/test/snapshot/__snapshots__/byref.test.js.snap index 021d20738..183851a2f 100644 --- a/test/snapshot/__snapshots__/byref.test.js.snap +++ b/test/snapshot/__snapshots__/byref.test.js.snap @@ -408,6 +408,7 @@ Program { "attrGroups": [], "byref": true, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1117,6 +1118,7 @@ Program { "attrGroups": [], "byref": true, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { diff --git a/test/snapshot/__snapshots__/call.test.js.snap b/test/snapshot/__snapshots__/call.test.js.snap index 47e1dc359..4945a5cd3 100644 --- a/test/snapshot/__snapshots__/call.test.js.snap +++ b/test/snapshot/__snapshots__/call.test.js.snap @@ -1386,6 +1386,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, ], "extends": null, @@ -1514,6 +1515,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, ], "extends": null, @@ -1627,6 +1629,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, ], "extends": null, diff --git a/test/snapshot/__snapshots__/class.test.js.snap b/test/snapshot/__snapshots__/class.test.js.snap index 3323fbbca..7282ecd4a 100644 --- a/test/snapshot/__snapshots__/class.test.js.snap +++ b/test/snapshot/__snapshots__/class.test.js.snap @@ -145,6 +145,7 @@ Program { }, ], "visibility": null, + "visibilitySet": null, }, Method { "arguments": [], @@ -166,6 +167,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, Method { "arguments": [], @@ -187,6 +189,7 @@ Program { "nullable": false, "type": null, "visibility": "private", + "visibilitySet": null, }, ], "extends": null, @@ -263,6 +266,7 @@ Program { "nullable": false, "type": null, "visibility": "protected", + "visibilitySet": null, }, ], "extends": [ @@ -327,6 +331,7 @@ Program { "nullable": false, "type": null, "visibility": "protected", + "visibilitySet": null, }, ], "kind": "trait", @@ -498,6 +503,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -549,6 +555,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -600,6 +607,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -654,6 +662,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, PropertyStatement { "isAbstract": false, @@ -691,6 +700,7 @@ Program { }, ], "visibility": "protected", + "visibilitySet": null, }, ], "extends": null, @@ -738,6 +748,7 @@ Program { }, ], "visibility": "", + "visibilitySet": null, }, Method { "arguments": [], @@ -759,6 +770,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, Method { "arguments": [], @@ -827,6 +839,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -970,6 +983,7 @@ Program { "attrGroups": [], "byref": false, "flags": 1, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -990,6 +1004,7 @@ Program { "attrGroups": [], "byref": false, "flags": 4, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1006,6 +1021,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1026,6 +1042,7 @@ Program { "attrGroups": [], "byref": false, "flags": 2, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1061,6 +1078,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1093,6 +1111,7 @@ Program { "attrGroups": [], "byref": false, "flags": 1, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1113,6 +1132,7 @@ Program { "attrGroups": [], "byref": false, "flags": 4, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1148,6 +1168,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1180,6 +1201,7 @@ Program { "attrGroups": [], "byref": false, "flags": 1, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1215,6 +1237,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1238,6 +1261,7 @@ Program { "attrGroups": [], "byref": false, "flags": 1, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1273,6 +1297,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1346,6 +1371,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, Method { "arguments": [ @@ -1353,6 +1379,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1416,6 +1443,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ClassConstant { "attrGroups": [], @@ -1447,6 +1475,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1504,6 +1533,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, PropertyStatement { "isAbstract": false, @@ -1526,6 +1556,7 @@ Program { }, ], "visibility": "protected", + "visibilitySet": null, }, PropertyStatement { "isAbstract": false, @@ -1548,6 +1579,7 @@ Program { }, ], "visibility": "private", + "visibilitySet": null, }, Method { "arguments": [], @@ -1569,6 +1601,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, ], "extends": Name { @@ -1768,6 +1801,7 @@ Program { "resolution": "uqn", }, "visibility": "protected", + "visibilitySet": null, }, ], "extends": null, @@ -1884,6 +1918,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, Method { "arguments": [], @@ -1912,6 +1947,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -2037,6 +2073,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -2213,6 +2250,7 @@ Program { }, ], "visibility": "protected", + "visibilitySet": null, }, ], "extends": null, diff --git a/test/snapshot/__snapshots__/classpropertyhooks.test.js.snap b/test/snapshot/__snapshots__/classpropertyhooks.test.js.snap index 172eebd77..9eff6dedd 100644 --- a/test/snapshot/__snapshots__/classpropertyhooks.test.js.snap +++ b/test/snapshot/__snapshots__/classpropertyhooks.test.js.snap @@ -50,6 +50,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -111,6 +112,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -172,6 +174,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -247,6 +250,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -343,6 +347,7 @@ Program { ], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -377,6 +382,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -462,6 +468,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -513,6 +520,7 @@ Program { }, ], "visibility": "private", + "visibilitySet": null, }, PropertyStatement { "isAbstract": false, @@ -607,6 +615,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -639,6 +648,7 @@ Program { "attrGroups": [], "byref": false, "flags": 1, + "flagsSet": 0, "hooks": [ PropertyHook { "attrGroups": [], @@ -698,6 +708,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -730,6 +741,7 @@ Program { "attrGroups": [], "byref": false, "flags": 1, + "flagsSet": 0, "hooks": [ PropertyHook { "attrGroups": [], @@ -813,6 +825,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -845,6 +858,7 @@ Program { "attrGroups": [], "byref": false, "flags": 1, + "flagsSet": 0, "hooks": [ PropertyHook { "attrGroups": [], @@ -934,6 +948,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -966,6 +981,7 @@ Program { "attrGroups": [], "byref": false, "flags": 1, + "flagsSet": 0, "hooks": [ PropertyHook { "attrGroups": [], @@ -1032,6 +1048,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1064,6 +1081,7 @@ Program { "attrGroups": [], "byref": false, "flags": 1, + "flagsSet": 0, "hooks": [ PropertyHook { "attrGroups": [ @@ -1134,6 +1152,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1166,6 +1185,7 @@ Program { "attrGroups": [], "byref": false, "flags": 1, + "flagsSet": 0, "hooks": [ PropertyHook { "attrGroups": [], @@ -1231,6 +1251,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1263,6 +1284,7 @@ Program { "attrGroups": [], "byref": false, "flags": 1, + "flagsSet": 0, "hooks": [ PropertyHook { "attrGroups": [], @@ -1322,6 +1344,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1386,6 +1409,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1534,6 +1558,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1585,6 +1610,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, PropertyStatement { "isAbstract": false, @@ -1635,6 +1661,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1707,6 +1734,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1790,6 +1818,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1881,6 +1910,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1945,6 +1975,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -2032,6 +2063,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -2135,6 +2167,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -2189,6 +2222,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -2232,6 +2266,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -2308,6 +2343,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -2418,6 +2454,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -2492,6 +2529,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -2526,6 +2564,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -2641,6 +2680,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -2675,6 +2715,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -2790,6 +2831,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -2816,6 +2858,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -2946,6 +2989,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -3022,6 +3066,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -3056,6 +3101,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -3132,6 +3178,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -3158,6 +3205,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -3239,6 +3287,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -3317,6 +3366,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -3372,6 +3422,7 @@ Program { }, ], "visibility": "private", + "visibilitySet": null, }, PropertyStatement { "isAbstract": false, @@ -3509,6 +3560,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -3549,6 +3601,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -3604,6 +3657,7 @@ Program { }, ], "visibility": "private", + "visibilitySet": null, }, PropertyStatement { "isAbstract": false, @@ -3762,6 +3816,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -3897,6 +3952,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -4006,6 +4062,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -4139,6 +4196,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -4244,6 +4302,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "kind": "trait", @@ -4337,6 +4396,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "kind": "trait", @@ -4417,6 +4477,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -4473,6 +4534,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, diff --git a/test/snapshot/__snapshots__/classreference.test.js.snap b/test/snapshot/__snapshots__/classreference.test.js.snap index 7e0fb26ab..f8c9c7a33 100644 --- a/test/snapshot/__snapshots__/classreference.test.js.snap +++ b/test/snapshot/__snapshots__/classreference.test.js.snap @@ -9,6 +9,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -55,6 +56,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { diff --git a/test/snapshot/__snapshots__/closure.test.js.snap b/test/snapshot/__snapshots__/closure.test.js.snap index e8dd0c29c..777fd5495 100644 --- a/test/snapshot/__snapshots__/closure.test.js.snap +++ b/test/snapshot/__snapshots__/closure.test.js.snap @@ -18,6 +18,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -84,6 +85,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -156,6 +158,7 @@ Program { "attrGroups": [], "byref": true, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -222,6 +225,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -238,6 +242,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -254,6 +259,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -320,6 +326,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -336,6 +343,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -352,6 +360,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -463,6 +472,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { diff --git a/test/snapshot/__snapshots__/comment.test.js.snap b/test/snapshot/__snapshots__/comment.test.js.snap index 9f7b87427..acce39d40 100644 --- a/test/snapshot/__snapshots__/comment.test.js.snap +++ b/test/snapshot/__snapshots__/comment.test.js.snap @@ -765,6 +765,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, Method { "arguments": [], @@ -804,6 +805,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, Method { "arguments": [], @@ -851,6 +853,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1224,6 +1227,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "leadingComments": [ @@ -1957,6 +1961,7 @@ Program { }, ], "visibility": "protected", + "visibilitySet": null, }, PropertyStatement { "isAbstract": false, @@ -1995,6 +2000,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, Method { "arguments": [], @@ -2030,6 +2036,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, diff --git a/test/snapshot/__snapshots__/enum.test.js.snap b/test/snapshot/__snapshots__/enum.test.js.snap index 743249359..833b057fa 100644 --- a/test/snapshot/__snapshots__/enum.test.js.snap +++ b/test/snapshot/__snapshots__/enum.test.js.snap @@ -166,6 +166,7 @@ Program { "raw": "void", }, "visibility": "public", + "visibilitySet": null, }, Method { "arguments": [], @@ -212,6 +213,7 @@ Program { "nullable": false, "type": null, "visibility": "protected", + "visibilitySet": null, }, ], "implements": null, @@ -378,6 +380,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, ], "extends": null, diff --git a/test/snapshot/__snapshots__/function.test.js.snap b/test/snapshot/__snapshots__/function.test.js.snap index 3763aeb1d..8d7df2646 100644 --- a/test/snapshot/__snapshots__/function.test.js.snap +++ b/test/snapshot/__snapshots__/function.test.js.snap @@ -9,6 +9,7 @@ Program { "attrGroups": [], "byref": false, "flags": 1, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": null, @@ -128,6 +129,7 @@ Program { "attrGroups": [], "byref": true, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -354,6 +356,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -377,6 +380,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -400,6 +404,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -423,6 +428,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -443,6 +449,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -463,6 +470,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -483,6 +491,7 @@ Program { "attrGroups": [], "byref": true, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -533,6 +542,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "leadingComments": [ @@ -589,6 +599,7 @@ Program { "attrGroups": [], "byref": true, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -756,6 +767,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -772,6 +784,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -869,6 +882,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -885,6 +899,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -901,6 +916,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -997,6 +1013,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1031,6 +1048,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1103,6 +1121,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1122,6 +1141,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1142,6 +1162,7 @@ Program { "attrGroups": [], "byref": true, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1192,6 +1213,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1341,6 +1363,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1375,6 +1398,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1481,6 +1505,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1515,6 +1540,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1590,6 +1616,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1624,6 +1651,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { diff --git a/test/snapshot/__snapshots__/graceful.test.js.snap b/test/snapshot/__snapshots__/graceful.test.js.snap index f4046ca38..57186bb59 100644 --- a/test/snapshot/__snapshots__/graceful.test.js.snap +++ b/test/snapshot/__snapshots__/graceful.test.js.snap @@ -307,6 +307,7 @@ Program { }, ], "visibility": "", + "visibilitySet": null, }, ], "extends": null, @@ -592,6 +593,7 @@ Program { }, ], "visibility": "", + "visibilitySet": null, }, PropertyStatement { "isAbstract": false, @@ -617,6 +619,7 @@ Program { }, ], "visibility": "", + "visibilitySet": null, }, ], "extends": null, @@ -777,6 +780,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, ], "extends": null, @@ -842,6 +846,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, ], "kind": "trait", @@ -901,6 +906,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, ], "extends": null, @@ -1164,6 +1170,7 @@ Program { }, ], "visibility": "", + "visibilitySet": null, }, PropertyStatement { "isAbstract": false, @@ -1190,6 +1197,7 @@ Program { }, ], "visibility": "", + "visibilitySet": null, }, ], "kind": "trait", diff --git a/test/snapshot/__snapshots__/heredoc.test.js.snap b/test/snapshot/__snapshots__/heredoc.test.js.snap index 8cc622953..c95fcc93a 100644 --- a/test/snapshot/__snapshots__/heredoc.test.js.snap +++ b/test/snapshot/__snapshots__/heredoc.test.js.snap @@ -1812,6 +1812,7 @@ FOOBAR", }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, diff --git a/test/snapshot/__snapshots__/interface.test.js.snap b/test/snapshot/__snapshots__/interface.test.js.snap index f9d745519..2d66c3b88 100644 --- a/test/snapshot/__snapshots__/interface.test.js.snap +++ b/test/snapshot/__snapshots__/interface.test.js.snap @@ -176,6 +176,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -232,6 +233,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -288,6 +290,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, diff --git a/test/snapshot/__snapshots__/location.test.js.snap b/test/snapshot/__snapshots__/location.test.js.snap index cdd6fdd3d..9a88e404c 100644 --- a/test/snapshot/__snapshots__/location.test.js.snap +++ b/test/snapshot/__snapshots__/location.test.js.snap @@ -5328,6 +5328,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "loc": Location { @@ -10018,6 +10019,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -10142,6 +10144,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, ], "extends": null, @@ -11452,6 +11455,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "loc": Location { @@ -11675,6 +11679,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "loc": Location { @@ -15554,6 +15559,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "loc": Location { diff --git a/test/snapshot/__snapshots__/namespace.test.js.snap b/test/snapshot/__snapshots__/namespace.test.js.snap index cb9cedb36..35c67b865 100644 --- a/test/snapshot/__snapshots__/namespace.test.js.snap +++ b/test/snapshot/__snapshots__/namespace.test.js.snap @@ -318,6 +318,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, Method { "arguments": [], @@ -413,6 +414,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, Method { "arguments": [], @@ -576,6 +578,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": Name { @@ -858,6 +861,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, Method { "arguments": [], @@ -953,6 +957,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, Method { "arguments": [], @@ -1116,6 +1121,7 @@ Program { "nullable": false, "type": null, "visibility": "public", + "visibilitySet": null, }, ], "extends": Name { diff --git a/test/snapshot/__snapshots__/nowdoc.test.js.snap b/test/snapshot/__snapshots__/nowdoc.test.js.snap index c6db798a6..8e8812076 100644 --- a/test/snapshot/__snapshots__/nowdoc.test.js.snap +++ b/test/snapshot/__snapshots__/nowdoc.test.js.snap @@ -348,6 +348,7 @@ FOOBAR", }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, diff --git a/test/snapshot/__snapshots__/parentreference.test.js.snap b/test/snapshot/__snapshots__/parentreference.test.js.snap index 342456f46..10bd4cf5c 100644 --- a/test/snapshot/__snapshots__/parentreference.test.js.snap +++ b/test/snapshot/__snapshots__/parentreference.test.js.snap @@ -9,6 +9,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -54,6 +55,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -149,6 +151,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -194,6 +197,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { diff --git a/test/snapshot/__snapshots__/php5.test.js.snap b/test/snapshot/__snapshots__/php5.test.js.snap index 44ddc98bb..2f42f4f7d 100644 --- a/test/snapshot/__snapshots__/php5.test.js.snap +++ b/test/snapshot/__snapshots__/php5.test.js.snap @@ -12,6 +12,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": null, @@ -37,6 +38,7 @@ Program { "nullable": false, "type": null, "visibility": "", + "visibilitySet": null, }, ], "extends": null, diff --git a/test/snapshot/__snapshots__/php73.test.js.snap b/test/snapshot/__snapshots__/php73.test.js.snap index 7036b6693..414dc6ac4 100644 --- a/test/snapshot/__snapshots__/php73.test.js.snap +++ b/test/snapshot/__snapshots__/php73.test.js.snap @@ -311,6 +311,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -327,6 +328,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -343,6 +345,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": null, diff --git a/test/snapshot/__snapshots__/pipe.test.js.snap b/test/snapshot/__snapshots__/pipe.test.js.snap index 23be543a8..6d83801b2 100644 --- a/test/snapshot/__snapshots__/pipe.test.js.snap +++ b/test/snapshot/__snapshots__/pipe.test.js.snap @@ -27,6 +27,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { diff --git a/test/snapshot/__snapshots__/property.test.js.snap b/test/snapshot/__snapshots__/property.test.js.snap index 8a3b46a45..cb8130a7e 100644 --- a/test/snapshot/__snapshots__/property.test.js.snap +++ b/test/snapshot/__snapshots__/property.test.js.snap @@ -27,6 +27,7 @@ Program { }, ], "visibility": "private", + "visibilitySet": null, }, ], "extends": null, @@ -77,6 +78,7 @@ Program { }, ], "visibility": "private", + "visibilitySet": null, }, ], "extends": null, @@ -124,6 +126,7 @@ Program { }, ], "visibility": "protected", + "visibilitySet": null, }, ], "extends": null, @@ -174,6 +177,7 @@ Program { }, ], "visibility": "protected", + "visibilitySet": null, }, ], "extends": null, @@ -221,6 +225,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -268,6 +273,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -318,6 +324,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -368,6 +375,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -415,6 +423,7 @@ Program { }, ], "visibility": null, + "visibilitySet": null, }, ], "extends": null, @@ -465,6 +474,7 @@ Program { }, ], "visibility": null, + "visibilitySet": null, }, ], "extends": null, @@ -539,6 +549,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -603,6 +614,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -661,6 +673,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -712,6 +725,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -763,6 +777,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -816,6 +831,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -885,6 +901,7 @@ EOD", }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -939,6 +956,7 @@ EOD", }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1013,6 +1031,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1066,6 +1085,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1116,6 +1136,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -1163,6 +1184,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, diff --git a/test/snapshot/__snapshots__/propertystatement.test.js.snap b/test/snapshot/__snapshots__/propertystatement.test.js.snap index 203f19268..abc37bef5 100644 --- a/test/snapshot/__snapshots__/propertystatement.test.js.snap +++ b/test/snapshot/__snapshots__/propertystatement.test.js.snap @@ -53,6 +53,7 @@ Program { }, ], "visibility": null, + "visibilitySet": null, }, ], "extends": null, @@ -126,6 +127,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, @@ -173,6 +175,7 @@ Program { }, ], "visibility": null, + "visibilitySet": null, }, ], "extends": null, @@ -220,6 +223,7 @@ Program { }, ], "visibility": "public", + "visibilitySet": null, }, ], "extends": null, diff --git a/test/snapshot/__snapshots__/scalar.test.js.snap b/test/snapshot/__snapshots__/scalar.test.js.snap index ddd66eb46..57d79eebd 100644 --- a/test/snapshot/__snapshots__/scalar.test.js.snap +++ b/test/snapshot/__snapshots__/scalar.test.js.snap @@ -291,6 +291,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { diff --git a/test/snapshot/__snapshots__/selfreference.test.js.snap b/test/snapshot/__snapshots__/selfreference.test.js.snap index 6193afb73..427af2b64 100644 --- a/test/snapshot/__snapshots__/selfreference.test.js.snap +++ b/test/snapshot/__snapshots__/selfreference.test.js.snap @@ -9,6 +9,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -54,6 +55,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -149,6 +151,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -195,6 +198,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -240,6 +244,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { diff --git a/test/snapshot/__snapshots__/trait.test.js.snap b/test/snapshot/__snapshots__/trait.test.js.snap index 6418e11d2..b487c539f 100644 --- a/test/snapshot/__snapshots__/trait.test.js.snap +++ b/test/snapshot/__snapshots__/trait.test.js.snap @@ -52,6 +52,60 @@ Program { } `; +exports[`trait trait alias with visibility 1`] = ` +Program { + "children": [ + Class { + "attrGroups": [], + "body": [ + TraitUse { + "adaptations": [ + TraitAlias { + "as": Identifier { + "kind": "identifier", + "name": "bar", + }, + "kind": "traitalias", + "method": "foo", + "trait": null, + "visibility": "public", + }, + TraitAlias { + "as": null, + "kind": "traitalias", + "method": "foo", + "trait": null, + "visibility": "protected", + }, + ], + "kind": "traituse", + "traits": [ + Name { + "kind": "name", + "name": "B", + "resolution": "uqn", + }, + ], + }, + ], + "extends": null, + "implements": null, + "isAbstract": false, + "isAnonymous": false, + "isFinal": false, + "isReadonly": false, + "kind": "class", + "name": Identifier { + "kind": "identifier", + "name": "A", + }, + }, + ], + "errors": [], + "kind": "program", +} +`; + exports[`trait trait name as identifier 1`] = ` Program { "children": [ diff --git a/test/snapshot/__snapshots__/typereference.test.js.snap b/test/snapshot/__snapshots__/typereference.test.js.snap index 0fd4eb576..8a17f5d39 100644 --- a/test/snapshot/__snapshots__/typereference.test.js.snap +++ b/test/snapshot/__snapshots__/typereference.test.js.snap @@ -9,6 +9,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -55,6 +56,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -101,6 +103,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -147,6 +150,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -193,6 +197,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -239,6 +244,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -285,6 +291,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -331,6 +338,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -377,6 +385,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -423,6 +432,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -469,6 +479,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -515,6 +526,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -561,6 +573,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -607,6 +620,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -653,6 +667,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -699,6 +714,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -745,6 +761,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -791,6 +808,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -837,6 +855,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -883,6 +902,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -929,6 +949,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -975,6 +996,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1021,6 +1043,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1067,6 +1090,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1113,6 +1137,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1159,6 +1184,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1205,6 +1231,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1251,6 +1278,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1297,6 +1325,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1343,6 +1372,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1389,6 +1419,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1435,6 +1466,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1481,6 +1513,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1527,6 +1560,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1573,6 +1607,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1619,6 +1654,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1665,6 +1701,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1711,6 +1748,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1757,6 +1795,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1803,6 +1842,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1849,6 +1889,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1895,6 +1936,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1941,6 +1983,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -1987,6 +2030,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -2033,6 +2077,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -2079,6 +2124,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -2125,6 +2171,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -2171,6 +2218,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -2217,6 +2265,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { diff --git a/test/snapshot/__snapshots__/union.test.js.snap b/test/snapshot/__snapshots__/union.test.js.snap index ef50c0940..57fe3442c 100644 --- a/test/snapshot/__snapshots__/union.test.js.snap +++ b/test/snapshot/__snapshots__/union.test.js.snap @@ -9,6 +9,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": null, @@ -147,6 +148,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -226,6 +228,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -294,6 +297,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -413,6 +417,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -483,6 +488,7 @@ Program { "attrGroups": [], "byref": true, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -540,6 +546,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -602,6 +609,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -659,6 +667,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -716,6 +725,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -773,6 +783,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -843,6 +854,7 @@ Program { "attrGroups": [], "byref": true, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -900,6 +912,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { @@ -962,6 +975,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": Identifier { diff --git a/test/snapshot/__snapshots__/useitem.test.js.snap b/test/snapshot/__snapshots__/useitem.test.js.snap index f24a58cbe..2a4e7b6ef 100644 --- a/test/snapshot/__snapshots__/useitem.test.js.snap +++ b/test/snapshot/__snapshots__/useitem.test.js.snap @@ -215,6 +215,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": null, @@ -228,6 +229,7 @@ Program { "attrGroups": [], "byref": false, "flags": 0, + "flagsSet": 0, "hooks": [], "kind": "parameter", "name": null, diff --git a/test/snapshot/asymmetric-visibility.test.js b/test/snapshot/asymmetric-visibility.test.js new file mode 100644 index 000000000..83c5d7c08 --- /dev/null +++ b/test/snapshot/asymmetric-visibility.test.js @@ -0,0 +1,144 @@ +const parser = require("../main"); + +const opts = { parser: { version: 804 } }; + +describe("asymmetric visibility", () => { + it("public private(set)", () => { + expect( + parser.parseEval("class Foo { public private(set) string $name; }", opts), + ).toMatchSnapshot(); + }); + it("public protected(set)", () => { + expect( + parser.parseEval( + "class Foo { public protected(set) string $url; }", + opts, + ), + ).toMatchSnapshot(); + }); + it("protected private(set)", () => { + expect( + parser.parseEval( + "class Foo { protected private(set) int $count; }", + opts, + ), + ).toMatchSnapshot(); + }); + it("private(set) shorthand", () => { + expect( + parser.parseEval("class Foo { private(set) string $label; }", opts), + ).toMatchSnapshot(); + }); + it("protected(set) shorthand", () => { + expect( + parser.parseEval("class Foo { protected(set) int $value; }", opts), + ).toMatchSnapshot(); + }); + it("public static private(set)", () => { + expect( + parser.parseEval( + "class Foo { public static private(set) string $name; }", + opts, + ), + ).toMatchSnapshot(); + }); + it("constructor promotion public private(set)", () => { + expect( + parser.parseEval( + "class Foo { public function __construct(public private(set) string $name) {} }", + opts, + ), + ).toMatchSnapshot(); + }); + it("constructor promotion private(set) shorthand", () => { + expect( + parser.parseEval( + "class Foo { public function __construct(private(set) string $name) {} }", + opts, + ), + ).toMatchSnapshot(); + }); + it("constructor promotion protected(set) shorthand", () => { + expect( + parser.parseEval( + "class Foo { public function __construct(protected(set) int $count) {} }", + opts, + ), + ).toMatchSnapshot(); + }); + it("constructor promotion public protected(set)", () => { + expect( + parser.parseEval( + "class Foo { public function __construct(public protected(set) string $url) {} }", + opts, + ), + ).toMatchSnapshot(); + }); + it("constructor promotion public public(set)", () => { + expect( + parser.parseEval( + "class Foo { public function __construct(public public(set) string $name) {} }", + opts, + ), + ).toMatchSnapshot(); + }); + it("duplicate set modifier", () => { + expect( + parser.parseEval( + "class Foo { public private(set) protected(set) string $name; }", + { parser: { version: 804, suppressErrors: true } }, + ), + ).toMatchSnapshot(); + }); + it("duplicate visibility", () => { + expect( + parser.parseEval("class Foo { public public string $name; }", { + parser: { version: 804, suppressErrors: true }, + }), + ).toMatchSnapshot(); + }); + it("duplicate static flag", () => { + expect( + parser.parseEval("class Foo { static static string $name; }", { + parser: { version: 804, suppressErrors: true }, + }), + ).toMatchSnapshot(); + }); + it("malformed set keyword in property", () => { + expect( + parser.parseEval("class Foo { public private(foo) string $name; }", { + parser: { version: 804, suppressErrors: true }, + }), + ).toMatchSnapshot(); + }); + it("constructor promotion malformed set keyword shorthand", () => { + expect( + parser.parseEval( + "class Foo { public function __construct(private(foo) string $name) {} }", + { parser: { version: 804, suppressErrors: true } }, + ), + ).toMatchSnapshot(); + }); + it("constructor promotion malformed set keyword explicit", () => { + expect( + parser.parseEval( + "class Foo { public function __construct(public private(foo) string $name) {} }", + { parser: { version: 804, suppressErrors: true } }, + ), + ).toMatchSnapshot(); + }); + it("asymmetric visibility on constant", () => { + expect( + parser.parseEval("class Foo { public private(set) const BAR = 1; }", { + parser: { version: 804, suppressErrors: true }, + }), + ).toMatchSnapshot(); + }); + it("ignored below PHP 8.4", () => { + expect( + parser.parseEval("class Foo { public private(set) string $name; }", { + parser: { version: 803, suppressErrors: true }, + }), + ).toMatchSnapshot(); + }); +}); diff --git a/test/snapshot/trait.test.js b/test/snapshot/trait.test.js index 3713aa415..e0b6ae42f 100644 --- a/test/snapshot/trait.test.js +++ b/test/snapshot/trait.test.js @@ -5,6 +5,14 @@ describe("trait", function () { expect(parser.parseEval("trait A {}")).toMatchSnapshot(); }); + it("trait alias with visibility", function () { + expect( + parser.parseEval( + "class A { use B { foo as public bar; foo as protected; } }", + ), + ).toMatchSnapshot(); + }); + it("trait alias with no visibility and no alias raises an error", function () { const test = parser.create({ parser: { suppressErrors: true } }); expect(test.parseEval("class A { use Foo { foo as; } }")).toMatchSnapshot(); diff --git a/types.d.ts b/types.d.ts index cde731cf0..e6ff6515d 100644 --- a/types.d.ts +++ b/types.d.ts @@ -226,6 +226,7 @@ declare module "php-parser" { */ parseFlags(flags: (number | null)[]): void; name: Identifier | string; + visibilitySet: string | null; } /** * The declare construct is used to set execution directives for a block of code @@ -732,6 +733,7 @@ declare module "php-parser" { attrGroups: AttrGroup[]; flags: MODIFIER_PUBLIC | MODIFIER_PROTECTED | MODIFIER_PRIVATE; hooks: PropertyHook[]; + flagsSet: MODIFIER_PUBLIC | MODIFIER_PROTECTED | MODIFIER_PRIVATE; } /** * Defines a class reference node @@ -810,6 +812,7 @@ declare module "php-parser" { parseFlags(flags: (number | null)[]): void; properties: Property[]; visibility: string | null; + visibilitySet: string | null; isStatic: boolean; isAbstract: boolean; isFinal: boolean;