Skip to content

Commit

Permalink
Merge branch '3.x' into 4.x
Browse files Browse the repository at this point in the history
* 3.x:
  Fix EscaperExtension constructor to not change from previous releases (will be the same in 4.x as well)
  • Loading branch information
fabpot committed May 4, 2024
2 parents c872976 + 78466e8 commit 0093bbf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']));
}

Expand Down
4 changes: 1 addition & 3 deletions src/Extension/EscaperExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Twig\Extension;

use Twig\Environment;
use Twig\FileExtensionEscapingStrategy;
use Twig\Node\Expression\ConstantExpression;
use Twig\Node\Node;
Expand All @@ -30,10 +29,9 @@ final class EscaperExtension extends AbstractExtension
*
* @see setDefaultStrategy()
*/
public function __construct(EscaperRuntime $escaper, $defaultStrategy = 'html')
public function __construct($defaultStrategy = 'html')
{
$this->setDefaultStrategy($defaultStrategy);
$this->escaper = $escaper;
}

public function getTokenParsers(): array
Expand Down
2 changes: 1 addition & 1 deletion tests/EnvironmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public function testAddRuntimeLoader()
'func_string_named_args' => '{{ from_runtime_string(name="foo") }}',
]);

$twig = new Environment($loader);
$twig = new Environment($loader, ['autoescape' => false]);
$twig->addExtension(new EnvironmentTest_ExtensionWithoutRuntime());
$twig->addRuntimeLoader($runtimeLoader);

Expand Down

0 comments on commit 0093bbf

Please sign in to comment.