This commit is contained in:
Fabien Potencier
2024-05-01 16:41:44 +02:00
parent 51bcd21df0
commit f582a3e381
7 changed files with 7 additions and 10 deletions
+2 -2
View File
@@ -76,7 +76,7 @@ class Compiler
$node->compile($this);
if ($this->didUseEcho) {
throw new \LogicException('Using "%s" is not supported; use "yield" instead in "%s".', $this->didUseEcho, \get_class($node));
throw new \LogicException('Using "%s" is not supported; use "yield" instead in "%s".', $this->didUseEcho, $node::class);
}
return $this;
@@ -101,7 +101,7 @@ class Compiler
$node->compile($this);
if ($this->didUseEcho) {
throw new \LogicException(sprintf('Using "%s" is not supported; use "yield" instead in "%s".', $this->didUseEcho, \get_class($node)));
throw new \LogicException(sprintf('Using "%s" is not supported; use "yield" instead in "%s".', $this->didUseEcho, $node::class));
}
return $this;
+1 -2
View File
@@ -504,7 +504,6 @@ final class CoreExtension extends AbstractExtension
$date = 'now';
}
return new \DateTimeImmutable($date, false !== $timezone ? $timezone : $env->getExtension(self::class)->getTimezone());
return new \DateTimeImmutable($date, false !== $timezone ? $timezone : $this->getTimezone());
}
@@ -1549,7 +1548,7 @@ final class CoreExtension extends AbstractExtension
if (!isset($cache[$class])) {
$methods = get_class_methods($object);
sort($methods);
$lcMethods = array_map(fn($value) => strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), $methods);
$lcMethods = array_map(fn ($value) => strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), $methods);
$classCache = [];
foreach ($methods as $i => $method) {
$classCache[$method] = $method;
+1 -1
View File
@@ -42,7 +42,7 @@ class CaptureNode extends Node
->subcompile($this->getNode('body'))
->write("return; yield '';\n")
->outdent()
->write("})(), false))")
->write('})(), false))')
;
if (!$this->getAttribute('raw')) {
$compiler->raw(") ? '' : new Markup(\$tmp, \$this->env->getCharset())");
+1 -1
View File
@@ -113,7 +113,7 @@ final class OptimizerNodeVisitor implements NodeVisitorInterface
return $node;
}
if (Node::class === get_class($node)) {
if (Node::class === $node::class) {
return new TextNode($text, $node->getTemplateLine());
}
+1 -1
View File
@@ -143,7 +143,7 @@ final class EscaperRuntime implements RuntimeExtensionInterface
if (!\is_string($string)) {
if (\is_object($string) && method_exists($string, '__toString')) {
if ($autoescape) {
$c = \get_class($string);
$c = $string::class;
if (!isset($this->safeClasses[$c])) {
$this->safeClasses[$c] = [];
foreach (class_parents($string) + class_implements($string) as $class) {
+1 -1
View File
@@ -65,7 +65,7 @@ final class SecurityPolicy implements SecurityPolicyInterface
{
$this->allowedMethods = [];
foreach ($methods as $class => $m) {
$this->allowedMethods[$class] = array_map(fn($value) => strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), \is_array($m) ? $m : [$m]);
$this->allowedMethods[$class] = array_map(fn ($value) => strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), \is_array($m) ? $m : [$m]);
}
}
-2
View File
@@ -24,9 +24,7 @@ use Twig\Loader\ArrayLoader;
use Twig\Loader\LoaderInterface;
use Twig\Node\Node;
use Twig\NodeVisitor\NodeVisitorInterface;
use Twig\Runtime\EscaperRuntime;
use Twig\RuntimeLoader\FactoryRuntimeLoader;
use Twig\RuntimeLoader\RuntimeLoaderInterface;
use Twig\Source;
use Twig\Token;
use Twig\TokenParser\AbstractTokenParser;