Skip to content

Commit fec7345

Browse files
minor #4664 CS fixes (nicolas-grekas)
This PR was merged into the 3.x branch. Discussion ---------- CS fixes Commits ------- 85a4817 CS fixes
2 parents 1680bba + 85a4817 commit fec7345

115 files changed

Lines changed: 919 additions & 78 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.php-cs-fixer.dist.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,17 @@
1313
'heredoc_to_nowdoc' => false,
1414
'ordered_imports' => true,
1515
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
16-
// TODO: Remove once the "compiler_optimized" set includes "sprintf"
17-
'native_function_invocation' => ['include' => ['@compiler_optimized', 'sprintf'], 'scope' => 'all'],
18-
])
16+
'header_comment' => [
17+
'header' => <<<EOF
18+
This file is part of Twig.
19+
20+
(c) Fabien Potencier
21+
22+
For the full copyright and license information, please view the LICENSE
23+
file that was distributed with this source code.
24+
EOF
25+
],
26+
])
1927
->setRiskyAllowed(true)
2028
->setFinder((new PhpCsFixer\Finder())->in(__DIR__))
2129
;

bin/generate_operators_precedence.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
use Twig\ExpressionParser\InfixExpressionParserInterface;
1717
use Twig\Loader\ArrayLoader;
1818

19-
require_once \dirname(__DIR__).'/vendor/autoload.php';
19+
require_once dirname(__DIR__).'/vendor/autoload.php';
2020

21-
$output = fopen(\dirname(__DIR__).'/doc/operators_precedence.rst', 'w');
21+
$output = fopen(dirname(__DIR__).'/doc/operators_precedence.rst', 'w');
2222

2323
$twig = new Environment(new ArrayLoader([]));
2424
$descriptionLength = 11;
@@ -29,7 +29,7 @@
2929
}
3030

3131
fwrite($output, "\n+------------+------------------+---------+---------------+".str_repeat('-', $descriptionLength + 2)."+\n");
32-
fwrite($output, "| Precedence | Operator | Type | Associativity | Description".str_repeat(' ', $descriptionLength - 11)." |\n");
32+
fwrite($output, '| Precedence | Operator | Type | Associativity | Description'.str_repeat(' ', $descriptionLength - 11)." |\n");
3333
fwrite($output, '+============+==================+=========+===============+'.str_repeat('=', $descriptionLength + 2).'+');
3434

