Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Aug 7, 2024
1 parent ea4d706 commit f5e10e1
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 72 deletions.
2 changes: 0 additions & 2 deletions extra/cache-extra/TokenParser/CacheTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

use Twig\Error\SyntaxError;
use Twig\Extra\Cache\Node\CacheNode;
use Twig\Node\Expression\ConstantExpression;
use Twig\Node\Expression\Filter\RawFilter;
use Twig\Node\Expression\FilterExpression;
use Twig\Node\Node;
use Twig\Node\PrintNode;
use Twig\Token;
Expand Down
4 changes: 2 additions & 2 deletions extra/markdown-extra/Tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getMarkdownTests()
Great!
{% endapply %}
EOF
, "<h1>Hello</h1>\n+<p>Great!</p>"],
, "<h1>Hello</h1>\n+<p>Great!</p>"],
[<<<EOF
{% apply markdown_to_html %}
Hello
Expand All @@ -79,7 +79,7 @@ public function getMarkdownTests()
Great!
{% endapply %}
EOF
, "<h1>Hello</h1>\n+<p>Great!</p>"],
, "<h1>Hello</h1>\n+<p>Great!</p>"],
["{{ include('html')|markdown_to_html }}", "<h1>Hello</h1>\n+<p>Great!</p>"],
];
}
Expand Down
2 changes: 1 addition & 1 deletion extra/string-extra/StringExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private function getInflector(string $locale): InflectorInterface
case 'en':
return $this->englishInflector ?? $this->englishInflector = new EnglishInflector();
default:
throw new \InvalidArgumentException(sprintf('Locale "%s" is not supported.', $locale));
throw new \InvalidArgumentException(\sprintf('Locale "%s" is not supported.', $locale));
}
}
}
2 changes: 1 addition & 1 deletion src/Extension/EscaperExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function getDefaultStrategy(string $name)
/**
* Defines a new escaper to be used via the escape filter.
*
* @param string $strategy The strategy name that should be used as a strategy in the escape call
* @param string $strategy The strategy name that should be used as a strategy in the escape call
* @param callable(Environment, string, string): string $callable A valid PHP callable
*
* @deprecated since Twig 3.10
Expand Down
2 changes: 1 addition & 1 deletion src/Node/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __toString()
{
$attributes = [];
foreach ($this->attributes as $name => $value) {
$attributes[] = \sprintf('%s: %s', $name, is_callable($value) ? '\Closure' : str_replace("\n", '', var_export($value, true)));
$attributes[] = \sprintf('%s: %s', $name, \is_callable($value) ? '\Closure' : str_replace("\n", '', var_export($value, true)));
}

$repr = [static::class.'('.implode(', ', $attributes)];
Expand Down
2 changes: 1 addition & 1 deletion src/Runtime/EscaperRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct($charset = 'UTF-8')
/**
* Defines a new escaper to be used via the escape filter.
*
* @param string $strategy The strategy name that should be used as a strategy in the escape call
* @param string $strategy The strategy name that should be used as a strategy in the escape call
* @param callable(string $string, string $charset): string $callable A valid PHP callable
*/
public function setEscaper($strategy, callable $callable)
Expand Down
4 changes: 2 additions & 2 deletions tests/Cache/ChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ public function testLoadMissing()
public function testWrite()
{
$content = $this->generateSource();

$cacheA = new FilesystemCache($this->directory.'/A');
$keyA = $cacheA->generateKey('_test_', $this->classname);

$this->assertFileDoesNotExist($keyA);
$this->assertFileDoesNotExist($this->directory.'/A');

$cacheB = new FilesystemCache($this->directory.'/B');
$keyB = $cacheB->generateKey('_test_', $this->classname);

Expand Down
2 changes: 1 addition & 1 deletion tests/Cache/ReadOnlyFilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
*/

use PHPUnit\Framework\TestCase;
use Twig\Tests\FilesystemHelper;
use Twig\Cache\ReadOnlyFilesystemCache;
use Twig\Tests\FilesystemHelper;

class ReadOnlyFilesystemTest extends TestCase
{
Expand Down
108 changes: 54 additions & 54 deletions tests/ExpressionParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,73 +93,73 @@ public function getTestsForSequence()
return [
// simple sequence
['{{ [1, 2] }}', new ArrayExpression([
new ConstantExpression(0, 1),
new ConstantExpression(1, 1),
new ConstantExpression(0, 1),
new ConstantExpression(1, 1),

new ConstantExpression(1, 1),
new ConstantExpression(2, 1),
], 1),
new ConstantExpression(1, 1),
new ConstantExpression(2, 1),
], 1),
],

// sequence with trailing ,
['{{ [1, 2, ] }}', new ArrayExpression([
new ConstantExpression(0, 1),
new ConstantExpression(1, 1),
new ConstantExpression(0, 1),
new ConstantExpression(1, 1),

new ConstantExpression(1, 1),
new ConstantExpression(2, 1),
], 1),
new ConstantExpression(1, 1),
new ConstantExpression(2, 1),
], 1),
],

// simple mapping
['{{ {"a": "b", "b": "c"} }}', new ArrayExpression([
new ConstantExpression('a', 1),
new ConstantExpression('b', 1),
new ConstantExpression('a', 1),
new ConstantExpression('b', 1),

new ConstantExpression('b', 1),
new ConstantExpression('c', 1),
], 1),
new ConstantExpression('b', 1),
new ConstantExpression('c', 1),
], 1),
],

