WillReturnCallbackFallbackToReturnFalseRector
Add a "return false" fallback to a willReturnCallback() closure that only returns booleans, but can fall through without a return
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
public function test()
{
$matcher = $this->exactly(2);
$this->eventMock->expects($matcher)
->method('checkContext')
->willReturnCallback(function (...$parameters) use ($matcher) {
if ($matcher->numberOfInvocations() === 1) {
return true;
}
if ($matcher->numberOfInvocations() === 2) {
return false;
}
+
+ return false;
});
}
}
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\WillReturnCallbackFallbackToReturnFalseRector;
return RectorConfig::configure()
->withRules([
WillReturnCallbackFallbackToReturnFalseRector::class,
]);