Skip to content

Commit

Permalink
minor #4164 Remove the templateClassPrefix property on Environment (f…
Browse files Browse the repository at this point in the history
…abpot)

This PR was merged into the 3.x branch.

Discussion
----------

Remove the templateClassPrefix property on Environment

Commits
-------

215f988 Remove the templateClassPrefix property on Environment
  • Loading branch information
fabpot committed Jul 31, 2024
2 parents 0d09230 + 215f988 commit 205ea9e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
3 changes: 1 addition & 2 deletions src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class Environment
private $resolvedGlobals;
private $loadedTemplates;
private $strictVariables;
private $templateClassPrefix = '__TwigTemplate_';
private $originalCache;
private $extensionSet;
private $runtimeLoaders = [];
Expand Down Expand Up @@ -290,7 +289,7 @@ public function getTemplateClass(string $name, ?int $index = null): string
{
$key = $this->getLoader()->getCacheKey($name).$this->optionsHash;

return $this->templateClassPrefix.hash(\PHP_VERSION_ID < 80100 ? 'sha256' : 'xxh128', $key).(null === $index ? '' : '___'.$index);
return '__TwigTemplate_'.hash(\PHP_VERSION_ID < 80100 ? 'sha256' : 'xxh128', $key).(null === $index ? '' : '___'.$index);
}

/**
Expand Down
5 changes: 0 additions & 5 deletions src/Test/IntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,6 @@ protected function doIntegrationTest($file, $message, $condition, $templates, $e
$twig->addFunction($function);
}

// avoid using the same PHP class name for different cases
$p = new \ReflectionProperty($twig, 'templateClassPrefix');
$p->setAccessible(true);
$p->setValue($twig, '__TwigTemplate_'.hash(\PHP_VERSION_ID < 80100 ? 'sha256' : 'xxh128', random_bytes(32), false).'_');

$deprecations = [];
try {
$prevHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations, &$prevHandler) {
Expand Down

0 comments on commit 205ea9e

Please sign in to comment.