diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon
index 4b1e5fd61f468d35fe5473852a5392b6a3e1153e..f4146fda0a79bbbbae870628a0e4599799700728 100644
--- a/core/phpstan-baseline.neon
+++ b/core/phpstan-baseline.neon
@@ -3403,16 +3403,6 @@ parameters:
 			count: 1
 			path: tests/Drupal/Tests/Core/Security/DoTrustedCallbackTraitTest.php
 
-		-
-			message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
-			count: 2
-			path: tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php
-
-		-
-			message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
-			count: 3
-			path: tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php
-
 		-
 			message: "#^Variable \\$value in isset\\(\\) always exists and is not nullable\\.$#"
 			count: 1
diff --git a/core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php b/core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php
index 7825534f6704935b8972d6016883a2a64c393b1e..1a02227339040772f67a01d10048466c9bbe9315 100644
--- a/core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php
+++ b/core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php
@@ -102,13 +102,12 @@ protected function setUp(): void {
    * @covers ::get
    */
   public function testGet() {
-    $this->keyValue->expects($this->exactly(3))
+    $calls = ['1:test_2', '1:test', '1:test'];
+    $this->keyValue->expects($this->exactly(count($calls)))
       ->method('get')
-      ->withConsecutive(
-        ['1:test_2'],
-        ['1:test'],
-        ['1:test'],
-      )
+      ->with($this->callback(function (string $key) use (&$calls): bool {
+        return array_shift($calls) == $key;
+      }))
       ->willReturnOnConsecutiveCalls(
         FALSE,
         $this->ownObject,
@@ -248,13 +247,12 @@ public function testDelete() {
       ->with('1:test_2')
       ->willReturn(TRUE);
 
-    $this->keyValue->expects($this->exactly(3))
+    $calls = ['1:test_1', '1:test_2', '1:test_3'];
+    $this->keyValue->expects($this->exactly(count($calls)))
       ->method('get')
-      ->withConsecutive(
-        ['1:test_1'],
-        ['1:test_2'],
-        ['1:test_3'],
-      )
+      ->with($this->callback(function (string $key) use (&$calls): bool {
+        return array_shift($calls) == $key;
+      }))
       ->willReturnOnConsecutiveCalls(
         FALSE,
         $this->ownObject,
diff --git a/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php b/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php
index 9b39ff79113911744ef9af9086ceaa6a44258223..08579807a1e4a76b31d7f46bc7860074ea8f8437 100644
--- a/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php
+++ b/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php
@@ -101,12 +101,12 @@ protected function setUp(): void {
    * @covers ::get
    */
   public function testGet() {
-    $this->keyValue->expects($this->exactly(2))
+    $calls = ['test_2', 'test'];
+    $this->keyValue->expects($this->exactly(count($calls)))
       ->method('get')
-      ->withConsecutive(
-        ['test_2'],
-        ['test'],
-      )
+      ->with($this->callback(function (string $key) use (&$calls): bool {
+        return array_shift($calls) == $key;
+      }))
       ->willReturnOnConsecutiveCalls(
         FALSE,
         $this->ownObject,
@@ -122,13 +122,12 @@ public function testGet() {
    * @covers ::getIfOwner
    */
   public function testGetIfOwner() {
-    $this->keyValue->expects($this->exactly(3))
+    $calls = ['test_2', 'test', 'test'];
+    $this->keyValue->expects($this->exactly(count($calls)))
       ->method('get')
-      ->withConsecutive(
-        ['test_2'],
-        ['test'],
-        ['test'],
-      )
+      ->with($this->callback(function (string $key) use (&$calls): bool {
+        return array_shift($calls) == $key;
+      }))
       ->willReturnOnConsecutiveCalls(
         FALSE,
         $this->ownObject,
@@ -328,13 +327,12 @@ public function testDeleteIfOwner() {
       ->with('test_2')
       ->willReturn(TRUE);
 
-    $this->keyValue->expects($this->exactly(3))
+    $calls = ['test_1', 'test_2', 'test_3'];
+    $this->keyValue->expects($this->exactly(count($calls)))
       ->method('get')
-      ->withConsecutive(
-        ['test_1'],
-        ['test_2'],
-        ['test_3'],
-      )
+      ->with($this->callback(function (string $key) use (&$calls): bool {
+        return array_shift($calls) == $key;
+      }))
       ->willReturnOnConsecutiveCalls(
         FALSE,
         $this->ownObject,