@@ -72,13 +72,16 @@ protected function withScopeCheck($modifiers, $nodes) {
7272
7373 protected function emitProperty ($ result , $ property ) {
7474 static $ lookup = [
75- 'public ' => MODIFIER_PUBLIC ,
76- 'protected ' => MODIFIER_PROTECTED ,
77- 'private ' => MODIFIER_PRIVATE ,
78- 'static ' => MODIFIER_STATIC ,
79- 'final ' => MODIFIER_FINAL ,
80- 'abstract ' => MODIFIER_ABSTRACT ,
81- 'readonly ' => MODIFIER_READONLY ,
75+ 'public ' => MODIFIER_PUBLIC ,
76+ 'protected ' => MODIFIER_PROTECTED ,
77+ 'private ' => MODIFIER_PRIVATE ,
78+ 'static ' => MODIFIER_STATIC ,
79+ 'final ' => MODIFIER_FINAL ,
80+ 'abstract ' => MODIFIER_ABSTRACT ,
81+ 'readonly ' => MODIFIER_READONLY ,
82+ 'public(set) ' => 0x1000000 ,
83+ 'protected(set) ' => 0x0000800 ,
84+ 'private(set) ' => 0x0001000 ,
8285 ];
8386
8487 // Emit XP meta information for the reflection API
@@ -88,6 +91,22 @@ protected function emitProperty($result, $property) {
8891 $ modifiers |= $ lookup [$ name ];
8992 }
9093
94+ // Derive modifiers for private(set) and protected(set), folding declarations
95+ // like `[visibility] [visibility](set)` to just the visibility itself.
96+ if ($ modifiers & 0x1000000 ) {
97+ $ check = null ;
98+ $ modifiers &= ~0x1000000 ;
99+ $ write = MODIFIER_PUBLIC ;
100+ } else if ($ modifiers & 0x0000800 ) {
101+ $ modifiers & MODIFIER_PROTECTED && $ modifiers &= ~0x0000800 ;
102+ $ write = MODIFIER_PROTECTED ;
103+ } else if ($ modifiers & 0x0001000 ) {
104+ $ modifiers & MODIFIER_PRIVATE && $ modifiers &= ~0x0001000 ;
105+ $ write = MODIFIER_PRIVATE ;
106+ } else {
107+ $ write = $ modifiers ;
108+ }
109+
91110 $ scope ->meta [self ::PROPERTY ][$ property ->name ]= [
92111 DETAIL_RETURNS => $ property ->type ? $ property ->type ->name () : 'var ' ,
93112 DETAIL_ANNOTATIONS => $ property ->annotations ,
@@ -137,7 +156,7 @@ protected function emitProperty($result, $property) {
137156 )],
138157 null // $hook->annotations
139158 ));
140- $ set = $ this ->withScopeCheck ($ modifiers , [new InvokeExpression (
159+ $ set = $ this ->withScopeCheck ($ write , [new InvokeExpression (
141160 new InstanceExpression (new Variable ('this ' ), new Literal ($ method )),
142161 [new Variable ('value ' )]
143162 )]);
0 commit comments