Repository: symfony/symfony
File: src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php (PHP)

Code before:

        parent::remove($key);

        if ('cache-control' === $uniqueKey) {
            $this->computedCacheControl = [];
        }

        if ('date' === $uniqueKey) {
            $this->initDate();
        }
    }

    public function hasCacheControlDirective(string $key): bool
    {
        return \array_key_exists($key, $this->computedCacheControl);
    }

    public function getCacheControlDirective(string $key): bool|string|null
    {
        return $this->computedCacheControl[$key] ?? null;
    }

    /**
     * Checks if a cache control directive was explicitly set (not auto-computed).
     */
    public function hasExplicitCacheControlDirective(string $key): bool
    {
        return isset($this->cacheControl[$key]);
    }

    public function setCookie(Cookie $cookie): void
    {
        $this->cookies[$cookie->getDomain() ?? ''][$cookie->getPath()][$cookie->getName()] = $cookie;
        $this->headerNames['set-cookie'] = 'Set-Cookie';
    }

    /**
     * Removes a cookie from the array, but does not unset it in the browser.
     */
    public function removeCookie(string $name, ?string $path = '/', ?string $domain = null): void
    {
        $path ??= '/';

        unset($this->cookies[$domain ?? ''][$path][$name]);

        if (empty($this->cookies[$domain ?? ''][$path])) {
            unset($this->cookies[$domain ?? ''][$path]);

            if (empty($this->cookies[$domain ?? ''])) {
                unset($this->cookies[$domain ?? '']);
            }

Review comment (bug):
adding a method is a hint about a new feature
BUT
why adding a method when we could use hasCacheControlDirective or getCacheControlDirective instead?
once this method is removed, we can consider this as a bugfix IMHO
and then, bugfixes should target the lowest affected branch. 6.4 in this case?

Code after:
     * @return void
     */
    public function remove(string $key)
    {
        $uniqueKey = strtr($key, self::UPPER, self::LOWER);
        unset($this->headerNames[$uniqueKey]);

        if ('set-cookie' === $uniqueKey) {
            $this->cookies = [];

            return;
        }

        parent::remove($key);

        if ('cache-control' === $uniqueKey) {
            $this->computedCacheControl = [];
        }

        if ('date' === $uniqueKey) {
            $this->initDate();
        }
    }

    public function hasCacheControlDirective(string $key): bool
    {
        return \array_key_exists($key, $this->computedCacheControl);
    }

    public function getCacheControlDirective(string $key): bool|string|null
    {
        return $this->computedCacheControl[$key] ?? null;
    }

    /**
     * @return void
     */
    public function setCookie(Cookie $cookie)
    {
        $this->cookies[$cookie->getDomain() ?? ''][$cookie->getPath()][$cookie->getName()] = $cookie;
        $this->headerNames['set-cookie'] = 'Set-Cookie';
    }

    /**
     * Removes a cookie from the array, but does not unset it in the browser.
     *
     * @return void
     */
    public function removeCookie(string $name, ?string $path = '/', ?string $domain = null)
    {
        $path ??= '/';