23
23
use Symfony \Bundle \FrameworkBundle \Controller \Controller ;
24
24
use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
25
25
use Symfony \Component \EventDispatcher \GenericEvent ;
26
- use Symfony \Component \HttpFoundation \JsonResponse ;
27
26
use Symfony \Component \HttpFoundation \Request ;
28
27
use Symfony \Component \HttpFoundation \Response ;
29
28
@@ -48,7 +47,7 @@ class BlogController extends Controller
48
47
* Content-Type header for the response.
49
48
* See https://symfony.com/doc/current/quick_tour/the_controller.html#using-formats
50
49
*/
51
- public function indexAction ($ page , $ _format )
50
+ public function indexAction (int $ page , string $ _format ): Response
52
51
{
53
52
$ em = $ this ->getDoctrine ()->getManager ();
54
53
$ posts = $ em ->getRepository (Post::class)->findLatest ($ page );
@@ -68,7 +67,7 @@ public function indexAction($page, $_format)
68
67
* value given in the route.
69
68
* See https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html
70
69
*/
71
- public function postShowAction (Post $ post )
70
+ public function postShowAction (Post $ post ): Response
72
71
{
73
72
// Symfony provides a function called 'dump()' which is an improved version
74
73
// of the 'var_dump()' function. It's useful to quickly debug the contents
@@ -93,7 +92,7 @@ public function postShowAction(Post $post)
93
92
* (postSlug) doesn't match any of the Doctrine entity properties (slug).
94
93
* See https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html#doctrine-converter
95
94
*/
96
- public function commentNewAction (Request $ request , Post $ post , EventDispatcherInterface $ eventDispatcher )
95
+ public function commentNewAction (Request $ request , Post $ post , EventDispatcherInterface $ eventDispatcher ): Response
97
96
{
98
97
$ comment = new Comment ();
99
98
$ comment ->setAuthor ($ this ->getUser ());
@@ -137,12 +136,8 @@ public function commentNewAction(Request $request, Post $post, EventDispatcherIn
137
136
*
138
137
* The "id" of the Post is passed in and then turned into a Post object
139
138
* automatically by the ParamConverter.
140
- *
141
- * @param Post $post
142
- *
143
- * @return Response
144
139
*/
145
- public function commentFormAction (Post $ post )
140
+ public function commentFormAction (Post $ post ): Response
146
141
{
147
142
$ form = $ this ->createForm (CommentType::class);
148
143
@@ -155,10 +150,8 @@ public function commentFormAction(Post $post)
155
150
/**
156
151
* @Route("/search", name="blog_search")
157
152
* @Method("GET")
158
- *
159
- * @return Response|JsonResponse
160
153
*/
161
- public function searchAction (Request $ request )
154
+ public function searchAction (Request $ request ): Response
162
155
{
163
156
if (!$ request ->isXmlHttpRequest ()) {
164
157
return $ this ->render ('blog/search.html.twig ' );
0 commit comments