Skip to content

Commit 16495a2

Browse files
committed
[Removing][CodeQuality] Record change when mutating in place, so skipped-print engine detects it
1 parent 2805d61 commit 16495a2

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎rules/CodeQuality/Rector/Class_/InlineConstructorDefaultToPropertyRector.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ public function refactor(Node $node): ?Node
101101
$hasParentConstructCall = false;
102102

103103
foreach ($constructClassMethod->stmts as $key => $stmt) {
104-
// code that is possibly breaking flow
104+
// code that is possibly breaking flow; keep any inlining already done before it
105105
if ($stmt instanceof If_) {
106-
return null;
106+
break;
107107
}
108108

109109
if (! $stmt instanceof Expression) {

‎rules/Removing/Rector/ClassMethod/ArgumentRemoverRector.php‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,13 @@ private function processPosition(
115115
): void {
116116
if ($argumentRemover->getValue() === null) {
117117
if ($node instanceof MethodCall || $node instanceof StaticCall) {
118-
unset($node->args[$argumentRemover->getPosition()]);
119-
} else {
118+
if (isset($node->args[$argumentRemover->getPosition()])) {
119+
unset($node->args[$argumentRemover->getPosition()]);
120+
$this->hasChanged = true;
121+
}
122+
} elseif (isset($node->params[$argumentRemover->getPosition()])) {
120123
unset($node->params[$argumentRemover->getPosition()]);
124+
$this->hasChanged = true;
121125
}
122126

123127
return;
@@ -149,6 +153,7 @@ private function removeByName(ClassMethod|StaticCall|MethodCall $node, int $posi
149153
if ($node instanceof MethodCall || $node instanceof StaticCall) {
150154
if (isset($node->args[$position]) && $this->isName($node->args[$position], $name)) {
151155
unset($node->args[$position]);
156+
$this->hasChanged = true;
152157
}
153158

154159
return;
@@ -159,6 +164,7 @@ private function removeByName(ClassMethod|StaticCall|MethodCall $node, int $posi
159164
}
160165

161166
unset($node->params[$position]);
167+
$this->hasChanged = true;
162168
}
163169

164170
/**

0 commit comments

Comments
 (0)