Skip to content

Commit df3275e

Browse files
committed
Use ::class instead of FQCN
1 parent 546edaf commit df3275e

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

DataCollector/TwigDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function getHtmlCallGraph()
140140

141141
public function getProfile()
142142
{
143-
return $this->profile ??= unserialize($this->data['profile'], ['allowed_classes' => ['Twig_Profiler_Profile', 'Twig\Profiler\Profile']]);
143+
return $this->profile ??= unserialize($this->data['profile'], ['allowed_classes' => ['Twig_Profiler_Profile', Profile::class]]);
144144
}
145145

146146
private function getComputedData(string $index)

Extension/FormExtension.php

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

1212
namespace Symfony\Bridge\Twig\Extension;
1313

14+
use Symfony\Bridge\Twig\Node\RenderBlockNode;
15+
use Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode;
1416
use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser;
1517
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
1618
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
1719
use Symfony\Component\Form\FormError;
20+
use Symfony\Component\Form\FormRenderer;
1821
use Symfony\Component\Form\FormView;
1922
use Symfony\Contracts\Translation\TranslatorInterface;
2023
use Twig\Extension\AbstractExtension;
@@ -54,16 +57,16 @@ public function getTokenParsers(): array
5457
public function getFunctions(): array
5558
{
5659
return [
57-
new TwigFunction('form_widget', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
58-
new TwigFunction('form_errors', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
59-
new TwigFunction('form_label', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
60-
new TwigFunction('form_help', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
61-
new TwigFunction('form_row', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
62-
new TwigFunction('form_rest', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
63-
new TwigFunction('form', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
64-
new TwigFunction('form_start', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
65-
new TwigFunction('form_end', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
66-
new TwigFunction('csrf_token', ['Symfony\Component\Form\FormRenderer', 'renderCsrfToken']),
60+
new TwigFunction('form_widget', null, ['node_class' => SearchAndRenderBlockNode::class, 'is_safe' => ['html']]),
61+
new TwigFunction('form_errors', null, ['node_class' => SearchAndRenderBlockNode::class, 'is_safe' => ['html']]),
62+
new TwigFunction('form_label', null, ['node_class' => SearchAndRenderBlockNode::class, 'is_safe' => ['html']]),
63+
new TwigFunction('form_help', null, ['node_class' => SearchAndRenderBlockNode::class, 'is_safe' => ['html']]),
64+
new TwigFunction('form_row', null, ['node_class' => SearchAndRenderBlockNode::class, 'is_safe' => ['html']]),
65+
new TwigFunction('form_rest', null, ['node_class' => SearchAndRenderBlockNode::class, 'is_safe' => ['html']]),
66+
new TwigFunction('form', null, ['node_class' => RenderBlockNode::class, 'is_safe' => ['html']]),
67+
new TwigFunction('form_start', null, ['node_class' => RenderBlockNode::class, 'is_safe' => ['html']]),
68+
new TwigFunction('form_end', null, ['node_class' => RenderBlockNode::class, 'is_safe' => ['html']]),
69+
new TwigFunction('csrf_token', [FormRenderer::class, 'renderCsrfToken']),
6770
new TwigFunction('form_parent', 'Symfony\Bridge\Twig\Extension\twig_get_form_parent'),
6871
new TwigFunction('field_name', [$this, 'getFieldName']),
6972
new TwigFunction('field_value', [$this, 'getFieldValue']),
@@ -80,8 +83,8 @@ public function getFunctions(): array
8083
public function getFilters(): array
8184
{
8285
return [
83-
new TwigFilter('humanize', ['Symfony\Component\Form\FormRenderer', 'humanize']),
84-
new TwigFilter('form_encode_currency', ['Symfony\Component\Form\FormRenderer', 'encodeCurrency'], ['is_safe' => ['html'], 'needs_environment' => true]),
86+
new TwigFilter('humanize', [FormRenderer::class, 'humanize']),
87+
new TwigFilter('form_encode_currency', [FormRenderer::class, 'encodeCurrency'], ['is_safe' => ['html'], 'needs_environment' => true]),
8588
];
8689
}
8790

Translation/TwigExtractor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\Twig\Translation;
1313

14+
use Symfony\Bridge\Twig\Extension\TranslationExtension;
1415
use Symfony\Component\Finder\Finder;
1516
use Symfony\Component\Translation\Extractor\AbstractFileExtractor;
1617
use Symfony\Component\Translation\Extractor\ExtractorInterface;
@@ -68,7 +69,7 @@ public function setPrefix(string $prefix)
6869

6970
protected function extractTemplate(string $template, MessageCatalogue $catalogue)
7071
{
71-
$visitor = $this->twig->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->getTranslationNodeVisitor();
72+
$visitor = $this->twig->getExtension(TranslationExtension::class)->getTranslationNodeVisitor();
7273
$visitor->enable();
7374

7475
$this->twig->parse($this->twig->tokenize(new Source($template, '')));

0 commit comments

Comments
 (0)