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

Skip to content

Commit 28923f4

Browse files
andreyboloninfabpot
authored andcommitted
Use CPP in full code base
1 parent 75d888f commit 28923f4

23 files changed

Lines changed: 74 additions & 119 deletions

src/Cache/ChainCache.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@
2121
*/
2222
final class ChainCache implements CacheInterface
2323
{
24-
private $caches;
25-
2624
/**
2725
* @param iterable<CacheInterface> $caches The ordered list of caches used to store and fetch cached items
2826
*/
29-
public function __construct(iterable $caches)
30-
{
31-
$this->caches = $caches;
27+
public function __construct(
28+
private iterable $caches,
29+
) {
3230
}
3331

3432
public function generateKey(string $name, string $className): string

src/Compiler.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@ class Compiler
2222
private $lastLine;
2323
private $source;
2424
private $indentation;
25-
private $env;
2625
private $debugInfo = [];
2726
private $sourceOffset;
2827
private $sourceLine;
2928
private $varNameSalt = 0;
3029
private $didUseEcho = false;
3130
private $didUseEchoStack = [];
3231

33-
public function __construct(Environment $env)
34-
{
35-
$this->env = $env;
32+
public function __construct(
33+
private Environment $env,
34+
) {
3635
}
3736

3837
public function getEnvironment(): Environment

src/Environment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class Environment
107107
* false (default): allows templates to use a mix of "yield" and "echo" calls to allow for a progressive migration
108108
* Switch to "true" when possible as this will be the only supported mode in Twig 4.0
109109
*/
110-
public function __construct(LoaderInterface $loader, $options = [])
110+
public function __construct(LoaderInterface $loader, array $options = [])
111111
{
112112
$this->setLoader($loader);
113113

src/ExpressionParser.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,16 @@ class ExpressionParser
4747
public const OPERATOR_LEFT = 1;
4848
public const OPERATOR_RIGHT = 2;
4949

50-
private $parser;
51-
private $env;
5250
/** @var array<string, array{precedence: int, class: class-string<AbstractUnary>}> */
5351
private $unaryOperators;
5452
/** @var array<string, array{precedence: int, class: class-string<AbstractBinary>, associativity: self::OPERATOR_*}> */
5553
private $binaryOperators;
5654
private $readyNodes = [];
5755

58-
public function __construct(Parser $parser, Environment $env)
59-
{
60-
$this->parser = $parser;
61-
$this->env = $env;
56+
public function __construct(
57+
private Parser $parser,
58+
private Environment $env,
59+
) {
6260
$this->unaryOperators = $env->getUnaryOperators();
6361
$this->binaryOperators = $env->getBinaryOperators();
6462
}

src/Extension/OptimizerExtension.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515

1616
final class OptimizerExtension extends AbstractExtension
1717
{
18-
private $optimizers;
19-
20-
public function __construct(int $optimizers = -1)
21-
{
22-
$this->optimizers = $optimizers;
18+
public function __construct(
19+
private int $optimizers = -1,
20+
) {
2321
}
2422

2523
public function getNodeVisitors(): array

src/Extension/YieldNotReadyExtension.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
*/
1919
final class YieldNotReadyExtension extends AbstractExtension
2020
{
21-
private $useYield;
22-
23-
public function __construct(bool $useYield)
24-
{
25-
$this->useYield = $useYield;
21+
public function __construct(
22+
private bool $useYield,
23+
) {
2624
}
2725

2826
public function getNodeVisitors(): array

src/Loader/ArrayLoader.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@
2828
*/
2929
final class ArrayLoader implements LoaderInterface
3030
{
31-
private $templates = [];
32-
3331
/**
3432
* @param array $templates An array of templates (keys are the names, and values are the source code)
3533
*/
36-
public function __construct(array $templates = [])
37-
{
38-
$this->templates = $templates;
34+
public function __construct(
35+
private array $templates = [],
36+
) {
3937
}
4038

4139
public function setTemplate(string $name, string $template): void

src/Loader/ChainLoader.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121
*/
2222
final class ChainLoader implements LoaderInterface
2323
{
24-
/**
25-
* @var \Traversable<LoaderInterface>|LoaderInterface[]
26-
*/
27-
private $loaders;
28-
2924
/**
3025
* @var array<string, bool>
3126
*/
@@ -34,9 +29,9 @@ final class ChainLoader implements LoaderInterface
3429
/**
3530
* @param iterable<LoaderInterface> $loaders
3631
*/
37-
public function __construct(iterable $loaders = [])
38-
{
39-
$this->loaders = $loaders;
32+
public function __construct(
33+
private iterable $loaders = [],
34+
) {
4035
}
4136

4237
public function addLoader(LoaderInterface $loader): void

src/Markup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class Markup implements \Countable, \JsonSerializable
2020
{
2121
private $content;
22-
private $charset;
22+
private ?string $charset;
2323

2424
public function __construct($content, $charset)
2525
{

src/NodeVisitor/OptimizerNodeVisitor.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ final class OptimizerNodeVisitor implements NodeVisitorInterface
4747

4848
private $loops = [];
4949
private $loopsTargets = [];
50-
private $optimizers;
5150

5251
/**
5352
* @param int $optimizers The optimizer mode
5453
*/
55-
public function __construct(int $optimizers = -1)
56-
{
54+
public function __construct(
55+
private int $optimizers = -1,
56+
) {
5757
if ($optimizers > (self::OPTIMIZE_FOR | self::OPTIMIZE_RAW_FILTER | self::OPTIMIZE_TEXT_NODES)) {
5858
throw new \InvalidArgumentException(\sprintf('Optimizer mode "%s" is not valid.', $optimizers));
5959
}
@@ -65,8 +65,6 @@ public function __construct(int $optimizers = -1)
6565
if (-1 !== $optimizers && self::OPTIMIZE_TEXT_NODES === (self::OPTIMIZE_TEXT_NODES & $optimizers)) {
6666
trigger_deprecation('twig/twig', '3.12', 'The "Twig\NodeVisitor\OptimizerNodeVisitor::OPTIMIZE_TEXT_NODES" option is deprecated and does nothing.');
6767
}
68-
69-
$this->optimizers = $optimizers;
7068
}
7169

7270
public function enterNode(Node $node, Environment $env): Node

0 commit comments

Comments
 (0)