Skip to content

[Cache] Add use Response & return hint #17188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions http_cache/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ content::

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class DefaultController extends AbstractController
{
public function homepage(Request $request)
public function homepage(Request $request): Response
{
$response = $this->render('static/homepage.html.twig');
$response->setEtag(md5($response->getContent()));
Expand Down Expand Up @@ -138,7 +139,7 @@ header value::

class ArticleController extends AbstractController
{
public function show(Article $article, Request $request)
public function show(Article $article, Request $request): Response
{
$author = $article->getAuthor();

Expand Down Expand Up @@ -196,7 +197,7 @@ the better. The ``Response::isNotModified()`` method does exactly that::

class ArticleController extends AbstractController
{
public function show($articleSlug, Request $request)
public function show(string $articleSlug, Request $request): Response
{
// Get the minimum information to compute
// the ETag or the Last-Modified value
Expand Down