@@ -31,14 +31,15 @@ apply the ``controller.service_arguments`` tag to your controller services::
31
31
// src/Controller/HelloController.php
32
32
namespace App\Controller;
33
33
34
+ use Symfony\Component\HttpFoundation\Response;
34
35
use Symfony\Component\HttpKernel\Attribute\AsController;
35
36
use Symfony\Component\Routing\Annotation\Route;
36
37
37
38
#[AsController]
38
39
class HelloController
39
40
{
40
41
#[Route('/hello', name: 'hello', methods: ['GET'])]
41
- public function index()
42
+ public function index(): Response
42
43
{
43
44
// ...
44
45
}
@@ -60,12 +61,13 @@ a service like: ``App\Controller\HelloController::index``:
60
61
// src/Controller/HelloController.php
61
62
namespace App\Controller;
62
63
64
+ use Symfony\Component\HttpFoundation\Response;
63
65
use Symfony\Component\Routing\Annotation\Route;
64
66
65
67
class HelloController
66
68
{
67
69
#[Route('/hello', name: 'hello', methods: ['GET'])]
68
- public function index()
70
+ public function index(): Response
69
71
{
70
72
// ...
71
73
}
@@ -127,7 +129,7 @@ which is a common practice when following the `ADR pattern`_
127
129
#[Route('/hello/{name}', name: 'hello')]
128
130
class Hello
129
131
{
130
- public function __invoke($name = 'World')
132
+ public function __invoke(string $name = 'World'): Response
131
133
{
132
134
return new Response(sprintf('Hello %s!', $name));
133
135
}
@@ -192,7 +194,7 @@ service and use it directly::
192
194
) {
193
195
}
194
196
195
- public function index($name)
197
+ public function index(string $name): Response
196
198
{
197
199
$content = $this->twig->render(
198
200
'hello/index.html.twig',
0 commit comments