rector icon indicating copy to clipboard operation
rector copied to clipboard

Error converting SecurityController (Symfony 5)

Open tacman opened this issue 3 years ago • 1 comments

vendor/bin/rector process src/Controller/SecurityController.php --dry-run

controller_error.zip

Attached is the log and file that caused the problem.

tacman avatar Jul 30 '22 12:07 tacman

Do you on windows? I can't reproduce in macOS:

vendor/bin/rector process src/Controller/SecurityController.php --dry-run                                  
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1 file with changes
===================

1) src/Controller/SecurityController.php:18

    ---------- begin diff ----------
@@ @@
 class SecurityController extends AbstractController
 {

-    /**
-     * @Route("/ws.php", name="app_piwigo")
-     */
+    #[Route(path: '/ws.php', name: 'app_piwigo')]
     public function PiwigoApi(Request $request, AuthenticationUtils $authenticationUtils, LoggerInterface $logger)
     {
         $logger->warning("wp.php called", [$request->request->all()]);
-//        return new Response(true); // or true?
-
+        //        return new Response(true); // or true?
         return new JsonResponse(['stat' => 'ok', 'result' => true]);
     }


-    /**
-     * @Route("/login", name="app_login")
-     */
+    #[Route(path: '/login', name: 'app_login')]
     public function login(AuthenticationUtils $authenticationUtils)
     {
         // get the login error if there is one
         $error = $authenticationUtils->getLastAuthenticationError();
-
         // last username entered by the user
         $lastUsername = $authenticationUtils->getLastUsername();
-
         return $this->render('security/login.html.twig', [
             'last_username' => $lastUsername,
             'error'         => $error,
@@ @@
         ]);
     }

-    /**
-     * @Route("/logout", name="app_logout")
-     */
-    public function logout()
+    #[Route(path: '/logout', name: 'app_logout')]
+    public function logout() : never
     {
         throw new \Exception('Will be intercepted before getting here');
     }

-    /**
-     * @Route("/register", name="app_register")
-     */
+    #[Route(path: '/register', name: 'app_register')]
     public function register(Request $request, UserPasswordEncoderInterface $passwordEncoder, GuardAuthenticatorHandler $guardHandler, LoginFormAuthenticator $formAuthenticator)
     {
         $form = $this->createForm(UserRegistrationFormType::class);
         $form->handleRequest($request);
-
         if ($form->isSubmitted() && $form->isValid()) {
             /** @var UserRegistrationFormModel $userModel */
             $userModel = $form->getData();
@@ @@
                 'main'
             );
         }
-
         return $this->render('security/register.html.twig', [
             'registrationForm' => $form->createView(),
         ]);
    ----------- end diff -----------

Applied rules:
 * AnnotationToAttributeRector (https://wiki.php.net/rfc/attributes_v2)
 * RenameClassRector
 * ReturnNeverTypeRector (https://wiki.php.net/rfc/noreturn_type)


                                                                                                                        
 [OK] 1 file would have changed (dry-run) by Rector                                                                     
                                                                                                                        

You may need to debug like this https://github.com/rectorphp/rector/blob/main/docs/how_to_troubleshoot_parallel_issues.md

samsonasik avatar Jul 30 '22 12:07 samsonasik

Similar to https://github.com/rectorphp/rector/issues/7330

We'll need a demo link to process this propperly: https://getrector.org/demo

Feel free to re-open with a demo link or reproducible repository on Github :+1: Thank you :slightly_smiling_face:

TomasVotruba avatar Aug 17 '22 14:08 TomasVotruba