[RFC][Routing] Added the Route attribute

by @derrabus

Some issues have been detected in this pull request

Issues that can be fixed by applying a patch

Review the proposed patch then download it to apply it manually or execute the following command from the repository root directory:

curl https://fabbot.io/patch/symfony/symfony/37474/f0978de493c15de7ba16b2894569c6a8ec577247/cs.diff | patch -p0
diff -ru src/Symfony/Component/Routing/Annotation/Route.php src/Symfony/Component/Routing/Annotation/Route.php
--- src/Symfony/Component/Routing/Annotation/Route.php	2020-10-04 14:23:35.524069680 +0000
+++ src/Symfony/Component/Routing/Annotation/Route.php	2020-10-04 14:23:41.822931085 +0000
@@ -22,7 +22,7 @@
  * @author Fabien Potencier <[email protected]>
  * @author Alexander M. Turek <[email protected]>
  */
-#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
+//[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
 class Route
 {
     private $path;
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/ActionPathController.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/ActionPathController.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/ActionPathController.php	2020-10-04 14:23:36.386050714 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/ActionPathController.php	2020-10-04 14:23:42.024926640 +0000
@@ -6,7 +6,7 @@
 
 class ActionPathController
 {
-    #[Route('/path', name: 'action')]
+    //[Route('/path', name: 'action')]
     public function action()
     {
     }
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/EncodingClass.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/EncodingClass.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/EncodingClass.php	2020-10-04 14:23:37.068035708 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/EncodingClass.php	2020-10-04 14:23:42.030926508 +0000
@@ -6,7 +6,7 @@
 
 class EncodingClass
 {
-    #[Route]
+    //[Route]
     public function routeƀction()
     {
     }
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/ExplicitLocalizedActionPathController.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/ExplicitLocalizedActionPathController.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/ExplicitLocalizedActionPathController.php	2020-10-04 14:23:37.330029944 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/ExplicitLocalizedActionPathController.php	2020-10-04 14:23:42.033926442 +0000
@@ -6,7 +6,7 @@
 
 class ExplicitLocalizedActionPathController
 {
-    #[Route(path: ['en' => '/path', 'nl' => '/pad'], name: 'action')]
+    //[Route(path: ['en' => '/path', 'nl' => '/pad'], name: 'action')]
     public function action()
     {
     }
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/GlobalDefaultsClass.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/GlobalDefaultsClass.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/GlobalDefaultsClass.php	2020-10-04 14:23:37.541025301 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/GlobalDefaultsClass.php	2020-10-04 14:23:42.041926266 +0000
@@ -13,15 +13,15 @@
 
 use Symfony\Component\Routing\Annotation\Route;
 
-#[Route(path: '/defaults', locale: 'g_locale', format: 'g_format')]
+//[Route(path: '/defaults', locale: 'g_locale', format: 'g_format')]
 class GlobalDefaultsClass
 {
-    #[Route(path: '/specific-locale', name: 'specific_locale', locale: 's_locale')]
+    //[Route(path: '/specific-locale', name: 'specific_locale', locale: 's_locale')]
     public function locale()
     {
     }
 
-    #[Route(path: '/specific-format', name: 'specific_format', format: 's_format')]
+    //[Route(path: '/specific-format', name: 'specific_format', format: 's_format')]
     public function format()
     {
     }
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/InvokableController.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/InvokableController.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/InvokableController.php	2020-10-04 14:23:37.772020218 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/InvokableController.php	2020-10-04 14:23:42.045926178 +0000
@@ -4,7 +4,7 @@
 
 use Symfony\Component\Routing\Annotation\Route;
 
-#[Route(path: '/here', name: 'lol', methods: ["GET", "POST"], schemes: ['https'])]
+//[Route(path: '/here', name: 'lol', methods: ["GET", "POST"], schemes: ['https'])]
 class InvokableController
 {
     public function __invoke()
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/InvokableLocalizedController.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/InvokableLocalizedController.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/InvokableLocalizedController.php	2020-10-04 14:23:37.990015422 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/InvokableLocalizedController.php	2020-10-04 14:23:42.048926112 +0000
@@ -4,7 +4,7 @@
 
 use Symfony\Component\Routing\Annotation\Route;
 
-#[Route(path: ["nl" => "/hier", "en" => "/here"], name: 'action')]
+//[Route(path: ["nl" => "/hier", "en" => "/here"], name: 'action')]
 class InvokableLocalizedController
 {
     public function __invoke()
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedActionPathController.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedActionPathController.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedActionPathController.php	2020-10-04 14:23:38.206010669 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedActionPathController.php	2020-10-04 14:23:42.051926046 +0000
@@ -6,7 +6,7 @@
 
 class LocalizedActionPathController
 {
-    #[Route(path: ['en' => '/path', 'nl' => '/pad'], name: 'action')]
+    //[Route(path: ['en' => '/path', 'nl' => '/pad'], name: 'action')]
     public function action()
     {
     }
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedMethodActionControllers.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedMethodActionControllers.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedMethodActionControllers.php	2020-10-04 14:23:38.427005807 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedMethodActionControllers.php	2020-10-04 14:23:42.059925870 +0000
@@ -4,15 +4,15 @@
 
 use Symfony\Component\Routing\Annotation\Route;
 
-#[Route(path: ['en' => '/the/path', 'nl' => '/het/pad'])]
+//[Route(path: ['en' => '/the/path', 'nl' => '/het/pad'])]
 class LocalizedMethodActionControllers
 {
-    #[Route(name: 'post', methods: ['POST'])]
+    //[Route(name: 'post', methods: ['POST'])]
     public function post()
     {
     }
 
-    #[Route(name: 'put', methods: ['PUT'])]
+    //[Route(name: 'put', methods: ['PUT'])]
     public function put()
     {
     }
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedPrefixLocalizedActionController.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedPrefixLocalizedActionController.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedPrefixLocalizedActionController.php	2020-10-04 14:23:38.643001054 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedPrefixLocalizedActionController.php	2020-10-04 14:23:42.062925804 +0000
@@ -4,10 +4,10 @@
 
 use Symfony\Component\Routing\Annotation\Route;
 
-#[Route(path: ['nl' => '/nl', 'en' => '/en'])]
+//[Route(path: ['nl' => '/nl', 'en' => '/en'])]
 class LocalizedPrefixLocalizedActionController
 {
-    #[Route(path: ['nl' => '/actie', 'en' => '/action'], name: 'action')]
+    //[Route(path: ['nl' => '/actie', 'en' => '/action'], name: 'action')]
     public function action()
     {
     }
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedPrefixWithRouteWithoutLocale.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedPrefixWithRouteWithoutLocale.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedPrefixWithRouteWithoutLocale.php	2020-10-04 14:23:38.855996368 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/LocalizedPrefixWithRouteWithoutLocale.php	2020-10-04 14:23:42.065925738 +0000
@@ -4,10 +4,10 @@
 
 use Symfony\Component\Routing\Annotation\Route;
 
-#[Route(path: ['en' => '/en', 'nl' => '/nl'])]
+//[Route(path: ['en' => '/en', 'nl' => '/nl'])]
 class LocalizedPrefixWithRouteWithoutLocale
 {
-    #[Route(path: '/suffix', name: 'action')]
+    //[Route(path: '/suffix', name: 'action')]
     public function action()
     {
     }
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/MethodActionControllers.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/MethodActionControllers.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/MethodActionControllers.php	2020-10-04 14:23:39.102990933 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/MethodActionControllers.php	2020-10-04 14:23:42.069925650 +0000
@@ -4,15 +4,15 @@
 
 use Symfony\Component\Routing\Annotation\Route;
 
-#[Route('/the/path')]
+//[Route('/the/path')]
 class MethodActionControllers
 {
-    #[Route(name: 'post', methods: ['POST'])]
+    //[Route(name: 'post', methods: ['POST'])]
     public function post()
     {
     }
 
-    #[Route(name: 'put', methods: ['PUT'], priority: 10)]
+    //[Route(name: 'put', methods: ['PUT'], priority: 10)]
     public function put()
     {
     }
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/MissingRouteNameController.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/MissingRouteNameController.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/MissingRouteNameController.php	2020-10-04 14:23:39.320986136 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/MissingRouteNameController.php	2020-10-04 14:23:42.072925584 +0000
@@ -6,7 +6,7 @@
 
 class MissingRouteNameController
 {
-    #[Route('/path')]
+    //[Route('/path')]
     public function action()
     {
     }
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/NothingButNameController.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/NothingButNameController.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/NothingButNameController.php	2020-10-04 14:23:39.540981296 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/NothingButNameController.php	2020-10-04 14:23:42.079925430 +0000
@@ -6,7 +6,7 @@
 
 class NothingButNameController
 {
-    #[Route(name: 'action')]
+    //[Route(name: 'action')]
     public function action()
     {
     }
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/PrefixedActionLocalizedRouteController.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/PrefixedActionLocalizedRouteController.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/PrefixedActionLocalizedRouteController.php	2020-10-04 14:23:39.775976125 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/PrefixedActionLocalizedRouteController.php	2020-10-04 14:23:42.082925364 +0000
@@ -4,10 +4,10 @@
 
 use Symfony\Component\Routing\Annotation\Route;
 
-#[Route('/prefix')]
+//[Route('/prefix')]
 class PrefixedActionLocalizedRouteController
 {
-    #[Route(path: ['en' => '/path', 'nl' => '/pad'], name: 'action')]
+    //[Route(path: ['en' => '/path', 'nl' => '/pad'], name: 'action')]
     public function action()
     {
     }
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/PrefixedActionPathController.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/PrefixedActionPathController.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/PrefixedActionPathController.php	2020-10-04 14:23:39.998971218 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/PrefixedActionPathController.php	2020-10-04 14:23:42.085925298 +0000
@@ -4,10 +4,10 @@
 
 use Symfony\Component\Routing\Annotation\Route;
 
-#[Route(path: '/prefix', host: 'frankdejonge.nl', condition: 'lol=fun')]
+//[Route(path: '/prefix', host: 'frankdejonge.nl', condition: 'lol=fun')]
 class PrefixedActionPathController
 {
-    #[Route(path: '/path', name: 'action')]
+    //[Route(path: '/path', name: 'action')]
     public function action()
     {
     }
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/RequirementsWithoutPlaceholderNameController.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/RequirementsWithoutPlaceholderNameController.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/RequirementsWithoutPlaceholderNameController.php	2020-10-04 14:23:40.205966664 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/RequirementsWithoutPlaceholderNameController.php	2020-10-04 14:23:42.088925232 +0000
@@ -13,10 +13,10 @@
 
 use Symfony\Component\Routing\Annotation\Route;
 
-#[Route(path: '/', requirements: ['foo', '\d+'])]
+//[Route(path: '/', requirements: ['foo', '\d+'])]
 class RequirementsWithoutPlaceholderNameController
 {
-    #[Route(path: '/{foo}', name: 'foo', requirements: ['foo', '\d+'])]
+    //[Route(path: '/{foo}', name: 'foo', requirements: ['foo', '\d+'])]
     public function foo()
     {
     }
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/RouteWithPrefixController.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/RouteWithPrefixController.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/RouteWithPrefixController.php	2020-10-04 14:23:40.421961911 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/RouteWithPrefixController.php	2020-10-04 14:23:42.091925166 +0000
@@ -4,10 +4,10 @@
 
 use Symfony\Component\Routing\Annotation\Route;
 
-#[Route('/prefix')]
+//[Route('/prefix')]
 class RouteWithPrefixController
 {
-    #[Route(path: '/path', name: 'action')]
+    //[Route(path: '/path', name: 'action')]
     public function action()
     {
     }
diff -ru src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/Utf8ActionControllers.php src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/Utf8ActionControllers.php
--- src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/Utf8ActionControllers.php	2020-10-04 14:23:40.630957312 +0000
+++ src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/Utf8ActionControllers.php	2020-10-04 14:23:42.100924968 +0000
@@ -4,15 +4,15 @@
 
 use Symfony\Component\Routing\Annotation\Route;
 
-#[Route('/test', utf8: true)]
+//[Route('/test', utf8: true)]
 class Utf8ActionControllers
 {
-    #[Route(name: 'one')]
+    //[Route(name: 'one')]
     public function one()
     {
     }
 
-    #[Route(name: 'two', utf8: false)]
+    //[Route(name: 'two', utf8: false)]
     public function two()
     {
     }

0
Common Typos

0
License Headers

0
Pull Request Contributor Headers

0
JSON Files Syntax

0
File Permissions

0
Merge Commits

0
Exception Messages Formatting