Repository: symfony/symfony
File: src/Symfony/Component/HttpKernel/EventListener/CacheAttributeListener.php (PHP)

Code before:
            }

            if (false === $cache->noStore) {
                $response->headers->removeCacheControlDirective('no-store');
            }
        }
    }

    public static function getSubscribedEvents(): array
    {
        return [
            KernelEvents::CONTROLLER_ARGUMENTS => ['onKernelControllerArguments', 10],
            KernelEvents::RESPONSE => ['onKernelResponse', -10],
        ];
    }

    public function reset(): void
    {
        $this->lastModified = new \SplObjectStorage();
        $this->etags = new \SplObjectStorage();
    }

    public function setUseStandardVarsInCacheExpr(bool $useStandardVarsInCacheExpr): void
    {
        $this->useStandardVarsInCacheExpr = $useStandardVarsInCacheExpr;
    }

    private function evaluate(string $expression, Request $request, array $arguments): mixed
    {
        return $this->getExpressionLanguage()->evaluate($expression, $this->useStandardVarsInCacheExpr ? [
            'request' => $request,
            'args' => $arguments,
        ] : array_merge($request->attributes->all(), $arguments));
    }

    private function getExpressionLanguage(): ExpressionLanguage
    {
        return $this->expressionLanguage ??= class_exists(ExpressionLanguage::class)
            ? new ExpressionLanguage()
            : throw new \LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".');
    }

    private function toSeconds(int|string $time): int
    {
        if (!is_numeric($time)) {
            $now = time();
            $time = strtotime($time, $now) - $now;
        }

        return $time;
    }

Review comment (suggestion):
I intentionally used a setter method instead of passing this via the constructor to make it easier to remove the method in the future, in case additional constructor arguments are added in the meantime.

Code after:

            if (false === $cache->noStore) {
                $response->headers->removeCacheControlDirective('no-store');
            }
        }
    }

    public static function getSubscribedEvents(): array
    {
        return [
            KernelEvents::CONTROLLER_ARGUMENTS => ['onKernelControllerArguments', 10],
            KernelEvents::RESPONSE => ['onKernelResponse', -10],
        ];
    }

    public function reset(): void
    {
        $this->lastModified = new \SplObjectStorage();
        $this->etags = new \SplObjectStorage();
    }

    private function getVariables(Request $request, ControllerArgumentsEvent $event): array
    {
        return array_merge([
            'request' => $request,
            'args' => $arguments = $event->getNamedArguments(),
        ], $request->attributes->all(), $arguments);
    }

    private function getExpressionLanguage(): ExpressionLanguage
    {
        return $this->expressionLanguage ??= class_exists(ExpressionLanguage::class)
            ? new ExpressionLanguage()
            : throw new \LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".');
    }

    private function toSeconds(int|string $time): int
    {
        if (!is_numeric($time)) {
            $now = time();
            $time = strtotime($time, $now) - $now;
        }

        return $time;
    }
}