minor #4542 Fix CS (fabpot)

This PR was merged into the 3.x branch.

Discussion
----------

Fix CS

Commits
-------

76062c8d51 Fix CS
This commit is contained in:
Fabien Potencier
2025-01-19 17:25:16 +01:00
13 changed files with 26 additions and 25 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ class IntegrationTest extends IntegrationTestCase
protected function getRuntimeLoaders()
{
return [
new class() implements RuntimeLoaderInterface {
new class implements RuntimeLoaderInterface {
public function load(string $class): ?object
{
return CacheRuntime::class === $class ? new CacheRuntime(new ArrayAdapter()) : null;
@@ -37,7 +37,7 @@ Hello
=====
Great!
EOF
EOF,
]));
$twig->addExtension(new MarkdownExtension());
$twig->addRuntimeLoader(new class($class) implements RuntimeLoaderInterface {
+1 -1
View File
@@ -53,7 +53,7 @@ abstract class AbstractExtension implements LastModifiedExtensionInterface
$lastModified = filemtime($filename);
// Track modifications of the runtime class if it exists and follows the naming convention
if (str_ends_with($filename, 'Extension.php') && is_file($filename = substr($filename, 0, -13) . 'Runtime.php')) {
if (str_ends_with($filename, 'Extension.php') && is_file($filename = substr($filename, 0, -13).'Runtime.php')) {
$lastModified = max($lastModified, filemtime($filename));
}
+1 -1
View File
@@ -917,7 +917,7 @@ final class CoreExtension extends AbstractExtension
}
/**
* Invokes a callable
* Invokes a callable.
*
* @internal
*/
+1 -1
View File
@@ -53,7 +53,7 @@ class Lexer
(?<DNUM>(?&LNUM)(?:(?&FRAC))?) # Decimal number 123_456.456
)(?:(?&DNUM)(?:(?&EXPONENT))?) # 123_456.456E+10
/Ax';
public const REGEX_DQ_STRING_DELIM = '/"/A';
public const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As';
public const REGEX_INLINE_COMMENT = '/#[^\n]*/A';
+2 -1
View File
@@ -318,6 +318,7 @@ abstract class Template
/**
* @internal
*
* @return $this
*/
public function unwrap(): self
@@ -492,7 +493,7 @@ abstract class Template
return $parent->hasMacro($name, $context);
}
protected function getTemplateForMacro(string $name, array $context, int $line, Source $source): Template
protected function getTemplateForMacro(string $name, array $context, int $line, Source $source): self
{
if (method_exists($this, $name)) {
return $this;
+2 -2
View File
@@ -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;
});
+2 -2
View File
@@ -179,7 +179,7 @@ class EnvironmentTest extends TestCase
// force compilation
$twig = new Environment($loader = new ArrayLoader(['index' => '{{ foo }}']), $options);
$twig->addExtension($extension = new class() extends AbstractExtension {
$twig->addExtension($extension = new class extends AbstractExtension {
public bool $throw = false;
public function getFilters(): array
@@ -475,7 +475,7 @@ EOF
public function testResettingGlobals()
{
$twig = new Environment(new ArrayLoader(['index' => '']));
$twig->addExtension(new class() extends AbstractExtension implements GlobalsInterface {
$twig->addExtension(new class extends AbstractExtension implements GlobalsInterface {
public function getGlobals(): array
{
return [
+5 -5
View File
@@ -41,7 +41,7 @@ class ErrorTest extends TestCase
{% block foo %}
{{ foo.bar }}
{% endblock %}
EOHTML
EOHTML,
]);
$twig = new Environment($loader, ['strict_variables' => true, 'debug' => true, 'cache' => false]);
@@ -70,7 +70,7 @@ EOHTML
{% block foo %}
{{ foo.bar }}
{% endblock %}
EOHTML
EOHTML,
]);
$twig = new Environment($loader, ['strict_variables' => true, 'debug' => true, 'cache' => false]);
@@ -163,7 +163,7 @@ EOHTML
{% for n in variable|filter(x => x > 3) %}
This list contains {{n}}.
{% endfor %}
EOHTML
EOHTML,
]);
$twig = new Environment($loader, ['debug' => true, 'cache' => false]);
@@ -190,7 +190,7 @@ EOHTML
{% for n in variable|map(x => x * 3) %}
{{- n -}}
{% endfor %}
EOHTML
EOHTML,
]);
$twig = new Environment($loader, ['debug' => true, 'cache' => false]);
@@ -215,7 +215,7 @@ EOHTML
'reduce-null.html' => <<<EOHTML
{# We expect a runtime error if `variable` is not traversable #}
{{ variable|reduce((carry, x) => carry + x) }}
EOHTML
EOHTML,
]);
$twig = new Environment($loader, ['debug' => true, 'cache' => false]);
+5 -5
View File
@@ -408,7 +408,7 @@ class ExpressionParserTest extends TestCase
public function testCompiledCodeForDynamicTest()
{
$env = new Environment(new ArrayLoader(['index' => '{{ "a" is foo_foo_bar_bar }}']), ['cache' => false, 'autoescape' => false]);
$env->addExtension(new class() extends AbstractExtension {
$env->addExtension(new class extends AbstractExtension {
public function getTests()
{
return [
@@ -423,7 +423,7 @@ class ExpressionParserTest extends TestCase
public function testCompiledCodeForDynamicFunction()
{
$env = new Environment(new ArrayLoader(['index' => '{{ foo_foo_bar_bar("a") }}']), ['cache' => false, 'autoescape' => false]);
$env->addExtension(new class() extends AbstractExtension {
$env->addExtension(new class extends AbstractExtension {
public function getFunctions()
{
return [
@@ -438,7 +438,7 @@ class ExpressionParserTest extends TestCase
public function testCompiledCodeForDynamicFilter()
{
$env = new Environment(new ArrayLoader(['index' => '{{ "a"|foo_foo_bar_bar }}']), ['cache' => false, 'autoescape' => false]);
$env->addExtension(new class() extends AbstractExtension {
$env->addExtension(new class extends AbstractExtension {
public function getFilters()
{
return [
@@ -569,10 +569,10 @@ class ExpressionParserTest extends TestCase
public function testUnaryPrecedenceChange()
{
$env = new Environment(new ArrayLoader(), ['cache' => false, 'autoescape' => false]);
$env->addExtension(new class () extends AbstractExtension {
$env->addExtension(new class extends AbstractExtension {
public function getOperators()
{
$class = new class (new ConstantExpression('foo', 1), 1) extends AbstractUnary {
$class = new class(new ConstantExpression('foo', 1), 1) extends AbstractUnary {
public function operator(Compiler $compiler): Compiler
{
return $compiler->raw('!');
+1 -1
View File
@@ -58,7 +58,7 @@ class CoreTest extends TestCase
{
return [
'empty' => [[]],
'non-countable' => [new class() extends \ArrayObject {
'non-countable' => [new class extends \ArrayObject {
}],
];
}
+3 -3
View File
@@ -565,7 +565,7 @@ EOF
public function testSandboxSourcePolicyEnableReturningFalse()
{
$twig = $this->getEnvironment(false, [], self::$templates, [], [], [], [], [], new class() implements \Twig\Sandbox\SourcePolicyInterface {
$twig = $this->getEnvironment(false, [], self::$templates, [], [], [], [], [], new class implements \Twig\Sandbox\SourcePolicyInterface {
public function enableSandbox(Source $source): bool
{
return '1_basic' != $source->getName();
@@ -576,7 +576,7 @@ EOF
public function testSandboxSourcePolicyEnableReturningTrue()
{
$twig = $this->getEnvironment(false, [], self::$templates, [], [], [], [], [], new class() implements \Twig\Sandbox\SourcePolicyInterface {
$twig = $this->getEnvironment(false, [], self::$templates, [], [], [], [], [], new class implements \Twig\Sandbox\SourcePolicyInterface {
public function enableSandbox(Source $source): bool
{
return '1_basic' === $source->getName();
@@ -588,7 +588,7 @@ EOF
public function testSandboxSourcePolicyFalseDoesntOverrideOtherEnables()
{
$twig = $this->getEnvironment(true, [], self::$templates, [], [], [], [], [], new class() implements \Twig\Sandbox\SourcePolicyInterface {
$twig = $this->getEnvironment(true, [], self::$templates, [], [], [], [], [], new class implements \Twig\Sandbox\SourcePolicyInterface {
public function enableSandbox(Source $source): bool
{
return false;
+1 -1
View File
@@ -180,7 +180,7 @@ class FilterTest extends NodeTestCase
private static function createExtension(): AbstractExtension
{
return new class() extends AbstractExtension {
return new class extends AbstractExtension {
public function getFilters(): array
{
return [