8000 use constructor property promotion · symfony/twig-bundle@d8e28af · GitHub
[go: up one dir, main page]

Skip to content

Commit d8e28af

Browse files
committed
use constructor property promotion
1 parent ea62eda commit d8e28af

File tree

3 files changed

+21
-32
lines changed

3 files changed

+21
-32
lines changed

CacheWarmer/TemplateCacheWarmer.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
*/
2727
class TemplateCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface
2828
{
29-
private ContainerInterface $container;
3029
private Environment $twig;
31-
private iterable $iterator;
3230

33-
public function __construct(ContainerInterface $container, iterable $iterator)
34-
{
35-
// As this cache warmer is optional, dependencies should be lazy-loaded, that's why a container should be injected.
36-
$this->container = $container;
37-
$this->iterator = $iterator;
31+
/**
32+
* As this cache warmer is optional, dependencies should be lazy-loaded, that's why a container should be injected.
33+
*/
34+
public function __construct(
35+
private ContainerInterface $container,
36+
private iterable $iterator,
37+
) {
3838
}
3939

4040
public function warmUp(string $cacheDir, ?string $buildDir = null): array

DependencyInjection/Configurator/EnvironmentConfigurator.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,14 @@
2222
*/
2323
class EnvironmentConfigurator
2424
{
25-
private string $dateFormat;
26-
private string $intervalFormat;
27-
private ?string $timezone;
28-
private int $decimals;
29-
private string $decimalPoint;
30-
private string $thousandsSeparator;
31-
32-
public function __construct(string $dateFormat, string $intervalFormat, ?string $timezone, int $decimals, string $decimalPoint, string $thousandsSeparator)
33-
{
34-
$this->dateFormat = $dateFormat;
35-
$this->intervalFormat = $intervalFormat;
36-
$this->timezone = $timezone;
37-
$this->decimals = $decimals;
38-
$this->decimalPoint = $decimalPoint;
39-
$this->thousandsSeparator = $thousandsSeparator;
25+
public function __construct(
26+
private string $dateFormat,
27+
private string $intervalFormat,
28+
private ?string $timezone,
29+
private int $decimals,
30+
private string $decimalPoint,
31+
private string $thousandsSeparator,
32+
) {
4033
}
4134

4235
public function configure(Environment $environment): void

TemplateIterator.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,19 @@
2525
*/
2626
class TemplateIterator implements \IteratorAggregate
2727
{
28-
private KernelInterface $kernel;
2928
private \Traversable $templates;
30-
private array $paths;
31-
private ?string $defaultPath;
32-
private array $namePatterns;
3329

3430
/**
3531
* @param array $paths Additional Twig paths to warm
3632
* @param string|null $defaultPath The directory where global templates can be stored
3733
* @param string[] $namePatterns Pattern of file names
3834
*/
39-
public function __construct(KernelInterface $kernel, array $paths = [], ?string $defaultPath = null, array $namePatterns = [])
40-
{
41-
$this->kernel = $kernel;
42-
$this->paths = $paths;
43-
$this->defaultPath = $defaultPath;
44-
$this->namePatterns = $namePatterns;
35+
public function __construct(
36+
private KernelInterface $kernel,
37+
private array $paths = [],
38+
private ?string $defaultPath = null,
39+
private array $namePatterns = [],
40+
) {
4541
}
4642

4743
public function getIterator(): \Traversable

0 commit comments

Comments
 (0)
0