Skip to content

Commit

Permalink
minor #1403 php8: fixed named arguments order (COil)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the main branch.

Discussion
----------

php8: fixed named arguments order

This is to fix:

<img width="695" alt="Capture d’écran 2023-02-14 à 22 25 44" src="https://user-images.githubusercontent.com/177844/218866627-05b23c90-ae83-472c-995f-54f7b55421ac.png">

Commits
-------

5eefef1 php8: fixed named arguments order
  • Loading branch information
javiereguiluz committed Feb 15, 2023
2 parents fd22be2 + 5eefef1 commit 84ae312
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/Controller/Admin/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class BlogController extends AbstractController
* could move this annotation to any other controller while maintaining
* the route name and therefore, without breaking any existing link.
*/
#[Route('/', methods: ['GET'], name: 'admin_index')]
#[Route('/', methods: ['GET'], name: 'admin_post_index')]
#[Route('/', name: 'admin_index', methods: ['GET'])]
#[Route('/', name: 'admin_post_index', methods: ['GET'])]
public function index(
#[CurrentUser] User $user,
PostRepository $posts,
Expand All @@ -70,7 +70,7 @@ public function index(
* to constraint the HTTP methods each controller responds to (by default
* it responds to all methods).
*/
#[Route('/new', methods: ['GET', 'POST'], name: 'admin_post_new')]
#[Route('/new', name: 'admin_post_new', methods: ['GET', 'POST'])]
public function new(
#[CurrentUser] User $user,
Request $request,
Expand Down Expand Up @@ -119,7 +119,7 @@ public function new(
/**
* Finds and displays a Post entity.
*/
#[Route('/{id<\d+>}', methods: ['GET'], name: 'admin_post_show')]
#[Route('/{id<\d+>}', name: 'admin_post_show', methods: ['GET'])]
public function show(Post $post): Response
{
// This security check can also be performed
Expand All @@ -134,7 +134,7 @@ public function show(Post $post): Response
/**
* Displays a form to edit an existing Post entity.
*/
#[Route('/{id<\d+>}/edit', methods: ['GET', 'POST'], name: 'admin_post_edit')]
#[Route('/{id<\d+>}/edit', name: 'admin_post_edit', methods: ['GET', 'POST'])]
#[IsGranted('edit', subject: 'post', message: 'Posts can only be edited by their authors.')]
public function edit(Request $request, Post $post, EntityManagerInterface $entityManager): Response
{
Expand All @@ -157,7 +157,7 @@ public function edit(Request $request, Post $post, EntityManagerInterface $entit
/**
* Deletes a Post entity.
*/
#[Route('/{id}/delete', methods: ['POST'], name: 'admin_post_delete')]
#[Route('/{id}/delete', name: 'admin_post_delete', methods: ['POST'])]
#[IsGranted('delete', subject: 'post')]
public function delete(Request $request, Post $post, EntityManagerInterface $entityManager): Response
{
Expand Down
12 changes: 6 additions & 6 deletions src/Controller/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class BlogController extends AbstractController
*
* See https://symfony.com/doc/current/routing.html#special-parameters
*/
#[Route('/', defaults: ['page' => '1', '_format' => 'html'], methods: ['GET'], name: 'blog_index')]
#[Route('/rss.xml', defaults: ['page' => '1', '_format' => 'xml'], methods: ['GET'], name: 'blog_rss')]
#[Route('/page/{page<[1-9]\d{0,8}>}', defaults: ['_format' => 'html'], methods: ['GET'], name: 'blog_index_paginated')]
#[Route('/', name: 'blog_index', defaults: ['page' => '1', '_format' => 'html'], methods: ['GET'])]
#[Route('/rss.xml', name: 'blog_rss', defaults: ['page' => '1', '_format' => 'xml'], methods: ['GET'])]
#[Route('/page/{page<[1-9]\d{0,8}>}', name: 'blog_index_paginated', defaults: ['_format' => 'html'], methods: ['GET'])]
#[Cache(smaxage: 10)]
public function index(Request $request, int $page, string $_format, PostRepository $posts, TagRepository $tags): Response
{
Expand All @@ -72,7 +72,7 @@ public function index(Request $request, int $page, string $_format, PostReposito
*
* See https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html
*/
#[Route('/posts/{slug}', methods: ['GET'], name: 'blog_post')]
#[Route('/posts/{slug}', name: 'blog_post', methods: ['GET'])]
public function postShow(Post $post): Response
{
// Symfony's 'dump()' function is an improved version of PHP's 'var_dump()' but
Expand All @@ -98,7 +98,7 @@ public function postShow(Post $post): Response
*
* See https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html#doctrine-converter
*/
#[Route('/comment/{postSlug}/new', methods: ['POST'], name: 'comment_new')]
#[Route('/comment/{postSlug}/new', name: 'comment_new', methods: ['POST'])]
#[IsGranted('IS_AUTHENTICATED')]
public function commentNew(
#[CurrentUser] User $user,
Expand Down Expand Up @@ -152,7 +152,7 @@ public function commentForm(Post $post): Response
]);
}

#[Route('/search', methods: ['GET'], name: 'blog_search')]
#[Route('/search', name: 'blog_search', methods: ['GET'])]
public function search(Request $request): Response
{
return $this->render('blog/search.html.twig', ['query' => (string) $request->query->get('q', '')]);
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#[Route('/profile'), IsGranted('ROLE_USER')]
class UserController extends AbstractController
{
#[Route('/edit', methods: ['GET', 'POST'], name: 'user_edit')]
#[Route('/edit', name: 'user_edit', methods: ['GET', 'POST'])]
public function edit(
#[CurrentUser] User $user,
Request $request,
Expand All @@ -57,7 +57,7 @@ public function edit(
]);
}

#[Route('/change-password', methods: ['GET', 'POST'], name: 'user_change_password')]
#[Route('/change-password', name: 'user_change_password', methods: ['GET', 'POST'])]
public function changePassword(
#[CurrentUser] User $user,
Request $request,
Expand Down

0 comments on commit 84ae312

Please sign in to comment.