@@ -114,6 +114,9 @@ module.exports = {
114114
115115 // check constant
116116 if ( this . token === this . tok . T_CONST ) {
117+ if ( flags [ 0 ] [ 1 ] !== - 1 ) {
118+ this . raiseError ( "Cannot use asymmetric visibility on constants" ) ;
119+ }
117120 const constants = this . read_constant_list ( flags , attrs ) ;
118121 if ( this . expect ( ";" ) ) {
119122 this . next ( ) ;
@@ -125,7 +128,7 @@ module.exports = {
125128 // jump over T_VAR then land on T_VARIABLE
126129 if ( allow_variables && this . token === this . tok . T_VAR ) {
127130 this . next ( ) . expect ( this . tok . T_VARIABLE ) ;
128- flags [ 0 ] = null ; // public (as null)
131+ flags [ 0 ] [ 0 ] = null ; // public (as null)
129132 flags [ 1 ] = 0 ; // non static var
130133 }
131134
@@ -267,14 +270,14 @@ module.exports = {
267270 /*
268271 * Read member flags
269272 * @return array
270- * 1st index : -1 => no visibility, 0 => public, 1 => protected, 2 => private
273+ * 1st index : [get, set] visibility tuple
274+ * get/set: -1 => no visibility, 0 => public, 1 => protected, 2 => private
271275 * 2nd index : 0 => instance member, 1 => static member
272276 * 3rd index : 0 => normal, 1 => abstract member, 2 => final member
273277 * 4th index : 0 => no readonly, 1 => readonly
274- * 5th index : -1 => no set modifier, 0 => public(set), 1 => protected(set), 2 => private(set)
275278 */
276279 read_member_flags ( asInterface ) {
277- const result = [ - 1 , 0 , 0 , 0 , - 1 ] ;
280+ const result = [ [ - 1 , - 1 ] , 0 , 0 , 0 ] ;
278281 const seen = new Set ( ) ;
279282 while ( this . is ( "T_MEMBER_FLAGS" ) ) {
280283 let idx = - 1 ,
@@ -307,19 +310,19 @@ module.exports = {
307310 if ( this . expect ( ")" ) ) {
308311 this . next ( ) ; // consume ')'
309312 }
310- if ( seen . has ( 4 ) ) {
313+ if ( seen . has ( "set" ) ) {
311314 this . error ( ) ; // set modifier already defined
312315 } else if ( val !== - 1 ) {
313- seen . add ( 4 ) ;
314- result [ 4 ] = val ;
316+ seen . add ( "set" ) ;
317+ result [ 0 ] [ 1 ] = val ;
315318 }
316319 continue ;
317320 }
318321 if ( seen . has ( idx ) ) {
319322 this . error ( ) ;
320323 } else if ( val !== - 1 ) {
321324 seen . add ( idx ) ;
322- result [ idx ] = val ;
325+ result [ 0 ] [ 0 ] = val ;
323326 }
324327 continue ;
325328 }
@@ -482,6 +485,9 @@ module.exports = {
482485
483486 // check constant
484487 if ( this . token === this . tok . T_CONST ) {
488+ if ( flags [ 0 ] [ 1 ] !== - 1 ) {
489+ this . raiseError ( "Cannot use asymmetric visibility on constants" ) ;
490+ }
485491 const constants = this . read_constant_list ( flags , attrs ) ;
486492 if ( this . expect ( ";" ) ) {
487493 this . next ( ) ;
0 commit comments