1717
1818class RateLimitAnnotationListener extends BaseListener
1919{
20- protected EventDispatcherInterface $ eventDispatcher ;
21-
22- protected RateLimitService $ rateLimitService ;
23-
24- protected PathLimitProcessor $ pathLimitProcessor ;
25-
2620 public function __construct (
27- EventDispatcherInterface $ eventDispatcher ,
28- RateLimitService $ rateLimitService ,
29- PathLimitProcessor $ pathLimitProcessor
21+ protected EventDispatcherInterface $ eventDispatcher ,
22+ protected RateLimitService $ rateLimitService ,
23+ protected PathLimitProcessor $ pathLimitProcessor
3024 ) {
31- $ this ->eventDispatcher = $ eventDispatcher ;
32- $ this ->rateLimitService = $ rateLimitService ;
33- $ this ->pathLimitProcessor = $ pathLimitProcessor ;
3425 }
3526
3627 public function onKernelController (ControllerEvent $ event ): void
3728 {
3829 // Skip if the bundle isn't enabled (for instance in test environment)
39- if ( ! $ this ->getParameter ('enabled ' , true )) {
30+ if (! $ this ->getParameter ('enabled ' , true )) {
4031 return ;
4132 }
4233
@@ -120,10 +111,8 @@ public function onKernelController(ControllerEvent $event): void
120111 });
121112 $ event ->stopPropagation ();
122113 }
123-
124114 }
125115
126-
127116 /**
128117 * @param RateLimit[] $rateLimits
129118 */
@@ -134,19 +123,19 @@ protected function findBestMethodMatch(Request $request, array $rateLimits): ?Ra
134123 return $ this ->pathLimitProcessor ->getRateLimit ($ request );
135124 }
136125
137- $ best_match = null ;
126+ $ bestMatch = null ;
138127 foreach ($ rateLimits as $ rateLimit ) {
139128 if (in_array ($ request ->getMethod (), $ rateLimit ->getMethods (), true )) {
140- $ best_match = $ rateLimit ;
129+ $ bestMatch = $ rateLimit ;
141130 }
142131
143132 // Only match "default" annotation when we don't have a best match
144- if ($ best_match === null && count ($ rateLimit ->methods ) === 0 ) {
145- $ best_match = $ rateLimit ;
133+ if ($ bestMatch === null && count ($ rateLimit ->methods ) === 0 ) {
134+ $ bestMatch = $ rateLimit ;
146135 }
147136 }
148137
149- return $ best_match ;
138+ return $ bestMatch ;
150139 }
151140
152141 /** @param RateLimit[] $rateLimits */
0 commit comments