@@ -81,7 +81,7 @@ public function changeNodeVisibility($node, int $visibility) : void
81
81
$ this ->replaceVisibilityFlag ($ node , $ visibility );
82
82
}
83
83
/**
84
- * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassConst $node
84
+ * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassConst|\PhpParser\Node\Param $node
85
85
*/
86
86
public function makePublic ($ node ) : void
87
87
{
@@ -130,7 +130,12 @@ public function isReadonly($node) : bool
130
130
*/
131
131
public function removeReadonly ($ node ) : void
132
132
{
133
- $ this ->removeVisibilityFlag ($ node , Visibility::READONLY );
133
+ $ isConstructorPromotionBefore = $ node instanceof Param && $ node ->isPromoted ();
134
+ $ node ->flags &= ~Modifiers::READONLY ;
135
+ $ isConstructorPromotionAfter = $ node instanceof Param && $ node ->isPromoted ();
136
+ if ($ node instanceof Param && $ isConstructorPromotionBefore && !$ isConstructorPromotionAfter ) {
137
+ $ this ->makePublic ($ node );
138
+ }
134
139
}
135
140
/**
136
141
* @param \PhpParser\Node\Stmt\ClassConst|\PhpParser\Node\Stmt\ClassMethod $node
@@ -182,13 +187,6 @@ private function addVisibilityFlag($node, int $visibility) : void
182
187
{
183
188
$ node ->flags |= $ visibility ;
184
189
}
185
- /**
186
- * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassConst|\PhpParser\Node\Param $node
187
- */
188
- private function removeVisibilityFlag ($ node , int $ visibility ) : void
189
- {
190
- $ node ->flags &= ~$ visibility ;
191
- }
192
190
/**
193
191
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Stmt\ClassConst|\PhpParser\Node\Param $node
194
192
*/
0 commit comments