@@ -270,15 +270,19 @@ protected function write(Request $request, Response $response): void
270270
271271 $ streamId = $ this ->streamIdMap [$ request ] ?? 1 ; // Default ID of 1 for upgrade requests.
272272
273+ /** @psalm-suppress RedundantCondition */
274+ \assert ((bool )$ streamId ); // For Psalm.
275+
273276 if (!isset ($ this ->streams [$ streamId ])) {
274277 return ; // Client closed the stream or connection.
275278 }
276279
280+ $ stream = $ this ->streams [$ streamId ];
281+
277282 if ($ streamId & 1 ) {
278283 $ this ->timeoutTracker ->update ($ streamId );
279284 }
280285
281- $ stream = $ this ->streams [$ streamId ]; // $this->streams[$streamId] may be unset in send().
282286 $ deferred = new DeferredFuture ;
283287 $ stream ->pendingWrite = $ deferred ->getFuture ();
284288 $ cancellation = $ stream ->deferredCancellation ->getCancellation ();
@@ -356,7 +360,7 @@ private function send(int $id, Response $response, Request $request, Cancellatio
356360 if ($ request ->getMethod () === "HEAD " ) {
357361 $ this ->streams [$ id ]->state |= Http2Stream::LOCAL_CLOSED ;
358362 $ this ->writeData ("" , $ id );
359- $ need = null ;
363+
360364 return ;
361365 }
362366
@@ -501,7 +505,7 @@ private function shutdown(?ClientException $reason = null): void
501505 } finally {
502506 if (!empty ($ this ->streams )) {
503507 $ reason ??= new ClientException ($ this ->client , "Connection closed unexpectedly " , Http2Parser::CANCEL );
504- foreach ($ this ->streams as $ id => $ stream ) {
508+ foreach ($ this ->streams as $ id => $ _stream ) {
505509 $ this ->releaseStream ($ id , $ reason );
506510 }
507511 }
@@ -925,7 +929,7 @@ public function handleConnectionWindowIncrement(int $windowSize): void
925929 #[\Override]
926930 public function handleHeaders (int $ streamId , array $ pseudo , array $ headers , bool $ streamEnded ): void
927931 {
928- foreach ($ pseudo as $ name => $ value ) {
932+ foreach ($ pseudo as $ name => $ _value ) {
929933 if (!isset (Http2Parser::KNOWN_REQUEST_PSEUDO_HEADERS [$ name ])) {
930934 throw new Http2StreamException (
931935 "Invalid pseudo header " ,
@@ -1242,7 +1246,7 @@ public function handleData(int $streamId, string $data): void
12421246 $ future ->ignore ();
12431247
12441248 if ($ stream ->serverWindow <= self ::MINIMUM_WINDOW ) {
1245- EventLoop::queue (function () use ($ future , $ stream , $ streamId ): void {
1249+ EventLoop::queue (function () use ($ future , $ streamId ): void {
12461250 try {
12471251 $ future ->await ();
12481252 } catch (\Throwable ) {
0 commit comments