From 85a4817128d4df83d47a315270d29e94dd94bf62 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 10 Jul 2025 11:37:14 +0200 Subject: [PATCH] CS fixes --- .php-cs-fixer.dist.php | 14 +++++++++++--- bin/generate_operators_precedence.php | 12 ++++++------ doc/_build/build.php | 13 +++++++++++-- extra/cssinliner-extra/CssInlinerExtension.php | 4 ++-- extra/cssinliner-extra/Resources/functions.php | 4 ++-- extra/inky-extra/InkyExtension.php | 4 ++-- extra/inky-extra/Resources/functions.php | 4 ++-- extra/markdown-extra/DefaultMarkdown.php | 3 +-- extra/markdown-extra/ErusevMarkdown.php | 6 ++---- .../Compiler/MissingExtensionSuggestorPass.php | 4 ++-- .../twig-extra-bundle/Tests/Fixture/Kernel.php | 9 +++++++++ .../Tests/IntegrationTest.php | 9 +++++++++ src/Attribute/AsTwigFilter.php | 18 +++++++++--------- src/Attribute/AsTwigFunction.php | 14 +++++++------- src/Attribute/AsTwigTest.php | 10 +++++----- src/Error/Error.php | 2 +- src/Extension/AttributeExtension.php | 7 +++---- src/Node/Expression/Binary/MatchesBinary.php | 2 +- .../FunctionNode/EnumCasesFunction.php | 9 +++++++++ .../Expression/FunctionNode/EnumFunction.php | 9 +++++++++ src/Node/Expression/GetAttrExpression.php | 4 ++-- src/Node/Expression/Test/DefinedTest.php | 8 -------- src/Node/TypesNode.php | 9 +++++++++ src/Resources/debug.php | 4 ++-- src/Resources/string_loader.php | 4 ++-- src/Runtime/EscaperRuntime.php | 2 +- src/Template.php | 4 ++-- tests/Cache/ChainTest.php | 9 +++++++++ tests/Cache/FilesystemTest.php | 9 +++++++++ tests/Cache/ReadOnlyFilesystemTest.php | 9 +++++++++ tests/CompilerTest.php | 9 +++++++++ tests/ContainerRuntimeLoaderTest.php | 9 +++++++++ tests/CustomExtensionTest.php | 9 +++++++++ tests/DeprecatedCallableInfoTest.php | 9 +++++++++ tests/DummyBackedEnum.php | 9 +++++++++ tests/DummyUnitEnum.php | 9 +++++++++ tests/EnvironmentTest.php | 9 +++++++++ tests/ErrorTest.php | 14 +++++++++++--- tests/ExpressionParserTest.php | 9 +++++++++ tests/Extension/AttributeExtensionTest.php | 17 +++++++++++++---- tests/Extension/CoreTest.php | 9 +++++++++ tests/Extension/EscaperTest.php | 9 +++++++++ .../Fixtures/ExtensionWithAttributes.php | 9 +++++++++ .../Extension/Fixtures/FilterWithoutValue.php | 9 +++++++++ tests/Extension/Fixtures/TestWithoutValue.php | 9 +++++++++ tests/Extension/SandboxTest.php | 9 +++++++++ tests/FactoryRuntimeLoaderTest.php | 9 +++++++++ tests/FileExtensionEscapingStrategyTest.php | 9 +++++++++ tests/FilesystemHelper.php | 9 +++++++++ tests/IntegrationTest.php | 9 +++++++++ tests/LexerTest.php | 9 +++++++++ tests/Loader/ArrayTest.php | 9 +++++++++ tests/Loader/ChainTest.php | 9 +++++++++ tests/Loader/FilesystemTest.php | 9 +++++++++ tests/Node/AutoEscapeTest.php | 9 +++++++++ tests/Node/BlockReferenceTest.php | 9 +++++++++ tests/Node/BlockTest.php | 9 +++++++++ tests/Node/DeprecatedTest.php | 9 +++++++++ tests/Node/DoTest.php | 9 +++++++++ tests/Node/Expression/ArrayTest.php | 9 +++++++++ tests/Node/Expression/Binary/AddTest.php | 9 +++++++++ tests/Node/Expression/Binary/AndTest.php | 9 +++++++++ tests/Node/Expression/Binary/ConcatTest.php | 9 +++++++++ tests/Node/Expression/Binary/DivTest.php | 9 +++++++++ tests/Node/Expression/Binary/FloorDivTest.php | 9 +++++++++ tests/Node/Expression/Binary/ModTest.php | 9 +++++++++ tests/Node/Expression/Binary/MulTest.php | 9 +++++++++ .../Expression/Binary/NullCoalesceTest.php | 9 +++++++++ tests/Node/Expression/Binary/OrTest.php | 9 +++++++++ tests/Node/Expression/Binary/SubTest.php | 9 +++++++++ tests/Node/Expression/CallTest.php | 9 +++++++++ tests/Node/Expression/ConditionalTest.php | 9 +++++++++ tests/Node/Expression/ConstantTest.php | 9 +++++++++ tests/Node/Expression/Filter/RawTest.php | 9 +++++++++ tests/Node/Expression/FilterTest.php | 9 +++++++++ tests/Node/Expression/FilterTestExtension.php | 9 +++++++++ tests/Node/Expression/FunctionTest.php | 9 +++++++++ tests/Node/Expression/GetAttrTest.php | 9 +++++++++ tests/Node/Expression/NullCoalesceTest.php | 9 +++++++++ tests/Node/Expression/ParentTest.php | 9 +++++++++ .../Ternary/ConditionalTernaryTest.php | 9 +++++++++ tests/Node/Expression/TestTest.php | 9 +++++++++ tests/Node/Expression/Unary/NegTest.php | 9 +++++++++ tests/Node/Expression/Unary/NotTest.php | 9 +++++++++ tests/Node/Expression/Unary/PosTest.php | 9 +++++++++ .../Variable/AssignContextVariableTest.php | 9 +++++++++ .../Variable/ContextVariableTest.php | 9 +++++++++ tests/Node/ForTest.php | 9 +++++++++ tests/Node/IfTest.php | 9 +++++++++ tests/Node/ImportTest.php | 9 +++++++++ tests/Node/IncludeTest.php | 9 +++++++++ tests/Node/MacroTest.php | 9 +++++++++ tests/Node/ModuleTest.php | 9 +++++++++ tests/Node/NodeTest.php | 9 +++++++++ tests/Node/PrintTest.php | 9 +++++++++ tests/Node/SandboxTest.php | 9 +++++++++ tests/Node/SetTest.php | 9 +++++++++ tests/Node/TextTest.php | 9 +++++++++ tests/Node/TypesTest.php | 9 +++++++++ tests/NodeVisitor/OptimizerTest.php | 9 +++++++++ tests/NodeVisitor/SandboxTest.php | 9 +++++++++ tests/ParserTest.php | 9 +++++++++ tests/Profiler/Dumper/BlackfireTest.php | 9 +++++++++ tests/Profiler/Dumper/HtmlTest.php | 9 +++++++++ tests/Profiler/Dumper/ProfilerTestCase.php | 9 +++++++++ tests/Profiler/Dumper/TextTest.php | 9 +++++++++ tests/Profiler/ProfileTest.php | 9 +++++++++ tests/Runtime/EscaperRuntimeTest.php | 9 +++++++++ tests/TemplateTest.php | 9 +++++++++ tests/TemplateWrapperTest.php | 9 +++++++++ tests/TokenParser/GuardTokenParserTest.php | 9 +++++++++ tests/TokenParser/TypesTokenParserTest.php | 9 +++++++++ tests/TokenStreamTest.php | 9 +++++++++ tests/Util/CallableArgumentsExtractorTest.php | 9 +++++++++ tests/Util/DeprecationCollectorTest.php | 9 +++++++++ 115 files changed, 919 insertions(+), 78 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 5c3a731a1..b57df306a 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -13,9 +13,17 @@ return (new PhpCsFixer\Config()) 'heredoc_to_nowdoc' => false, 'ordered_imports' => true, 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], - // TODO: Remove once the "compiler_optimized" set includes "sprintf" - 'native_function_invocation' => ['include' => ['@compiler_optimized', 'sprintf'], 'scope' => 'all'], - ]) + 'header_comment' => [ + 'header' => <<setRiskyAllowed(true) ->setFinder((new PhpCsFixer\Finder())->in(__DIR__)) ; diff --git a/bin/generate_operators_precedence.php b/bin/generate_operators_precedence.php index 31477be62..185a0147e 100644 --- a/bin/generate_operators_precedence.php +++ b/bin/generate_operators_precedence.php @@ -16,9 +16,9 @@ use Twig\ExpressionParser\InfixAssociativity; use Twig\ExpressionParser\InfixExpressionParserInterface; use Twig\Loader\ArrayLoader; -require_once \dirname(__DIR__).'/vendor/autoload.php'; +require_once dirname(__DIR__).'/vendor/autoload.php'; -$output = fopen(\dirname(__DIR__).'/doc/operators_precedence.rst', 'w'); +$output = fopen(dirname(__DIR__).'/doc/operators_precedence.rst', 'w'); $twig = new Environment(new ArrayLoader([])); $descriptionLength = 11; @@ -29,7 +29,7 @@ foreach ($twig->getExpressionParsers() as $expressionParser) { } fwrite($output, "\n+------------+------------------+---------+---------------+".str_repeat('-', $descriptionLength + 2)."+\n"); -fwrite($output, "| Precedence | Operator | Type | Associativity | Description".str_repeat(' ', $descriptionLength - 11)." |\n"); +fwrite($output, '| Precedence | Operator | Type | Associativity | Description'.str_repeat(' ', $descriptionLength - 11)." |\n"); fwrite($output, '+============+==================+=========+===============+'.str_repeat('=', $descriptionLength + 2).'+'); usort($expressionParsers, fn ($a, $b) => $b->getPrecedence() <=> $a->getPrecedence()); @@ -46,7 +46,7 @@ foreach ($expressionParsers as $expressionParser) { if ($previousPrecedence !== $precedence) { $previous = null; } - fwrite($output, rtrim(\sprintf("\n| %-10s | %-16s | %-7s | %-13s | %-{$descriptionLength}s |\n", + fwrite($output, rtrim(sprintf("\n| %-10s | %-16s | %-7s | %-13s | %-{$descriptionLength}s |\n", (!$previous || $previousPrecedence !== $precedence ? $precedence : '').($expressionParser->getPrecedenceChange() ? ' => '.$expressionParser->getPrecedenceChange()->getNewPrecedence() : ''), '``'.$expressionParser->getName().'``', !$previous || ExpressionParserType::getType($previous) !== ExpressionParserType::getType($expressionParser) ? ExpressionParserType::getType($expressionParser)->value : '', @@ -61,7 +61,7 @@ fwrite($output, "\nWhen a precedence will change in 4.0, the new precedence is i fwrite($output, "\nHere is the same table for Twig 4.0 with adjusted precedences:\n"); fwrite($output, "\n+------------+------------------+---------+---------------+".str_repeat('-', $descriptionLength + 2)."+\n"); -fwrite($output, "| Precedence | Operator | Type | Associativity | Description".str_repeat(' ', $descriptionLength - 11)." |\n"); +fwrite($output, '| Precedence | Operator | Type | Associativity | Description'.str_repeat(' ', $descriptionLength - 11)." |\n"); fwrite($output, '+============+==================+=========+===============+'.str_repeat('=', $descriptionLength + 2).'+'); usort($expressionParsers, function ($a, $b) { @@ -83,7 +83,7 @@ foreach ($expressionParsers as $expressionParser) { if ($previousPrecedence !== $precedence) { $previous = null; } - fwrite($output, rtrim(\sprintf("\n| %-10s | %-16s | %-7s | %-13s | %-{$descriptionLength}s |\n", + fwrite($output, rtrim(sprintf("\n| %-10s | %-16s | %-7s | %-13s | %-{$descriptionLength}s |\n", !$previous || $previousPrecedence !== $precedence ? $precedence : '', '``'.$expressionParser->getName().'``', !$previous || ExpressionParserType::getType($previous) !== ExpressionParserType::getType($expressionParser) ? ExpressionParserType::getType($expressionParser)->value : '', diff --git a/doc/_build/build.php b/doc/_build/build.php index 2b183b186..25950f789 100755 --- a/doc/_build/build.php +++ b/doc/_build/build.php @@ -1,6 +1,15 @@ #!/usr/bin/env php success(\sprintf('The Twig docs were successfully built at %s', realpath($outputDir))); + $io->success(sprintf('The Twig docs were successfully built at %s', realpath($outputDir))); } else { - $io->error(\sprintf("There were some errors while building the docs:\n\n%s\n", $result->getErrorTrace())); + $io->error(sprintf("There were some errors while building the docs:\n\n%s\n", $result->getErrorTrace())); $io->newLine(); $io->comment('Tip: you can add the -v, -vv or -vvv flags to this command to get debug information.'); diff --git a/extra/cssinliner-extra/CssInlinerExtension.php b/extra/cssinliner-extra/CssInlinerExtension.php index 94d3c4b7f..0447b4df0 100644 --- a/extra/cssinliner-extra/CssInlinerExtension.php +++ b/extra/cssinliner-extra/CssInlinerExtension.php @@ -1,9 +1,9 @@ + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/extra/cssinliner-extra/Resources/functions.php b/extra/cssinliner-extra/Resources/functions.php index 60305e231..d2bcecafd 100644 --- a/extra/cssinliner-extra/Resources/functions.php +++ b/extra/cssinliner-extra/Resources/functions.php @@ -1,9 +1,9 @@ + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/extra/inky-extra/InkyExtension.php b/extra/inky-extra/InkyExtension.php index 9ee4f823a..b8ac22da9 100644 --- a/extra/inky-extra/InkyExtension.php +++ b/extra/inky-extra/InkyExtension.php @@ -1,9 +1,9 @@ + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/extra/inky-extra/Resources/functions.php b/extra/inky-extra/Resources/functions.php index 0fa4111de..9ebe92045 100644 --- a/extra/inky-extra/Resources/functions.php +++ b/extra/inky-extra/Resources/functions.php @@ -1,9 +1,9 @@ + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/extra/markdown-extra/DefaultMarkdown.php b/extra/markdown-extra/DefaultMarkdown.php index 6650a661a..a20993d45 100644 --- a/extra/markdown-extra/DefaultMarkdown.php +++ b/extra/markdown-extra/DefaultMarkdown.php @@ -13,7 +13,6 @@ namespace Twig\Extra\Markdown; use League\CommonMark\CommonMarkConverter; use Michelf\MarkdownExtra; -use Parsedown; class DefaultMarkdown implements MarkdownInterface { @@ -25,7 +24,7 @@ class DefaultMarkdown implements MarkdownInterface $this->converter = new LeagueMarkdown(); } elseif (class_exists(MarkdownExtra::class)) { $this->converter = new MichelfMarkdown(); - } elseif (class_exists(Parsedown::class)) { + } elseif (class_exists(\Parsedown::class)) { $this->converter = new ErusevMarkdown(); } else { throw new \LogicException('You cannot use the "markdown_to_html" filter as no Markdown library is available; try running "composer require league/commonmark".'); diff --git a/extra/markdown-extra/ErusevMarkdown.php b/extra/markdown-extra/ErusevMarkdown.php index 47b030893..923cf0eeb 100644 --- a/extra/markdown-extra/ErusevMarkdown.php +++ b/extra/markdown-extra/ErusevMarkdown.php @@ -11,15 +11,13 @@ namespace Twig\Extra\Markdown; -use Parsedown; - class ErusevMarkdown implements MarkdownInterface { private $converter; - public function __construct(?Parsedown $converter = null) + public function __construct(?\Parsedown $converter = null) { - $this->converter = $converter ?: new Parsedown(); + $this->converter = $converter ?: new \Parsedown(); } public function convert(string $body): string diff --git a/extra/twig-extra-bundle/DependencyInjection/Compiler/MissingExtensionSuggestorPass.php b/extra/twig-extra-bundle/DependencyInjection/Compiler/MissingExtensionSuggestorPass.php index 83c6643f0..0ab51cb2d 100644 --- a/extra/twig-extra-bundle/DependencyInjection/Compiler/MissingExtensionSuggestorPass.php +++ b/extra/twig-extra-bundle/DependencyInjection/Compiler/MissingExtensionSuggestorPass.php @@ -1,9 +1,9 @@ + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/extra/twig-extra-bundle/Tests/Fixture/Kernel.php b/extra/twig-extra-bundle/Tests/Fixture/Kernel.php index faad85c18..8986f8ecd 100644 --- a/extra/twig-extra-bundle/Tests/Fixture/Kernel.php +++ b/extra/twig-extra-bundle/Tests/Fixture/Kernel.php @@ -1,5 +1,14 @@ getTrace(); - array_unshift($traces, ['file' => $e instanceof Error ? $e->phpFile : $e->getFile(), 'line' => $e instanceof Error ? $e->phpLine : $e->getLine()]); + array_unshift($traces, ['file' => $e instanceof self ? $e->phpFile : $e->getFile(), 'line' => $e instanceof self ? $e->phpLine : $e->getLine()]); while ($trace = array_shift($traces)) { if (!isset($trace['file']) || !isset($trace['line']) || $file != $trace['file']) { continue; diff --git a/src/Extension/AttributeExtension.php b/src/Extension/AttributeExtension.php index 44e4f3f6b..74fcbb857 100644 --- a/src/Extension/AttributeExtension.php +++ b/src/Extension/AttributeExtension.php @@ -104,7 +104,7 @@ final class AttributeExtension extends AbstractExtension ]); if ($callable->getMinimalNumberOfRequiredArguments() > $method->getNumberOfParameters()) { - throw new \LogicException(sprintf('"%s::%s()" needs at least %d arguments to be used AsTwigFilter, but only %d defined.', $reflectionClass->getName(), $method->getName(), $callable->getMinimalNumberOfRequiredArguments(), $method->getNumberOfParameters())); + throw new \LogicException(\sprintf('"%s::%s()" needs at least %d arguments to be used AsTwigFilter, but only %d defined.', $reflectionClass->getName(), $method->getName(), $callable->getMinimalNumberOfRequiredArguments(), $method->getNumberOfParameters())); } $filters[$attribute->name] = $callable; @@ -125,14 +125,13 @@ final class AttributeExtension extends AbstractExtension ]); if ($callable->getMinimalNumberOfRequiredArguments() > $method->getNumberOfParameters()) { - throw new \LogicException(sprintf('"%s::%s()" needs at least %d arguments to be used AsTwigFunction, but only %d defined.', $reflectionClass->getName(), $method->getName(), $callable->getMinimalNumberOfRequiredArguments(), $method->getNumberOfParameters())); + throw new \LogicException(\sprintf('"%s::%s()" needs at least %d arguments to be used AsTwigFunction, but only %d defined.', $reflectionClass->getName(), $method->getName(), $callable->getMinimalNumberOfRequiredArguments(), $method->getNumberOfParameters())); } $functions[$attribute->name] = $callable; } foreach ($method->getAttributes(AsTwigTest::class) as $reflectionAttribute) { - /** @var AsTwigTest $attribute */ $attribute = $reflectionAttribute->newInstance(); @@ -145,7 +144,7 @@ final class AttributeExtension extends AbstractExtension ]); if ($callable->getMinimalNumberOfRequiredArguments() > $method->getNumberOfParameters()) { - throw new \LogicException(sprintf('"%s::%s()" needs at least %d arguments to be used AsTwigTest, but only %d defined.', $reflectionClass->getName(), $method->getName(), $callable->getMinimalNumberOfRequiredArguments(), $method->getNumberOfParameters())); + throw new \LogicException(\sprintf('"%s::%s()" needs at least %d arguments to be used AsTwigTest, but only %d defined.', $reflectionClass->getName(), $method->getName(), $callable->getMinimalNumberOfRequiredArguments(), $method->getNumberOfParameters())); } $tests[$attribute->name] = $callable; diff --git a/src/Node/Expression/Binary/MatchesBinary.php b/src/Node/Expression/Binary/MatchesBinary.php index 32e8d34e4..569dfde05 100644 --- a/src/Node/Expression/Binary/MatchesBinary.php +++ b/src/Node/Expression/Binary/MatchesBinary.php @@ -13,8 +13,8 @@ namespace Twig\Node\Expression\Binary; use Twig\Compiler; use Twig\Error\SyntaxError; -use Twig\Node\Expression\ReturnBoolInterface; use Twig\Node\Expression\ConstantExpression; +use Twig\Node\Expression\ReturnBoolInterface; use Twig\Node\Node; class MatchesBinary extends AbstractBinary implements ReturnBoolInterface diff --git a/src/Node/Expression/FunctionNode/EnumCasesFunction.php b/src/Node/Expression/FunctionNode/EnumCasesFunction.php index 7e5c25ff4..170d0a13b 100644 --- a/src/Node/Expression/FunctionNode/EnumCasesFunction.php +++ b/src/Node/Expression/FunctionNode/EnumCasesFunction.php @@ -1,5 +1,14 @@ setAttribute('optimizable', false); $node->setAttribute('ignore_strict_check', true); - if ($node->getNode('node') instanceof GetAttrExpression) { + if ($node->getNode('node') instanceof self) { $this->changeIgnoreStrictCheck($node->getNode('node')); } } diff --git a/src/Node/Expression/Test/DefinedTest.php b/src/Node/Expression/Test/DefinedTest.php index f17715bc6..d73502990 100644 --- a/src/Node/Expression/Test/DefinedTest.php +++ b/src/Node/Expression/Test/DefinedTest.php @@ -15,16 +15,8 @@ use Twig\Attribute\FirstClassTwigCallableReady; use Twig\Compiler; use Twig\Error\SyntaxError; use Twig\Node\Expression\AbstractExpression; -use Twig\Node\Expression\ArrayExpression; -use Twig\Node\Expression\BlockReferenceExpression; -use Twig\Node\Expression\ConstantExpression; -use Twig\Node\Expression\FunctionExpression; -use Twig\Node\Expression\GetAttrExpression; -use Twig\Node\Expression\MacroReferenceExpression; -use Twig\Node\Expression\MethodCallExpression; use Twig\Node\Expression\SupportDefinedTestInterface; use Twig\Node\Expression\TestExpression; -use Twig\Node\Expression\Variable\ContextVariable; use Twig\Node\Node; use Twig\TwigTest; diff --git a/src/Node/TypesNode.php b/src/Node/TypesNode.php index b5949848d..a18288083 100644 --- a/src/Node/TypesNode.php +++ b/src/Node/TypesNode.php @@ -1,5 +1,14 @@ + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Resources/string_loader.php b/src/Resources/string_loader.php index 8f0e6492a..c499e5ec2 100644 --- a/src/Resources/string_loader.php +++ b/src/Resources/string_loader.php @@ -1,9 +1,9 @@ + * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Runtime/EscaperRuntime.php b/src/Runtime/EscaperRuntime.php index 17ed76cc9..3b3148fae 100644 --- a/src/Runtime/EscaperRuntime.php +++ b/src/Runtime/EscaperRuntime.php @@ -17,7 +17,7 @@ use Twig\Markup; final class EscaperRuntime implements RuntimeExtensionInterface { - /** @var array */ + /** @var array */ private $escapers = []; /** @internal */ diff --git a/src/Template.php b/src/Template.php index faf7aee1e..c37209287 100644 --- a/src/Template.php +++ b/src/Template.php @@ -270,7 +270,7 @@ abstract class Template /** * @param string|TemplateWrapper|array $template */ - protected function load(string|TemplateWrapper|array $template, int $line, int|null $index = null): self + protected function load(string|TemplateWrapper|array $template, int $line, ?int $index = null): self { try { if (\is_array($template)) { @@ -315,7 +315,7 @@ abstract class Template * * @deprecated since Twig 3.21 and will be removed in 4.0. Use Template::load() instead. */ - protected function loadTemplate($template, $templateName = null, int|null $line = null, int|null $index = null): self|TemplateWrapper + protected function loadTemplate($template, $templateName = null, ?int $line = null, ?int $index = null): self|TemplateWrapper { trigger_deprecation('twig/twig', '3.21', 'The "%s" method is deprecated.', __METHOD__); diff --git a/tests/Cache/ChainTest.php b/tests/Cache/ChainTest.php index 3120ab188..4383e6034 100644 --- a/tests/Cache/ChainTest.php +++ b/tests/Cache/ChainTest.php @@ -1,5 +1,14 @@ getCurrent()->getLine(); $stream->expect(Token::BLOCK_END_TYPE); - return new #[YieldReady]class($lineno, $this->addDebugInfo, $this->exceptionWithLineAndContext) extends Node - { + return new #[YieldReady] class($lineno, $this->addDebugInfo, $this->exceptionWithLineAndContext) extends Node { public function __construct(int $lineno, private bool $addDebugInfo, private bool $exceptionWithLineAndContext) { parent::__construct([], [], $lineno); @@ -295,7 +303,7 @@ EOHTML, if ($this->exceptionWithLineAndContext) { $compiler ->write('throw new \Twig\Error\RuntimeError("Runtime error.", ') - ->repr($this->lineno)->raw(", \$this->getSourceContext()") + ->repr($this->lineno)->raw(', $this->getSourceContext()') ->raw(");\n") ; } else { diff --git a/tests/ExpressionParserTest.php b/tests/ExpressionParserTest.php index f13405292..4f1685820 100644 --- a/tests/ExpressionParserTest.php +++ b/tests/ExpressionParserTest.php @@ -1,5 +1,14 @@ fail(sprintf('Filter "%s" is not registered.', $name)); + $this->fail(\sprintf('Filter "%s" is not registered.', $name)); } public static function provideFilters() @@ -58,7 +67,7 @@ class AttributeExtensionTest extends TestCase } } - $this->fail(sprintf('Function "%s" is not registered.', $name)); + $this->fail(\sprintf('Function "%s" is not registered.', $name)); } public static function provideFunctions() @@ -86,7 +95,7 @@ class AttributeExtensionTest extends TestCase } } - $this->fail(sprintf('Test "%s" is not registered.', $name)); + $this->fail(\sprintf('Test "%s" is not registered.', $name)); } public static function provideTests() diff --git a/tests/Extension/CoreTest.php b/tests/Extension/CoreTest.php index bbea3d56c..10d7e881d 100644 --- a/tests/Extension/CoreTest.php +++ b/tests/Extension/CoreTest.php @@ -1,5 +1,14 @@