Skip to content

Commit f22ebf9

Browse files
committed
More bullet-proof expression evaluation
In some scenarios evaluating expression can lead to TypeError (unresolved DI params being strings, not expected integers etc).
1 parent 1a7bf06 commit f22ebf9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private function checkType(Definition $checkedDefinition, mixed $value, \Reflect
228228
} elseif ($value instanceof Expression) {
229229
try {
230230
$value = $this->getExpressionLanguage()->evaluate($value, ['container' => $this->container]);
231-
} catch (\Exception) {
231+
} catch (\Throwable $e) {
232232
// If a service from the expression cannot be fetched from the container, we skip the validation.
233233
return;
234234
}
@@ -243,7 +243,7 @@ private function checkType(Definition $checkedDefinition, mixed $value, \Reflect
243243
if ('' === preg_replace('/'.$envPlaceholderUniquePrefix.'_\w+_[a-f0-9]{32}/U', '', $value, -1, $c) && 1 === $c) {
244244
try {
245245
$value = $this->container->resolveEnvPlaceholders($value, true);
246-
} catch (\Exception) {
246+
} catch (\Throwable) {
247247
// If an env placeholder cannot be resolved, we skip the validation.
248248
return;
249249
}

0 commit comments

Comments
 (0)