Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d508d5f

Browse filesBrowse files
minor #54244 [TwigBridge] Use CPP (connorhu)
This PR was squashed before being merged into the 7.1 branch. Discussion ---------- [TwigBridge] Use CPP | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | N/A | License | MIT I can also help with this kind of thing. So here we are. Commits ------- d4f8f39 [TwigBridge] Use CPP
2 parents 37d91c7 + d4f8f39 commit d508d5f
Copy full SHA for d508d5f

26 files changed

+99
-149
lines changed

‎src/Symfony/Bridge/Twig/Command/DebugCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Command/DebugCommand.php
+7-15Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,19 @@
3636
#[AsCommand(name: 'debug:twig', description: 'Show a list of twig functions, filters, globals and tests')]
3737
class DebugCommand extends Command
3838
{
39-
private Environment $twig;
40-
private ?string $projectDir;
41-
private array $bundlesMetadata;
42-
private ?string $twigDefaultPath;
43-
4439
/**
4540
* @var FilesystemLoader[]
4641
*/
4742
private array $filesystemLoaders;
4843

49-
private ?FileLinkFormatter $fileLinkFormatter;
50-
51-
public function __construct(Environment $twig, ?string $projectDir = null, array $bundlesMetadata = [], ?string $twigDefaultPath = null, ?FileLinkFormatter $fileLinkFormatter = null)
52-
{
44+
public function __construct(
45+
private Environment $twig,
46+
private ?string $projectDir = null,
47+
private array $bundlesMetadata = [],
48+
private ?string $twigDefaultPath = null,
49+
private ?FileLinkFormatter $fileLinkFormatter = null,
50+
) {
5351
parent::__construct();
54-
55-
$this->twig = $twig;
56-
$this->projectDir = $projectDir;
57-
$this->bundlesMetadata = $bundlesMetadata;
58-
$this->twigDefaultPath = $twigDefaultPath;
59-
$this->fileLinkFormatter = $fileLinkFormatter;
6052
}
6153

6254
protected function configure(): void

‎src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@
2828
*/
2929
class TwigDataCollector extends DataCollector implements LateDataCollectorInterface
3030
{
31-
private Profile $profile;
32-
private ?Environment $twig;
3331
private array $computed;
3432

35-
public function __construct(Profile $profile, ?Environment $twig = null)
36-
{
37-
$this->profile = $profile;
38-
$this->twig = $twig;
33+
public function __construct(
34+
private Profile $profile,
35+
private ?Environment $twig = null,
36+
) {
3937
}
4038

4139
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void

‎src/Symfony/Bridge/Twig/ErrorRenderer/TwigErrorRenderer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/ErrorRenderer/TwigErrorRenderer.php
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@
2525
*/
2626
class TwigErrorRenderer implements ErrorRendererInterface
2727
{
28-
private Environment $twig;
2928
private HtmlErrorRenderer $fallbackErrorRenderer;
3029
private \Closure|bool $debug;
3130

3231
/**
3332
* @param bool|callable $debug The debugging mode as a boolean or a callable that should return it
3433
*/
35-
public function __construct(Environment $twig, ?HtmlErrorRenderer $fallbackErrorRenderer = null, bool|callable $debug = false)
36-
{
37-
$this->twig = $twig;
34+
public function __construct(
35+
private Environment $twig,
36+
?HtmlErrorRenderer $fallbackErrorRenderer = null,
37+
bool|callable $debug = false,
38+
) {
3839
$this->fallbackErrorRenderer = $fallbackErrorRenderer ?? new HtmlErrorRenderer();
3940
$this->debug = \is_bool($debug) ? $debug : $debug(...);
4041
}

‎src/Symfony/Bridge/Twig/Extension/AssetExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/AssetExtension.php
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@
2222
*/
2323
final class AssetExtension extends AbstractExtension
2424
{
25-
private Packages $packages;
26-
27-
public function __construct(Packages $packages)
28-
{
29-
$this->packages = $packages;
25+
public function __construct(
26+
private Packages $packages,
27+
) {
3028
}
3129

3230
public function getFunctions(): array

‎src/Symfony/Bridge/Twig/Extension/CsrfRuntime.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/CsrfRuntime.php
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919
*/
2020
final class CsrfRuntime
2121
{
22-
private CsrfTokenManagerInterface $csrfTokenManager;
23-
24-
public function __construct(CsrfTokenManagerInterface $csrfTokenManager)
25-
{
26-
$this->csrfTokenManager = $csrfTokenManager;
22+
public function __construct(
23+
private CsrfTokenManagerInterface $csrfTokenManager,
24+
) {
2725
}
2826

2927
public function getCsrfToken(string $tokenId): string

‎src/Symfony/Bridge/Twig/Extension/DumpExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/DumpExtension.php
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@
2626
*/
2727
final class DumpExtension extends AbstractExtension
2828
{
29-
private ClonerInterface $cloner;
30-
private ?HtmlDumper $dumper;
31-
32-
public function __construct(ClonerInterface $cloner, ?HtmlDumper $dumper = null)
33-
{
34-
$this->cloner = $cloner;
35-
$this->dumper = $dumper;
29+
public function __construct(
30+
private ClonerInterface $cloner,
31+
private ?HtmlDumper $dumper = null,
32+
) {
3633
}
3734

3835
public function getFunctions(): array

‎src/Symfony/Bridge/Twig/Extension/FormExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/FormExtension.php
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@
3333
*/
3434
final class FormExtension extends AbstractExtension
3535
{
36-
private ?TranslatorInterface $translator;
37-
38-
public function __construct(?TranslatorInterface $translator = null)
39-
{
40-
$this->translator = $translator;
36+
public function __construct(
37+
private ?TranslatorInterface $translator = null,
38+
) {
4139
}
4240

4341
public function getTokenParsers(): array

‎src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323
*/
2424
final class HttpFoundationExtension extends AbstractExtension
2525
{
26-
private UrlHelper $urlHelper;
27-
28-
public function __construct(UrlHelper $urlHelper)
29-
{
30-
$this->urlHelper = $urlHelper;
26+
public function __construct(
27+
private UrlHelper $urlHelper,
28+
) {
3129
}
3230

3331
public function getFunctions(): array

‎src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@
2222
*/
2323
final class HttpKernelRuntime
2424
{
25-
private FragmentHandler $handler;
26-
private ?FragmentUriGeneratorInterface $fragmentUriGenerator;
27-
28-
public function __construct(FragmentHandler $handler, ?FragmentUriGeneratorInterface $fragmentUriGenerator = null)
29-
{
30-
$this->handler = $handler;
31-
$this->fragmentUriGenerator = $fragmentUriGenerator;
25+
public function __construct(
26+
private FragmentHandler $handler,
27+
private ?FragmentUriGeneratorInterface $fragmentUriGenerator = null,
28+
) {
3229
}
3330

3431
/**

‎src/Symfony/Bridge/Twig/Extension/ImportMapRuntime.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/ImportMapRuntime.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
*/
1919
class ImportMapRuntime
2020
{
21-
public function __construct(private readonly ImportMapRenderer $importMapRenderer)
22-
{
21+
public function __construct(
22+
private readonly ImportMapRenderer $importMapRenderer,
23+
) {
2324
}
2425

2526
public function importmap(string|array $entryPoint = 'app', array $attributes = []): string

‎src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@
2222
*/
2323
final class LogoutUrlExtension extends AbstractExtension
2424
{
25-
private LogoutUrlGenerator $generator;
26-
27-
public function __construct(LogoutUrlGenerator $generator)
28-
{
29-
$this->generator = $generator;
25+
public function __construct(
26+
private LogoutUrlGenerator $generator,
27+
) {
3028
}
3129

3230
public function getFunctions(): array

‎src/Symfony/Bridge/Twig/Extension/ProfilerExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/ProfilerExtension.php
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,17 @@
2121
*/
2222
final class ProfilerExtension extends BaseProfilerExtension
2323
{
24-
private ?Stopwatch $stopwatch;
25-
2624
/**
2725
* @var \SplObjectStorage<Profile, StopwatchEvent>
2826
*/
2927
private \SplObjectStorage $events;
3028

31-
public function __construct(Profile $profile, ?Stopwatch $stopwatch = null)
32-
{
29+
public function __construct(
30+
Profile $profile,
31+
private ?Stopwatch $stopwatch = null,
32+
) {
3333
parent::__construct($profile);
3434

35-
$this->stopwatch = $stopwatch;
3635
$this->events = new \SplObjectStorage();
3736
}
3837

‎src/Symfony/Bridge/Twig/Extension/RoutingExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/RoutingExtension.php
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@
2525
*/
2626
final class RoutingExtension extends AbstractExtension
2727
{
28-
private UrlGeneratorInterface $generator;
29-
30-
public function __construct(UrlGeneratorInterface $generator)
31-
{
32-
$this->generator = $generator;
28+
public function __construct(
29+
private UrlGeneratorInterface $generator,
30+
) {
3331
}
3432

3533
public function getFunctions(): array

‎src/Symfony/Bridge/Twig/Extension/SecurityExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/SecurityExtension.php
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@
2525
*/
2626
final class SecurityExtension extends AbstractExtension
2727
{
28-
private ?AuthorizationCheckerInterface $securityChecker;
29-
private ?ImpersonateUrlGenerator $impersonateUrlGenerator;
30-
31-
public function __construct(?AuthorizationCheckerInterface $securityChecker = null, ?ImpersonateUrlGenerator $impersonateUrlGenerator = null)
32-
{
33-
$this->securityChecker = $securityChecker;
34-
$this->impersonateUrlGenerator = $impersonateUrlGenerator;
28+
public function __construct(
29+
private ?AuthorizationCheckerInterface $securityChecker = null,
30+
private ?ImpersonateUrlGenerator $impersonateUrlGenerator = null,
31+
) {
3532
}
3633

3734
public function isGranted(mixed $role, mixed $object = null, ?string $field = null): bool

‎src/Symfony/Bridge/Twig/Extension/SerializerRuntime.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/SerializerRuntime.php
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919
*/
2020
final class SerializerRuntime implements RuntimeExtensionInterface
2121
{
22-
private SerializerInterface $serializer;
23-
24-
public function __construct(SerializerInterface $serializer)
25-
{
26-
$this->serializer = $serializer;
22+
public function __construct(
23+
private SerializerInterface $serializer,
24+
) {
2725
}
2826

2927
public function serialize(mixed $data, string $format = 'json', array $context = []): string

‎src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,10 @@
2323
*/
2424
final class StopwatchExtension extends AbstractExtension
2525
{
26-
private ?Stopwatch $stopwatch;
27-
private bool $enabled;
28-
29-
public function __construct(?Stopwatch $stopwatch = null, bool $enabled = true)
30-
{
31-
$this->stopwatch = $stopwatch;
32-
$this->enabled = $enabled;
26+
public function __construct(
27+
private ?Stopwatch $stopwatch = null,
28+
private bool $enabled = true,
29+
) {
3330
}
3431

3532
public function getStopwatch(): Stopwatch

‎src/Symfony/Bridge/Twig/Extension/TranslationExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/TranslationExtension.php
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,10 @@ class_exists(TranslatorTrait::class);
3434
*/
3535
final class TranslationExtension extends AbstractExtension
3636
{
37-
private ?TranslatorInterface $translator;
38-
private ?TranslationNodeVisitor $translationNodeVisitor;
39-
40-
public function __construct(?TranslatorInterface $translator = null, ?TranslationNodeVisitor $translationNodeVisitor = null)
41-
{
42-
$this->translator = $translator;
43-
$this->translationNodeVisitor = $translationNodeVisitor;
37+
public function __construct(
38+
private ?TranslatorInterface $translator = null,
39+
private ?TranslationNodeVisitor $translationNodeVisitor = null,
40+
) {
4441
}
4542

4643
public function getTranslator(): TranslatorInterface

‎src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
*/
2525
final class WebLinkExtension extends AbstractExtension
2626
{
27-
private RequestStack $requestStack;
28-
29-
public function __construct(RequestStack $requestStack)
30-
{
31-
$this->requestStack = $requestStack;
27+
public function __construct(
28+
private RequestStack $requestStack,
29+
) {
3230
}
3331

3432
public function getFunctions(): array

‎src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@
2525
*/
2626
final class WorkflowExtension extends AbstractExtension
2727
{
28-
private Registry $workflowRegistry;
29-
30-
public function __construct(Registry $workflowRegistry)
31-
{
32-
$this->workflowRegistry = $workflowRegistry;
28+
public function __construct(
29+
private Registry $workflowRegistry,
30+
) {
3331
}
3432

3533
public function getFunctions(): array

‎src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
*/
2222
class TwigRendererEngine extends AbstractRendererEngine
2323
{
24-
private Environment $environment;
2524
private Template $template;
2625

27-
public function __construct(array $defaultThemes, Environment $environment)
28-
{
26+
public function __construct(
27+
array $defaultThemes,
28+
private Environment $environment,
29+
) {
2930
parent::__construct($defaultThemes);
30-
$this->environment = $environment;
3131
}
3232

3333
public function renderBlock(FormView $view, mixed $resource, string $blockName, array $variables = []): string

‎src/Symfony/Bridge/Twig/Mime/BodyRenderer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Mime/BodyRenderer.php
+6-8Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,15 @@
2626
*/
2727
final class BodyRenderer implements BodyRendererInterface
2828
{
29-
private Environment $twig;
30-
private array $context;
3129
private HtmlToTextConverterInterface $converter;
32-
private ?LocaleSwitcher $localeSwitcher = null;
3330

34-
public function __construct(Environment $twig, array $context = [], ?HtmlToTextConverterInterface $converter = null, ?LocaleSwitcher $localeSwitcher = null)
35-
{
36-
$this->twig = $twig;
37-
$this->context = $context;
31+
public function __construct(
32+
private Environment $twig,
33+
private array $context = [],
34+
?HtmlToTextConverterInterface $converter = null,
35+
private ?LocaleSwitcher $localeSwitcher = null,
36+
) {
3837
$this->converter = $converter ?: (interface_exists(HtmlConverterInterface::class) ? new LeagueHtmlToMarkdownConverter() : new DefaultHtmlToTextConverter());
39-
$this->localeSwitcher = $localeSwitcher;
4038
}
4139

4240
public function render(Message $message): void

‎src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,10 @@
2323
*/
2424
final class WrappedTemplatedEmail
2525
{
26-
private Environment $twig;
27-
private TemplatedEmail $message;
28-
29-
public function __construct(Environment $twig, TemplatedEmail $message)
30-
{
31-
$this->twig = $twig;
32-
$this->message = $message;
26+
public function __construct(
27+
private Environment $twig,
28+
private TemplatedEmail $message,
29+
) {
3330
}
3431

3532
public function toName(): string

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.