RequestBagPropertyAssignToReplaceRector

Replace deprecated assign of a new bag to Request bag property with replace() call on the existing bag

 use Symfony\Component\HttpFoundation\InputBag;
 use Symfony\Component\HttpFoundation\Request;

 function run(Request $request)
 {
-    $request->query = new InputBag(['page' => 2]);
+    $request->query->replace(['page' => 2]);
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Symfony\Symfony81\Rector\Expression\RequestBagPropertyAssignToReplaceRector;

return RectorConfig::configure()
    ->withRules([
        RequestBagPropertyAssignToReplaceRector::class,
    ]);
PACKAGE:  symfony/http-foundation >=8.1

Other rules in the symfony/http-foundation set