Issue Task Resolved

#110476Static analysis fails for settled promises with guzzle v8

Stefan Bürk 08/13/26, 14:22 updated 08/13/26, 15:35

Description

Problem

The nightly build of 13.4 fails in the “phpstan php 8.2 max” job:

bc. Instanceof between Psr\Http\Message\ResponseInterface and Psr\Http\Message\ResponseInterface will always evaluate to true. (instanceof.alwaysTrue)

reported for the callback of TYPO3\CMS\Core\Security\ContentSecurityPolicy\HashProxy,
which maps the result of a settled promise list onto response body contents. The
callback checks the state of each settled promise and guards the value with an
instanceof before reading the body.

Allowing guzzlehttp/guzzle v8 widened the constraints to accept guzzle 8, promises 3
and psr7 3. The job resolving the highest versions therefore installs guzzle 8 for the
first time. Its improved annotations already describe the settled value as a response,
so static analysis considers the guard redundant and reports it.

The job resolving the locked versions stays on guzzle 7 and passes, so the branch is
only red in the nightly and no patch is blocked.

Why only 13.4 is affected

main and 14.3 resolve the same versions in the same job and pass, because both disable
“treatPhpDocTypesAsCertain” globally. On 13.4 that option is only passed as an argument
to the custom UnneededInstanceOfRule service, so the built-in check still trusts
annotations of dependencies. Enabling the option globally on 13.4 is not an option: it
invalidates a large part of the existing baseline and surfaces further findings that
each need a separate decision.

Solution

Declare the mapped value as a plain array of mixed values inside the callback, so the
runtime guard is not evaluated against the annotations of whichever guzzle version
happens to be installed. The guard itself stays untouched, since both major versions
have to be supported.

The placement matters. An annotation on the closure parameter has no effect here,
because the parameter type is inferred from the mapped array and that inference wins.
A variable annotation inside the callback body does override it.

Only 13.4 needs this. main and 14.3 resolve the same versions in the same job and stay
silent, so nothing is changed there.

Reviews 1

History 23

  1. Stefan Bürk commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-08-13T15:35:11+00:00" > 08/13/26, 15:35 </span>

    Applied in changeset commit:2a99f5939d455705a90851f53c049fb5132f933d.