Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3b4c877

Browse files
committed
CS
1 parent 80dcb4f commit 3b4c877

28 files changed

+48
-146
lines changed

core-bundle/src/Command/DebugContaoTwigCommand.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ protected function configure(): void
5757

5858
protected function execute(InputInterface $input, OutputInterface $output): int
5959
{
60-
$io = new SymfonyStyle($input, $output);
61-
6260
$rows = [];
63-
6461
$chains = $this->hierarchy->getInheritanceChains();
6562

6663
if (null !== ($prefix = $input->getOption('filter'))) {
@@ -77,19 +74,15 @@ static function (string $identifier) use ($prefix) {
7774
$i = 0;
7875

7976
foreach ($chain as $path => $name) {
80-
$rows[] = [
81-
0 === $i ? $identifier : '',
82-
$name,
83-
$path,
84-
];
85-
++$i;
77+
$rows[] = [0 === $i++ ? $identifier : '', $name, $path];
8678
}
8779

8880
$rows[] = new TableSeparator();
8981
}
9082

9183
array_pop($rows);
9284

85+
$io = new SymfonyStyle($input, $output);
9386
$io->title('Template hierarchy');
9487
$io->table(['Identifier', 'Effective logical name', 'Path'], $rows);
9588

core-bundle/src/Resources/contao/library/Contao/TemplateInheritance.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,9 @@ protected function getTemplatePath($strTemplate, $strFormat='html5', $blnDefault
331331
return Controller::getTemplate($strTemplate);
332332
}
333333

334+
/**
335+
* Render a Twig template if one exists
336+
*/
334337
protected function renderTwigSurrogateIfExists(): ?string
335338
{
336339
if (!$this instanceof Template || null === ($twig = System::getContainer()->get('twig', ContainerInterface::NULL_ON_INVALID_REFERENCE)))

core-bundle/src/Twig/Extension/ContaoExtension.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,19 @@ public function __construct(Environment $environment, TemplateHierarchyInterface
5757

5858
/** @var EscaperExtension $escaperExtension */
5959
$escaperExtension = $environment->getExtension(EscaperExtension::class);
60-
61-
$escaperExtension->setEscaper(
62-
'contao_html',
63-
[(new ContaoEscaper()), '__invoke']
64-
);
60+
$escaperExtension->setEscaper('contao_html', [(new ContaoEscaper()), '__invoke']);
6561

6662
$this->hierarchy = $hierarchy;
6763

68-
// Use our escaper on all templates in the `@Contao` and `@Contao_*`
69-
// namespaces
64+
// Use our escaper on all templates in the `@Contao` and `@Contao_*` namespaces
7065
$this->addContaoEscaperRule('%^@Contao(_[a-zA-Z0-9_-]*)?/%');
7166
}
7267

7368
/**
74-
* Add a contao escaper rule.
69+
* Adds a Contao escaper rule.
7570
*
76-
* If a template name matches any of the defined rules it will be processed
77-
* with the `contao_html` escaper strategy. Make sure your rule will only
71+
* If a template name matches any of the defined rules, it will be processed
72+
* with the 'contao_html' escaper strategy. Make sure your rule will only
7873
* match templates with input encoded contexts!
7974
*/
8075
public function addContaoEscaperRule(string $regularExpression): void

core-bundle/src/Twig/Inheritance/DynamicExtendsTokenParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Twig\TokenStream;
2020

2121
/**
22-
* This parser is a drop in replacement for @\Twig\TokenParser\ExtendsTokenParser.
22+
* This parser is a drop in replacement for @\Twig\TokenParser\ExtendsTokenParser
2323
* that adds support for the Contao template hierarchy.
2424
*
2525
* @experimental

core-bundle/src/Twig/Inheritance/DynamicIncludeTokenParser.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Twig\TokenParser\IncludeTokenParser;
1919

2020
/**
21-
* This parser is a drop in replacement for @\Twig\TokenParser\IncludeTokenParser.
21+
* This parser is a drop in replacement for @\Twig\TokenParser\IncludeTokenParser
2222
* that adds support for the Contao template hierarchy.
2323
*
2424
* @experimental
@@ -58,7 +58,6 @@ public static function adjustTemplateName(string $name, TemplateHierarchyInterfa
5858
try {
5959
return $hierarchy->getFirst($shortNameOrIdentifier);
6060
} catch (\LogicException $e) {
61-
// Enrich exception: theme directories are not supported
6261
throw new \LogicException($e->getMessage().' Did you try to include a non-existent template or a template from a theme directory?', 0, $e);
6362
}
6463
}

core-bundle/src/Twig/Inheritance/TokenParserHelper.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
/**
1919
* @experimental
20-
*
21-
* @internal
2220
*/
2321
final class TokenParserHelper
2422
{

core-bundle/src/Twig/Interop/ContaoEscaper.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
* This strategy will get dropped once we move to output encoding.
2424
*
2525
* @experimental
26-
*
27-
* @internal
2826
*/
2927
final class ContaoEscaper
3028
{
@@ -34,7 +32,7 @@ final class ContaoEscaper
3432
*
3533
* @see twig_escape_filter
3634
*/
37-
public function __invoke(Environment $environment, $string, ?string $charset)
35+
public function __invoke(Environment $environment, $string, ?string $charset): string
3836
{
3937
$string = (string) $string;
4038

core-bundle/src/Twig/Interop/ContaoEscaperNodeVisitor.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
* to is amongst the configured affected templates.
2626
*
2727
* @experimental
28-
*
29-
* @internal
3028
*/
3129
final class ContaoEscaperNodeVisitor extends AbstractNodeVisitor
3230
{
@@ -98,8 +96,7 @@ private function isEscaperFilterExpressionWithHtmlStrategy(Node $node): bool
9896
&& 'escape' === $node->getNode('filter')->getAttribute('value')
9997
&& $node->getNode('arguments')->hasNode(0)
10098
&& ($argument = $node->getNode('arguments')->getNode(0)) instanceof ConstantExpression
101-
&& 'html' === $argument->getAttribute('value')
102-
;
99+
&& 'html' === $argument->getAttribute('value');
103100
}
104101

105102
private function setContaoEscaperArguments(FilterExpression $node): void

core-bundle/src/Twig/Interop/ContextHelper.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,16 @@ public function __toString(): string
7878
return (string) $this();
7979
} catch (\Throwable $e) {
8080
// A __toString function may not throw an exception in PHP<7.4
81-
// @codeCoverageIgnoreStart
8281
if (\PHP_VERSION_ID < 70400) {
8382
return '';
8483
}
85-
// @codeCoverageIgnoreEnd
8684

87-
// Enhance exception message
8885
throw new \RuntimeException("Error evaluating '{$this->name}': {$e->getMessage()}", 0, $e);
8986
}
9087
}
9188

9289
/**
93-
* Called when evaluating `{{ var.invoke(…) }}` in a Twig template.
90+
* Called when evaluating '{{ var.invoke(…) }}' in a Twig template.
9491
* We do not cast to string here, so that other types (like arrays)
9592
* are supported as well.
9693
*/

core-bundle/src/Twig/Interop/PhpTemplateProxyNode.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
/**
1919
* @experimental
20-
*
21-
* @internal
2220
*/
2321
final class PhpTemplateProxyNode extends Node
2422
{
@@ -31,18 +29,15 @@ public function __construct(string $extensionName)
3129

3230
public function compile(Compiler $compiler): void
3331
{
34-
/*
35-
* echo $this->extensions["Contao\\…\\ContaoExtension"]->renderLegacyTemplate(
36-
* $this->getTemplateName(),
37-
* array_map(
38-
* function(callable $block) use ($context): string {
39-
* if ($this->env->isDebug()) { ob_start(); } else { ob_start(static function () { return ''; }); }
40-
* try { $block($context); return ob_get_contents(); } finally { ob_end_clean(); }
41-
* }, $blocks
42-
* ), $context
43-
* );
44-
*/
45-
32+
// echo $this->extensions["Contao\\…\\ContaoExtension"]->renderLegacyTemplate(
33+
// $this->getTemplateName(),
34+
// array_map(
35+
// function(callable $block) use ($context): string {
36+
// if ($this->env->isDebug()) { ob_start(); } else { ob_start(static function () { return ''; }); }
37+
// try { $block($context); return ob_get_contents(); } finally { ob_end_clean(); }
38+
// }, $blocks
39+
// ), $context
40+
// );
4641
$compiler
4742
->write('echo $this->extensions[')
4843
->repr($this->getAttribute('extension_name'))

0 commit comments

Comments
 (0)