mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 12:06:56 +00:00
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:
@@ -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 {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -917,7 +917,7 @@ final class CoreExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes a callable
|
||||
* Invokes a callable.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
|
||||
+1
-1
@@ -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
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
|
||||
@@ -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
@@ -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]);
|
||||
|
||||
@@ -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('!');
|
||||
|
||||
@@ -58,7 +58,7 @@ class CoreTest extends TestCase
|
||||
{
|
||||
return [
|
||||
'empty' => [[]],
|
||||
'non-countable' => [new class() extends \ArrayObject {
|
||||
'non-countable' => [new class extends \ArrayObject {
|
||||
}],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 [
|
||||
|
||||
Reference in New Issue
Block a user