Skip to content

Commit 877f6b2

Browse files
Use CPP where possible
1 parent a03a2f6 commit 877f6b2

File tree

81 files changed

+332
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+332
-480
lines changed

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/CachePoolClearerCacheWarmer.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,13 @@
2525
*/
2626
final class CachePoolClearerCacheWarmer implements CacheWarmerInterface
2727
{
28-
private Psr6CacheClearer $poolClearer;
29-
private array $pools;
30-
3128
/**
3229
* @param string[] $pools
3330
*/
34-
public function __construct(Psr6CacheClearer $poolClearer, array $pools = [])
35-
{
36-
$this->poolClearer = $poolClearer;
37-
$this->pools = $pools;
31+
public function __construct(
32+
private Psr6CacheClearer $poolClearer,
33+
private array $pools = [],
34+
) {
3835
}
3936

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

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ConfigBuilderCacheWarmer.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,10 @@
3434
*/
3535
class ConfigBuilderCacheWarmer implements CacheWarmerInterface
3636
{
37-
private KernelInterface $kernel;
38-
private ?LoggerInterface $logger;
39-
40-
public function __construct(KernelInterface $kernel, ?LoggerInterface $logger = null)
41-
{
42-
$this->kernel = $kernel;
43-
$this->logger = $logger;
37+
public function __construct(
38+
private KernelInterface $kernel,
39+
private ?LoggerInterface $logger = null,
40+
) {
4441
}
4542

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

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
*/
2727
class RouterCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface
2828
{
29-
private ContainerInterface $container;
30-
31-
public function __construct(ContainerInterface $container)
32-
{
33-
// As this cache warmer is optional, dependencies should be lazy-loaded, that's why a container should be injected.
34-
$this->container = $container;
29+
/**
30+
* As this cache warmer is optional, dependencies should be lazy-loaded, that's why a container should be injected.
31+
*/
32+
public function __construct(
33+
private ContainerInterface $container,
34+
) {
3535
}
3636

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

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@
2626
*/
2727
class TranslationsCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface
2828
{
29-
private ContainerInterface $container;
3029
private TranslatorInterface $translator;
3130

32-
public function __construct(ContainerInterface $container)
33-
{
34-
// As this cache warmer is optional, dependencies should be lazy-loaded, that's why a container should be injected.
35-
$this->container = $container;
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+
) {
3637
}
3738

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

src/Symfony/Bundle/FrameworkBundle/Routing/Router.php

+9-4
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,21 @@
3535
*/
3636
class Router extends BaseRouter implements WarmableInterface, ServiceSubscriberInterface
3737
{
38-
private ContainerInterface $container;
3938
private array $collectedParameters = [];
4039
private \Closure $paramFetcher;
4140

4241
/**
4342
* @param mixed $resource The main resource to load
4443
*/
45-
public function __construct(ContainerInterface $container, mixed $resource, array $options = [], ?RequestContext $context = null, ?ContainerInterface $parameters = null, ?LoggerInterface $logger = null, ?string $defaultLocale = null)
46-
{
47-
$this->container = $container;
44+
public function __construct(
45+
private ContainerInterface $container,
46+
mixed $resource,
47+
array $options = [],
48+
?RequestContext $context = null,
49+
?ContainerInterface $parameters = null,
50+
?LoggerInterface $logger = null,
51+
?string $defaultLocale = null,
52+
) {
4853
$this->resource = $resource;
4954
$this->context = $context ?? new RequestContext();
5055
$this->logger = $logger;

src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,19 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface
2626
private string|\Stringable|null $decryptionKey = null;
2727
private string $pathPrefix;
2828
private ?string $secretsDir;
29-
private ?string $derivedSecretEnvVar;
3029

3130
/**
3231
* @param $decryptionKey A string or a stringable object that defines the private key to use to decrypt the vault
3332
* or null to store generated keys in the provided $secretsDir
3433
*/
35-
public function __construct(string $secretsDir, #[\SensitiveParameter] string|\Stringable|null $decryptionKey = null, ?string $derivedSecretEnvVar = null)
36-
{
34+
public function __construct(
35+
string $secretsDir,
36+
#[\SensitiveParameter] string|\Stringable|null $decryptionKey = null,
37+
private ?string $derivedSecretEnvVar = null,
38+
) {
3739
$this->pathPrefix = rtrim(strtr($secretsDir, '/', \DIRECTORY_SEPARATOR), \DIRECTORY_SEPARATOR).\DIRECTORY_SEPARATOR.basename($secretsDir).'.';
3840
$this->decryptionKey = $decryptionKey;
3941
$this->secretsDir = $secretsDir;
40-
$this->derivedSecretEnvVar = $derivedSecretEnvVar;
4142
}
4243

4344
public function generateKeys(bool $override = false): bool

src/Symfony/Component/Asset/Exception/AssetNotFoundException.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616
*/
1717
class AssetNotFoundException extends RuntimeException
1818
{
19-
private array $alternatives;
20-
2119
/**
2220
* @param string $message Exception message to throw
2321
* @param array $alternatives List of similar defined names
2422
* @param int $code Exception code
2523
* @param \Throwable $previous Previous exception used for the exception chaining
2624
*/
27-
public function __construct(string $message, array $alternatives = [], int $code = 0, ?\Throwable $previous = null)
28-
{
25+
public function __construct(
26+
string $message,
27+
private array $alternatives = [],
28+
int $code = 0,
29+
?\Throwable $previous = null,
30+
) {
2931
parent::__construct($message, $code, $previous);
30-
31-
$this->alternatives = $alternatives;
3232
}
3333

3434
public function getAlternatives(): array

src/Symfony/Component/BrowserKit/Test/Constraint/BrowserCookieValueSame.php

+7-13
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,13 @@
1616

1717
final class BrowserCookieValueSame extends Constraint
1818
{
19-
private string $name;
20-
private string $value;
21-
private bool $raw;
22-
private string $path;
23-
private ?string $domain;
24-
25-
public function __construct(string $name, string $value, bool $raw = false, string $path = '/', ?string $domain = null)
26-
{
27-
$this->name = $name;
28-
$this->path = $path;
29-
$this->domain = $domain;
30-
$this->value = $value;
31-
$this->raw = $raw;
19+
public function __construct(
20+
private string $name,
21+
private string $value,
22+
private bool $raw = false,
23+
private string $path = '/',
24+
private ?string $domain = null,
25+
) {
3226
}
3327

3428
public function toString(): string

src/Symfony/Component/BrowserKit/Test/Constraint/BrowserHasCookie.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@
1616

1717
final class BrowserHasCookie extends Constraint
1818
{
19-
private string $name;
20-
private string $path;
21-
private ?string $domain;
22-
23-
public function __construct(string $name, string $path = '/', ?string $domain = null)
24-
{
25-
$this->name = $name;
26-
$this->path = $path;
27-
$this->domain = $domain;
19+
public function __construct(
20+
private string $name,
21+
private string $path = '/',
22+
private ?string $domain = null,
23+
) {
2824
}
2925

3026
public function toString(): string

src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,8 @@ private function getFileKey(string $file): string
305305
*/
306306
class LazyValue
307307
{
308-
public string $file;
309-
310-
public function __construct(string $file)
311-
{
312-
$this->file = $file;
308+
public function __construct(
309+
public string $file,
310+
) {
313311
}
314312
}

src/Symfony/Component/Cache/Adapter/TraceableAdapter.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727
*/
2828
class TraceableAdapter implements AdapterInterface, CacheInterface, PruneableInterface, ResettableInterface
2929
{
30-
protected AdapterInterface $pool;
3130
private array $calls = [];
3231

33-
public function __construct(AdapterInterface $pool)
34-
{
35-
$this->pool = $pool;
32+
public function __construct(
33+
protected AdapterInterface $pool,
34+
) {
3635
}
3736

3837
public function get(string $key, callable $callback, ?float $beta = null, ?array &$metadata = null): mixed

src/Symfony/Component/Cache/Messenger/EarlyExpirationMessage.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
*/
2121
final class EarlyExpirationMessage
2222
{
23-
private CacheItem $item;
24-
private string $pool;
25-
private string|array $callback;
26-
2723
public static function create(ReverseContainer $reverseContainer, callable $callback, CacheItem $item, AdapterInterface $pool): ?self
2824
{
2925
try {
@@ -91,10 +87,10 @@ public function findCallback(ReverseContainer $reverseContainer): callable
9187
return $callback;
9288
}
9389

94-
private function __construct(CacheItem $item, string $pool, string|array $callback)
95-
{
96-
$this->item = $item;
97-
$this->pool = $pool;
98-
$this->callback = $callback;
90+
private function __construct(
91+
private CacheItem $item,
92+
private string $pool,
93+
private string|array $callback,
94+
) {
9995
}
10096
}

src/Symfony/Component/Config/Definition/NumericNode.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
*/
2121
class NumericNode extends ScalarNode
2222
{
23-
protected int|float|null $min;
24-
protected int|float|null $max;
25-
26-
public function __construct(?string $name, ?NodeInterface $parent = null, int|float|null $min = null, int|float|null $max = null, string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR)
27-
{
23+
public function __construct(
24+
?string $name,
25+
?NodeInterface $parent = null,
26+
protected int|float|null $min = null,
27+
protected int|float|null $max = null,
28+
string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR,
29+
) {
2830
parent::__construct($name, $parent, $pathSeparator);
29-
$this->min = $min;
30-
$this->max = $max;
3131
}
3232

3333
protected function finalizeValue(mixed $value): mixed

src/Symfony/Component/Config/Exception/FileLocatorFileNotFoundException.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
*/
1919
class FileLocatorFileNotFoundException extends \InvalidArgumentException
2020
{
21-
private array $paths;
22-
23-
public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null, array $paths = [])
24-
{
21+
public function __construct(
22+
string $message = '',
23+
int $code = 0,
24+
?\Throwable $previous = null,
25+
private array $paths = [],
26+
) {
2527
parent::__construct($message, $code, $previous);
26-
27-
$this->paths = $paths;
2828
}
2929

3030
public function getPaths(): array

src/Symfony/Component/Config/Loader/FileLoader.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ abstract class FileLoader extends Loader
2727
{
2828
protected static array $loading = [];
2929

30-
protected FileLocatorInterface $locator;
31-
3230
private ?string $currentDir = null;
3331

34-
public function __construct(FileLocatorInterface $locator, ?string $env = null)
35-
{
36-
$this->locator = $locator;
32+
public function __construct(
33+
protected FileLocatorInterface $locator,
34+
?string $env = null,
35+
) {
3736
parent::__construct($env);
3837
}
3938

src/Symfony/Component/Config/Resource/ReflectionClassResource.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ class ReflectionClassResource implements SelfCheckingResourceInterface
2323
{
2424
private array $files = [];
2525
private string $className;
26-
private \ReflectionClass $classReflector;
2726
private array $excludedVendors = [];
2827
private string $hash;
2928

30-
public function __construct(\ReflectionClass $classReflector, array $excludedVendors = [])
31-
{
29+
public function __construct(
30+
private \ReflectionClass $classReflector,
31+
array $excludedVendors = [],
32+
) {
3233
$this->className = $classReflector->name;
33-
$this->classReflector = $classReflector;
3434
$this->excludedVendors = $excludedVendors;
3535
}
3636

src/Symfony/Component/Console/CI/GithubActionReporter.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
*/
2121
class GithubActionReporter
2222
{
23-
private OutputInterface $output;
24-
2523
/**
2624
* @see https://github.com/actions/toolkit/blob/5e5e1b7aacba68a53836a34db4a288c3c1c1585b/packages/core/src/command.ts#L80-L85
2725
*/
@@ -42,9 +40,9 @@ class GithubActionReporter
4240
',' => '%2C',
4341
];
4442

45-
public function __construct(OutputInterface $output)
46-
{
47-
$this->output = $output;
43+
public function __construct(
44+
private OutputInterface $output,
45+
) {
4846
}
4947

5048
public static function isGithubActionEnvironment(): bool

src/Symfony/Component/Console/Formatter/OutputFormatter.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424
class OutputFormatter implements WrappableOutputFormatterInterface
2525
{
26-
private bool $decorated;
2726
private array $styles = [];
2827
private OutputFormatterStyleStack $styleStack;
2928

@@ -67,10 +66,10 @@ public static function escapeTrailingBackslash(string $text): string
6766
*
6867
* @param OutputFormatterStyleInterface[] $styles Array of "name => FormatterStyle" instances
6968
*/
70-
public function __construct(bool $decorated = false, array $styles = [])
71-
{
72-
$this->decorated = $decorated;
73-
69+
public function __construct(
70+
private bool $decorated = false,
71+
array $styles = [],
72+
) {
7473
$this->setStyle('error', new OutputFormatterStyle('white', 'red'));
7574
$this->setStyle('info', new OutputFormatterStyle('green'));
7675
$this->setStyle('comment', new OutputFormatterStyle('yellow'));

src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ public static function getSubscribedServices(): array
452452
'autowired' => new ServiceClosureArgument(new TypedReference('service.id', 'stdClass', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, 'autowired', [new Autowire(service: 'service.id')])),
453453
'autowired.nullable' => new ServiceClosureArgument(new TypedReference('service.id', 'stdClass', ContainerInterface::IGNORE_ON_INVALID_REFERENCE, 'autowired.nullable', [new Autowire(service: 'service.id')])),
454454
'autowired.parameter' => new ServiceClosureArgument('foobar'),
455-
'autowire.decorated' => new ServiceClosureArgument(new Reference('.service_locator.PIYLhDv.inner', ContainerInterface::NULL_ON_INVALID_REFERENCE)),
455+
'autowire.decorated' => new ServiceClosureArgument(new Reference('.service_locator.oNVewcO.inner', ContainerInterface::NULL_ON_INVALID_REFERENCE)),
456456
'target' => new ServiceClosureArgument(new TypedReference('stdClass', 'stdClass', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, 'target', [new Target('someTarget')])),
457457
];
458458
$this->assertEquals($expected, $container->getDefinition((string) $locator->getFactory()[0])->getArgument(0));

0 commit comments

Comments
 (0)