Bug Report
| Subject |
Details |
| Rector version |
2.4 |
When converting Symfony routes from annotations to attributes using withAttributesSets, comments are being removed in addition to the route annotation when they appear after the route.
Minimal PHP Code Causing Issue
I am not sure how to get this to work in the demo but here is what I tried and below is a diff of running the rule with the comment before and after the route.
https://getrector.com/demo/eeb66d58-4507-41bb-bec2-1c814fadc3b1
---------- begin diff ----------
@@ Line 17 @@
/**
- * This is an example comment
- *
- * @Route("/test", name="test_route")
- */
- public function test(): Response
+ * This is an example comment
+ */
+ #[Route(path: '/test', name: 'test_route')]
+ public function test(): Response
{
return $this->render("test.html.twig", []);
----------- end diff -----------
Applied rules:
* AnnotationToAttributeRector
---------- begin diff ----------
@@ Line 16 @@
{
- /**
- * @Route("/test", name="test_route")
- * This is an example comment
- */
- public function test(): Response
+ #[Route(path: '/test', name: 'test_route')]
+ public function test(): Response
{
return $this->render("test.html.twig", []);
----------- end diff -----------
Applied rules:
* AnnotationToAttributeRector
Expected Behaviour
Rector should not delete the comment.
Bug Report
When converting Symfony routes from annotations to attributes using withAttributesSets, comments are being removed in addition to the route annotation when they appear after the route.
Minimal PHP Code Causing Issue
I am not sure how to get this to work in the demo but here is what I tried and below is a diff of running the rule with the comment before and after the route.
https://getrector.com/demo/eeb66d58-4507-41bb-bec2-1c814fadc3b1
Expected Behaviour
Rector should not delete the comment.