Skip to content

Commit 9f85f14

Browse files
OskarStarknicolas-grekas
authored andcommitted
[Dotenv][ErrorHandler][EventDispatcher] Use CPP
1 parent 5cc5396 commit 9f85f14

5 files changed

+23
-36
lines changed

Debug/TraceableEventDispatcher.php

+6-11
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

Debug/WrappedListener.php

+7-8
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);

DependencyInjection/AddEventAliasesPass.php

+3-5
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

GenericEvent.php

+4-7
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
/**

ImmutableEventDispatcher.php

+3-5
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

0 commit comments

Comments
 (0)