mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-19 05:46:41 +00:00
Fix CS
This commit is contained in:
@@ -113,10 +113,10 @@ final class HtmlExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|list<string|null> $base
|
||||
* @param string|list<string|null> $base
|
||||
* @param array<string, array<string, string|array<string>> $variants
|
||||
* @param array<array<string, string|array<string>>> $compoundVariants
|
||||
* @param array<string, string> $defaultVariant
|
||||
* @param array<array<string, string|array<string>>> $compoundVariants
|
||||
* @param array<string, string> $defaultVariant
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use Symfony\Component\ErrorHandler\ErrorHandler;
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
// see https://github.com/symfony/symfony/issues/53812#issuecomment-1962740145
|
||||
set_exception_handler([new ErrorHandler(), 'handleException']);
|
||||
|
||||
@@ -22,7 +22,6 @@ use Twig\Node\Expression\Binary\ConcatBinary;
|
||||
use Twig\Node\Expression\ConstantExpression;
|
||||
use Twig\Node\Expression\GetAttrExpression;
|
||||
use Twig\Node\Expression\MacroReferenceExpression;
|
||||
use Twig\Node\Expression\NameExpression;
|
||||
use Twig\Node\Expression\Ternary\ConditionalTernary;
|
||||
use Twig\Node\Expression\TestExpression;
|
||||
use Twig\Node\Expression\Unary\AbstractUnary;
|
||||
@@ -782,7 +781,7 @@ class ExpressionParser
|
||||
$name = null;
|
||||
if (($token = $stream->nextIf(Token::OPERATOR_TYPE, '=')) || ($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');
|
||||
$value = $this->parseExpression();
|
||||
@@ -830,8 +829,7 @@ class ExpressionParser
|
||||
|
||||
if (
|
||||
$node instanceof ContextVariable
|
||||
&&
|
||||
(
|
||||
&& (
|
||||
null !== $this->parser->getImportedSymbol('template', $node->getAttribute('name'))
|
||||
|| '_self' === $node->getAttribute('name') && $attribute instanceof ConstantExpression
|
||||
)
|
||||
|
||||
@@ -378,7 +378,7 @@ final class CoreExtension extends AbstractExtension
|
||||
throw new RuntimeError('The "cycle" function expects an array or "ArrayAccess" as first argument.');
|
||||
}
|
||||
|
||||
if (!\is_countable($values)) {
|
||||
if (!is_countable($values)) {
|
||||
throw new RuntimeError('The "cycle" function expects a countable sequence as first argument.');
|
||||
}
|
||||
|
||||
@@ -504,7 +504,6 @@ final class CoreExtension extends AbstractExtension
|
||||
* Returns a formatted string.
|
||||
*
|
||||
* @param string|null $format
|
||||
* @param ...$values
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
|
||||
+1
-1
@@ -433,7 +433,7 @@ class Lexer
|
||||
|
||||
if (isset(self::SPECIAL_CHARS[$nextChar])) {
|
||||
$result .= self::SPECIAL_CHARS[$nextChar];
|
||||
} elseif ($nextChar === '\\' || $nextChar === $quoteType) {
|
||||
} elseif ('\\' === $nextChar || $nextChar === $quoteType) {
|
||||
$result .= $nextChar;
|
||||
} elseif ('#' === $nextChar && $i + 1 < $length && '{' === $str[$i + 1]) {
|
||||
$result .= '#{';
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace Twig\Node\Expression;
|
||||
|
||||
use Twig\Compiler;
|
||||
use Twig\Extension\ExtensionInterface;
|
||||
use Twig\TwigCallableInterface;
|
||||
use Twig\Util\CallableArgumentsExtractor;
|
||||
use Twig\Util\ReflectionCallable;
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace Twig\Node\Expression\Variable;
|
||||
|
||||
use Twig\Compiler;
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\Node\Expression\Variable\ContextVariable;
|
||||
|
||||
final class AssignContextVariable extends ContextVariable
|
||||
{
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
namespace Twig\Node\Expression\Variable;
|
||||
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\Compiler;
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\Node\Expression\AbstractExpression;
|
||||
|
||||
final class LocalVariable extends AbstractExpression
|
||||
@@ -26,9 +26,9 @@ final class LocalVariable extends AbstractExpression
|
||||
throw new SyntaxError(\sprintf('You cannot assign a value to "%s".', $name), $lineno);
|
||||
}
|
||||
|
||||
if (null !== $name && (is_int($name) || ctype_digit($name))) {
|
||||
if (null !== $name && (\is_int($name) || ctype_digit($name))) {
|
||||
$name = (int) $name;
|
||||
} elseif (in_array($name, self::RESERVED_NAMES)) {
|
||||
} elseif (\in_array($name, self::RESERVED_NAMES)) {
|
||||
$name = "\u{035C}".$name;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ final class TemplateVariable extends AbstractExpression
|
||||
throw new SyntaxError(\sprintf('You cannot assign a value to "%s".', $name), $lineno);
|
||||
}
|
||||
|
||||
if (null !== $name && (is_int($name) || ctype_digit($name))) {
|
||||
if (null !== $name && (\is_int($name) || ctype_digit($name))) {
|
||||
$name = (int) $name;
|
||||
} elseif (in_array($name, self::RESERVED_NAMES)) {
|
||||
} elseif (\in_array($name, self::RESERVED_NAMES)) {
|
||||
$name = "\u{035C}".$name;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class ForNode extends Node
|
||||
}
|
||||
|
||||
$compiler
|
||||
->write("foreach (\$iterator as ")
|
||||
->write('foreach ($iterator as ')
|
||||
->subcompile($this->getNode('key_target'))
|
||||
->raw(' => ')
|
||||
->subcompile($this->getNode('value_target'))
|
||||
|
||||
@@ -15,7 +15,6 @@ use Twig\Attribute\YieldReady;
|
||||
use Twig\Compiler;
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\Node\Expression\ArrayExpression;
|
||||
use Twig\Node\Expression\Variable\LocalVariable;
|
||||
|
||||
/**
|
||||
* Represents a macro node.
|
||||
|
||||
@@ -33,7 +33,7 @@ class SetNode extends Node implements NodeCaptureInterface
|
||||
$safe = false;
|
||||
if ($capture) {
|
||||
$safe = true;
|
||||
if ($values instanceof Nodes && !count($values)) {
|
||||
if ($values instanceof Nodes && !\count($values)) {
|
||||
$values = new ConstantExpression('', $values->getTemplateLine());
|
||||
$capture = false;
|
||||
} elseif ($values instanceof TextNode) {
|
||||
|
||||
@@ -58,7 +58,7 @@ final class OptimizerNodeVisitor implements NodeVisitorInterface
|
||||
public function __construct(
|
||||
private int $optimizers = -1,
|
||||
) {
|
||||
if ($optimizers > (self::OPTIMIZE_FOR)) {
|
||||
if ($optimizers > self::OPTIMIZE_FOR) {
|
||||
throw new \InvalidArgumentException(\sprintf('Optimizer mode "%s" is not valid.', $optimizers));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ use Twig\Node\Expression\Binary\RangeBinary;
|
||||
use Twig\Node\Expression\FilterExpression;
|
||||
use Twig\Node\Expression\FunctionExpression;
|
||||
use Twig\Node\Expression\GetAttrExpression;
|
||||
use Twig\Node\Expression\Variable\ContextVariable;
|
||||
use Twig\Node\Expression\Unary\SpreadUnary;
|
||||
use Twig\Node\Expression\Variable\ContextVariable;
|
||||
use Twig\Node\ModuleNode;
|
||||
use Twig\Node\Node;
|
||||
use Twig\Node\Nodes;
|
||||
|
||||
@@ -17,9 +17,7 @@ use Twig\Node\BlockNode;
|
||||
use Twig\Node\BlockReferenceNode;
|
||||
use Twig\Node\BodyNode;
|
||||
use Twig\Node\EmptyNode;
|
||||
use Twig\Node\Expression\AbstractExpression;
|
||||
use Twig\Node\Expression\Variable\AssignTemplateVariable;
|
||||
use Twig\Node\Expression\Variable\TemplateVariable;
|
||||
use Twig\Node\MacroNode;
|
||||
use Twig\Node\ModuleNode;
|
||||
use Twig\Node\Node;
|
||||
|
||||
@@ -22,6 +22,7 @@ use Twig\Error\RuntimeError;
|
||||
*
|
||||
* @template TKey
|
||||
* @template TValue
|
||||
*
|
||||
* @implements \Iterator<TKey, TValue>
|
||||
*/
|
||||
final class LoopIterator implements \Iterator
|
||||
|
||||
@@ -287,6 +287,7 @@ abstract class Template
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function unwrap(): self
|
||||
|
||||
@@ -30,7 +30,7 @@ class DeprecatedCallableInfoTest extends TestCase
|
||||
if (\E_USER_DEPRECATED === $type) {
|
||||
$deprecations[] = $msg;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -62,7 +62,7 @@ class DeprecatedCallableInfoTest extends TestCase
|
||||
if (\E_USER_DEPRECATED === $type) {
|
||||
$deprecations[] = $msg;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace Twig\Tests\Extension;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\Environment;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\Extension\SandboxExtension;
|
||||
use Twig\Extension\StringLoaderExtension;
|
||||
|
||||
@@ -114,7 +114,7 @@ class FilterTest extends NodeTestCase
|
||||
|
||||
// from extension
|
||||
$node = self::createFilter($environment, $string, 'foo');
|
||||
$tests[] = [$node, \sprintf('$this->extensions[\'%s\']->foo("abc")', get_class(self::createExtension())), $environment];
|
||||
$tests[] = [$node, \sprintf('$this->extensions[\'%s\']->foo("abc")', \get_class(self::createExtension())), $environment];
|
||||
|
||||
$node = self::createFilter($environment, $string, 'foobar');
|
||||
$tests[] = [$node, '$this->env->getFilter(\'foobar\')->getCallable()("abc")', $environment];
|
||||
|
||||
Reference in New Issue
Block a user