Closed Seldaek closed 2 weeks ago
Hi @Seldaek,
This is untrue.
The has
method is based on array_key_exists
, which means you can still have a NULL headers.
public function has(string $key): bool
{
return \array_key_exists(strtr($key, self::UPPER, self::LOWER), $this->all());
}
The same issue exists for InputBag/ParameterBag ; I opened https://github.com/phpstan/phpstan-symfony/pull/409
Yeah I guess you're right from an implementation standpoint. I don't know what would ever cause a header to receive a null value in the real world though, but definitely could happen in tests etc..
Right now calling this triggers an error as the returned header is string|null, but really after
->has($key)
returns true, we can assert that->get($sameKey)
will bestring
. At least as long as there is no other impure call made in between like->remove()
or->replace()