@@ -115,6 +115,9 @@ module.exports = {
115115
116116 // check constant
117117 if ( this . token === this . tok . T_CONST ) {
118+ if ( flags [ 0 ] [ 1 ] !== - 1 ) {
119+ this . raiseError ( "Cannot use asymmetric visibility on constants" ) ;
120+ }
118121 const constants = this . read_constant_list ( flags , attrs ) ;
119122 if ( this . expect ( ";" ) ) {
120123 this . next ( ) ;
@@ -126,7 +129,7 @@ module.exports = {
126129 // jump over T_VAR then land on T_VARIABLE
127130 if ( allow_variables && this . token === this . tok . T_VAR ) {
128131 this . next ( ) . expect ( this . tok . T_VARIABLE ) ;
129- flags [ 0 ] = null ; // public (as null)
132+ flags [ 0 ] [ 0 ] = null ; // public (as null)
130133 flags [ 1 ] = 0 ; // non static var
131134 }
132135
@@ -388,14 +391,14 @@ module.exports = {
388391 /*
389392 * Read member flags
390393 * @return array
391- * 1st index : -1 => no visibility, 0 => public, 1 => protected, 2 => private
394+ * 1st index : [get, set] visibility tuple
395+ * get/set: -1 => no visibility, 0 => public, 1 => protected, 2 => private
392396 * 2nd index : 0 => instance member, 1 => static member
393397 * 3rd index : 0 => normal, 1 => abstract member, 2 => final member
394398 * 4th index : 0 => no readonly, 1 => readonly
395- * 5th index : -1 => no set modifier, 0 => public(set), 1 => protected(set), 2 => private(set)
396399 */
397400 read_member_flags ( asInterface ) {
398- const result = [ - 1 , 0 , 0 , 0 , - 1 ] ;
401+ const result = [ [ - 1 , - 1 ] , 0 , 0 , 0 ] ;
399402 const seen = new Set ( ) ;
400403 while ( this . is ( "T_MEMBER_FLAGS" ) ) {
401404 let idx = - 1 ,
@@ -428,19 +431,19 @@ module.exports = {
428431 if ( this . expect ( ")" ) ) {
429432 this . next ( ) ; // consume ')'
430433 }
431- if ( seen . has ( 4 ) ) {
434+ if ( seen . has ( "set" ) ) {
432435 this . error ( ) ; // set modifier already defined
433436 } else if ( val !== - 1 ) {
434- seen . add ( 4 ) ;
435- result [ 4 ] = val ;
437+ seen . add ( "set" ) ;
438+ result [ 0 ] [ 1 ] = val ;
436439 }
437440 continue ;
438441 }
439442 if ( seen . has ( idx ) ) {
440443 this . error ( ) ;
441444 } else if ( val !== - 1 ) {
442445 seen . add ( idx ) ;
443- result [ idx ] = val ;
446+ result [ 0 ] [ 0 ] = val ;
444447 }
445448 continue ;
446449 }
@@ -606,6 +609,9 @@ module.exports = {
606609
607610 // check constant
608611 if ( this . token === this . tok . T_CONST ) {
612+ if ( flags [ 0 ] [ 1 ] !== - 1 ) {
613+ this . raiseError ( "Cannot use asymmetric visibility on constants" ) ;
614+ }
609615 const constants = this . read_constant_list ( flags , attrs ) ;
610616 if ( this . expect ( ";" ) ) {
611617 this . next ( ) ;
0 commit comments