8000 [Dotenv][ErrorHandler][EventDispatcher] Use CPP · symfony/symfony@5c7ecdc · GitHub
[go: up one dir, main page]

Skip to content

Commit 5c7ecdc

Browse files
OskarStarknicolas-grekas
authored andcommitted
[Dotenv][ErrorHandler][EventDispatcher] Use CPP
1 parent 944122a commit 5c7ecdc

22 files changed

+109
-148
lines changed

src/Symfony/Component/Dotenv/Command/DebugCommand.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,10 @@
2929
#[AsCommand(name: 'debug:dotenv', description: 'List all dotenv files with variables and values')]
3030
final class DebugCommand extends Command
3131
{
32-
private string $kernelEnvironment;
33-
private string $projectDirectory;
34-
35-
public function __construct(string $kernelEnvironment, string $projectDirectory)
36-
{
37-
$this->kernelEnvironment = $kernelEnvironment;
38-
$this->projectDirectory = $projectDirectory;
39-
32+
public function __construct(
33+
private string $kernelEnvironment,
34+
private string $projectDirectory,
35+
) {
4036
parent::__construct();
4137
}
4238

src/Symfony/Component/Dotenv/Command/DotenvDumpCommand.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,10 @@
2929
#[AsCommand(name: 'dotenv:dump', description: 'Compile .env files to .env.local.php')]
3030
final class DotenvDumpCommand extends Command
3131
{
32-
private string $projectDir;
33-
private ?string $defaultEnv;
34-
35-
public function __construct(string $projectDir, string $defaultEnv = null)
36-
{
37-
$this->projectDir = $projectDir;
38-
$this->defaultEnv = $defaultEnv;
39-
32+
public function __construct(
33+
private string $projectDir,
34+
private ?string $defaultEnv = null,
35+
) {
4036
parent::__construct();
4137
}
4238

src/Symfony/Component/Dotenv/Dotenv.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,13 @@ final class Dotenv
3535
private string $data;
3636
private int $end;
3737
private array $values = [];
38-
private string $envKey;
39-
private string $debugKey;
4038
private array $prodEnvs = ['prod'];
4139
private bool $usePutenv = false;
4240

43-
public function __construct(string $envKey = 'APP_ENV', string $debugKey = 'APP_DEBUG')
44-
{
45-
$this->envKey = $envKey;
46-
$this->debugKey = $debugKey;
41+
public function __construct(
42+
private string $envKey = 'APP_ENV',
43+
private string $debugKey = 'APP_DEBUG',
44+
) {
4745
}
4846

4947
/**

src/Symfony/Component/Dotenv/Exception/FormatException.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
*/
1919
final class FormatException extends \LogicException implements ExceptionInterface
2020
{
21-
private FormatExceptionContext $context;
22-
23-
public function __construct(string $message, FormatExceptionContext $context, int $code = 0, \Throwable $previous = null)
24-
{
25-
$this->context = $context;
26-
21+
public function __construct(
22+
string $message,
23+
private FormatExceptionContext $context,
24+
int $code = 0,
25+
\Throwable $previous = null,
26+
) {
2727
parent::__construct(sprintf("%s in \"%s\" at line %d.\n%s", $message, $context->getPath(), $context->getLineno(), $context->getDetails()), $code, $previous);
2828
}
2929

src/Symfony/Component/Dotenv/Exception/FormatExceptionContext.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@
1616
*/
1717
final class FormatExceptionContext
1818
{
19-
private string $data;
20-
private string $path;
21-
private int $lineno;
22-
private int $cursor;
23-
24-
public function __construct(string $data, string $path, int $lineno, int $cursor)
25-
{
26-
$this->data = $data;
27-
$this->path = $path;
28-
$this->lineno = $lineno;
29-
$this->cursor = $cursor;
19+
public function __construct(
20+
private string $data,
21+
private string $path,
22+
private int $lineno,
23+
private int $cursor,
24+
) {
3025
}
3126

3227
public function getPath(): string

src/Symfony/Component/ErrorHandler/Error/FatalError.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@
1313

1414
class FatalError extends \Error
1515
{
16-
private array $error;
17-
1816
/**
1917
* @param array $error An array as returned by error_get_last()
2018
*/
21-
public function __construct(string $message, int $code, array $error, int $traceOffset = null, bool $traceArgs = true, array $trace = null)
22-
{
19+
public function __construct(
20+
string $message,
21+
int $code,
22+
private array $error,
23+
int $traceOffset = null,
24+
bool $traceArgs = true,
25+
array $trace = null,
26+
) {
2327
parent::__construct($message, $code);
2428

25-
$this->error = $error;
26-
2729
if (null !== $trace) {
2830
if (!$traceArgs) {
2931
foreach ($trace as &$frame) {

src/Symfony/Component/ErrorHandler/ErrorRenderer/FileLinkFormatter.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@
2525
class FileLinkFormatter
2626
{
2727
private array|false $fileLinkFormat;
28-
private ?RequestStack $requestStack = null;
29-
private ?string $baseDir = null;
30-
private \Closure|string|null $urlFormat;
3128

3229
/**
3330
* @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand
3431
*/
35-
public function __construct(string|array $fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, string|\Closure $urlFormat = null)
36-
{
32+
public function __construct(
33+
string|array $fileLinkFormat = null,
34+
private ?RequestStack $requestStack = null,
35+
private ?string $baseDir = null,
36+
private null|string|\Closure $urlFormat = null,
37+
) {
3738
$fileLinkFormat ??= $_ENV['SYMFONY_IDE'] ?? $_SERVER['SYMFONY_IDE'] ?? '';
3839

3940
if (!\is_array($f = $fileLinkFormat)) {
@@ -43,9 +44,6 @@ public function __construct(string|array $fileLinkFormat = null, RequestStack $r
4344
}
4445

4546
$this->fileLinkFormat = $fileLinkFormat;
46-
$this->requestStack = $requestStack;
47-
$this->baseDir = $baseDir;
48-
$this->urlFormat = $urlFormat;
4947
}
5048

5149
public function format(string $file, int $line): string|false

src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,26 @@ class HtmlErrorRenderer implements ErrorRendererInterface
3737
private bool|\Closure $debug;
3838
private string $charset;
3939
private FileLinkFormatter $fileLinkFormat;
40-
private ?string $projectDir;
4140
private string|\Closure $outputBuffer;
42-
private ?LoggerInterface $logger;
4341

4442
private static string $template = 'views/error.html.php';
4543

4644
/**
4745
* @param bool|callable $debug The debugging mode as a boolean or a callable that should return it
4846
* @param string|callable $outputBuffer The output buffer as a string or a callable that should return it
4947
*/
50-
public function __construct(bool|callable $debug = false, string $charset = null, string|FileLinkFormatter $fileLinkFormat = null, string $projectDir = null, string|callable $outputBuffer = '', LoggerInterface $logger = null)
51-
{
48+
public function __construct(
49+
bool|callable $debug = false,
50+
string $charset = null,
51+
string|FileLinkFormatter $fileLinkFormat = null,
52+
private ?string $projectDir = null,
53+
string|callable $outputBuffer = '',
54+
private ?LoggerInterface $logger = null,
55+
) {
5256
$this->debug = \is_bool($debug) ? $debug : $debug(...);
5357
$this->charset = $charset ?: (\ini_get('default_charset') ?: 'UTF-8');
5458
$this->fileLinkFormat = $fileLinkFormat instanceof FileLinkFormatter ? $fileLinkFormat : new FileLinkFormatter($fileLinkFormat);
55-
$this->projectDir = $projectDir;
5659
$this->outputBuffer = \is_string($outputBuffer) ? $outputBuffer : $outputBuffer(...);
57-
$this->logger = $logger;
5860
}
5961

6062
public function render(\Throwable $exception): FlattenException

src/Symfony/Component/ErrorHandler/ErrorRenderer/SerializerErrorRenderer.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
*/
2525
class SerializerErrorRenderer implements ErrorRendererInterface
2626
{
27-
private SerializerInterface $serializer;
2827
private string|\Closure $format;
2928
private ErrorRendererInterface $fallbackErrorRenderer;
3029
private bool|\Closure $debug;
@@ -34,9 +33,12 @@ class SerializerErrorRenderer implements ErrorRendererInterface
3433
* formats not supported by Request::getMimeTypes() should be given as mime types
3534
* @param bool|callable $debug The debugging mode as a boolean or a callable that should return it
3635
*/
37-
public function __construct(SerializerInterface $serializer, string|callable $format, ErrorRendererInterface $fallbackErrorRenderer = null, bool|callable $debug = false)
38-
{
39-
$this->serializer = $serializer;
36+
public function __construct(
37+
private SerializerInterface $serializer,
38+
string|callable $format,
39+
ErrorRendererInterface $fallbackErrorRenderer = null,
40+
bool|callable $debug = false,
41+
) {
4042
$this->format = \is_string($format) ? $format : $format(...);
4143
$this->fallbackErrorRenderer = $fallbackErrorRenderer ?? new HtmlErrorRenderer();
4244
$this->debug = \is_bool($debug) ? $debug : $debug(...);

src/Symfony/Component/ErrorHandler/Exception/SilencedErrorContext.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,13 @@ class SilencedErrorContext implements \JsonSerializable
2020
{
2121
public int $count = 1;
2222

23-
private int $severity;
24-
private string $file;
25-
private int $line;
26-
private array $trace;
27-
28-
public function __construct(int $severity, string $file, int $line, array $trace = [], int $count = 1)
29-
{
30-
$this->severity = $severity;
31-
$this->file = $file;
32-
$this->line = $line;
33-
$this->trace = $trace;
23+
public function __construct(
24+
private int $severity,
25+
private string $file,
26+
private int $line,
27+
private array $trace = [],
28+
int $count = 1,
29+
) {
3430
$this->count = $count;
3531
}
3632

src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,20 @@
3030
*/
3131
class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterface
3232
{
33-
protected ?LoggerInterface $logger;
34-
protected Stopwatch $stopwatch;
35-
3633
/**
3734
* @var \SplObjectStorage<WrappedListener, array{string, string}>|null
3835
*/
3936
private ?\SplObjectStorage $callStack = null;
40-
private EventDispatcherInterface $dispatcher;
4137
private array $wrappedListeners = [];
4238
private array $orphanedEvents = [];
43-
private ?RequestStack $requestStack;
4439
private string $currentRequestHash = '';
4540

46-
public function __construct(EventDispatcherInterface $dispatcher, Stopwatch $stopwatch, LoggerInterface $logger = null, RequestStack $requestStack = null)
47-
{
48-
$this->dispatcher = $dispatcher;
49-
$this->stopwatch = $stopwatch;
50-
$this->logger = $logger;
51-
$this->requestStack = $requestStack;
41+
public function __construct(
42+
private EventDispatcherInterface $dispatcher,
43+
protected Stopwatch $stopwatch,
44+
protected ?LoggerInterface $logger = null,
45+
private ?RequestStack $requestStack = null,
46+
) {
5247
}
5348

5449
public function addListener(string $eventName, callable|array $listener, int $priority = 0): void

src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,20 @@ final class WrappedListener
2626
private string $name;
2727
private bool $called = false;
2828
private bool $stoppedPropagation = false;
29-
private Stopwatch $stopwatch;
30-
private ?EventDispatcherInterface $dispatcher;
3129
private string $pretty;
3230
private string $callableRef;
3331
private ClassStub|string $stub;
34-
private ?int $priority = null;
3532
private static bool $hasClassStub;
3633

37-
public function __construct(callable|array $listener, ?string $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null, int $priority = null)
38-
{
34+
public function __construct(
35+
callable|array $listener,
36+
?string $name,
37+
private Stopwatch $stopwatch,
38+
private ?EventDispatcherInterface $dispatcher = null,
39+
private ?int $priority = null,
40+
) {
3941
$this->listener = $listener;
4042
$this->optimizedListener = $listener instanceof \Closure ? $listener : (\is_callable($listener) ? $listener(...) : null);
41-
$this->stopwatch = $stopwatch;
42-
$this->dispatcher = $dispatcher;
43-
$this->priority = $priority;
4443

4544
if (\is_array($listener)) {
4645
[$this->name, $this->callableRef] = $this->parseListener($listener);

src/Symfony/Component/EventDispatcher/DependencyInjection/AddEventAliasesPass.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@
2121
*/
2222
class AddEventAliasesPass implements CompilerPassInterface
2323
{
24-
private array $eventAliases;
25-
26-
public function __construct(array $eventAliases)
27-
{
28-
$this->eventAliases = $eventAliases;
24+
public function __construct(
25+
private array $eventAliases,
26+
) {
2927
}
3028

3129
public function process(ContainerBuilder $container): void

src/Symfony/Component/EventDispatcher/GenericEvent.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,16 @@
2525
*/
2626
class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
2727
{
28-
protected mixed $subject;
29-
protected array $arguments;
30-
3128
/**
3229
* Encapsulate an event with $subject and $arguments.
3330
*
3431
* @param mixed $subject The subject of the event, usually an object or a callable
3532
* @param array $arguments Arguments to store in the event
3633
*/
37-
public function __construct(mixed $subject = null, array $arguments = [])
38-
{
39-
$this->subject = $subject;
40-
$this->arguments = $arguments;
34+
public function __construct(
35+
protected mixed $subject = null,
36+
protected array $arguments = [],
37+
) {
4138
}
4239

4340
/**

src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php

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

2826
public function dispatch(object $event, string $eventName = null): object

src/Symfony/Component/ExpressionLanguage/Compiler.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
class Compiler implements ResetInterface
2222
{
2323
private string $source = '';
24-
private array $functions;
2524

26-
public function __construct(array $functions)
27-
{
28-
$this->functions = $functions;
25+
public function __construct(
26+
private array $functions,
27+
) {
2928
}
3029

3130
public function getFunction(string $name): array

src/Symfony/Component/ExpressionLanguage/Expression.php

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

2826
/**

0 commit comments

Comments
 (0)
0