Replace PHPUnit method `withConsecutive` (abandoned in PHPUnit 10)

As method withConsecutive will be deleted in PHPUnit 10 (in 9.6 it's deprecated) I need to replace all of occurrences of this method to new code.

Try to find some solutions and didn't find any of reasonable solution.

For example, I have a code

            [$personFirst, $employeeFirst],
            [$personSecond, $employeeSecond],
        ->willReturnOnConsecutiveCalls($personDTO, $personSecondDTO);

To which code should I replace withConsecutive ?

P.S. Documentation on official site still shows how use withConsecutive


  • I have replaced withConsecutive with the following.

    $matcher = $this->exactly(2);
        ->willReturnCallback(function (string $key, string $value) use ($matcher,$expected1, $expected2) {
            match ($matcher->numberOfInvocations()) {
                1 =>  $this->assertEquals($expected1, $value),
                2 =>  $this->assertEquals($expected2, $value),