3535
usort($expressionParsers, fn ($a, $b) => $b->getPrecedence() <=> $a->getPrecedence());
@@ -46,7 +46,7 @@
4646
if ($previousPrecedence !== $precedence) {
4747
$previous = null;
4848
}
49-
fwrite($output, rtrim(\sprintf("\n| %-10s | %-16s | %-7s | %-13s | %-{$descriptionLength}s |\n",
49+
fwrite($output, rtrim(sprintf("\n| %-10s | %-16s | %-7s | %-13s | %-{$descriptionLength}s |\n",
5050
(!$previous || $previousPrecedence !== $precedence ? $precedence : '').($expressionParser->getPrecedenceChange() ? ' => '.$expressionParser->getPrecedenceChange()->getNewPrecedence() : ''),
5151
'``'.$expressionParser->getName().'``',
5252
!$previous || ExpressionParserType::getType($previous) !== ExpressionParserType::getType($expressionParser) ? ExpressionParserType::getType($expressionParser)->value : '',
@@ -61,7 +61,7 @@
6161
fwrite($output, "\nHere is the same table for Twig 4.0 with adjusted precedences:\n");
6262

6363
fwrite($output, "\n+------------+------------------+---------+---------------+".str_repeat('-', $descriptionLength + 2)."+\n");
64-
fwrite($output, "| Precedence | Operator | Type | Associativity | Description".str_repeat(' ', $descriptionLength - 11)." |\n");
64+
fwrite($output, '| Precedence | Operator | Type | Associativity | Description'.str_repeat(' ', $descriptionLength - 11)." |\n");
6565
fwrite($output, '+============+==================+=========+===============+'.str_repeat('=', $descriptionLength + 2).'+');
6666

6767
usort($expressionParsers, function ($a, $b) {
@@ -83,7 +83,7 @@
8383
if ($previousPrecedence !== $precedence) {
8484
$previous = null;
8585
}
86-
fwrite($output, rtrim(\sprintf("\n| %-10s | %-16s | %-7s | %-13s | %-{$descriptionLength}s |\n",
86+
fwrite($output, rtrim(sprintf("\n| %-10s | %-16s | %-7s | %-13s | %-{$descriptionLength}s |\n",
8787
!$previous || $previousPrecedence !== $precedence ? $precedence : '',
8888
'``'.$expressionParser->getName().'``',
8989
!$previous || ExpressionParserType::getType($previous) !== ExpressionParserType::getType($expressionParser) ? ExpressionParserType::getType($expressionParser)->value : '',

doc/_build/build.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
#!/usr/bin/env php
22
<?php
33

4+
/*
5+
* This file is part of Twig.
6+
*
7+
* (c) Fabien Potencier
8+
*
9+
* For the full copyright and license information, please view the LICENSE
10+
* file that was distributed with this source code.
11+
*/
12+
413
require __DIR__.'/vendor/autoload.php';
514

615
use Symfony\Component\Console\Application;
@@ -40,9 +49,9 @@
4049
file_put_contents($htmlFilePath, str_replace('href="assets/', 'href="/assets/', $htmlContents));
4150
}
4251

43-
$io->success(\sprintf('The Twig docs were successfully built at %s', realpath($outputDir)));
52+
$io->success(sprintf('The Twig docs were successfully built at %s', realpath($outputDir)));
4453
} else {
45-
$io->error(\sprintf("There were some errors while building the docs:\n\n%s\n", $result->getErrorTrace()));
54+
$io->error(sprintf("There were some errors while building the docs:\n\n%s\n", $result->getErrorTrace()));
4655
$io->newLine();
4756
$io->comment('Tip: you can add the -v, -vv or -vvv flags to this command to get debug information.');
4857

extra/cssinliner-extra/CssInlinerExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

33
/*
4-
* This file is part of the Symfony package.
4+
* This file is part of Twig.
55
*
6-
* (c) Fabien Potencier <fabien@symfony.com>
6+
* (c) Fabien Potencier
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.

extra/cssinliner-extra/Resources/functions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

33
/*
4-
* This file is part of the Symfony package.
4+
* This file is part of Twig.
55
*
6-
* (c) Fabien Potencier <fabien@symfony.com>
6+
* (c) Fabien Potencier
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.

extra/inky-extra/InkyExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

33
/*
4-
* This file is part of the Symfony package.
4+
* This file is part of Twig.
55
*
6-
* (c) Fabien Potencier <fabien@symfony.com>
6+
* (c) Fabien Potencier
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.

extra/inky-extra/Resources/functions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

33
/*
4-
* This file is part of the Symfony package.
4+
* This file is part of Twig.
55
*
6-
* (c) Fabien Potencier <fabien@symfony.com>
6+
* (c) Fabien Potencier
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.

extra/markdown-extra/DefaultMarkdown.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use League\CommonMark\CommonMarkConverter;
1515
use Michelf\MarkdownExtra;
16-
use Parsedown;
1716

1817
class DefaultMarkdown implements MarkdownInterface
1918
{
@@ -25,7 +24,7 @@ public function __construct()
2524
$this->converter = new LeagueMarkdown();
2625
} elseif (class_exists(MarkdownExtra::class)) {
2726
$this->converter = new MichelfMarkdown();
28-
} elseif (class_exists(Parsedown::class)) {
27+
} elseif (class_exists(\Parsedown::class)) {
2928
$this->converter = new ErusevMarkdown();
3029
} else {
3130
throw new \LogicException('You cannot use the "markdown_to_html" filter as no Markdown library is available; try running "composer require league/commonmark".');

extra/markdown-extra/ErusevMarkdown.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@
1111

1212
namespace Twig\Extra\Markdown;
1313

14-
use Parsedown;
15-
1614
class ErusevMarkdown implements MarkdownInterface
1715
{
1816
private $converter;
1917

20-
public function __construct(?Parsedown $converter = null)
18+
public function __construct(?\Parsedown $converter = null)
2119
{
22-
$this->converter = $converter ?: new Parsedown();
20+
$this->converter = $converter ?: new \Parsedown();
2321
}
2422

2523
public function convert(string $body): string

extra/twig-extra-bundle/DependencyInjection/Compiler/MissingExtensionSuggestorPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

33
/*
4-
* This file is part of the Symfony package.
4+
* This file is part of Twig.
55
*
6-
* (c) Fabien Potencier <fabien@symfony.com>
6+
* (c) Fabien Potencier
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.

0 commit comments

Comments
 (0)