@@ -72,13 +72,16 @@ protected function withScopeCheck($modifiers, $nodes) {
72
72
73
73
protected function emitProperty ($ result , $ property ) {
74
74
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 ,
82
85
];
83
86
84
87
// Emit XP meta information for the reflection API
@@ -88,6 +91,22 @@ protected function emitProperty($result, $property) {
88
91
$ modifiers |= $ lookup [$ name ];
89
92
}
90
93
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
+
91
110
$ scope ->meta [self ::PROPERTY ][$ property ->name ]= [
92
111
DETAIL_RETURNS => $ property ->type ? $ property ->type ->name () : 'var ' ,
93
112
DETAIL_ANNOTATIONS => $ property ->annotations ,
@@ -137,7 +156,7 @@ protected function emitProperty($result, $property) {
137
156
)],
138
157
null // $hook->annotations
139
158
));
140
- $ set = $ this ->withScopeCheck ($ modifiers , [new InvokeExpression (
159
+ $ set = $ this ->withScopeCheck ($ write , [new InvokeExpression (
141
160
new InstanceExpression (new Variable ('this ' ), new Literal ($ method )),
142
161
[new Variable ('value ' )]
143
162
)]);
0 commit comments