Skip to content

Commit

Permalink
Updates CoreExtension::twig_constant to check for definition first to…
Browse files Browse the repository at this point in the history
… avoid hard crash
  • Loading branch information
Alex Henderson-Roche committed Nov 8, 2022
1 parent 0986e54 commit 497d4c2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Extension/CoreExtension.php
Expand Up @@ -1329,6 +1329,12 @@ function twig_constant($constant, $object = null)
$constant = \get_class($object).'::'.$constant;
}

if (!\defined($constant)) {
throw new RuntimeError(
sprintf('Expected constant "%s" to resolve', $constant)
);
}

return \constant($constant);
}

Expand Down

0 comments on commit 497d4c2

Please sign in to comment.