@@ -89,7 +89,7 @@ public function changeNodeVisibility(ClassMethod | Property | ClassConst $node,
89
89
$ this ->replaceVisibilityFlag ($ node , $ visibility );
90
90
}
91
91
92
- public function makePublic (ClassMethod | Property | ClassConst $ node ): void
92
+ public function makePublic (ClassMethod | Property | ClassConst | Param $ node ): void
93
93
{
94
94
$ this ->replaceVisibilityFlag ($ node , Visibility::PUBLIC );
95
95
}
@@ -130,7 +130,15 @@ public function isReadonly(Class_ | Property | Param $node): bool
130
130
131
131
public function removeReadonly (Class_ | Property | Param $ node ): void
132
132
{
133
- $ this ->removeVisibilityFlag ($ node , Visibility::READONLY );
133
+ $ isConstructorPromotionBefore = $ node instanceof Param && $ node ->isPromoted ();
134
+
135
+ $ node ->flags &= ~Modifiers::READONLY ;
136
+
137
+ $ isConstructorPromotionAfter = $ node instanceof Param && $ node ->isPromoted ();
138
+
139
+ if ($ node instanceof Param && $ isConstructorPromotionBefore && ! $ isConstructorPromotionAfter ) {
140
+ $ this ->makePublic ($ node );
141
+ }
134
142
}
135
143
136
144
public function publicize (ClassConst |ClassMethod $ node ): ClassConst |ClassMethod |null
@@ -188,13 +196,6 @@ private function addVisibilityFlag(
188
196
$ node ->flags |= $ visibility ;
189
197
}
190
198
191
- private function removeVisibilityFlag (
192
- Class_ | ClassMethod | Property | ClassConst | Param $ node ,
193
- int $ visibility
194
- ): void {
195
- $ node ->flags &= ~$ visibility ;
196
- }
197
-
198
199
private function replaceVisibilityFlag (ClassMethod | Property | ClassConst | Param $ node , int $ visibility ): void
199
200
{
200
201
$ isStatic = $ node instanceof ClassMethod && $ node ->isStatic ();
0 commit comments