Skip to content

Commit 9197606

Browse files
committed
Leverage non-capturing catches
1 parent 2e9de12 commit 9197606

File tree

9 files changed

+12
-12
lines changed

9 files changed

+12
-12
lines changed

Controller/ArgumentResolver/DateTimeValueResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
6868
}
6969
try {
7070
$date = new $class($value);
71-
} catch (\Exception $e) {
71+
} catch (\Exception) {
7272
$date = false;
7373
}
7474
}

Controller/ControllerResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected function createController(string $controller): callable
112112
if ((new \ReflectionMethod($class, $method))->isStatic()) {
113113
return $class.'::'.$method;
114114
}
115-
} catch (\ReflectionException $reflectionException) {
115+
} catch (\ReflectionException) {
116116
throw $e;
117117
}
118118

DataCollector/RequestDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ private function parseController(array|object|string|null $controller): array|st
449449
'file' => $r->getFileName(),
450450
'line' => $r->getStartLine(),
451451
];
452-
} catch (\ReflectionException $e) {
452+
} catch (\ReflectionException) {
453453
if (\is_callable($controller)) {
454454
// using __call or __callStatic
455455
return [

Debug/FileLinkFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static function generateUrlFormat(UrlGeneratorInterface $router, string $
8181
{
8282
try {
8383
return $router->generate($routeName).$queryString;
84-
} catch (\Throwable $e) {
84+
} catch (\Throwable) {
8585
return null;
8686
}
8787
}

Debug/TraceableEventDispatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function beforeDispatch(string $eventName, object $event)
5252
// which must be caught.
5353
try {
5454
$this->stopwatch->openSection($sectionId);
55-
} catch (\LogicException $e) {
55+
} catch (\LogicException) {
5656
}
5757
break;
5858
}
@@ -83,7 +83,7 @@ protected function afterDispatch(string $eventName, object $event)
8383
}
8484
try {
8585
$this->stopwatch->stopSection($sectionId);
86-
} catch (\LogicException $e) {
86+
} catch (\LogicException) {
8787
}
8888
break;
8989
}

EventListener/LocaleAwareListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private function setLocale(string $locale, string $defaultLocale): void
6969
foreach ($this->localeAwareServices as $service) {
7070
try {
7171
$service->setLocale($locale);
72-
} catch (\InvalidArgumentException $e) {
72+
} catch (\InvalidArgumentException) {
7373
$service->setLocale($defaultLocale);
7474
}
7575
}

Exception/ControllerDoesNotReturnResponseException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private function parseControllerDefinition(callable $controller): ?array
4949
'file' => $r->getFileName(),
5050
'line' => $r->getEndLine(),
5151
];
52-
} catch (\ReflectionException $e) {
52+
} catch (\ReflectionException) {
5353
return null;
5454
}
5555
}
@@ -68,7 +68,7 @@ private function parseControllerDefinition(callable $controller): ?array
6868

6969
try {
7070
$line = $r->getMethod('__invoke')->getEndLine();
71-
} catch (\ReflectionException $e) {
71+
} catch (\ReflectionException) {
7272
$line = $r->getEndLine();
7373
}
7474

HttpKernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ private function handleThrowable(\Throwable $e, Request $request, int $type): Re
237237

238238
try {
239239
return $this->filterResponse($response, $request, $type);
240-
} catch (\Exception $e) {
240+
} catch (\Exception) {
241241
return $response;
242242
}
243243
}

Profiler/Profiler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function collect(Request $request, Response $response, \Throwable $except
142142
$profile->setStatusCode($response->getStatusCode());
143143
try {
144144
$profile->setIp($request->getClientIp());
145-
} catch (ConflictingHeadersException $e) {
145+
} catch (ConflictingHeadersException) {
146146
$profile->setIp('Unknown');
147147
}
148148

@@ -233,7 +233,7 @@ private function getTimestamp(?string $value): ?int
233233

234234
try {
235235
$value = new \DateTime(is_numeric($value) ? '@'.$value : $value);
236-
} catch (\Exception $e) {
236+
} catch (\Exception) {
237237
return null;
238238
}
239239

0 commit comments

Comments
 (0)