From e0a762a864a56fbbc8fc0fb9c21743138bd6da38 Mon Sep 17 00:00:00 2001 From: Stephan Vock Date: Tue, 10 Sep 2024 11:14:35 +0100 Subject: [PATCH] Twig: adjust version check to not dependend on changing VERSION constant --- phpstan.neon.dist | 3 ++- src/Twig/Version.php | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 76225e6..5396309 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -28,4 +28,5 @@ parameters: dynamicConstantNames: - Symfony\Component\HttpKernel\Kernel::VERSION - - Twig\Environment::VERSION_ID + - Twig\Environment::MAJOR_VERSION + - Twig\Environment::MINOR_VERSION diff --git a/src/Twig/Version.php b/src/Twig/Version.php index d1307c5..e56d995 100644 --- a/src/Twig/Version.php +++ b/src/Twig/Version.php @@ -13,6 +13,8 @@ namespace Nelmio\SecurityBundle\Twig; +use Twig\Environment; + /** * @internal */ @@ -20,6 +22,10 @@ final class Version { public static function needsNodeTag(): bool { - return \Twig\Environment::VERSION_ID < 301200; + if (Environment::MAJOR_VERSION < 3) { + return true; + } + + return Environment::MAJOR_VERSION === 3 && Environment::MINOR_VERSION < 12; } }