// mapping with trailing ,
['{{ {"a": "b", "b": "c", } }}', new ArrayExpression([
new ConstantExpression('a', 1),
new ConstantExpression('b', 1),
new ConstantExpression('a', 1),
new ConstantExpression('b', 1),

new ConstantExpression('b', 1),
new ConstantExpression('c', 1),
], 1),
new ConstantExpression('b', 1),
new ConstantExpression('c', 1),
], 1),
],

// mapping in a sequence
['{{ [1, {"a": "b", "b": "c"}] }}', new ArrayExpression([
new ConstantExpression(0, 1),
new ConstantExpression(1, 1),
new ConstantExpression(0, 1),
new ConstantExpression(1, 1),

new ConstantExpression(1, 1),
new ArrayExpression([
new ConstantExpression('a', 1),
new ConstantExpression('b', 1),
new ConstantExpression(1, 1),
new ArrayExpression([
new ConstantExpression('a', 1),
new ConstantExpression('b', 1),

new ConstantExpression('b', 1),
new ConstantExpression('c', 1),
], 1),
new ConstantExpression('b', 1),
new ConstantExpression('c', 1),
], 1),
], 1),
],

// sequence in a mapping
['{{ {"a": [1, 2], "b": "c"} }}', new ArrayExpression([
new ConstantExpression('a', 1),
new ArrayExpression([
new ConstantExpression(0, 1),
new ConstantExpression(1, 1),
new ConstantExpression('a', 1),
new ArrayExpression([
new ConstantExpression(0, 1),
new ConstantExpression(1, 1),

new ConstantExpression(1, 1),
new ConstantExpression(2, 1),
], 1),
new ConstantExpression('b', 1),
new ConstantExpression('c', 1),
new ConstantExpression(1, 1),
new ConstantExpression(2, 1),
], 1),
new ConstantExpression('b', 1),
new ConstantExpression('c', 1),
], 1),
],
['{{ {a, b} }}', new ArrayExpression([
new ConstantExpression('a', 1),
Expand All @@ -170,29 +170,29 @@ public function getTestsForSequence()

// sequence with spread operator
['{{ [1, 2, ...foo] }}',
new ArrayExpression([
new ConstantExpression(0, 1),
new ConstantExpression(1, 1),
new ArrayExpression([
new ConstantExpression(0, 1),
new ConstantExpression(1, 1),

new ConstantExpression(1, 1),
new ConstantExpression(2, 1),
new ConstantExpression(1, 1),
new ConstantExpression(2, 1),

new ConstantExpression(2, 1),
$this->createNameExpression('foo', ['spread' => true]),
], 1)],
new ConstantExpression(2, 1),
$this->createNameExpression('foo', ['spread' => true]),
], 1)],

// mapping with spread operator
['{{ {"a": "b", "b": "c", ...otherLetters} }}',
new ArrayExpression([
new ConstantExpression('a', 1),
new ConstantExpression('b', 1),
new ArrayExpression([
new ConstantExpression('a', 1),
new ConstantExpression('b', 1),

new ConstantExpression('b', 1),
new ConstantExpression('c', 1),
new ConstantExpression('b', 1),
new ConstantExpression('c', 1),

new ConstantExpression(0, 1),
$this->createNameExpression('otherLetters', ['spread' => true]),
], 1)],
new ConstantExpression(0, 1),
$this->createNameExpression('otherLetters', ['spread' => true]),
], 1)],
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Node/DeprecatedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function getTests()
\$$varName = foo();
@trigger_error(\$$varName." (\"foo.twig\" at line 1).", E_USER_DEPRECATED);
EOF
, $environment];
, $environment];

return $tests;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Node/Expression/Filter/RawTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testConstructor()
$this->assertSame(12, $filter->getTemplateLine());
$this->assertSame('raw', $filter->getNode('filter')->getAttribute('value'));
$this->assertSame($node, $filter->getNode('node'));
$this->assertSame(0, count($filter->getNode('arguments')));
$this->assertCount(0, $filter->getNode('arguments'));
}

public function getTests()
Expand Down
1 change: 1 addition & 0 deletions tests/Node/Expression/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ private function getExtension()
if ($this->extension) {
return $this->extension;
}

return $this->extension = new class() extends AbstractExtension {
public function getFilters(): array
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Node/IncludeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function getTests()
yield from \$__internal_%s->unwrap()->yield(CoreExtension::toArray(["foo" => true]));
}
EOF
, null, true];
, null, true];

return $tests;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Node/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function getSourceContext()
}
}
EOF
, $twig, true];
, $twig, true];

$import = new ImportNode(new ConstantExpression('foo.twig', 1), new AssignNameExpression('macro', 1), 2);

Expand Down Expand Up @@ -207,7 +207,7 @@ public function getSourceContext()
}
}
EOF
, $twig, true];
, $twig, true];

$set = new SetNode(false, new Node([new AssignNameExpression('foo', 4)]), new Node([new ConstantExpression('foo', 4)]), 4);
$body = new Node([$set]);
Expand Down Expand Up @@ -297,7 +297,7 @@ public function getSourceContext()
}
}
EOF
, $twig, true];
, $twig, true];

return $tests;
}
Expand Down
1 change: 0 additions & 1 deletion tests/TemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Twig\Extension\CoreExtension;
use Twig\Extension\SandboxExtension;
use Twig\Loader\ArrayLoader;
use Twig\Loader\LoaderInterface;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityPolicy;
use Twig\Source;
Expand Down

0 comments on commit f5e10e1

Please sign in to comment.