The request and response objects in PSR-7 are implemented as value objects, so they are immutable.
Each time you need another object, you create a new instance from the previous one, for example
$newRequest = $oldRequest->withMethod('GET');
and from this point of use a new instance.
middlewares next(), (, ).
, , ServerRequestInterface withAttribute withAttributes, .
, , .