Skip to content

Commit a6202f5

Browse files
authored
[CodeQuality][PHPUnit80] Return node when arg removed in place, so change is recorded (#810)
1 parent 6fa53ef commit a6202f5

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎rules/CodeQuality/Rector/MethodCall/AssertCompareOnCountableWithMethodToAssertCountRector.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ public function refactor(Node $node): MethodCall|StaticCall|null
110110

111111
$node->args = $args;
112112
$this->renameMethod($node);
113+
114+
return $node;
113115
}
114116
}
115117

‎rules/PHPUnit80/Rector/MethodCall/AssertEqualsParameterToSpecificMethodsTypeRector.php‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,19 @@ public function refactor(Node $node): ?Node
117117
return $newMethodCall;
118118
}
119119

120+
$hasChanged = false;
120121
if (isset($node->args[4])) {
121122
// add new node only in case of non-default value
122123
unset($node->args[4]);
124+
$hasChanged = true;
123125
}
124126

125-
return $this->processAssertEqualsWithDelta($node);
127+
$newMethodCall = $this->processAssertEqualsWithDelta($node);
128+
if ($newMethodCall !== null) {
129+
return $newMethodCall;
130+
}
131+
132+
return $hasChanged ? $node : null;
126133
}
127134

128135
/**
@@ -203,7 +210,8 @@ private function processAssertEqualsWithDelta(MethodCall|StaticCall $call): Meth
203210
unset($call->args[3]);
204211

205212
if ($this->valueResolver->isValue($thirdArg->value, 0.0)) {
206-
return null;
213+
// default delta removed in place, no dedicated method needed
214+
return $call;
207215
}
208216

209217
$newMethodCall = $this->assertCallFactory->createCallWithName($call, 'assertEqualsWithDelta');

0 commit comments

Comments
 (0)