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

[TwigBridge] Use CPP #54244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[TwigBridge] Use CPP
  • Loading branch information
connorhu authored and nicolas-grekas committed Mar 12, 2024
commit d4f8f3940a169b38be3a06d3e85c1af11312c90b
22 changes: 7 additions & 15 deletions 22 src/Symfony/Bridge/Twig/Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,19 @@
#[AsCommand(name: 'debug:twig', description: 'Show a list of twig functions, filters, globals and tests')]
class DebugCommand extends Command
{
private Environment $twig;
private ?string $projectDir;
private array $bundlesMetadata;
private ?string $twigDefaultPath;

/**
* @var FilesystemLoader[]
*/
private array $filesystemLoaders;

private ?FileLinkFormatter $fileLinkFormatter;

public function __construct(Environment $twig, ?string $projectDir = null, array $bundlesMetadata = [], ?string $twigDefaultPath = null, ?FileLinkFormatter $fileLinkFormatter = null)
{
public function __construct(
private Environment $twig,
private ?string $projectDir = null,
private array $bundlesMetadata = [],
private ?string $twigDefaultPath = null,
private ?FileLinkFormatter $fileLinkFormatter = null,
) {
parent::__construct();

$this->twig = $twig;
$this->projectDir = $projectDir;
$this->bundlesMetadata = $bundlesMetadata;
$this->twigDefaultPath = $twigDefaultPath;
$this->fileLinkFormatter = $fileLinkFormatter;
}

protected function configure(): void
Expand Down
10 changes: 4 additions & 6 deletions 10 src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@
*/
class TwigDataCollector extends DataCollector implements LateDataCollectorInterface
{
private Profile $profile;
private ?Environment $twig;
private array $computed;

public function __construct(Profile $profile, ?Environment $twig = null)
{
$this->profile = $profile;
$this->twig = $twig;
public function __construct(
private Profile $profile,
private ?Environment $twig = null,
) {
}

public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
Expand Down
9 changes: 5 additions & 4 deletions 9 src/Symfony/Bridge/Twig/ErrorRenderer/TwigErrorRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@
*/
class TwigErrorRenderer implements ErrorRendererInterface
{
private Environment $twig;
private HtmlErrorRenderer $fallbackErrorRenderer;
private \Closure|bool $debug;

/**
* @param bool|callable $debug The debugging mode as a boolean or a callable that should return it
*/
public function __construct(Environment $twig, ?HtmlErrorRenderer $fallbackErrorRenderer = null, bool|callable $debug = false)
{
$this->twig = $twig;
public function __construct(
private Environment $twig,
?HtmlErrorRenderer $fallbackErrorRenderer = null,
bool|callable $debug = false,
) {
$this->fallbackErrorRenderer = $fallbackErrorRenderer ?? new HtmlErrorRenderer();
$this->debug = \is_bool($debug) ? $debug : $debug(...);
}
Expand Down
8 changes: 3 additions & 5 deletions 8 src/Symfony/Bridge/Twig/Extension/AssetExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
*/
final class AssetExtension extends AbstractExtension
{
private Packages $packages;

public function __construct(Packages $packages)
{
$this->packages = $packages;
public function __construct(
private Packages $packages,
) {
}

public function getFunctions(): array
Expand Down
8 changes: 3 additions & 5 deletions 8 src/Symfony/Bridge/Twig/Extension/CsrfRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
*/
final class CsrfRuntime
{
private CsrfTokenManagerInterface $csrfTokenManager;

public function __construct(CsrfTokenManagerInterface $csrfTokenManager)
{
$this->csrfTokenManager = $csrfTokenManager;
public function __construct(
private CsrfTokenManagerInterface $csrfTokenManager,
) {
}

public function getCsrfToken(string $tokenId): string
Expand Down
11 changes: 4 additions & 7 deletions 11 src/Symfony/Bridge/Twig/Extension/DumpExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@
*/
final class DumpExtension extends AbstractExtension
{
private ClonerInterface $cloner;
private ?HtmlDumper $dumper;

public function __construct(ClonerInterface $cloner, ?HtmlDumper $dumper = null)
{
$this->cloner = $cloner;
$this->dumper = $dumper;
public function __construct(
private ClonerInterface $cloner,
private ?HtmlDumper $dumper = null,
) {
}

public function getFunctions(): array
Expand Down
8 changes: 3 additions & 5 deletions 8 src/Symfony/Bridge/Twig/Extension/FormExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@
*/
final class FormExtension extends AbstractExtension
{
private ?TranslatorInterface $translator;

public function __construct(?TranslatorInterface $translator = null)
{
$this->translator = $translator;
public function __construct(
private ?TranslatorInterface $translator = null,
) {
}

public function getTokenParsers(): array
Expand Down
8 changes: 3 additions & 5 deletions 8 src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@
*/
final class HttpFoundationExtension extends AbstractExtension
{
private UrlHelper $urlHelper;

public function __construct(UrlHelper $urlHelper)
{
$this->urlHelper = $urlHelper;
public function __construct(
private UrlHelper $urlHelper,
) {
}

public function getFunctions(): array
Expand Down
11 changes: 4 additions & 7 deletions 11 src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
*/
final class HttpKernelRuntime
{
private FragmentHandler $handler;
private ?FragmentUriGeneratorInterface $fragmentUriGenerator;

public function __construct(FragmentHandler $handler, ?FragmentUriGeneratorInterface $fragmentUriGenerator = null)
{
$this->handler = $handler;
$this->fragmentUriGenerator = $fragmentUriGenerator;
public function __construct(
private FragmentHandler $handler,
private ?FragmentUriGeneratorInterface $fragmentUriGenerator = null,
) {
}

/**
Expand Down
5 changes: 3 additions & 2 deletions 5 src/Symfony/Bridge/Twig/Extension/ImportMapRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
*/
class ImportMapRuntime
{
public function __construct(private readonly ImportMapRenderer $importMapRenderer)
{
public function __construct(
private readonly ImportMapRenderer $importMapRenderer,
) {
}

public function importmap(string|array $entryPoint = 'app', array $attributes = []): string
Expand Down
8 changes: 3 additions & 5 deletions 8 src/Symfony/Bridge/Twig/Extension/LogoutUrlExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
*/
final class LogoutUrlExtension extends AbstractExtension
{
private LogoutUrlGenerator $generator;

public function __construct(LogoutUrlGenerator $generator)
{
$this->generator = $generator;
public function __construct(
private LogoutUrlGenerator $generator,
) {
}

public function getFunctions(): array
Expand Down
9 changes: 4 additions & 5 deletions 9 src/Symfony/Bridge/Twig/Extension/ProfilerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@
*/
final class ProfilerExtension extends BaseProfilerExtension
{
private ?Stopwatch $stopwatch;

/**
* @var \SplObjectStorage<Profile, StopwatchEvent>
*/
private \SplObjectStorage $events;

public function __construct(Profile $profile, ?Stopwatch $stopwatch = null)
{
public function __construct(
Profile $profile,
private ?Stopwatch $stopwatch = null,
) {
parent::__construct($profile);

$this->stopwatch = $stopwatch;
$this->events = new \SplObjectStorage();
}

Expand Down
8 changes: 3 additions & 5 deletions 8 src/Symfony/Bridge/Twig/Extension/RoutingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
*/
final class RoutingExtension extends AbstractExtension
{
private UrlGeneratorInterface $generator;

public function __construct(UrlGeneratorInterface $generator)
{
$this->generator = $generator;
public function __construct(
private UrlGeneratorInterface $generator,
) {
}

public function getFunctions(): array
Expand Down
11 changes: 4 additions & 7 deletions 11 src/Symfony/Bridge/Twig/Extension/SecurityExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,10 @@
*/
final class SecurityExtension extends AbstractExtension
{
private ?AuthorizationCheckerInterface $securityChecker;
private ?ImpersonateUrlGenerator $impersonateUrlGenerator;

public function __construct(?AuthorizationCheckerInterface $securityChecker = null, ?ImpersonateUrlGenerator $impersonateUrlGenerator = null)
{
$this->securityChecker = $securityChecker;
$this->impersonateUrlGenerator = $impersonateUrlGenerator;
public function __construct(
private ?AuthorizationCheckerInterface $securityChecker = null,
private ?ImpersonateUrlGenerator $impersonateUrlGenerator = null,
) {
}

public function isGranted(mixed $role, mixed $object = null, ?string $field = null): bool
Expand Down
8 changes: 3 additions & 5 deletions 8 src/Symfony/Bridge/Twig/Extension/SerializerRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
*/
final class SerializerRuntime implements RuntimeExtensionInterface
{
private SerializerInterface $serializer;

public function __construct(SerializerInterface $serializer)
{
$this->serializer = $serializer;
public function __construct(
private SerializerInterface $serializer,
) {
}

public function serialize(mixed $data, string $format = 'json', array $context = []): string
Expand Down
11 changes: 4 additions & 7 deletions 11 src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@
*/
final class StopwatchExtension extends AbstractExtension
{
private ?Stopwatch $stopwatch;
private bool $enabled;

public function __construct(?Stopwatch $stopwatch = null, bool $enabled = true)
{
$this->stopwatch = $stopwatch;
$this->enabled = $enabled;
public function __construct(
private ?Stopwatch $stopwatch = null,
private bool $enabled = true,
) {
}

public function getStopwatch(): Stopwatch
Expand Down
11 changes: 4 additions & 7 deletions 11 src/Symfony/Bridge/Twig/Extension/TranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@ class_exists(TranslatorTrait::class);
*/
final class TranslationExtension extends AbstractExtension
{
private ?TranslatorInterface $translator;
private ?TranslationNodeVisitor $translationNodeVisitor;

public function __construct(?TranslatorInterface $translator = null, ?TranslationNodeVisitor $translationNodeVisitor = null)
{
$this->translator = $translator;
$this->translationNodeVisitor = $translationNodeVisitor;
public function __construct(
private ?TranslatorInterface $translator = null,
private ?TranslationNodeVisitor $translationNodeVisitor = null,
) {
}

public function getTranslator(): TranslatorInterface
Expand Down
8 changes: 3 additions & 5 deletions 8 src/Symfony/Bridge/Twig/Extension/WebLinkExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
*/
final class WebLinkExtension extends AbstractExtension
{
private RequestStack $requestStack;

public function __construct(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
public function __construct(
private RequestStack $requestStack,
) {
}

public function getFunctions(): array
Expand Down
8 changes: 3 additions & 5 deletions 8 src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
*/
final class WorkflowExtension extends AbstractExtension
{
private Registry $workflowRegistry;

public function __construct(Registry $workflowRegistry)
{
$this->workflowRegistry = $workflowRegistry;
public function __construct(
private Registry $workflowRegistry,
) {
}

public function getFunctions(): array
Expand Down
8 changes: 4 additions & 4 deletions 8 src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
*/
class TwigRendererEngine extends AbstractRendererEngine
{
private Environment $environment;
private Template $template;

public function __construct(array $defaultThemes, Environment $environment)
{
public function __construct(
array $defaultThemes,
private Environment $environment,
) {
parent::__construct($defaultThemes);
$this->environment = $environment;
}

public function renderBlock(FormView $view, mixed $resource, string $blockName, array $variables = []): string
Expand Down
14 changes: 6 additions & 8 deletions 14 src/Symfony/Bridge/Twig/Mime/BodyRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@
*/
final class BodyRenderer implements BodyRendererInterface
{
private Environment $twig;
private array $context;
private HtmlToTextConverterInterface $converter;
private ?LocaleSwitcher $localeSwitcher = null;

public function __construct(Environment $twig, array $context = [], ?HtmlToTextConverterInterface $converter = null, ?LocaleSwitcher $localeSwitcher = null)
{
$this->twig = $twig;
$this->context = $context;
public function __construct(
private Environment $twig,
private array $context = [],
?HtmlToTextConverterInterface $converter = null,
private ?LocaleSwitcher $localeSwitcher = null,
) {
$this->converter = $converter ?: (interface_exists(HtmlConverterInterface::class) ? new LeagueHtmlToMarkdownConverter() : new DefaultHtmlToTextConverter());
$this->localeSwitcher = $localeSwitcher;
}

public function render(Message $message): void
Expand Down
11 changes: 4 additions & 7 deletions 11 src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@
*/
final class WrappedTemplatedEmail
{
private Environment $twig;
private TemplatedEmail $message;

public function __construct(Environment $twig, TemplatedEmail $message)
{
$this->twig = $twig;
$this->message = $message;
public function __construct(
private Environment $twig,
private TemplatedEmail $message,
) {
}

public function toName(): string
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.