Remove the templateClassPrefix property on Environment

This commit is contained in:
Fabien Potencier
2024-07-28 16:25:21 +02:00
parent ae04075ed1
commit 215f9880f1
2 changed files with 1 additions and 7 deletions
+1 -2
View File
@@ -63,7 +63,6 @@ class Environment
private $resolvedGlobals; private $resolvedGlobals;
private $loadedTemplates; private $loadedTemplates;
private $strictVariables; private $strictVariables;
private $templateClassPrefix = '__TwigTemplate_';
private $originalCache; private $originalCache;
private $extensionSet; private $extensionSet;
private $runtimeLoaders = []; private $runtimeLoaders = [];
@@ -290,7 +289,7 @@ class Environment
{ {
$key = $this->getLoader()->getCacheKey($name).$this->optionsHash; $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);
} }
/** /**
-5
View File
@@ -185,11 +185,6 @@ abstract class IntegrationTestCase extends TestCase
$twig->addFunction($function); $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 = []; $deprecations = [];
try { try {
$prevHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations, &$prevHandler) { $prevHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations, &$prevHandler) {