Closed
Description
Symfony version(s) affected: 5.3.5
Description
Uncaught PHP Exception TypeError: "Argument 1 passed to str_contains() must be of the type string, null given, called in vendor/symfony/http-foundation/Response.php on line 327" at vendor/symfony/polyfill-php80/bootstrap.php line 29
from Response.php:327:
if ('1.0' == $this->getProtocolVersion() && str_contains($headers->get('Cache-Control'), 'no-cache')) {
It seems that happens when $headers->get('Cache-Control')
is null.
How to reproduce
Request with missing 'Cache-Control' header
Possible Solution
Pass default value ''
in the second argument of get()
$headers->get('Cache-Control', '')
Additional info
phpDoc claims that method \Symfony\Component\HttpFoundation\HeaderBag::get
can return string|null
,
but str_contains
can receive only string
in the first argument
I can create PR with this solution