mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-24 19:46:27 +00:00
Fix CS
This commit is contained in:
@@ -77,7 +77,7 @@ final class HtmlExtension extends AbstractExtension
|
||||
$repr .= ';'.$key.'='.rawurlencode($value);
|
||||
}
|
||||
|
||||
if (0 === strpos($mime, 'text/')) {
|
||||
if (str_starts_with($mime, 'text/')) {
|
||||
$repr .= ','.rawurlencode($data);
|
||||
} else {
|
||||
$repr .= ';base64,'.base64_encode($data);
|
||||
|
||||
@@ -58,7 +58,7 @@ class Configuration implements ConfigurationInterface
|
||||
->end()
|
||||
->enumNode('html_input')
|
||||
->info('How to handle HTML input.')
|
||||
->values(['strip','allow','escape'])
|
||||
->values(['strip', 'allow', 'escape'])
|
||||
->end()
|
||||
->booleanNode('allow_unsafe_links')
|
||||
->info('Remove risky link and image URLs by setting this to false.')
|
||||
@@ -66,7 +66,7 @@ class Configuration implements ConfigurationInterface
|
||||
->end()
|
||||
->integerNode('max_nesting_level')
|
||||
->info('The maximum nesting level for blocks.')
|
||||
->defaultValue(PHP_INT_MAX)
|
||||
->defaultValue(\PHP_INT_MAX)
|
||||
->end()
|
||||
->arrayNode('slug_normalizer')
|
||||
->info('Array of options for configuring how URL-safe slugs are created.')
|
||||
|
||||
@@ -27,12 +27,12 @@ class TwigExtraExtensionTest extends TestCase
|
||||
]));
|
||||
$container->registerExtension(new TwigExtraExtension());
|
||||
$container->loadFromExtension('twig_extra', [
|
||||
'commonmark' => [
|
||||
'commonmark' => [
|
||||
'extra_key' => true,
|
||||
'renderer' => [
|
||||
'block_separator' => "\n",
|
||||
'inner_separator' => "\n",
|
||||
'soft_break' => "\n",
|
||||
'soft_break' => "\n",
|
||||
],
|
||||
'commonmark' => [
|
||||
'enable_em' => true,
|
||||
@@ -43,7 +43,7 @@ class TwigExtraExtensionTest extends TestCase
|
||||
],
|
||||
'html_input' => 'escape',
|
||||
'allow_unsafe_links' => false,
|
||||
'max_nesting_level' => PHP_INT_MAX,
|
||||
'max_nesting_level' => \PHP_INT_MAX,
|
||||
'slug_normalizer' => [
|
||||
'max_length' => 255,
|
||||
],
|
||||
|
||||
+2
-2
@@ -74,7 +74,7 @@ class Compiler
|
||||
$node->compile($this);
|
||||
|
||||
if ($this->didUseEcho) {
|
||||
trigger_deprecation('twig/twig', '3.9', 'Using "%s" is deprecated, use "yield" instead in "%s", then flag the class with #[\Twig\Attribute\YieldReady].', $this->didUseEcho, \get_class($node));
|
||||
trigger_deprecation('twig/twig', '3.9', 'Using "%s" is deprecated, use "yield" instead in "%s", then flag the class with #[\Twig\Attribute\YieldReady].', $this->didUseEcho, $node::class);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -99,7 +99,7 @@ class Compiler
|
||||
$node->compile($this);
|
||||
|
||||
if ($this->didUseEcho) {
|
||||
trigger_deprecation('twig/twig', '3.9', 'Using "%s" is deprecated, use "yield" instead in "%s", then flag the class with #[\Twig\Attribute\YieldReady].', $this->didUseEcho, \get_class($node));
|
||||
trigger_deprecation('twig/twig', '3.9', 'Using "%s" is deprecated, use "yield" instead in "%s", then flag the class with #[\Twig\Attribute\YieldReady].', $this->didUseEcho, $node::class);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
@@ -258,7 +258,7 @@ class ExpressionParser
|
||||
$name = null;
|
||||
if ($namedArguments && (($token = $stream->nextIf(Token::OPERATOR_TYPE, '=')) || (!$definition && $token = $stream->nextIf(Token::PUNCTUATION_TYPE, ':')))) {
|
||||
if (!$value instanceof ContextVariable) {
|
||||
throw new SyntaxError(\sprintf('A parameter name must be a string, "%s" given.', \get_class($value)), $token->getLine(), $stream->getSourceContext());
|
||||
throw new SyntaxError(\sprintf('A parameter name must be a string, "%s" given.', $value::class), $token->getLine(), $stream->getSourceContext());
|
||||
}
|
||||
$name = $value->getAttribute('name');
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ use Twig\Node\Expression\AbstractExpression;
|
||||
use Twig\Node\Expression\ArrayExpression;
|
||||
use Twig\Node\Expression\Binary\ConcatBinary;
|
||||
use Twig\Node\Expression\ConstantExpression;
|
||||
use Twig\Node\Expression\Unary\SpreadUnary;
|
||||
use Twig\Node\Expression\Variable\ContextVariable;
|
||||
use Twig\Parser;
|
||||
use Twig\Token;
|
||||
|
||||
@@ -542,7 +542,6 @@ final class CoreExtension extends AbstractExtension
|
||||
* Returns a formatted string.
|
||||
*
|
||||
* @param string|null $format
|
||||
* @param ...$values
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
@@ -1001,8 +1000,6 @@ final class CoreExtension extends AbstractExtension
|
||||
*
|
||||
* @param array|\Traversable|string|null $item
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function shuffle(string $charset, $item)
|
||||
@@ -1437,8 +1434,6 @@ final class CoreExtension extends AbstractExtension
|
||||
* {# ... #}
|
||||
* {% endif %}
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function testSequence($value): bool
|
||||
@@ -1462,8 +1457,6 @@ final class CoreExtension extends AbstractExtension
|
||||
* {# ... #}
|
||||
* {% endif %}
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function testMapping($value): bool
|
||||
@@ -1613,10 +1606,10 @@ final class CoreExtension extends AbstractExtension
|
||||
{
|
||||
if (null !== $object) {
|
||||
if ('class' === $constant) {
|
||||
return $checkDefined ? true : \get_class($object);
|
||||
return $checkDefined ? true : $object::class;
|
||||
}
|
||||
|
||||
$constant = \get_class($object).'::'.$constant;
|
||||
$constant = $object::class.'::'.$constant;
|
||||
}
|
||||
|
||||
if (!\defined($constant)) {
|
||||
@@ -1720,9 +1713,9 @@ final class CoreExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
if ($object instanceof \ArrayAccess) {
|
||||
$message = \sprintf('Key "%s" in object with ArrayAccess of class "%s" does not exist.', $arrayItem, \get_class($object));
|
||||
$message = \sprintf('Key "%s" in object with ArrayAccess of class "%s" does not exist.', $arrayItem, $object::class);
|
||||
} elseif (\is_object($object)) {
|
||||
$message = \sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface.', $item, \get_class($object));
|
||||
$message = \sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface.', $item, $object::class);
|
||||
} elseif (\is_array($object)) {
|
||||
if (!$object) {
|
||||
$message = \sprintf('Key "%s" does not exist as the sequence/mapping is empty.', $arrayItem);
|
||||
@@ -1818,7 +1811,7 @@ final class CoreExtension extends AbstractExtension
|
||||
|
||||
static $cache = [];
|
||||
|
||||
$class = \get_class($object);
|
||||
$class = $object::class;
|
||||
|
||||
// object method
|
||||
// precedence: getXxx() > isXxx() > hasXxx()
|
||||
|
||||
@@ -118,10 +118,6 @@ final class SandboxExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $obj
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws SecurityNotAllowedMethodError
|
||||
*/
|
||||
public function ensureToStringAllowed($obj, int $lineno = -1, ?Source $source = null)
|
||||
|
||||
@@ -142,7 +142,7 @@ final class ExtensionSet
|
||||
|
||||
public function addExtension(ExtensionInterface $extension): void
|
||||
{
|
||||
$class = \get_class($extension);
|
||||
$class = $extension::class;
|
||||
|
||||
if ($this->initialized) {
|
||||
throw new \LogicException(\sprintf('Unable to register extension "%s" as extensions have already been initialized.', $class));
|
||||
@@ -484,11 +484,11 @@ final class ExtensionSet
|
||||
|
||||
$operators = $extension->getOperators();
|
||||
if (!\is_array($operators)) {
|
||||
throw new \InvalidArgumentException(\sprintf('"%s::getOperators()" must return an array with operators, got "%s".', \get_class($extension), get_debug_type($operators).(\is_resource($operators) ? '' : '#'.$operators)));
|
||||
throw new \InvalidArgumentException(\sprintf('"%s::getOperators()" must return an array with operators, got "%s".', $extension::class, get_debug_type($operators).(\is_resource($operators) ? '' : '#'.$operators)));
|
||||
}
|
||||
|
||||
if (2 !== \count($operators)) {
|
||||
throw new \InvalidArgumentException(\sprintf('"%s::getOperators()" must return an array of 2 elements, got %d.', \get_class($extension), \count($operators)));
|
||||
throw new \InvalidArgumentException(\sprintf('"%s::getOperators()" must return an array of 2 elements, got %d.', $extension::class, \count($operators)));
|
||||
}
|
||||
|
||||
$expressionParsers = [];
|
||||
|
||||
@@ -104,7 +104,7 @@ final class ChainLoader implements LoaderInterface
|
||||
try {
|
||||
return $loader->getCacheKey($name);
|
||||
} catch (LoaderError $e) {
|
||||
$exceptions[] = \get_class($loader).': '.$e->getMessage();
|
||||
$exceptions[] = $loader::class.': '.$e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ final class ChainLoader implements LoaderInterface
|
||||
try {
|
||||
return $loader->isFresh($name, $time);
|
||||
} catch (LoaderError $e) {
|
||||
$exceptions[] = \get_class($loader).': '.$e->getMessage();
|
||||
$exceptions[] = $loader::class.': '.$e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,6 @@ class Markup implements \Countable, \JsonSerializable, \Stringable
|
||||
return mb_strlen($this->content, $this->charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
{
|
||||
|
||||
@@ -25,10 +25,10 @@ abstract class AbstractBinary extends AbstractExpression implements BinaryInterf
|
||||
public function __construct(Node $left, Node $right, int $lineno)
|
||||
{
|
||||
if (!$left instanceof AbstractExpression) {
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "left" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($left));
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "left" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, $left::class);
|
||||
}
|
||||
if (!$right instanceof AbstractExpression) {
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "right" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($right));
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "right" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, $right::class);
|
||||
}
|
||||
|
||||
parent::__construct(['left' => $left, 'right' => $right], [], $lineno);
|
||||
|
||||
@@ -28,7 +28,7 @@ class BlockReferenceExpression extends AbstractExpression
|
||||
public function __construct(Node $name, ?Node $template, int $lineno)
|
||||
{
|
||||
if (!$name instanceof AbstractExpression) {
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($name));
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, $name::class);
|
||||
}
|
||||
|
||||
$nodes = ['name' => $name];
|
||||
|
||||
@@ -42,7 +42,7 @@ class DefaultFilter extends FilterExpression
|
||||
public function __construct(Node $node, TwigFilter|ConstantExpression $filter, Node $arguments, int $lineno)
|
||||
{
|
||||
if (!$node instanceof AbstractExpression) {
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($node));
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, $node::class);
|
||||
}
|
||||
|
||||
if ($filter instanceof TwigFilter) {
|
||||
|
||||
@@ -32,7 +32,7 @@ class RawFilter extends FilterExpression
|
||||
public function __construct(Node $node, TwigFilter|ConstantExpression|null $filter = null, ?Node $arguments = null, int $lineno = 0)
|
||||
{
|
||||
if (!$node instanceof AbstractExpression) {
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($node));
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, $node::class);
|
||||
}
|
||||
|
||||
parent::__construct($node, $filter ?: new TwigFilter('raw', null, ['is_safe' => ['all']]), $arguments ?: new EmptyNode(), $lineno ?: $node->getTemplateLine());
|
||||
|
||||
@@ -27,7 +27,7 @@ class FilterExpression extends CallExpression
|
||||
public function __construct(Node $node, TwigFilter|ConstantExpression $filter, Node $arguments, int $lineno)
|
||||
{
|
||||
if (!$node instanceof AbstractExpression) {
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($node));
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, $node::class);
|
||||
}
|
||||
|
||||
if ($filter instanceof TwigFilter) {
|
||||
|
||||
@@ -33,10 +33,10 @@ class NullCoalesceExpression extends ConditionalExpression
|
||||
trigger_deprecation('twig/twig', '3.17', \sprintf('"%s" is deprecated; use "%s" instead.', __CLASS__, NullCoalesceBinary::class));
|
||||
|
||||
if (!$left instanceof AbstractExpression) {
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "left" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($left));
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "left" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, $left::class);
|
||||
}
|
||||
if (!$right instanceof AbstractExpression) {
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "right" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($right));
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "right" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, $right::class);
|
||||
}
|
||||
|
||||
$test = new DefinedTest(clone $left, new TwigTest('defined'), new EmptyNode(), $left->getTemplateLine());
|
||||
|
||||
@@ -46,7 +46,7 @@ class DefinedTest extends TestExpression
|
||||
public function __construct(Node $node, TwigTest|string $name, ?Node $arguments, int $lineno)
|
||||
{
|
||||
if (!$node instanceof AbstractExpression) {
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($node));
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, $node::class);
|
||||
}
|
||||
|
||||
if ($node instanceof ContextVariable) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class TestExpression extends CallExpression
|
||||
public function __construct(Node $node, string|TwigTest $test, ?Node $arguments, int $lineno)
|
||||
{
|
||||
if (!$node instanceof AbstractExpression) {
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($node));
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, $node::class);
|
||||
}
|
||||
|
||||
$nodes = ['node' => $node];
|
||||
|
||||
@@ -24,7 +24,7 @@ abstract class AbstractUnary extends AbstractExpression implements UnaryInterfac
|
||||
public function __construct(Node $node, int $lineno)
|
||||
{
|
||||
if (!$node instanceof AbstractExpression) {
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance argument to "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, \get_class($node));
|
||||
trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance argument to "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, $node::class);
|
||||
}
|
||||
|
||||
parent::__construct(['node' => $node], ['with_parentheses' => false], $lineno);
|
||||
|
||||
@@ -149,9 +149,6 @@ class Node implements \Countable, \IteratorAggregate
|
||||
return \array_key_exists($name, $this->attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAttribute(string $name)
|
||||
{
|
||||
if (!\array_key_exists($name, $this->attributes)) {
|
||||
|
||||
@@ -34,7 +34,7 @@ class SetNode extends Node implements NodeCaptureInterface
|
||||
if ($capture) {
|
||||
$safe = true;
|
||||
// Node::class === get_class($values) should be removed in Twig 4.0
|
||||
if (($values instanceof Nodes || Node::class === \get_class($values)) && !\count($values)) {
|
||||
if (($values instanceof Nodes || Node::class === $values::class) && !\count($values)) {
|
||||
$values = new ConstantExpression('', $values->getTemplateLine());
|
||||
$capture = false;
|
||||
} elseif ($values instanceof TextNode) {
|
||||
|
||||
@@ -30,7 +30,7 @@ final class YieldNotReadyNodeVisitor implements NodeVisitorInterface
|
||||
|
||||
public function enterNode(Node $node, Environment $env): Node
|
||||
{
|
||||
$class = \get_class($node);
|
||||
$class = $node::class;
|
||||
|
||||
if ($node instanceof AbstractExpression || isset($this->yieldReadyNodes[$class])) {
|
||||
return $node;
|
||||
|
||||
+1
-1
@@ -549,7 +549,7 @@ class Parser
|
||||
// here, $nested means "being at the root level of a child template"
|
||||
// we need to discard the wrapping "Node" for the "body" node
|
||||
// Node::class !== \get_class($node) should be removed in Twig 4.0
|
||||
$nested = $nested || (Node::class !== \get_class($node) && !$node instanceof Nodes);
|
||||
$nested = $nested || (Node::class !== $node::class && !$node instanceof Nodes);
|
||||
foreach ($node as $k => $n) {
|
||||
if (null !== $n && null === $this->filterBodyNodes($n, $nested)) {
|
||||
$node->removeNode($k);
|
||||
|
||||
@@ -106,7 +106,7 @@ final class EscaperRuntime implements RuntimeExtensionInterface
|
||||
if (!\is_string($string)) {
|
||||
if ($string instanceof \Stringable) {
|
||||
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) {
|
||||
|
||||
@@ -107,7 +107,7 @@ final class SecurityPolicy implements SecurityPolicyInterface
|
||||
}
|
||||
|
||||
if (!$allowed) {
|
||||
$class = \get_class($obj);
|
||||
$class = $obj::class;
|
||||
throw new SecurityNotAllowedMethodError(\sprintf('Calling "%s" method on a "%s" object is not allowed.', $method, $class), $class, $method);
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ final class SecurityPolicy implements SecurityPolicyInterface
|
||||
}
|
||||
|
||||
if (!$allowed) {
|
||||
$class = \get_class($obj);
|
||||
$class = $obj::class;
|
||||
throw new SecurityNotAllowedPropertyError(\sprintf('Calling "%s" property on a "%s" object is not allowed.', $property, $class), $class, $property);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,14 +275,14 @@ abstract class IntegrationTestCase extends TestCase
|
||||
} catch (\Exception $e) {
|
||||
if (false !== $exception) {
|
||||
$message = $e->getMessage();
|
||||
$this->assertSame(trim($exception), trim(\sprintf('%s: %s', \get_class($e), $message)));
|
||||
$this->assertSame(trim($exception), trim(\sprintf('%s: %s', $e::class, $message)));
|
||||
$last = substr($message, \strlen($message) - 1);
|
||||
$this->assertTrue('.' === $last || '?' === $last, 'Exception message must end with a dot or a question mark.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(\sprintf('%s: %s', \get_class($e), $e->getMessage()), -1, null, $e);
|
||||
throw new Error(\sprintf('%s: %s', $e::class, $e->getMessage()), -1, null, $e);
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
}
|
||||
@@ -293,14 +293,14 @@ abstract class IntegrationTestCase extends TestCase
|
||||
$output = trim($template->render(eval($match[1].';')), "\n ");
|
||||
} catch (\Exception $e) {
|
||||
if (false !== $exception) {
|
||||
$this->assertStringMatchesFormat(trim($exception), trim(\sprintf('%s: %s', \get_class($e), $e->getMessage())));
|
||||
$this->assertStringMatchesFormat(trim($exception), trim(\sprintf('%s: %s', $e::class, $e->getMessage())));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$e = new Error(\sprintf('%s: %s', \get_class($e), $e->getMessage()), -1, null, $e);
|
||||
$e = new Error(\sprintf('%s: %s', $e::class, $e->getMessage()), -1, null, $e);
|
||||
|
||||
$output = trim(\sprintf('%s: %s', \get_class($e), $e->getMessage()));
|
||||
$output = trim(\sprintf('%s: %s', $e::class, $e->getMessage()));
|
||||
}
|
||||
|
||||
if (false !== $exception) {
|
||||
|
||||
@@ -134,9 +134,6 @@ final class Token
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
|
||||
@@ -16,18 +16,12 @@ namespace Twig\Util;
|
||||
*/
|
||||
class TemplateDirIterator extends \IteratorIterator
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current()
|
||||
{
|
||||
return file_get_contents(parent::current());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key()
|
||||
{
|
||||
|
||||
@@ -332,7 +332,7 @@ class EnvironmentTest extends TestCase
|
||||
$twig = new Environment($loader);
|
||||
$twig->addExtension($extension);
|
||||
|
||||
$this->assertInstanceOf(ExtensionInterface::class, $twig->getExtension(\get_class($extension)));
|
||||
$this->assertInstanceOf(ExtensionInterface::class, $twig->getExtension($extension::class));
|
||||
$this->assertTrue($twig->isTemplateFresh('page', time()));
|
||||
}
|
||||
|
||||
|
||||
@@ -307,7 +307,7 @@ class TwigTestExtension extends AbstractExtension
|
||||
|
||||
public function is_multi_word($value)
|
||||
{
|
||||
return false !== strpos($value, ' ');
|
||||
return str_contains($value, ' ');
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
|
||||
@@ -70,7 +70,7 @@ class OptimizerTest extends TestCase
|
||||
public function checkForVarConfiguration(Node $node, $target)
|
||||
{
|
||||
foreach ($node as $n) {
|
||||
if (NameExpression::class === \get_class($n) && $target === $n->getAttribute('name')) {
|
||||
if (NameExpression::class === $n::class && $target === $n->getAttribute('name')) {
|
||||
$this->assertTrue($n->getAttribute('always_defined'));
|
||||
} else {
|
||||
$this->checkForVarConfiguration($n, $target);
|
||||
|
||||
Reference in New Issue
Block a user