Skip to content

Commit a889944

Browse files
committed
[HttpKernel] Use CPP
1 parent 9a1048a commit a889944

Some content is hidden

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

52 files changed

+271
-386
lines changed

CacheClearer/ChainCacheClearer.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@
2020
*/
2121
class ChainCacheClearer implements CacheClearerInterface
2222
{
23-
private iterable $clearers;
24-
2523
/**
2624
* @param iterable<mixed, CacheClearerInterface> $clearers
2725
*/
28-
public function __construct(iterable $clearers = [])
29-
{
30-
$this->clearers = $clearers;
26+
public function __construct(
27+
private iterable $clearers = [],
28+
) {
3129
}
3230

3331
public function clear(string $cacheDir): void

CacheWarmer/CacheWarmerAggregate.php

+5-8
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,17 @@
2222
*/
2323
class CacheWarmerAggregate implements CacheWarmerInterface
2424
{
25-
private iterable $warmers;
26-
private bool $debug;
27-
private ?string $deprecationLogsFilepath;
2825
private bool $optionalsEnabled = false;
2926
private bool $onlyOptionalsEnabled = false;
3027

3128
/**
3229
* @param iterable<mixed, CacheWarmerInterface> $warmers
3330
*/
34-
public function __construct(iterable $warmers = [], bool $debug = false, ?string $deprecationLogsFilepath = null)
35-
{
36-
$this->warmers = $warmers;
37-
$this->debug = $debug;
38-
$this->deprecationLogsFilepath = $deprecationLogsFilepath;
31+
public function __construct(
32+
private iterable $warmers = [],
33+
private bool $debug = false,
34+
private ?string $deprecationLogsFilepath = null,
35+
) {
3936
}
4037

4138
public function enableOptionalWarmers(): void

Config/FileLocator.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,9 @@
2121
*/
2222
class FileLocator extends BaseFileLocator
2323
{
24-
private KernelInterface $kernel;
25-
26-
public function __construct(KernelInterface $kernel)
27-
{
28-
$this->kernel = $kernel;
29-
24+
public function __construct(
25+
private KernelInterface $kernel,
26+
) {
3027
parent::__construct();
3128
}
3229

Controller/ArgumentResolver/ServiceValueResolver.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
*/
2525
final class ServiceValueResolver implements ValueResolverInterface
2626
{
27-
private ContainerInterface $container;
28-
29-
public function __construct(ContainerInterface $container)
30-
{
31-
$this->container = $container;
27+
public function __construct(
28+
private ContainerInterface $container,
29+
) {
3230
}
3331

3432
public function resolve(Request $request, ArgumentMetadata $argument): array

Controller/ContainerControllerResolver.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@
2323
*/
2424
class ContainerControllerResolver extends ControllerResolver
2525
{
26-
protected ContainerInterface $container;
27-
28-
public function __construct(ContainerInterface $container, ?LoggerInterface $logger = null)
29-
{
30-
$this->container = $container;
31-
26+
public function __construct(
27+
protected ContainerInterface $container,
28+
?LoggerInterface $logger = null,
29+
) {
3230
parent::__construct($logger);
3331
}
3432

Controller/ControllerReference.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
*/
2727
class ControllerReference
2828
{
29-
public string $controller;
3029
public array $attributes = [];
3130
public array $query = [];
3231

@@ -35,9 +34,11 @@ class ControllerReference
3534
* @param array $attributes An array of parameters to add to the Request attributes
3635
* @param array $query An array of parameters to add to the Request query string
3736
*/
38-
public function __construct(string $controller, array $attributes = [], array $query = [])
39-
{
40-
$this->controller = $controller;
37+
public function __construct(
38+
public string $controller,
39+
array $attributes = [],
40+
array $query = [],
41+
) {
4142
$this->attributes = $attributes;
4243
$this->query = $query;
4344
}

Controller/ControllerResolver.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@
2525
*/
2626
class ControllerResolver implements ControllerResolverInterface
2727
{
28-
private ?LoggerInterface $logger;
2928
private array $allowedControllerTypes = [];
3029
private array $allowedControllerAttributes = [AsController::class => AsController::class];
3130

32-
public function __construct(?LoggerInterface $logger = null)
33-
{
34-
$this->logger = $logger;
31+
public function __construct(
32+
private ?LoggerInterface $logger = null,
33+
) {
3534
}
3635

3736
/**

Controller/ErrorController.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,11 @@
2525
*/
2626
class ErrorController
2727
{
28-
private HttpKernelInterface $kernel;
29-
private string|object|array|null $controller;
30-
private ErrorRendererInterface $errorRenderer;
31-
32-
public function __construct(HttpKernelInterface $kernel, string|object|array|null $controller, ErrorRendererInterface $errorRenderer)
33-
{
34-
$this->kernel = $kernel;
35-
$this->controller = $controller;
36-
$this->errorRenderer = $errorRenderer;
28+
public function __construct(
29+
private HttpKernelInterface $kernel,
30+
private string|object|array|null $controller,
31+
private ErrorRendererInterface $errorRenderer,
32+
) {
3733
}
3834

3935
public function __invoke(\Throwable $exception): Response

Controller/TraceableArgumentResolver.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
*/
2020
class TraceableArgumentResolver implements ArgumentResolverInterface
2121
{
22-
private ArgumentResolverInterface $resolver;
23-
private Stopwatch $stopwatch;
24-
25-
public function __construct(ArgumentResolverInterface $resolver, Stopwatch $stopwatch)
26-
{
27-
$this->resolver = $resolver;
28-
$this->stopwatch = $stopwatch;
22+
public function __construct(
23+
private ArgumentResolverInterface $resolver,
24+
private Stopwatch $stopwatch,
25+
) {
2926
}
3027

3128
public function getArguments(Request $request, callable $controller, ?\ReflectionFunctionAbstract $reflector = null): array

Controller/TraceableControllerResolver.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
*/
2020
class TraceableControllerResolver implements ControllerResolverInterface
2121
{
22-
private ControllerResolverInterface $resolver;
23-
private Stopwatch $stopwatch;
24-
25-
public function __construct(ControllerResolverInterface $resolver, Stopwatch $stopwatch)
26-
{
27-
$this->resolver = $resolver;
28-
$this->stopwatch = $stopwatch;
22+
public function __construct(
23+
private ControllerResolverInterface $resolver,
24+
private Stopwatch $stopwatch,
25+
) {
2926
}
3027

3128
public function getController(Request $request): callable|false

ControllerMetadata/ArgumentMetadata.php

+9-16
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,19 @@ class ArgumentMetadata
2020
{
2121
public const IS_INSTANCEOF = 2;
2222

23-
private string $name;
24-
private ?string $type;
25-
private bool $isVariadic;
26-
private bool $hasDefaultValue;
27-
private mixed $defaultValue;
28-
private bool $isNullable;
29-
private array $attributes;
30-
3123
/**
3224
* @param object[] $attributes
3325
*/
34-
public function __construct(string $name, ?string $type, bool $isVariadic, bool $hasDefaultValue, mixed $defaultValue, bool $isNullable = false, array $attributes = [])
35-
{
36-
$this->name = $name;
37-
$this->type = $type;
38-
$this->isVariadic = $isVariadic;
39-
$this->hasDefaultValue = $hasDefaultValue;
40-
$this->defaultValue = $defaultValue;
26+
public function __construct(
27+
private string $name,
28+
private ?string $type,
29+
private bool $isVariadic,
30+
private bool $hasDefaultValue,
31+
private mixed $defaultValue,
32+
private bool $isNullable = false,
33+
private array $attributes = [],
34+
) {
4135
$this->isNullable = $isNullable || null === $type || ($hasDefaultValue && null === $defaultValue);
42-
$this->attributes = $attributes;
4336
}
4437

4538
/**

DataCollector/DumpDataCollector.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,27 @@
3131
*/
3232
class DumpDataCollector extends DataCollector implements DataDumperInterface
3333
{
34-
private ?Stopwatch $stopwatch = null;
3534
private string|FileLinkFormatter|false $fileLinkFormat;
3635
private int $dataCount = 0;
3736
private bool $isCollected = true;
3837
private int $clonesCount = 0;
3938
private int $clonesIndex = 0;
4039
private array $rootRefs;
4140
private string $charset;
42-
private ?RequestStack $requestStack;
43-
private DataDumperInterface|Connection|null $dumper;
4441
private mixed $sourceContextProvider;
4542
private bool $webMode;
4643

47-
public function __construct(?Stopwatch $stopwatch = null, string|FileLinkFormatter|null $fileLinkFormat = null, ?string $charset = null, ?RequestStack $requestStack = null, DataDumperInterface|Connection|null $dumper = null, ?bool $webMode = null)
48-
{
44+
public function __construct(
45+
private ?Stopwatch $stopwatch = null,
46+
string|FileLinkFormatter|null $fileLinkFormat = null,
47+
?string $charset = null,
48+
private ?RequestStack $requestStack = null,
49+
private DataDumperInterface|Connection|null $dumper = null,
50+
?bool $webMode = null,
51+
) {
4952
$fileLinkFormat = $fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
50-
$this->stopwatch = $stopwatch;
5153
$this->fileLinkFormat = $fileLinkFormat instanceof FileLinkFormatter && false === $fileLinkFormat->format('', 0) ? false : $fileLinkFormat;
5254
$this->charset = $charset ?: \ini_get('php.output_encoding') ?: \ini_get('default_charset') ?: 'UTF-8';
53-
$this->requestStack = $requestStack;
54-
$this->dumper = $dumper;
5555
$this->webMode = $webMode ?? !\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true);
5656

5757
// All clones share these properties by reference:
@@ -180,7 +180,7 @@ public function __wakeup(): void
180180
}
181181
}
182182

183-
self::__construct($this->stopwatch, \is_string($fileLinkFormat) || $fileLinkFormat instanceof FileLinkFormatter ? $fileLinkFormat : null, \is_string($charset) ? $charset : null);
183+
self::__construct($this->stopwatch ?? null, \is_string($fileLinkFormat) || $fileLinkFormat instanceof FileLinkFormatter ? $fileLinkFormat : null, \is_string($charset) ? $charset : null);
184184
}
185185

186186
public function getDumpsCount(): int

DataCollector/LoggerDataCollector.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,15 @@
2727
class LoggerDataCollector extends DataCollector implements LateDataCollectorInterface
2828
{
2929
private ?DebugLoggerInterface $logger;
30-
private ?string $containerPathPrefix;
3130
private ?Request $currentRequest = null;
32-
private ?RequestStack $requestStack;
3331
private ?array $processedLogs = null;
3432

35-
public function __construct(?object $logger = null, ?string $containerPathPrefix = null, ?RequestStack $requestStack = null)
36-
{
33+
public function __construct(
34+
?object $logger = null,
35+
private ?string $containerPathPrefix = null,
36+
private ?RequestStack $requestStack = null,
37+
) {
3738
$this->logger = DebugLoggerConfigurator::getDebugLogger($logger);
38-
$this->containerPathPrefix = $containerPathPrefix;
39-
$this->requestStack = $requestStack;
4039
}
4140

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

DataCollector/RequestDataCollector.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
3636
*/
3737
private \SplObjectStorage $controllers;
3838
private array $sessionUsages = [];
39-
private ?RequestStack $requestStack;
4039

41-
public function __construct(?RequestStack $requestStack = null)
42-
{
40+
public function __construct(
41+
private ?RequestStack $requestStack = null,
42+
) {
4343
$this->controllers = new \SplObjectStorage();
44-
$this->requestStack = $requestStack;
4544
}
4645

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

DataCollector/TimeDataCollector.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@
2424
*/
2525
class TimeDataCollector extends DataCollector implements LateDataCollectorInterface
2626
{
27-
private ?KernelInterface $kernel;
28-
private ?Stopwatch $stopwatch;
29-
30-
public function __construct(?KernelInterface $kernel = null, ?Stopwatch $stopwatch = null)
31-
{
32-
$this->kernel = $kernel;
33-
$this->stopwatch = $stopwatch;
27+
public function __construct(
28+
private readonly ?KernelInterface $kernel = null,
29+
private readonly ?Stopwatch $stopwatch = null,
30+
) {
3431
$this->data = ['events' => [], 'stopwatch_installed' => false, 'start_time' => 0];
3532
}
3633

Debug/ErrorHandlerConfigurator.php

+8-10
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,25 @@
2323
*/
2424
class ErrorHandlerConfigurator
2525
{
26-
private ?LoggerInterface $logger;
27-
private ?LoggerInterface $deprecationLogger;
2826
private array|int|null $levels;
2927
private ?int $throwAt;
30-
private bool $scream;
31-
private bool $scope;
3228

3329
/**
3430
* @param array|int|null $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants
3531
* @param int|null $throwAt Thrown errors in a bit field of E_* constants, or null to keep the current value
3632
* @param bool $scream Enables/disables screaming mode, where even silenced errors are logged
3733
* @param bool $scope Enables/disables scoping mode
3834
*/
39-
public function __construct(?LoggerInterface $logger = null, array|int|null $levels = \E_ALL, ?int $throwAt = \E_ALL, bool $scream = true, bool $scope = true, ?LoggerInterface $deprecationLogger = null)
40-
{
41-
$this->logger = $logger;
35+
public function __construct(
36+
private ?LoggerInterface $logger = null,
37+
array|int|null $levels = \E_ALL,
38+
?int $throwAt = \E_ALL,
39+
private bool $scream = true,
40+
private bool $scope = true,
41+
private ?LoggerInterface $deprecationLogger = null,
42+
) {
4243
$this->levels = $levels ?? \E_ALL;
4344
$this->throwAt = \is_int($throwAt) ? $throwAt : (null === $throwAt ? null : ($throwAt ? \E_ALL : null));
44-
$this->scream = $scream;
45-
$this->scope = $scope;
46-
$this->deprecationLogger = $deprecationLogger;
4745
}
4846

4947
/**

DependencyInjection/AddAnnotatedClassesToCachePass.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
*/
2525
class AddAnnotatedClassesToCachePass implements CompilerPassInterface
2626
{
27-
private Kernel $kernel;
28-
29-
public function __construct(Kernel $kernel)
30-
{
31-
$this->kernel = $kernel;
27+
public function __construct(
28+
private Kernel $kernel,
29+
) {
3230
}
3331

3432
public function process(ContainerBuilder $container): void

DependencyInjection/LazyLoadingFragmentHandler.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@
2323
*/
2424
class LazyLoadingFragmentHandler extends FragmentHandler
2525
{
26-
private ContainerInterface $container;
27-
2826
/**
2927
* @var array<string, bool>
3028
*/
3129
private array $initialized = [];
3230

33-
public function __construct(ContainerInterface $container, RequestStack $requestStack, bool $debug = false)
34-
{
35-
$this->container = $container;
36-
31+
public function __construct(
32+
private ContainerInterface $container,
33+
RequestStack $requestStack,
34+
bool $debug = false,
35+
) {
3736
parent::__construct($requestStack, [], $debug);
3837
}
3938

0 commit comments

Comments
 (0)