Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed May 1, 2024
1 parent 51bcd21 commit f582a3e
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Compiler.php
Expand Up @@ -76,7 +76,7 @@ public function compile(Node $node, int $indentation = 0)
$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;
Expand All @@ -101,7 +101,7 @@ public function subcompile(Node $node, bool $raw = true)
$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;
Expand Down
3 changes: 1 addition & 2 deletions src/Extension/CoreExtension.php
Expand Up @@ -504,7 +504,6 @@ public function convertDate($date = null, $timezone = null): \DateTimeImmutable
$date = 'now';
}

return new \DateTimeImmutable($date, false !== $timezone ? $timezone : $env->getExtension(self::class)->getTimezone());
return new \DateTimeImmutable($date, false !== $timezone ? $timezone : $this->getTimezone());
}

Expand Down Expand Up @@ -1549,7 +1548,7 @@ public static function getAttribute(Environment $env, Source $source, $object, $
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;
Expand Down
2 changes: 1 addition & 1 deletion src/Node/CaptureNode.php
Expand Up @@ -42,7 +42,7 @@ public function compile(Compiler $compiler): void
->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())");
Expand Down
2 changes: 1 addition & 1 deletion src/NodeVisitor/OptimizerNodeVisitor.php
Expand Up @@ -113,7 +113,7 @@ private function mergeTextNodeCalls(Node $node): Node
return $node;
}

if (Node::class === get_class($node)) {
if (Node::class === $node::class) {
return new TextNode($text, $node->getTemplateLine());
}

Expand Down
2 changes: 1 addition & 1 deletion src/Runtime/EscaperRuntime.php
Expand Up @@ -143,7 +143,7 @@ public function escape($string, string $strategy = 'html', ?string $charset = nu
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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Sandbox/SecurityPolicy.php
Expand Up @@ -65,7 +65,7 @@ public function setAllowedMethods(array $methods): void
{
$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]);
}
}

Expand Down
2 changes: 0 additions & 2 deletions tests/EnvironmentTest.php
Expand Up @@ -24,9 +24,7 @@
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;
Expand Down

0 comments on commit f582a3e

Please sign in to comment.