diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 2845159..e37652c 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -232,12 +232,7 @@ function () { ); foreach ($this->app['config']->get('twigbridge.twig.safe_classes', []) as $safeClass => $strategy) { - // "Since twig/twig 3.10: The "Twig\Extension\EscaperExtension::addSafeClass()" method is deprecated, use the "Twig\Runtime\EscaperRuntime::addSafeClass()" method instead." - if (class_exists(EscaperRuntime::class)) { - $twig->getRuntime(EscaperRuntime::class)->addSafeClass($safeClass, $strategy); - } else { - $twig->getExtension(EscaperExtension::class)->addSafeClass($safeClass, $strategy); - } + $twig->getExtension(EscaperExtension::class)->addSafeClass($safeClass, $strategy); } // Instantiate and add extensions diff --git a/tests/Node/GetAttrTest.php b/tests/Node/GetAttrTest.php index 8deffb5..99ac401 100644 --- a/tests/Node/GetAttrTest.php +++ b/tests/Node/GetAttrTest.php @@ -122,10 +122,10 @@ public function getTests() $node = $this->getNode($expr, $attr, $args, Template::ARRAY_CALL); $tests[] = [ $node, - '(($__internal_%s = // line 1' . "\n" + '(($_v0 = // line 1' . "\n" . '($context["foo"] ?? null))' - . ' && is_array($__internal_%s)' - . ' || $__internal_%s instanceof ArrayAccess ? ($__internal_%s["bar"] ?? null) : null)', + . ' && is_array($_v0)' + . ' || $_v0 instanceof ArrayAccess ? ($_v0["bar"] ?? null) : null)', null, true, ]; diff --git a/tests/Node/TemplateForTest.php b/tests/Node/TemplateForTest.php index ba45261..8b22d3b 100644 --- a/tests/Node/TemplateForTest.php +++ b/tests/Node/TemplateForTest.php @@ -5,6 +5,7 @@ use Twig\Environment; use Twig\Source; use Twig\Template; +use Twig\TemplateWrapper; class TemplateForTest extends Template { @@ -36,23 +37,24 @@ public function getTrue() return true; } - public function getTemplateName() + public function getTemplateName(): string { return $this->name; } - public function getDebugInfo() + public function getDebugInfo(): array { return []; } - protected function doGetParent(array $context) + protected function doGetParent(array $context): bool|string|self|TemplateWrapper { return false; } - protected function doDisplay(array $context, array $blocks = []) + protected function doDisplay(array $context, array $blocks = []): iterable { + return []; } /** @@ -60,7 +62,7 @@ protected function doDisplay(array $context, array $blocks = []) * * @return Source */ - public function getSourceContext() + public function getSourceContext(): Source { return new Source('', $this->getTemplateName()); } diff --git a/tests/TwigIntegrationTests/TwigIntegrationTest.php b/tests/TwigIntegrationTests/TwigIntegrationTest.php index ce04ff5..4483a02 100644 --- a/tests/TwigIntegrationTests/TwigIntegrationTest.php +++ b/tests/TwigIntegrationTests/TwigIntegrationTest.php @@ -112,11 +112,6 @@ protected function doIntegrationTest( $twig->addFunction($function); } - // avoid using the same PHP class name for different cases - $p = new \ReflectionProperty(Environment::class, 'templateClassPrefix'); - $p->setAccessible(true); - $p->setValue($twig, '__TwigTemplate_' . hash('sha256', uniqid(mt_rand(), true), false) . '_'); - $deprecations = []; try { $prevHandler = set_error_handler(