diff --git a/src/Environment.php b/src/Environment.php index da0438df39f..183b8c493e2 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -138,7 +138,7 @@ public function __construct(LoaderInterface $loader, $options = []) ]); $this->addExtension(new CoreExtension()); - $this->addExtension(new EscaperExtension($this->getRuntime(EscaperRuntime::class), $options['autoescape'])); + $this->addExtension(new EscaperExtension($options['autoescape'])); $this->addExtension(new OptimizerExtension($options['optimizations'])); } diff --git a/src/Extension/EscaperExtension.php b/src/Extension/EscaperExtension.php index 3cb847beb64..6204fe77889 100644 --- a/src/Extension/EscaperExtension.php +++ b/src/Extension/EscaperExtension.php @@ -11,7 +11,6 @@ namespace Twig\Extension; -use Twig\Environment; use Twig\FileExtensionEscapingStrategy; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Node; @@ -22,18 +21,10 @@ final class EscaperExtension extends AbstractExtension { - private $escaper; - private $defaultStrategy; - - /** - * @param string|false|callable $defaultStrategy An escaping strategy - * - * @see setDefaultStrategy() - */ - public function __construct(EscaperRuntime $escaper, $defaultStrategy = 'html') - { + public function __construct( + private $defaultStrategy = 'html' + ) { $this->setDefaultStrategy($defaultStrategy); - $this->escaper = $escaper; } public function getTokenParsers(): array