2323use Symfony \Bundle \FrameworkBundle \Controller \Controller ;
2424use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
2525use Symfony \Component \EventDispatcher \GenericEvent ;
26- use Symfony \Component \HttpFoundation \JsonResponse ;
2726use Symfony \Component \HttpFoundation \Request ;
2827use Symfony \Component \HttpFoundation \Response ;
2928
@@ -48,7 +47,7 @@ class BlogController extends Controller
4847 * Content-Type header for the response.
4948 * See https://symfony.com/doc/current/quick_tour/the_controller.html#using-formats
5049 */
51- public function indexAction ($ page , $ _format )
50+ public function indexAction (int $ page , string $ _format ): Response
5251 {
5352 $ em = $ this ->getDoctrine ()->getManager ();
5453 $ posts = $ em ->getRepository (Post::class)->findLatest ($ page );
@@ -68,7 +67,7 @@ public function indexAction($page, $_format)
6867 * value given in the route.
6968 * See https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html
7069 */
71- public function postShowAction (Post $ post )
70+ public function postShowAction (Post $ post ): Response
7271 {
7372 // Symfony provides a function called 'dump()' which is an improved version
7473 // of the 'var_dump()' function. It's useful to quickly debug the contents
@@ -93,7 +92,7 @@ public function postShowAction(Post $post)
9392 * (postSlug) doesn't match any of the Doctrine entity properties (slug).
9493 * See https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html#doctrine-converter
9594 */
96- public function commentNewAction (Request $ request , Post $ post , EventDispatcherInterface $ eventDispatcher )
95+ public function commentNewAction (Request $ request , Post $ post , EventDispatcherInterface $ eventDispatcher ): Response
9796 {
9897 $ comment = new Comment ();
9998 $ comment ->setAuthor ($ this ->getUser ());
@@ -137,12 +136,8 @@ public function commentNewAction(Request $request, Post $post, EventDispatcherIn
137136 *
138137 * The "id" of the Post is passed in and then turned into a Post object
139138 * automatically by the ParamConverter.
140- *
141- * @param Post $post
142- *
143- * @return Response
144139 */
145- public function commentFormAction (Post $ post )
140+ public function commentFormAction (Post $ post ): Response
146141 {
147142 $ form = $ this ->createForm (CommentType::class);
148143
@@ -155,10 +150,8 @@ public function commentFormAction(Post $post)
155150 /**
156151 * @Route("/search", name="blog_search")
157152 * @Method("GET")
158- *
159- * @return Response|JsonResponse
160153 */
161- public function searchAction (Request $ request )
154+ public function searchAction (Request $ request ): Response
162155 {
163156 if (!$ request ->isXmlHttpRequest ()) {
164157 return $ this ->render ('blog/search.html.twig ' );
0 commit comments