Passed
Pull Request — master (#1115)
by Maxim
22:29
created
src/Broadcasting/src/TopicRegistry.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
     public function __construct(array $topics = [])
12 12
     {
13
-        foreach ($topics as $topic => $callback) {
13
+        foreach ($topics as $topic => $callback){
14 14
             $this->register($topic, $callback);
15 15
         }
16 16
     }
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 
23 23
     public function findCallback(string $topic, array &$matches): ?callable
24 24
     {
25
-        foreach ($this->patterns as $pattern => $callback) {
26
-            if (\preg_match($pattern, $topic, $matches)) {
25
+        foreach ($this->patterns as $pattern => $callback){
26
+            if (\preg_match($pattern, $topic, $matches)){
27 27
                 return $callback;
28 28
             }
29 29
         }
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
     private function compilePattern(string $topic): string
35 35
     {
36 36
         $replaces = [];
37
-        if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) {
37
+        if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)){
38 38
             $variables = \array_combine($matches[1], $matches[2]);
39
-            foreach ($variables as $key => $_) {
40
-                $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)';
39
+            foreach ($variables as $key => $_){
40
+                $replaces['{'.$key.'}'] = '(?P<'.$key.'>[^\/\.]+)';
41 41
             }
42 42
         }
43 43
 
44
-        return '/^' . \strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']) . '$/iu';
44
+        return '/^'.\strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']).'$/iu';
45 45
     }
46 46
 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@  discard block
 block discarded – undo
10 10
 
11 11
     public function __construct(array $topics = [])
12 12
     {
13
-        foreach ($topics as $topic => $callback) {
13
+        foreach ($topics as $topic => $callback)
14
+        {
14 15
             $this->register($topic, $callback);
15 16
         }
16 17
     }
@@ -22,8 +23,10 @@  discard block
 block discarded – undo
22 23
 
23 24
     public function findCallback(string $topic, array &$matches): ?callable
24 25
     {
25
-        foreach ($this->patterns as $pattern => $callback) {
26
-            if (\preg_match($pattern, $topic, $matches)) {
26
+        foreach ($this->patterns as $pattern => $callback)
27
+        {
28
+            if (\preg_match($pattern, $topic, $matches))
29
+            {
27 30
                 return $callback;
28 31
             }
29 32
         }
@@ -34,9 +37,11 @@  discard block
 block discarded – undo
34 37
     private function compilePattern(string $topic): string
35 38
     {
36 39
         $replaces = [];
37
-        if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) {
40
+        if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches))
41
+        {
38 42
             $variables = \array_combine($matches[1], $matches[2]);
39
-            foreach ($variables as $key => $_) {
43
+            foreach ($variables as $key => $_)
44
+            {
40 45
                 $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)';
41 46
             }
42 47
         }
Please login to merge, or discard this patch.
src/Broadcasting/src/Config/BroadcastConfig.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function getDefaultConnection(): string
55 55
     {
56
-        if (empty($this->config['default'])) {
56
+        if (empty($this->config['default'])){
57 57
             throw new InvalidArgumentException('Default broadcast connection is not defined.');
58 58
         }
59 59
 
60
-        if (!\is_string($this->config['default'])) {
60
+        if (!\is_string($this->config['default'])){
61 61
             throw new InvalidArgumentException('Default broadcast connection config value must be a string');
62 62
         }
63 63
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
     public function getConnectionConfig(string $name): array
68 68
     {
69
-        if (!isset($this->config['connections'][$name])) {
69
+        if (!isset($this->config['connections'][$name])){
70 70
             throw new InvalidArgumentException(
71 71
                 \sprintf('Config for connection `%s` is not defined.', $name)
72 72
             );
@@ -74,19 +74,19 @@  discard block
 block discarded – undo
74 74
 
75 75
         $config = $this->config['connections'][$name];
76 76
 
77
-        if (!isset($config['driver'])) {
77
+        if (!isset($config['driver'])){
78 78
             throw new InvalidArgumentException(
79 79
                 \sprintf('Driver for `%s` connection is not defined.', $name)
80 80
             );
81 81
         }
82 82
 
83
-        if (!\is_string($config['driver'])) {
83
+        if (!\is_string($config['driver'])){
84 84
             throw new InvalidArgumentException(
85 85
                 \sprintf('Driver value for `%s` connection must be a string', $name)
86 86
             );
87 87
         }
88 88
 
89
-        if (isset($this->config['driverAliases'][$config['driver']])) {
89
+        if (isset($this->config['driverAliases'][$config['driver']])){
90 90
             $config['driver'] = $this->config['driverAliases'][$config['driver']];
91 91
         }
92 92
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -53,11 +53,13 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function getDefaultConnection(): string
55 55
     {
56
-        if (empty($this->config['default'])) {
56
+        if (empty($this->config['default']))
57
+        {
57 58
             throw new InvalidArgumentException('Default broadcast connection is not defined.');
58 59
         }
59 60
 
60
-        if (!\is_string($this->config['default'])) {
61
+        if (!\is_string($this->config['default']))
62
+        {
61 63
             throw new InvalidArgumentException('Default broadcast connection config value must be a string');
62 64
         }
63 65
 
@@ -66,7 +68,8 @@  discard block
 block discarded – undo
66 68
 
67 69
     public function getConnectionConfig(string $name): array
68 70
     {
69
-        if (!isset($this->config['connections'][$name])) {
71
+        if (!isset($this->config['connections'][$name]))
72
+        {
70 73
             throw new InvalidArgumentException(
71 74
                 \sprintf('Config for connection `%s` is not defined.', $name)
72 75
             );
@@ -74,19 +77,22 @@  discard block
 block discarded – undo
74 77
 
75 78
         $config = $this->config['connections'][$name];
76 79
 
77
-        if (!isset($config['driver'])) {
80
+        if (!isset($config['driver']))
81
+        {
78 82
             throw new InvalidArgumentException(
79 83
                 \sprintf('Driver for `%s` connection is not defined.', $name)
80 84
             );
81 85
         }
82 86
 
83
-        if (!\is_string($config['driver'])) {
87
+        if (!\is_string($config['driver']))
88
+        {
84 89
             throw new InvalidArgumentException(
85 90
                 \sprintf('Driver value for `%s` connection must be a string', $name)
86 91
             );
87 92
         }
88 93
 
89
-        if (isset($this->config['driverAliases'][$config['driver']])) {
94
+        if (isset($this->config['driverAliases'][$config['driver']]))
95
+        {
90 96
             $config['driver'] = $this->config['driverAliases'][$config['driver']];
91 97
         }
92 98
 
Please login to merge, or discard this patch.
src/Broadcasting/src/Event/Authorized.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
     public function __construct(
13 13
         public AuthorizationStatus $status,
14 14
         public readonly ServerRequestInterface $request
15
-    ) {
15
+    ){
16 16
     }
17 17
 }
Please login to merge, or discard this patch.
src/Broadcasting/src/Driver/NullBroadcast.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
 final class NullBroadcast implements BroadcastInterface
10 10
 {
11
-    public function publish(iterable|string|\Stringable $topics, iterable|string $messages): void
11
+    public function publish(iterable | string | \Stringable $topics, iterable | string $messages): void
12 12
     {
13 13
         // Do nothing
14 14
     }
Please login to merge, or discard this patch.
src/Broadcasting/src/Driver/LogBroadcast.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,17 +12,17 @@
 block discarded – undo
12 12
     public function __construct(
13 13
         private readonly LoggerInterface $logger,
14 14
         private readonly string $level = LogLevel::INFO
15
-    ) {
15
+    ){
16 16
     }
17 17
 
18
-    public function publish(iterable|string|\Stringable $topics, iterable|string $messages): void
18
+    public function publish(iterable | string | \Stringable $topics, iterable | string $messages): void
19 19
     {
20 20
         $topics = \implode(', ', $this->formatTopics($this->toArray($topics)));
21 21
 
22 22
         /** @var string $message */
23
-        foreach ($this->toArray($messages) as $message) {
23
+        foreach ($this->toArray($messages) as $message){
24 24
             \assert(\is_string($message), 'Message argument must be a type of string');
25
-            $this->logger->log($this->level, 'Broadcasting on channels [' . $topics . '] with payload: ' . $message);
25
+            $this->logger->log($this->level, 'Broadcasting on channels ['.$topics.'] with payload: '.$message);
26 26
         }
27 27
     }
28 28
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@
 block discarded – undo
20 20
         $topics = \implode(', ', $this->formatTopics($this->toArray($topics)));
21 21
 
22 22
         /** @var string $message */
23
-        foreach ($this->toArray($messages) as $message) {
23
+        foreach ($this->toArray($messages) as $message)
24
+        {
24 25
             \assert(\is_string($message), 'Message argument must be a type of string');
25 26
             $this->logger->log($this->level, 'Broadcasting on channels [' . $topics . '] with payload: ' . $message);
26 27
         }
Please login to merge, or discard this patch.
src/Broadcasting/src/Driver/AbstractBroadcast.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
      */
17 17
     protected function formatTopics(array $topics): array
18 18
     {
19
-        return \array_map(fn (string|\Stringable $topic) => (string) $topic, $topics);
19
+        return \array_map(fn (string | \Stringable $topic) => (string)$topic, $topics);
20 20
     }
21 21
 
22 22
     /**
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      * @param iterable<T>|T $entries
25 25
      * @return array<T>
26 26
      */
27
-    protected function toArray(iterable|string|\Stringable $entries): array
27
+    protected function toArray(iterable | string | \Stringable $entries): array
28 28
     {
29 29
         return match (true) {
30 30
             \is_array($entries) => $entries,
Please login to merge, or discard this patch.
src/Broadcasting/src/Bootloader/BroadcastingBootloader.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 
28 28
     public function __construct(
29 29
         private readonly ConfiguratorInterface $config
30
-    ) {
30
+    ){
31 31
     }
32 32
 
33 33
     public function registerDriverAlias(string $driverClass, string $alias): void
Please login to merge, or discard this patch.
src/Broadcasting/src/BroadcastInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,5 +26,5 @@
 block discarded – undo
26 26
      * @param MessagesList $messages
27 27
      * @throws BroadcastException
28 28
      */
29
-    public function publish(iterable|string|\Stringable $topics, iterable|string $messages): void;
29
+    public function publish(iterable | string | \Stringable $topics, iterable | string $messages): void;
30 30
 }
Please login to merge, or discard this patch.
src/Broadcasting/src/Middleware/AuthorizationMiddleware.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,20 +22,20 @@  discard block
 block discarded – undo
22 22
         private readonly ResponseFactoryInterface $responseFactory,
23 23
         private readonly ?string $authorizationPath = null,
24 24
         private readonly ?EventDispatcherInterface $dispatcher = null
25
-    ) {
25
+    ){
26 26
     }
27 27
 
28 28
     public function process(
29 29
         ServerRequestInterface $request,
30 30
         RequestHandlerInterface $handler
31 31
     ): ResponseInterface {
32
-        if ($request->getUri()->getPath() !== $this->authorizationPath) {
32
+        if ($request->getUri()->getPath() !== $this->authorizationPath){
33 33
             return $handler->handle($request);
34 34
         }
35 35
 
36
-        if ($this->broadcast instanceof GuardInterface) {
36
+        if ($this->broadcast instanceof GuardInterface){
37 37
             $status = $this->broadcast->authorize($request);
38
-        } else {
38
+        }else{
39 39
             $status = new AuthorizationStatus(
40 40
                 success: true,
41 41
                 topics: null
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 
45 45
         $this->dispatcher?->dispatch(new Authorized($status, $request));
46 46
 
47
-        if ($status->response !== null) {
47
+        if ($status->response !== null){
48 48
             return $status->response;
49 49
         }
50 50
 
51
-        if (!$status->success) {
51
+        if (!$status->success){
52 52
             return $this->responseFactory->createResponse(403);
53 53
         }
54 54
 
Please login to merge, or discard this patch.
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,13 +29,17 @@  discard block
 block discarded – undo
29 29
         ServerRequestInterface $request,
30 30
         RequestHandlerInterface $handler
31 31
     ): ResponseInterface {
32
-        if ($request->getUri()->getPath() !== $this->authorizationPath) {
32
+        if ($request->getUri()->getPath() !== $this->authorizationPath)
33
+        {
33 34
             return $handler->handle($request);
34 35
         }
35 36
 
36
-        if ($this->broadcast instanceof GuardInterface) {
37
+        if ($this->broadcast instanceof GuardInterface)
38
+        {
37 39
             $status = $this->broadcast->authorize($request);
38
-        } else {
40
+        }
41
+        else
42
+        {
39 43
             $status = new AuthorizationStatus(
40 44
                 success: true,
41 45
                 topics: null
@@ -44,11 +48,13 @@  discard block
 block discarded – undo
44 48
 
45 49
         $this->dispatcher?->dispatch(new Authorized($status, $request));
46 50
 
47
-        if ($status->response !== null) {
51
+        if ($status->response !== null)
52
+        {
48 53
             return $status->response;
49 54
         }
50 55
 
51
-        if (!$status->success) {
56
+        if (!$status->success)
57
+        {
52 58
             return $this->responseFactory->createResponse(403);
53 59
         }
54 60
 
Please login to merge, or discard this patch.