@@ -12,7 +12,7 @@ |
||
12 | 12 | #[Listener] |
13 | 13 | final class ClassDoubleTheSameAttribute |
14 | 14 | { |
15 | - public function __invoke(FooEvent|BarEvent $event): void |
|
15 | + public function __invoke(FooEvent | BarEvent $event): void |
|
16 | 16 | { |
17 | 17 | } |
18 | 18 | } |
@@ -17,6 +17,6 @@ |
||
17 | 17 | public readonly ?string $event = null, |
18 | 18 | public ?string $method = null, |
19 | 19 | public readonly int $priority = 0 |
20 | - ) { |
|
20 | + ){ |
|
21 | 21 | } |
22 | 22 | } |
@@ -14,7 +14,7 @@ |
||
14 | 14 | public string $listener, |
15 | 15 | ?string $method = null, |
16 | 16 | public int $priority = 0 |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | $this->method = !empty($method) ? $method : self::DEFAULT_METHOD; |
19 | 19 | } |
20 | 20 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | public function getListeners(): array |
34 | 34 | { |
35 | 35 | $listeners = []; |
36 | - foreach ($this->config['listeners'] as $event => $eventListeners) { |
|
36 | + foreach ($this->config['listeners'] as $event => $eventListeners){ |
|
37 | 37 | $listeners[$event] = \array_map( |
38 | 38 | self::normalizeListener(...), |
39 | 39 | $eventListeners |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * @param TListener $listener |
56 | 56 | */ |
57 | - private static function normalizeListener(string|EventListener $listener): EventListener |
|
57 | + private static function normalizeListener(string | EventListener $listener): EventListener |
|
58 | 58 | { |
59 | 59 | return \is_string($listener) ? new EventListener($listener) : $listener; |
60 | 60 | } |
@@ -33,7 +33,8 @@ |
||
33 | 33 | public function getListeners(): array |
34 | 34 | { |
35 | 35 | $listeners = []; |
36 | - foreach ($this->config['listeners'] as $event => $eventListeners) { |
|
36 | + foreach ($this->config['listeners'] as $event => $eventListeners) |
|
37 | + { |
|
37 | 38 | $listeners[$event] = \array_map( |
38 | 39 | self::normalizeListener(...), |
39 | 40 | $eventListeners |
@@ -14,16 +14,16 @@ |
||
14 | 14 | private readonly EventsConfig $config, |
15 | 15 | private readonly ListenerFactoryInterface $factory, |
16 | 16 | private readonly ?ListenerRegistryInterface $registry = null, |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function process(): void |
21 | 21 | { |
22 | - if ($this->registry === null) { |
|
22 | + if ($this->registry === null){ |
|
23 | 23 | return; |
24 | 24 | } |
25 | - foreach ($this->config->getListeners() as $event => $eventListeners) { |
|
26 | - foreach ($eventListeners as $listener) { |
|
25 | + foreach ($this->config->getListeners() as $event => $eventListeners){ |
|
26 | + foreach ($eventListeners as $listener){ |
|
27 | 27 | $method = $this->getMethod($listener->listener, $listener->method); |
28 | 28 | |
29 | 29 | $this->registry->addListener( |
@@ -19,11 +19,14 @@ |
||
19 | 19 | |
20 | 20 | public function process(): void |
21 | 21 | { |
22 | - if ($this->registry === null) { |
|
22 | + if ($this->registry === null) |
|
23 | + { |
|
23 | 24 | return; |
24 | 25 | } |
25 | - foreach ($this->config->getListeners() as $event => $eventListeners) { |
|
26 | - foreach ($eventListeners as $listener) { |
|
26 | + foreach ($this->config->getListeners() as $event => $eventListeners) |
|
27 | + { |
|
28 | + foreach ($eventListeners as $listener) |
|
29 | + { |
|
27 | 30 | $method = $this->getMethod($listener->listener, $listener->method); |
28 | 31 | |
29 | 32 | $this->registry->addListener( |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | protected function getEventFromTypeDeclaration(\ReflectionMethod $method): array |
18 | 18 | { |
19 | - if ($method->getNumberOfParameters() > 1) { |
|
19 | + if ($method->getNumberOfParameters() > 1){ |
|
20 | 20 | throw $this->badClassMethod($method->class, $method->getName()); |
21 | 21 | } |
22 | 22 | $type = $method->getParameters()[0]->getType(); |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | }; |
30 | 30 | |
31 | 31 | $result = []; |
32 | - foreach ($eventTypes as $type) { |
|
33 | - if ($type->isBuiltin()) { |
|
32 | + foreach ($eventTypes as $type){ |
|
33 | + if ($type->isBuiltin()){ |
|
34 | 34 | continue; |
35 | 35 | } |
36 | 36 | $result[] = $type->getName(); |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected function getMethod(string $class, string $name): \ReflectionMethod |
46 | 46 | { |
47 | - try { |
|
47 | + try{ |
|
48 | 48 | return new \ReflectionMethod($class, $name); |
49 | - } catch (\ReflectionException) { |
|
49 | + }catch (\ReflectionException){ |
|
50 | 50 | throw $this->badClassMethod($class, $name); |
51 | 51 | } |
52 | 52 | } |
@@ -16,7 +16,8 @@ discard block |
||
16 | 16 | */ |
17 | 17 | protected function getEventFromTypeDeclaration(\ReflectionMethod $method): array |
18 | 18 | { |
19 | - if ($method->getNumberOfParameters() > 1) { |
|
19 | + if ($method->getNumberOfParameters() > 1) |
|
20 | + { |
|
20 | 21 | throw $this->badClassMethod($method->class, $method->getName()); |
21 | 22 | } |
22 | 23 | $type = $method->getParameters()[0]->getType(); |
@@ -29,8 +30,10 @@ discard block |
||
29 | 30 | }; |
30 | 31 | |
31 | 32 | $result = []; |
32 | - foreach ($eventTypes as $type) { |
|
33 | - if ($type->isBuiltin()) { |
|
33 | + foreach ($eventTypes as $type) |
|
34 | + { |
|
35 | + if ($type->isBuiltin()) |
|
36 | + { |
|
34 | 37 | continue; |
35 | 38 | } |
36 | 39 | $result[] = $type->getName(); |
@@ -44,9 +47,12 @@ discard block |
||
44 | 47 | */ |
45 | 48 | protected function getMethod(string $class, string $name): \ReflectionMethod |
46 | 49 | { |
47 | - try { |
|
50 | + try |
|
51 | + { |
|
48 | 52 | return new \ReflectionMethod($class, $name); |
49 | - } catch (\ReflectionException) { |
|
53 | + } |
|
54 | + catch (\ReflectionException) |
|
55 | + { |
|
50 | 56 | throw $this->badClassMethod($class, $name); |
51 | 57 | } |
52 | 58 | } |
@@ -20,11 +20,11 @@ |
||
20 | 20 | |
21 | 21 | public function process(): void |
22 | 22 | { |
23 | - if ($this->processed) { |
|
23 | + if ($this->processed){ |
|
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
27 | - foreach ($this->processors as $processor) { |
|
27 | + foreach ($this->processors as $processor){ |
|
28 | 28 | $processor->process(); |
29 | 29 | } |
30 | 30 |
@@ -20,11 +20,13 @@ |
||
20 | 20 | |
21 | 21 | public function process(): void |
22 | 22 | { |
23 | - if ($this->processed) { |
|
23 | + if ($this->processed) |
|
24 | + { |
|
24 | 25 | return; |
25 | 26 | } |
26 | 27 | |
27 | - foreach ($this->processors as $processor) { |
|
28 | + foreach ($this->processors as $processor) |
|
29 | + { |
|
28 | 30 | $processor->process(); |
29 | 31 | } |
30 | 32 |
@@ -11,5 +11,5 @@ |
||
11 | 11 | * @return \Closure(object $event): void |
12 | 12 | * @throws \BadMethodCallException |
13 | 13 | */ |
14 | - public function create(string|object $listener, string $method): \Closure; |
|
14 | + public function create(string | object $listener, string $method): \Closure; |
|
15 | 15 | } |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | |
10 | 10 | final class AutowireListenerFactory implements ListenerFactoryInterface |
11 | 11 | { |
12 | - public function create(string|object $listener, string $method): \Closure |
|
12 | + public function create(string | object $listener, string $method): \Closure |
|
13 | 13 | { |
14 | - if ($this->listenerShouldBeAutowired($listener, $method)) { |
|
14 | + if ($this->listenerShouldBeAutowired($listener, $method)){ |
|
15 | 15 | return static function (object $event) use ($listener, $method): void { |
16 | 16 | ContainerScope::getContainer() |
17 | 17 | ->get(InvokerInterface::class) |
@@ -30,26 +30,26 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return TClass |
32 | 32 | */ |
33 | - private static function getListener(string|object $listener): object |
|
33 | + private static function getListener(string | object $listener): object |
|
34 | 34 | { |
35 | - if (\is_object($listener)) { |
|
35 | + if (\is_object($listener)){ |
|
36 | 36 | return $listener; |
37 | 37 | } |
38 | 38 | |
39 | 39 | return ContainerScope::getContainer()->get($listener); |
40 | 40 | } |
41 | 41 | |
42 | - private function listenerShouldBeAutowired(object|string $listener, string $method): bool |
|
42 | + private function listenerShouldBeAutowired(object | string $listener, string $method): bool |
|
43 | 43 | { |
44 | - if (!\is_object($listener) && !\class_exists($listener) && !\interface_exists($listener)) { |
|
44 | + if (!\is_object($listener) && !\class_exists($listener) && !\interface_exists($listener)){ |
|
45 | 45 | return true; |
46 | 46 | } |
47 | 47 | |
48 | - try { |
|
48 | + try{ |
|
49 | 49 | $refMethod = new \ReflectionMethod($listener, $method); |
50 | 50 | |
51 | 51 | return $refMethod->getNumberOfParameters() > 1; |
52 | - } catch (\ReflectionException $e) { |
|
52 | + }catch (\ReflectionException $e){ |
|
53 | 53 | $listener = \is_object($listener) ? $listener::class : $listener; |
54 | 54 | |
55 | 55 | throw match (true) { |
@@ -11,7 +11,8 @@ discard block |
||
11 | 11 | { |
12 | 12 | public function create(string|object $listener, string $method): \Closure |
13 | 13 | { |
14 | - if ($this->listenerShouldBeAutowired($listener, $method)) { |
|
14 | + if ($this->listenerShouldBeAutowired($listener, $method)) |
|
15 | + { |
|
15 | 16 | return static function (object $event) use ($listener, $method): void { |
16 | 17 | ContainerScope::getContainer() |
17 | 18 | ->get(InvokerInterface::class) |
@@ -32,7 +33,8 @@ discard block |
||
32 | 33 | */ |
33 | 34 | private static function getListener(string|object $listener): object |
34 | 35 | { |
35 | - if (\is_object($listener)) { |
|
36 | + if (\is_object($listener)) |
|
37 | + { |
|
36 | 38 | return $listener; |
37 | 39 | } |
38 | 40 | |
@@ -41,15 +43,19 @@ discard block |
||
41 | 43 | |
42 | 44 | private function listenerShouldBeAutowired(object|string $listener, string $method): bool |
43 | 45 | { |
44 | - if (!\is_object($listener) && !\class_exists($listener) && !\interface_exists($listener)) { |
|
46 | + if (!\is_object($listener) && !\class_exists($listener) && !\interface_exists($listener)) |
|
47 | + { |
|
45 | 48 | return true; |
46 | 49 | } |
47 | 50 | |
48 | - try { |
|
51 | + try |
|
52 | + { |
|
49 | 53 | $refMethod = new \ReflectionMethod($listener, $method); |
50 | 54 | |
51 | 55 | return $refMethod->getNumberOfParameters() > 1; |
52 | - } catch (\ReflectionException $e) { |
|
56 | + } |
|
57 | + catch (\ReflectionException $e) |
|
58 | + { |
|
53 | 59 | $listener = \is_object($listener) ? $listener::class : $listener; |
54 | 60 | |
55 | 61 | throw match (true) { |