From d049fbe0e5ba0ad758f647fa8f99e840bca43f6f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 11 Sep 2024 15:27:43 +0200 Subject: [PATCH] use DeprecatedCallableInfo for Twig callables if possible --- Tests/Command/LintCommandTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Tests/Command/LintCommandTest.php b/Tests/Command/LintCommandTest.php index 18d09b20..3c09f1b9 100644 --- a/Tests/Command/LintCommandTest.php +++ b/Tests/Command/LintCommandTest.php @@ -18,6 +18,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Tester\CommandCompletionTester; use Symfony\Component\Console\Tester\CommandTester; +use Twig\DeprecatedCallableInfo; use Twig\Environment; use Twig\Loader\FilesystemLoader; use Twig\TwigFilter; @@ -163,9 +164,14 @@ private function createCommandTester(): CommandTester private function createCommand(): Command { $environment = new Environment(new FilesystemLoader(\dirname(__DIR__).'/Fixtures/templates/')); + if (class_exists(DeprecatedCallableInfo::class)) { + $options = ['deprecation_info' => new DeprecatedCallableInfo('foo/bar', '1.1')]; + } else { + $options = ['deprecated' => true]; + } $environment->addFilter(new TwigFilter('deprecated_filter', function ($v) { return $v; - }, ['deprecated' => true])); + }, $options)); $command = new LintCommand($environment);