@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | |
58 | 58 | $this->mailer->expects('send')->with($email)->andThrow(new TransportException('failed')); |
59 | 59 | |
60 | - try { |
|
60 | + try{ |
|
61 | 61 | $this->getHandler()->handle( |
62 | 62 | MailQueue::JOB_NAME, |
63 | 63 | 'id', |
64 | 64 | json_encode(MessageSerializer::pack($this->getMail())) |
65 | 65 | ); |
66 | - } catch (TransportException) { |
|
66 | + }catch (TransportException){ |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | private function expectRenderer(Email $email): void |
122 | 122 | { |
123 | 123 | $this->renderer->expects('render')->withArgs( |
124 | - function (Message $message) { |
|
124 | + function (Message $message){ |
|
125 | 125 | $this->assertSame($message->getSubject(), 'test'); |
126 | 126 | return true; |
127 | 127 | } |
@@ -57,13 +57,16 @@ discard block |
||
57 | 57 | |
58 | 58 | $this->mailer->expects('send')->with($email)->andThrow(new TransportException('failed')); |
59 | 59 | |
60 | - try { |
|
60 | + try |
|
61 | + { |
|
61 | 62 | $this->getHandler()->handle( |
62 | 63 | MailQueue::JOB_NAME, |
63 | 64 | 'id', |
64 | 65 | json_encode(MessageSerializer::pack($this->getMail())) |
65 | 66 | ); |
66 | - } catch (TransportException) { |
|
67 | + } |
|
68 | + catch (TransportException) |
|
69 | + { |
|
67 | 70 | } |
68 | 71 | } |
69 | 72 | |
@@ -121,7 +124,8 @@ discard block |
||
121 | 124 | private function expectRenderer(Email $email): void |
122 | 125 | { |
123 | 126 | $this->renderer->expects('render')->withArgs( |
124 | - function (Message $message) { |
|
127 | + function (Message $message) |
|
128 | + { |
|
125 | 129 | $this->assertSame($message->getSubject(), 'test'); |
126 | 130 | return true; |
127 | 131 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | |
18 | 18 | public function __toString(): string |
19 | 19 | { |
20 | - return (string) $this->value; |
|
20 | + return (string)$this->value; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function setValue(mixed $data): self |
@@ -24,23 +24,23 @@ discard block |
||
24 | 24 | |
25 | 25 | public function __toString(): string |
26 | 26 | { |
27 | - try { |
|
27 | + try{ |
|
28 | 28 | return $this->getContents(); |
29 | - } catch (\Exception) { |
|
29 | + }catch (\Exception){ |
|
30 | 30 | return ''; |
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | 34 | public function close(): void |
35 | 35 | { |
36 | - if ($this->stream !== null) { |
|
36 | + if ($this->stream !== null){ |
|
37 | 37 | $this->detach(); |
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
41 | 41 | public function detach() |
42 | 42 | { |
43 | - if ($this->stream === null) { |
|
43 | + if ($this->stream === null){ |
|
44 | 44 | return null; |
45 | 45 | } |
46 | 46 | $this->stream = null; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | public function rewind(): void |
80 | 80 | { |
81 | - if ($this->stream !== null) { |
|
81 | + if ($this->stream !== null){ |
|
82 | 82 | $this->stream->rewind(); |
83 | 83 | } |
84 | 84 | $this->caret = 0; |
@@ -102,26 +102,26 @@ discard block |
||
102 | 102 | |
103 | 103 | public function read($length): string |
104 | 104 | { |
105 | - if (!$this->readable) { |
|
105 | + if (!$this->readable){ |
|
106 | 106 | throw new RuntimeException('Cannot read from non-readable stream.'); |
107 | 107 | } |
108 | - if ($this->stream === null) { |
|
108 | + if ($this->stream === null){ |
|
109 | 109 | throw new RuntimeException('Cannot read from detached stream.'); |
110 | 110 | } |
111 | - do { |
|
112 | - if ($this->started) { |
|
111 | + do{ |
|
112 | + if ($this->started){ |
|
113 | 113 | $read = (string)$this->stream->send(null); |
114 | - } else { |
|
114 | + }else{ |
|
115 | 115 | $this->started = true; |
116 | 116 | $read = (string)$this->stream->current(); |
117 | 117 | } |
118 | - if (!$this->stream->valid()) { |
|
118 | + if (!$this->stream->valid()){ |
|
119 | 119 | $read .= $this->stream->getReturn(); |
120 | 120 | break; |
121 | 121 | } |
122 | - } while ($read === ''); |
|
122 | + }while ($read === ''); |
|
123 | 123 | $this->caret += \strlen($read); |
124 | - if (!$this->stream->valid()) { |
|
124 | + if (!$this->stream->valid()){ |
|
125 | 125 | $this->size = $this->caret; |
126 | 126 | } |
127 | 127 | return $read; |
@@ -129,19 +129,19 @@ discard block |
||
129 | 129 | |
130 | 130 | public function getContents(): string |
131 | 131 | { |
132 | - if ($this->stream === null) { |
|
132 | + if ($this->stream === null){ |
|
133 | 133 | throw new RuntimeException('Unable to read stream contents.'); |
134 | 134 | } |
135 | 135 | $content = ''; |
136 | - do { |
|
136 | + do{ |
|
137 | 137 | $content .= $this->read(PHP_INT_MAX); |
138 | - } while ($this->stream->valid()); |
|
138 | + }while ($this->stream->valid()); |
|
139 | 139 | return $content; |
140 | 140 | } |
141 | 141 | |
142 | 142 | public function getMetadata($key = null) |
143 | 143 | { |
144 | - if ($this->stream === null) { |
|
144 | + if ($this->stream === null){ |
|
145 | 145 | return $key ? null : []; |
146 | 146 | } |
147 | 147 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | 'eof' => $this->eof(), |
151 | 151 | ]; |
152 | 152 | |
153 | - if (null === $key) { |
|
153 | + if (null === $key){ |
|
154 | 154 | return $meta; |
155 | 155 | } |
156 | 156 |
@@ -24,23 +24,28 @@ discard block |
||
24 | 24 | |
25 | 25 | public function __toString(): string |
26 | 26 | { |
27 | - try { |
|
27 | + try |
|
28 | + { |
|
28 | 29 | return $this->getContents(); |
29 | - } catch (\Exception) { |
|
30 | + } |
|
31 | + catch (\Exception) |
|
32 | + { |
|
30 | 33 | return ''; |
31 | 34 | } |
32 | 35 | } |
33 | 36 | |
34 | 37 | public function close(): void |
35 | 38 | { |
36 | - if ($this->stream !== null) { |
|
39 | + if ($this->stream !== null) |
|
40 | + { |
|
37 | 41 | $this->detach(); |
38 | 42 | } |
39 | 43 | } |
40 | 44 | |
41 | 45 | public function detach() |
42 | 46 | { |
43 | - if ($this->stream === null) { |
|
47 | + if ($this->stream === null) |
|
48 | + { |
|
44 | 49 | return null; |
45 | 50 | } |
46 | 51 | $this->stream = null; |
@@ -78,7 +83,8 @@ discard block |
||
78 | 83 | |
79 | 84 | public function rewind(): void |
80 | 85 | { |
81 | - if ($this->stream !== null) { |
|
86 | + if ($this->stream !== null) |
|
87 | + { |
|
82 | 88 | $this->stream->rewind(); |
83 | 89 | } |
84 | 90 | $this->caret = 0; |
@@ -102,26 +108,34 @@ discard block |
||
102 | 108 | |
103 | 109 | public function read($length): string |
104 | 110 | { |
105 | - if (!$this->readable) { |
|
111 | + if (!$this->readable) |
|
112 | + { |
|
106 | 113 | throw new RuntimeException('Cannot read from non-readable stream.'); |
107 | 114 | } |
108 | - if ($this->stream === null) { |
|
115 | + if ($this->stream === null) |
|
116 | + { |
|
109 | 117 | throw new RuntimeException('Cannot read from detached stream.'); |
110 | 118 | } |
111 | - do { |
|
112 | - if ($this->started) { |
|
119 | + do |
|
120 | + { |
|
121 | + if ($this->started) |
|
122 | + { |
|
113 | 123 | $read = (string)$this->stream->send(null); |
114 | - } else { |
|
124 | + } |
|
125 | + else |
|
126 | + { |
|
115 | 127 | $this->started = true; |
116 | 128 | $read = (string)$this->stream->current(); |
117 | 129 | } |
118 | - if (!$this->stream->valid()) { |
|
130 | + if (!$this->stream->valid()) |
|
131 | + { |
|
119 | 132 | $read .= $this->stream->getReturn(); |
120 | 133 | break; |
121 | 134 | } |
122 | 135 | } while ($read === ''); |
123 | 136 | $this->caret += \strlen($read); |
124 | - if (!$this->stream->valid()) { |
|
137 | + if (!$this->stream->valid()) |
|
138 | + { |
|
125 | 139 | $this->size = $this->caret; |
126 | 140 | } |
127 | 141 | return $read; |
@@ -129,11 +143,13 @@ discard block |
||
129 | 143 | |
130 | 144 | public function getContents(): string |
131 | 145 | { |
132 | - if ($this->stream === null) { |
|
146 | + if ($this->stream === null) |
|
147 | + { |
|
133 | 148 | throw new RuntimeException('Unable to read stream contents.'); |
134 | 149 | } |
135 | 150 | $content = ''; |
136 | - do { |
|
151 | + do |
|
152 | + { |
|
137 | 153 | $content .= $this->read(PHP_INT_MAX); |
138 | 154 | } while ($this->stream->valid()); |
139 | 155 | return $content; |
@@ -141,7 +157,8 @@ discard block |
||
141 | 157 | |
142 | 158 | public function getMetadata($key = null) |
143 | 159 | { |
144 | - if ($this->stream === null) { |
|
160 | + if ($this->stream === null) |
|
161 | + { |
|
145 | 162 | return $key ? null : []; |
146 | 163 | } |
147 | 164 | |
@@ -150,7 +167,8 @@ discard block |
||
150 | 167 | 'eof' => $this->eof(), |
151 | 168 | ]; |
152 | 169 | |
153 | - if (null === $key) { |
|
170 | + if (null === $key) |
|
171 | + { |
|
154 | 172 | return $meta; |
155 | 173 | } |
156 | 174 |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | |
33 | 33 | $this->assertNull(ContainerScope::getContainer()); |
34 | 34 | |
35 | - try { |
|
35 | + try{ |
|
36 | 36 | $this->assertTrue(ContainerScope::runScope($container, function () use ($container): void { |
37 | 37 | throw new RuntimeException('exception'); |
38 | 38 | })); |
39 | - } catch (\Throwable $e) { |
|
39 | + }catch (\Throwable $e){ |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $this->assertInstanceOf(RuntimeException::class, $e); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $this->assertTrue($c->runScope([ |
55 | 55 | 'bucket' => new Bucket('b'), |
56 | 56 | 'other' => new SampleClass() |
57 | - ], function ($c) { |
|
57 | + ], function ($c){ |
|
58 | 58 | $this->assertSame('b', $c->get('bucket')->getName()); |
59 | 59 | $this->assertTrue($c->has('other')); |
60 | 60 | |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | $this->assertTrue($c->runScope([ |
77 | 77 | 'bucket' => new Bucket('b'), |
78 | 78 | 'other' => new SampleClass() |
79 | - ], function ($c) { |
|
79 | + ], function ($c){ |
|
80 | 80 | $this->assertSame('b', $c->get('bucket')->getName()); |
81 | 81 | $this->assertTrue($c->has('other')); |
82 | 82 | |
83 | 83 | return $c->get('bucket')->getName() == 'b' && $c->has('other'); |
84 | 84 | })); |
85 | 85 | |
86 | - try { |
|
86 | + try{ |
|
87 | 87 | $this->assertTrue($c->runScope([ |
88 | 88 | 'bucket' => new Bucket('b'), |
89 | 89 | 'other' => new SampleClass() |
90 | 90 | ], function () use ($c): void { |
91 | 91 | throw new RuntimeException('exception'); |
92 | 92 | })); |
93 | - } catch (\Throwable) { |
|
93 | + }catch (\Throwable){ |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $this->assertSame('a', $c->get('bucket')->getName()); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $container->bindSingleton('test', new #[Singleton] class {}); |
142 | 142 | $container->make('test'); |
143 | 143 | |
144 | - $container->runScoped(function (Container $container) { |
|
144 | + $container->runScoped(function (Container $container){ |
|
145 | 145 | $this->assertTrue($container->hasInstance('test')); |
146 | 146 | }); |
147 | 147 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $container->bindSingleton('test', SampleClass::class); |
153 | 153 | $container->make('test'); |
154 | 154 | |
155 | - $container->runScoped(function (Container $container) { |
|
155 | + $container->runScoped(function (Container $container){ |
|
156 | 156 | $this->assertTrue($container->hasInstance('test')); |
157 | 157 | }); |
158 | 158 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $container->bindSingleton('bar', 'foo'); |
168 | 168 | $container->make('bar'); |
169 | 169 | |
170 | - $container->runScoped(function (Container $container) { |
|
170 | + $container->runScoped(function (Container $container){ |
|
171 | 171 | $this->assertTrue($container->hasInstance('bar')); |
172 | 172 | }); |
173 | 173 | } |
@@ -32,11 +32,14 @@ discard block |
||
32 | 32 | |
33 | 33 | $this->assertNull(ContainerScope::getContainer()); |
34 | 34 | |
35 | - try { |
|
35 | + try |
|
36 | + { |
|
36 | 37 | $this->assertTrue(ContainerScope::runScope($container, function () use ($container): void { |
37 | 38 | throw new RuntimeException('exception'); |
38 | 39 | })); |
39 | - } catch (\Throwable $e) { |
|
40 | + } |
|
41 | + catch (\Throwable $e) |
|
42 | + { |
|
40 | 43 | } |
41 | 44 | |
42 | 45 | $this->assertInstanceOf(RuntimeException::class, $e); |
@@ -54,7 +57,8 @@ discard block |
||
54 | 57 | $this->assertTrue($c->runScope([ |
55 | 58 | 'bucket' => new Bucket('b'), |
56 | 59 | 'other' => new SampleClass() |
57 | - ], function ($c) { |
|
60 | + ], function ($c) |
|
61 | + { |
|
58 | 62 | $this->assertSame('b', $c->get('bucket')->getName()); |
59 | 63 | $this->assertTrue($c->has('other')); |
60 | 64 | |
@@ -76,21 +80,25 @@ discard block |
||
76 | 80 | $this->assertTrue($c->runScope([ |
77 | 81 | 'bucket' => new Bucket('b'), |
78 | 82 | 'other' => new SampleClass() |
79 | - ], function ($c) { |
|
83 | + ], function ($c) |
|
84 | + { |
|
80 | 85 | $this->assertSame('b', $c->get('bucket')->getName()); |
81 | 86 | $this->assertTrue($c->has('other')); |
82 | 87 | |
83 | 88 | return $c->get('bucket')->getName() == 'b' && $c->has('other'); |
84 | 89 | })); |
85 | 90 | |
86 | - try { |
|
91 | + try |
|
92 | + { |
|
87 | 93 | $this->assertTrue($c->runScope([ |
88 | 94 | 'bucket' => new Bucket('b'), |
89 | 95 | 'other' => new SampleClass() |
90 | 96 | ], function () use ($c): void { |
91 | 97 | throw new RuntimeException('exception'); |
92 | 98 | })); |
93 | - } catch (\Throwable) { |
|
99 | + } |
|
100 | + catch (\Throwable) |
|
101 | + { |
|
94 | 102 | } |
95 | 103 | |
96 | 104 | $this->assertSame('a', $c->get('bucket')->getName()); |
@@ -138,10 +146,13 @@ discard block |
||
138 | 146 | public function testHasInstanceAfterMakeWithoutAliasInScope(): void |
139 | 147 | { |
140 | 148 | $container = new Container(); |
141 | - $container->bindSingleton('test', new #[Singleton] class {}); |
|
149 | + $container->bindSingleton('test', new #[Singleton] class |
|
150 | + { |
|
151 | +}); |
|
142 | 152 | $container->make('test'); |
143 | 153 | |
144 | - $container->runScoped(function (Container $container) { |
|
154 | + $container->runScoped(function (Container $container) |
|
155 | + { |
|
145 | 156 | $this->assertTrue($container->hasInstance('test')); |
146 | 157 | }); |
147 | 158 | } |
@@ -152,7 +163,8 @@ discard block |
||
152 | 163 | $container->bindSingleton('test', SampleClass::class); |
153 | 164 | $container->make('test'); |
154 | 165 | |
155 | - $container->runScoped(function (Container $container) { |
|
166 | + $container->runScoped(function (Container $container) |
|
167 | + { |
|
156 | 168 | $this->assertTrue($container->hasInstance('test')); |
157 | 169 | }); |
158 | 170 | } |
@@ -167,7 +179,8 @@ discard block |
||
167 | 179 | $container->bindSingleton('bar', 'foo'); |
168 | 180 | $container->make('bar'); |
169 | 181 | |
170 | - $container->runScoped(function (Container $container) { |
|
182 | + $container->runScoped(function (Container $container) |
|
183 | + { |
|
171 | 184 | $this->assertTrue($container->hasInstance('bar')); |
172 | 185 | }); |
173 | 186 | } |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | string $name, |
29 | 29 | ?string $comment = null, |
30 | 30 | ?string $namespace = null, |
31 | - ) { |
|
31 | + ){ |
|
32 | 32 | parent::__construct($config, $name, $comment, $namespace); |
33 | 33 | |
34 | - try { |
|
34 | + try{ |
|
35 | 35 | $this->validationConfig = $container->get(ValidationConfig::class); |
36 | - } catch (\Throwable) { |
|
36 | + }catch (\Throwable){ |
|
37 | 37 | // Validation is not configured |
38 | 38 | $this->validationConfig = null; |
39 | 39 | } |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | public function addFilterDefinition(): void |
51 | 51 | { |
52 | 52 | $validation = $this->validationConfig?->getDefaultValidator(); |
53 | - if ($validation === null) { |
|
53 | + if ($validation === null){ |
|
54 | 54 | throw new ValidationException( |
55 | 55 | 'Default Validator is not configured. Read more at https://spiral.dev/docs/validation-factory' |
56 | 56 | ); |
57 | 57 | } |
58 | 58 | |
59 | - if (!\class_exists($validation)) { |
|
59 | + if (!\class_exists($validation)){ |
|
60 | 60 | throw new ValidationException( |
61 | 61 | \sprintf( |
62 | 62 | 'Default Validator "%s" is not class or does not exist.', |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $p = $this->class->addProperty($property->getName()) |
91 | 91 | ->setType($property->getType()); |
92 | 92 | |
93 | - foreach ($property->getAttributes() as $attribute) { |
|
93 | + foreach ($property->getAttributes() as $attribute){ |
|
94 | 94 | $p->addAttribute($attribute->getName(), $attribute->getArguments()); |
95 | 95 | } |
96 | 96 | } |
@@ -107,12 +107,12 @@ discard block |
||
107 | 107 | { |
108 | 108 | $declaredType = null; |
109 | 109 | |
110 | - if (\str_contains($property, ':')) { |
|
110 | + if (\str_contains($property, ':')){ |
|
111 | 111 | $segments = \explode(':', $property, 3); |
112 | 112 | |
113 | - if (\count($segments) === 3) { |
|
113 | + if (\count($segments) === 3){ |
|
114 | 114 | [$property, $source, $declaredType] = $segments; |
115 | - } else { |
|
115 | + }else{ |
|
116 | 116 | [$property, $source] = $segments; |
117 | 117 | } |
118 | 118 | } |
@@ -31,9 +31,12 @@ discard block |
||
31 | 31 | ) { |
32 | 32 | parent::__construct($config, $name, $comment, $namespace); |
33 | 33 | |
34 | - try { |
|
34 | + try |
|
35 | + { |
|
35 | 36 | $this->validationConfig = $container->get(ValidationConfig::class); |
36 | - } catch (\Throwable) { |
|
37 | + } |
|
38 | + catch (\Throwable) |
|
39 | + { |
|
37 | 40 | // Validation is not configured |
38 | 41 | $this->validationConfig = null; |
39 | 42 | } |
@@ -50,13 +53,15 @@ discard block |
||
50 | 53 | public function addFilterDefinition(): void |
51 | 54 | { |
52 | 55 | $validation = $this->validationConfig?->getDefaultValidator(); |
53 | - if ($validation === null) { |
|
56 | + if ($validation === null) |
|
57 | + { |
|
54 | 58 | throw new ValidationException( |
55 | 59 | 'Default Validator is not configured. Read more at https://spiral.dev/docs/validation-factory' |
56 | 60 | ); |
57 | 61 | } |
58 | 62 | |
59 | - if (!\class_exists($validation)) { |
|
63 | + if (!\class_exists($validation)) |
|
64 | + { |
|
60 | 65 | throw new ValidationException( |
61 | 66 | \sprintf( |
62 | 67 | 'Default Validator "%s" is not class or does not exist.', |
@@ -90,7 +95,8 @@ discard block |
||
90 | 95 | $p = $this->class->addProperty($property->getName()) |
91 | 96 | ->setType($property->getType()); |
92 | 97 | |
93 | - foreach ($property->getAttributes() as $attribute) { |
|
98 | + foreach ($property->getAttributes() as $attribute) |
|
99 | + { |
|
94 | 100 | $p->addAttribute($attribute->getName(), $attribute->getArguments()); |
95 | 101 | } |
96 | 102 | } |
@@ -107,12 +113,16 @@ discard block |
||
107 | 113 | { |
108 | 114 | $declaredType = null; |
109 | 115 | |
110 | - if (\str_contains($property, ':')) { |
|
116 | + if (\str_contains($property, ':')) |
|
117 | + { |
|
111 | 118 | $segments = \explode(':', $property, 3); |
112 | 119 | |
113 | - if (\count($segments) === 3) { |
|
120 | + if (\count($segments) === 3) |
|
121 | + { |
|
114 | 122 | [$property, $source, $declaredType] = $segments; |
115 | - } else { |
|
123 | + } |
|
124 | + else |
|
125 | + { |
|
116 | 126 | [$property, $source] = $segments; |
117 | 127 | } |
118 | 128 | } |
@@ -20,20 +20,20 @@ |
||
20 | 20 | |
21 | 21 | public function __construct( |
22 | 22 | #[Proxy] protected InvokerInterface $invoker, |
23 | - ) { |
|
23 | + ){ |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function handle(string $name, string $id, mixed $payload, array $headers = []): void |
27 | 27 | { |
28 | - try { |
|
28 | + try{ |
|
29 | 29 | $params = ['payload' => $payload, 'id' => $id, 'headers' => $headers]; |
30 | 30 | |
31 | - if (\is_array($payload)) { |
|
31 | + if (\is_array($payload)){ |
|
32 | 32 | $params = \array_merge($params, $payload); |
33 | 33 | } |
34 | 34 | |
35 | 35 | $this->invoker->invoke([$this, $this->getHandlerMethod()], $params); |
36 | - } catch (\Throwable $e) { |
|
36 | + }catch (\Throwable $e){ |
|
37 | 37 | $message = \sprintf('[%s] %s', static::class, $e->getMessage()); |
38 | 38 | throw new JobException($message, (int)$e->getCode(), $e); |
39 | 39 | } |
@@ -25,15 +25,19 @@ |
||
25 | 25 | |
26 | 26 | public function handle(string $name, string $id, mixed $payload, array $headers = []): void |
27 | 27 | { |
28 | - try { |
|
28 | + try |
|
29 | + { |
|
29 | 30 | $params = ['payload' => $payload, 'id' => $id, 'headers' => $headers]; |
30 | 31 | |
31 | - if (\is_array($payload)) { |
|
32 | + if (\is_array($payload)) |
|
33 | + { |
|
32 | 34 | $params = \array_merge($params, $payload); |
33 | 35 | } |
34 | 36 | |
35 | 37 | $this->invoker->invoke([$this, $this->getHandlerMethod()], $params); |
36 | - } catch (\Throwable $e) { |
|
38 | + } |
|
39 | + catch (\Throwable $e) |
|
40 | + { |
|
37 | 41 | $message = \sprintf('[%s] %s', static::class, $e->getMessage()); |
38 | 42 | throw new JobException($message, (int)$e->getCode(), $e); |
39 | 43 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | { |
23 | 23 | public function __construct( |
24 | 24 | private readonly QueueInterface $connection, |
25 | - ) { |
|
25 | + ){ |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | string $action, |
35 | 35 | array $parameters = ['options' => null, 'payload' => []], |
36 | 36 | ): string { |
37 | - if ($parameters['options'] === null) { |
|
37 | + if ($parameters['options'] === null){ |
|
38 | 38 | $parameters['options'] = new Options(); |
39 | 39 | } |
40 | 40 | |
41 | 41 | $tracer = $this->getTracer(); |
42 | 42 | |
43 | - if (\method_exists($parameters['options'], 'withHeader')) { |
|
44 | - foreach ($tracer->getContext() as $key => $data) { |
|
43 | + if (\method_exists($parameters['options'], 'withHeader')){ |
|
44 | + foreach ($tracer->getContext() as $key => $data){ |
|
45 | 45 | $parameters['options'] = $parameters['options']->withHeader($key, $data); |
46 | 46 | } |
47 | 47 | } |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | |
71 | 71 | private function getTracer(): TracerInterface |
72 | 72 | { |
73 | - try { |
|
73 | + try{ |
|
74 | 74 | return ContainerScope::getContainer()->get(TracerInterface::class); |
75 | - } catch (\Throwable) { |
|
75 | + }catch (\Throwable){ |
|
76 | 76 | return new NullTracer(); |
77 | 77 | } |
78 | 78 | } |
@@ -34,14 +34,17 @@ discard block |
||
34 | 34 | string $action, |
35 | 35 | array $parameters = ['options' => null, 'payload' => []], |
36 | 36 | ): string { |
37 | - if ($parameters['options'] === null) { |
|
37 | + if ($parameters['options'] === null) |
|
38 | + { |
|
38 | 39 | $parameters['options'] = new Options(); |
39 | 40 | } |
40 | 41 | |
41 | 42 | $tracer = $this->getTracer(); |
42 | 43 | |
43 | - if (\method_exists($parameters['options'], 'withHeader')) { |
|
44 | - foreach ($tracer->getContext() as $key => $data) { |
|
44 | + if (\method_exists($parameters['options'], 'withHeader')) |
|
45 | + { |
|
46 | + foreach ($tracer->getContext() as $key => $data) |
|
47 | + { |
|
45 | 48 | $parameters['options'] = $parameters['options']->withHeader($key, $data); |
46 | 49 | } |
47 | 50 | } |
@@ -70,9 +73,12 @@ discard block |
||
70 | 73 | |
71 | 74 | private function getTracer(): TracerInterface |
72 | 75 | { |
73 | - try { |
|
76 | + try |
|
77 | + { |
|
74 | 78 | return ContainerScope::getContainer()->get(TracerInterface::class); |
75 | - } catch (\Throwable) { |
|
79 | + } |
|
80 | + catch (\Throwable) |
|
81 | + { |
|
76 | 82 | return new NullTracer(); |
77 | 83 | } |
78 | 84 | } |
@@ -41,7 +41,8 @@ discard block |
||
41 | 41 | |
42 | 42 | public function testHandleWithHandleMethod(): void |
43 | 43 | { |
44 | - $object = new class($this) { |
|
44 | + $object = new class($this) |
|
45 | + { |
|
45 | 46 | public function __construct(private $testCase) |
46 | 47 | { |
47 | 48 | } |
@@ -61,7 +62,8 @@ discard block |
||
61 | 62 | |
62 | 63 | public function testHandleWithInvokeMethod(): void |
63 | 64 | { |
64 | - $object = new class($this) { |
|
65 | + $object = new class($this) |
|
66 | + { |
|
65 | 67 | public function __construct(private $testCase) |
66 | 68 | { |
67 | 69 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function __construct( |
39 | 39 | protected ResolverInterface $resolver |
40 | - ) { |
|
40 | + ){ |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -48,20 +48,20 @@ discard block |
||
48 | 48 | $parameters = \compact('actor', 'permission', 'context') + $context; |
49 | 49 | |
50 | 50 | //Mounting aliases |
51 | - foreach (static::ALIASES as $target => $alias) { |
|
51 | + foreach (static::ALIASES as $target => $alias){ |
|
52 | 52 | $parameters[$target] = $parameters[$alias]; |
53 | 53 | } |
54 | 54 | |
55 | - try { |
|
55 | + try{ |
|
56 | 56 | $method = new \ReflectionMethod($this, static::CHECK_METHOD); |
57 | - } catch (\ReflectionException $e) { |
|
57 | + }catch (\ReflectionException $e){ |
|
58 | 58 | throw new RuleException($e->getMessage(), $e->getCode(), $e); |
59 | 59 | } |
60 | 60 | |
61 | - try { |
|
61 | + try{ |
|
62 | 62 | return $method->invokeArgs($this, $this->resolver->resolveArguments($method, $parameters)); |
63 | - } catch (\Throwable $e) { |
|
64 | - throw new RuleException(\sprintf('[%s] %s', static::class, $e->getMessage()), (int) $e->getCode(), $e); |
|
63 | + }catch (\Throwable $e){ |
|
64 | + throw new RuleException(\sprintf('[%s] %s', static::class, $e->getMessage()), (int)$e->getCode(), $e); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | } |
@@ -48,19 +48,26 @@ |
||
48 | 48 | $parameters = \compact('actor', 'permission', 'context') + $context; |
49 | 49 | |
50 | 50 | //Mounting aliases |
51 | - foreach (static::ALIASES as $target => $alias) { |
|
51 | + foreach (static::ALIASES as $target => $alias) |
|
52 | + { |
|
52 | 53 | $parameters[$target] = $parameters[$alias]; |
53 | 54 | } |
54 | 55 | |
55 | - try { |
|
56 | + try |
|
57 | + { |
|
56 | 58 | $method = new \ReflectionMethod($this, static::CHECK_METHOD); |
57 | - } catch (\ReflectionException $e) { |
|
59 | + } |
|
60 | + catch (\ReflectionException $e) |
|
61 | + { |
|
58 | 62 | throw new RuleException($e->getMessage(), $e->getCode(), $e); |
59 | 63 | } |
60 | 64 | |
61 | - try { |
|
65 | + try |
|
66 | + { |
|
62 | 67 | return $method->invokeArgs($this, $this->resolver->resolveArguments($method, $parameters)); |
63 | - } catch (\Throwable $e) { |
|
68 | + } |
|
69 | + catch (\Throwable $e) |
|
70 | + { |
|
64 | 71 | throw new RuleException(\sprintf('[%s] %s', static::class, $e->getMessage()), (int) $e->getCode(), $e); |
65 | 72 | } |
66 | 73 | } |