Passed
Pull Request — master (#656)
by Abdul Malik
09:06 queued 02:28
created
src/Http/src/SapiRequestFactory.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         UriFactoryInterface $uriFactory,
70 70
         StreamFactoryInterface $streamFactory,
71 71
         UploadedFileFactoryInterface $uploadedFileFactory
72
-    ) {
72
+    ){
73 73
         $this->requestFactory = $requestFactory;
74 74
         $this->uriFactory = $uriFactory;
75 75
         $this->streamFactory = $streamFactory;
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
         $uri = $this->getUri($server);
107 107
 
108 108
         $request = $this->requestFactory->createServerRequest($method, $uri, $server);
109
-        foreach ($headers as $name => $value) {
109
+        foreach ($headers as $name => $value){
110 110
             $request = $request->withAddedHeader($name, $value);
111 111
         }
112 112
 
113 113
         $protocol = '1.1';
114
-        if (!empty($_SERVER['SERVER_PROTOCOL'])) {
114
+        if (!empty($_SERVER['SERVER_PROTOCOL'])){
115 115
             $protocol = str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']);
116 116
         }
117 117
 
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
             ->withCookieParams($cookies)
123 123
             ->withUploadedFiles($this->getUploadedFilesArray($files));
124 124
 
125
-        if ($body === null) {
125
+        if ($body === null){
126 126
             return $request;
127 127
         }
128 128
 
129
-        if (\is_resource($body)) {
129
+        if (\is_resource($body)){
130 130
             $body = $this->streamFactory->createStreamFromResource($body);
131
-        } elseif (\is_string($body)) {
131
+        } elseif (\is_string($body)){
132 132
             $body = $this->streamFactory->createStream($body);
133
-        } elseif (!$body instanceof StreamInterface) {
133
+        } elseif (!$body instanceof StreamInterface){
134 134
             throw new InvalidArgumentException(
135 135
                 'Body parameter for ServerRequestFactory::createFromParameters() '
136 136
                 . 'must be instance of StreamInterface, resource or null.'
@@ -143,29 +143,29 @@  discard block
 block discarded – undo
143 143
     private function getUri(array $server): UriInterface
144 144
     {
145 145
         $uri = $this->uriFactory->createUri();
146
-        if (isset($server['HTTPS'])) {
146
+        if (isset($server['HTTPS'])){
147 147
             $uri = $uri->withScheme($server['HTTPS'] === 'on' ? 'https' : 'http');
148 148
         }
149 149
 
150
-        if (isset($server['HTTP_HOST'])) {
151
-            if (1 === \preg_match('/^(.+)\:(\d+)$/', $server['HTTP_HOST'], $matches)) {
150
+        if (isset($server['HTTP_HOST'])){
151
+            if (1 === \preg_match('/^(.+)\:(\d+)$/', $server['HTTP_HOST'], $matches)){
152 152
                 $uri = $uri->withHost($matches[1])->withPort($matches[2]);
153
-            } else {
153
+            }else{
154 154
                 $uri = $uri->withHost($server['HTTP_HOST']);
155 155
             }
156
-        } elseif (isset($server['SERVER_NAME'])) {
156
+        } elseif (isset($server['SERVER_NAME'])){
157 157
             $uri = $uri->withHost($server['SERVER_NAME']);
158 158
         }
159 159
 
160
-        if (isset($server['SERVER_PORT'])) {
160
+        if (isset($server['SERVER_PORT'])){
161 161
             $uri = $uri->withPort($server['SERVER_PORT']);
162 162
         }
163 163
 
164
-        if (isset($server['REQUEST_URI'])) {
164
+        if (isset($server['REQUEST_URI'])){
165 165
             $uri = $uri->withPath(\explode('?', $server['REQUEST_URI'])[0]);
166 166
         }
167 167
 
168
-        if (isset($server['QUERY_STRING'])) {
168
+        if (isset($server['QUERY_STRING'])){
169 169
             $uri = $uri->withQuery($server['QUERY_STRING']);
170 170
         }
171 171
 
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
 
175 175
     private static function getHeadersFromGlobals(): array
176 176
     {
177
-        if (\function_exists('getallheaders')) {
177
+        if (\function_exists('getallheaders')){
178 178
             $headers = getallheaders();
179
-        } else {
179
+        }else{
180 180
             $headers = [];
181
-            foreach ($_SERVER as $name => $value) {
182
-                if (strncmp($name, 'HTTP_', 5) === 0) {
181
+            foreach ($_SERVER as $name => $value){
182
+                if (strncmp($name, 'HTTP_', 5) === 0){
183 183
                     $name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
184 184
                     $headers[$name] = $value;
185 185
                 }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     private function getUploadedFilesArray(array $filesArray): array
193 193
     {
194 194
         $files = [];
195
-        foreach ($filesArray as $class => $info) {
195
+        foreach ($filesArray as $class => $info){
196 196
             $files[$class] = [];
197 197
             $this->populateUploadedFileRecursive(
198 198
                 $files[$class],
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
      */
221 221
     private function populateUploadedFileRecursive(&$files, $names, $tempNames, $types, $sizes, $errors): void
222 222
     {
223
-        if (\is_array($names)) {
224
-            foreach ($names as $i => $name) {
223
+        if (\is_array($names)){
224
+            foreach ($names as $i => $name){
225 225
                 $files[$i] = [];
226 226
                 $this->populateUploadedFileRecursive(
227 227
                     $files[$i],
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
                     $errors[$i]
233 233
                 );
234 234
             }
235
-        } else {
236
-            try {
235
+        }else{
236
+            try{
237 237
                 $stream = $this->streamFactory->createStreamFromFile($tempNames);
238
-            } catch (RuntimeException $e) {
238
+            }catch (RuntimeException $e){
239 239
                 $stream = $this->streamFactory->createStream();
240 240
             }
241 241
 
Please login to merge, or discard this patch.
Braces   +55 added lines, -24 removed lines patch added patch discarded remove patch
@@ -106,12 +106,14 @@  discard block
 block discarded – undo
106 106
         $uri = $this->getUri($server);
107 107
 
108 108
         $request = $this->requestFactory->createServerRequest($method, $uri, $server);
109
-        foreach ($headers as $name => $value) {
109
+        foreach ($headers as $name => $value)
110
+        {
110 111
             $request = $request->withAddedHeader($name, $value);
111 112
         }
112 113
 
113 114
         $protocol = '1.1';
114
-        if (!empty($_SERVER['SERVER_PROTOCOL'])) {
115
+        if (!empty($_SERVER['SERVER_PROTOCOL']))
116
+        {
115 117
             $protocol = str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']);
116 118
         }
117 119
 
@@ -122,15 +124,21 @@  discard block
 block discarded – undo
122 124
             ->withCookieParams($cookies)
123 125
             ->withUploadedFiles($this->getUploadedFilesArray($files));
124 126
 
125
-        if ($body === null) {
127
+        if ($body === null)
128
+        {
126 129
             return $request;
127 130
         }
128 131
 
129
-        if (\is_resource($body)) {
132
+        if (\is_resource($body))
133
+        {
130 134
             $body = $this->streamFactory->createStreamFromResource($body);
131
-        } elseif (\is_string($body)) {
135
+        }
136
+        elseif (\is_string($body))
137
+        {
132 138
             $body = $this->streamFactory->createStream($body);
133
-        } elseif (!$body instanceof StreamInterface) {
139
+        }
140
+        elseif (!$body instanceof StreamInterface)
141
+        {
134 142
             throw new InvalidArgumentException(
135 143
                 'Body parameter for ServerRequestFactory::createFromParameters() '
136 144
                 . 'must be instance of StreamInterface, resource or null.'
@@ -143,29 +151,39 @@  discard block
 block discarded – undo
143 151
     private function getUri(array $server): UriInterface
144 152
     {
145 153
         $uri = $this->uriFactory->createUri();
146
-        if (isset($server['HTTPS'])) {
154
+        if (isset($server['HTTPS']))
155
+        {
147 156
             $uri = $uri->withScheme($server['HTTPS'] === 'on' ? 'https' : 'http');
148 157
         }
149 158
 
150
-        if (isset($server['HTTP_HOST'])) {
151
-            if (1 === \preg_match('/^(.+)\:(\d+)$/', $server['HTTP_HOST'], $matches)) {
159
+        if (isset($server['HTTP_HOST']))
160
+        {
161
+            if (1 === \preg_match('/^(.+)\:(\d+)$/', $server['HTTP_HOST'], $matches))
162
+            {
152 163
                 $uri = $uri->withHost($matches[1])->withPort($matches[2]);
153
-            } else {
164
+            }
165
+            else
166
+            {
154 167
                 $uri = $uri->withHost($server['HTTP_HOST']);
155 168
             }
156
-        } elseif (isset($server['SERVER_NAME'])) {
169
+        }
170
+        elseif (isset($server['SERVER_NAME']))
171
+        {
157 172
             $uri = $uri->withHost($server['SERVER_NAME']);
158 173
         }
159 174
 
160
-        if (isset($server['SERVER_PORT'])) {
175
+        if (isset($server['SERVER_PORT']))
176
+        {
161 177
             $uri = $uri->withPort($server['SERVER_PORT']);
162 178
         }
163 179
 
164
-        if (isset($server['REQUEST_URI'])) {
180
+        if (isset($server['REQUEST_URI']))
181
+        {
165 182
             $uri = $uri->withPath(\explode('?', $server['REQUEST_URI'])[0]);
166 183
         }
167 184
 
168
-        if (isset($server['QUERY_STRING'])) {
185
+        if (isset($server['QUERY_STRING']))
186
+        {
169 187
             $uri = $uri->withQuery($server['QUERY_STRING']);
170 188
         }
171 189
 
@@ -174,12 +192,17 @@  discard block
 block discarded – undo
174 192
 
175 193
     private static function getHeadersFromGlobals(): array
176 194
     {
177
-        if (\function_exists('getallheaders')) {
195
+        if (\function_exists('getallheaders'))
196
+        {
178 197
             $headers = getallheaders();
179
-        } else {
198
+        }
199
+        else
200
+        {
180 201
             $headers = [];
181
-            foreach ($_SERVER as $name => $value) {
182
-                if (strncmp($name, 'HTTP_', 5) === 0) {
202
+            foreach ($_SERVER as $name => $value)
203
+            {
204
+                if (strncmp($name, 'HTTP_', 5) === 0)
205
+                {
183 206
                     $name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
184 207
                     $headers[$name] = $value;
185 208
                 }
@@ -192,7 +215,8 @@  discard block
 block discarded – undo
192 215
     private function getUploadedFilesArray(array $filesArray): array
193 216
     {
194 217
         $files = [];
195
-        foreach ($filesArray as $class => $info) {
218
+        foreach ($filesArray as $class => $info)
219
+        {
196 220
             $files[$class] = [];
197 221
             $this->populateUploadedFileRecursive(
198 222
                 $files[$class],
@@ -220,8 +244,10 @@  discard block
 block discarded – undo
220 244
      */
221 245
     private function populateUploadedFileRecursive(&$files, $names, $tempNames, $types, $sizes, $errors): void
222 246
     {
223
-        if (\is_array($names)) {
224
-            foreach ($names as $i => $name) {
247
+        if (\is_array($names))
248
+        {
249
+            foreach ($names as $i => $name)
250
+            {
225 251
                 $files[$i] = [];
226 252
                 $this->populateUploadedFileRecursive(
227 253
                     $files[$i],
@@ -232,10 +258,15 @@  discard block
 block discarded – undo
232 258
                     $errors[$i]
233 259
                 );
234 260
             }
235
-        } else {
236
-            try {
261
+        }
262
+        else
263
+        {
264
+            try
265
+            {
237 266
                 $stream = $this->streamFactory->createStreamFromFile($tempNames);
238
-            } catch (RuntimeException $e) {
267
+            }
268
+            catch (RuntimeException $e)
269
+            {
239 270
                 $stream = $this->streamFactory->createStream();
240 271
             }
241 272
 
Please login to merge, or discard this patch.
src/Http/src/Stream/GeneratorStream.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -28,23 +28,23 @@  discard block
 block discarded – undo
28 28
 
29 29
     public function __toString(): string
30 30
     {
31
-        try {
31
+        try{
32 32
             return $this->getContents();
33
-        } catch (Exception $e) {
33
+        }catch (Exception $e){
34 34
             return '';
35 35
         }
36 36
     }
37 37
 
38 38
     public function close(): void
39 39
     {
40
-        if ($this->stream !== null) {
40
+        if ($this->stream !== null){
41 41
             $this->detach();
42 42
         }
43 43
     }
44 44
 
45 45
     public function detach()
46 46
     {
47
-        if ($this->stream === null) {
47
+        if ($this->stream === null){
48 48
             return null;
49 49
         }
50 50
         $this->stream = null;
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
     public function rewind(): void
84 84
     {
85
-        if ($this->stream !== null) {
85
+        if ($this->stream !== null){
86 86
             $this->stream->rewind();
87 87
         }
88 88
         $this->caret = 0;
@@ -106,26 +106,26 @@  discard block
 block discarded – undo
106 106
 
107 107
     public function read($length): string
108 108
     {
109
-        if (!$this->readable) {
109
+        if (!$this->readable){
110 110
             throw new RuntimeException('Cannot read from non-readable stream.');
111 111
         }
112
-        if ($this->stream === null) {
112
+        if ($this->stream === null){
113 113
             throw new RuntimeException('Cannot read from detached stream.');
114 114
         }
115
-        do {
116
-            if ($this->started) {
115
+        do{
116
+            if ($this->started){
117 117
                 $read = (string)$this->stream->send(null);
118
-            } else {
118
+            }else{
119 119
                 $this->started = true;
120 120
                 $read = (string)$this->stream->current();
121 121
             }
122
-            if (!$this->stream->valid()) {
122
+            if (!$this->stream->valid()){
123 123
                 $read .= $this->stream->getReturn();
124 124
                 break;
125 125
             }
126
-        } while ($read === '');
126
+        }while ($read === '');
127 127
         $this->caret += \strlen($read);
128
-        if (!$this->stream->valid()) {
128
+        if (!$this->stream->valid()){
129 129
             $this->size = $this->caret;
130 130
         }
131 131
         return $read;
@@ -133,19 +133,19 @@  discard block
 block discarded – undo
133 133
 
134 134
     public function getContents(): string
135 135
     {
136
-        if ($this->stream === null) {
136
+        if ($this->stream === null){
137 137
             throw new RuntimeException('Unable to read stream contents.');
138 138
         }
139 139
         $content = '';
140
-        do {
140
+        do{
141 141
             $content .= $this->read(PHP_INT_MAX);
142
-        } while ($this->stream->valid());
142
+        }while ($this->stream->valid());
143 143
         return $content;
144 144
     }
145 145
 
146 146
     public function getMetadata($key = null)
147 147
     {
148
-        if ($this->stream === null) {
148
+        if ($this->stream === null){
149 149
             return $key ? null : [];
150 150
         }
151 151
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             'eof' => $this->eof(),
155 155
         ];
156 156
 
157
-        if (null === $key) {
157
+        if (null === $key){
158 158
             return $meta;
159 159
         }
160 160
 
Please login to merge, or discard this patch.
Braces   +34 added lines, -16 removed lines patch added patch discarded remove patch
@@ -28,23 +28,28 @@  discard block
 block discarded – undo
28 28
 
29 29
     public function __toString(): string
30 30
     {
31
-        try {
31
+        try
32
+        {
32 33
             return $this->getContents();
33
-        } catch (Exception $e) {
34
+        }
35
+        catch (Exception $e)
36
+        {
34 37
             return '';
35 38
         }
36 39
     }
37 40
 
38 41
     public function close(): void
39 42
     {
40
-        if ($this->stream !== null) {
43
+        if ($this->stream !== null)
44
+        {
41 45
             $this->detach();
42 46
         }
43 47
     }
44 48
 
45 49
     public function detach()
46 50
     {
47
-        if ($this->stream === null) {
51
+        if ($this->stream === null)
52
+        {
48 53
             return null;
49 54
         }
50 55
         $this->stream = null;
@@ -82,7 +87,8 @@  discard block
 block discarded – undo
82 87
 
83 88
     public function rewind(): void
84 89
     {
85
-        if ($this->stream !== null) {
90
+        if ($this->stream !== null)
91
+        {
86 92
             $this->stream->rewind();
87 93
         }
88 94
         $this->caret = 0;
@@ -106,26 +112,34 @@  discard block
 block discarded – undo
106 112
 
107 113
     public function read($length): string
108 114
     {
109
-        if (!$this->readable) {
115
+        if (!$this->readable)
116
+        {
110 117
             throw new RuntimeException('Cannot read from non-readable stream.');
111 118
         }
112
-        if ($this->stream === null) {
119
+        if ($this->stream === null)
120
+        {
113 121
             throw new RuntimeException('Cannot read from detached stream.');
114 122
         }
115
-        do {
116
-            if ($this->started) {
123
+        do
124
+        {
125
+            if ($this->started)
126
+            {
117 127
                 $read = (string)$this->stream->send(null);
118
-            } else {
128
+            }
129
+            else
130
+            {
119 131
                 $this->started = true;
120 132
                 $read = (string)$this->stream->current();
121 133
             }
122
-            if (!$this->stream->valid()) {
134
+            if (!$this->stream->valid())
135
+            {
123 136
                 $read .= $this->stream->getReturn();
124 137
                 break;
125 138
             }
126 139
         } while ($read === '');
127 140
         $this->caret += \strlen($read);
128
-        if (!$this->stream->valid()) {
141
+        if (!$this->stream->valid())
142
+        {
129 143
             $this->size = $this->caret;
130 144
         }
131 145
         return $read;
@@ -133,11 +147,13 @@  discard block
 block discarded – undo
133 147
 
134 148
     public function getContents(): string
135 149
     {
136
-        if ($this->stream === null) {
150
+        if ($this->stream === null)
151
+        {
137 152
             throw new RuntimeException('Unable to read stream contents.');
138 153
         }
139 154
         $content = '';
140
-        do {
155
+        do
156
+        {
141 157
             $content .= $this->read(PHP_INT_MAX);
142 158
         } while ($this->stream->valid());
143 159
         return $content;
@@ -145,7 +161,8 @@  discard block
 block discarded – undo
145 161
 
146 162
     public function getMetadata($key = null)
147 163
     {
148
-        if ($this->stream === null) {
164
+        if ($this->stream === null)
165
+        {
149 166
             return $key ? null : [];
150 167
         }
151 168
 
@@ -154,7 +171,8 @@  discard block
 block discarded – undo
154 171
             'eof' => $this->eof(),
155 172
         ];
156 173
 
157
-        if (null === $key) {
174
+        if (null === $key)
175
+        {
158 176
             return $meta;
159 177
         }
160 178
 
Please login to merge, or discard this patch.
src/Encrypter/src/Encrypter.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function __construct(string $key)
39 39
     {
40
-        try {
40
+        try{
41 41
             $this->key = Key::loadFromAsciiSafeString($key);
42
-        } catch (CryptoException $e) {
42
+        }catch (CryptoException $e){
43 43
             throw new EncrypterException($e->getMessage(), $e->getCode(), $e);
44 44
         }
45 45
     }
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
     public function withKey(string $key): EncrypterInterface
51 51
     {
52 52
         $encrypter = clone $this;
53
-        try {
53
+        try{
54 54
             $encrypter->key = Key::loadFromAsciiSafeString($key);
55
-        } catch (CryptoException $e) {
55
+        }catch (CryptoException $e){
56 56
             throw new EncrypterException($e->getMessage(), $e->getCode(), $e);
57 57
         }
58 58
 
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public function getKey(): string
66 66
     {
67
-        try {
67
+        try{
68 68
             return $this->key->saveToAsciiSafeString();
69
-        } catch (EnvironmentIsBrokenException $e) {
69
+        }catch (EnvironmentIsBrokenException $e){
70 70
             throw new EncrypterException($e->getMessage(), $e->getCode(), $e);
71 71
         }
72 72
     }
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
     {
81 81
         $packed = json_encode($data, JSON_THROW_ON_ERROR);
82 82
 
83
-        try {
83
+        try{
84 84
             return base64_encode(Crypto::Encrypt($packed, $this->key));
85
-        } catch (Throwable $e) {
85
+        }catch (Throwable $e){
86 86
             throw new EncryptException($e->getMessage(), $e->getCode(), $e);
87 87
         }
88 88
     }
@@ -94,14 +94,14 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function decrypt(string $payload)
96 96
     {
97
-        try {
97
+        try{
98 98
             $result = Crypto::Decrypt(
99 99
                 base64_decode($payload),
100 100
                 $this->key
101 101
             );
102 102
 
103 103
             return json_decode($result, true, 512, JSON_THROW_ON_ERROR);
104
-        } catch (Throwable $e) {
104
+        }catch (Throwable $e){
105 105
             throw new DecryptException($e->getMessage(), $e->getCode(), $e);
106 106
         }
107 107
     }
Please login to merge, or discard this patch.
Braces   +25 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,9 +37,12 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function __construct(string $key)
39 39
     {
40
-        try {
40
+        try
41
+        {
41 42
             $this->key = Key::loadFromAsciiSafeString($key);
42
-        } catch (CryptoException $e) {
43
+        }
44
+        catch (CryptoException $e)
45
+        {
43 46
             throw new EncrypterException($e->getMessage(), $e->getCode(), $e);
44 47
         }
45 48
     }
@@ -50,9 +53,12 @@  discard block
 block discarded – undo
50 53
     public function withKey(string $key): EncrypterInterface
51 54
     {
52 55
         $encrypter = clone $this;
53
-        try {
56
+        try
57
+        {
54 58
             $encrypter->key = Key::loadFromAsciiSafeString($key);
55
-        } catch (CryptoException $e) {
59
+        }
60
+        catch (CryptoException $e)
61
+        {
56 62
             throw new EncrypterException($e->getMessage(), $e->getCode(), $e);
57 63
         }
58 64
 
@@ -64,9 +70,12 @@  discard block
 block discarded – undo
64 70
      */
65 71
     public function getKey(): string
66 72
     {
67
-        try {
73
+        try
74
+        {
68 75
             return $this->key->saveToAsciiSafeString();
69
-        } catch (EnvironmentIsBrokenException $e) {
76
+        }
77
+        catch (EnvironmentIsBrokenException $e)
78
+        {
70 79
             throw new EncrypterException($e->getMessage(), $e->getCode(), $e);
71 80
         }
72 81
     }
@@ -80,9 +89,12 @@  discard block
 block discarded – undo
80 89
     {
81 90
         $packed = json_encode($data, JSON_THROW_ON_ERROR);
82 91
 
83
-        try {
92
+        try
93
+        {
84 94
             return base64_encode(Crypto::Encrypt($packed, $this->key));
85
-        } catch (Throwable $e) {
95
+        }
96
+        catch (Throwable $e)
97
+        {
86 98
             throw new EncryptException($e->getMessage(), $e->getCode(), $e);
87 99
         }
88 100
     }
@@ -94,14 +106,17 @@  discard block
 block discarded – undo
94 106
      */
95 107
     public function decrypt(string $payload)
96 108
     {
97
-        try {
109
+        try
110
+        {
98 111
             $result = Crypto::Decrypt(
99 112
                 base64_decode($payload),
100 113
                 $this->key
101 114
             );
102 115
 
103 116
             return json_decode($result, true, 512, JSON_THROW_ON_ERROR);
104
-        } catch (Throwable $e) {
117
+        }
118
+        catch (Throwable $e)
119
+        {
105 120
             throw new DecryptException($e->getMessage(), $e->getCode(), $e);
106 121
         }
107 122
     }
Please login to merge, or discard this patch.
src/Views/src/Engine/Native/NativeView.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -43,21 +43,21 @@
 block discarded – undo
43 43
         ob_start();
44 44
         $__outputLevel__ = ob_get_level();
45 45
 
46
-        try {
46
+        try{
47 47
             ContainerScope::runScope($this->container, function () use ($data): void {
48 48
                 extract($data, EXTR_OVERWRITE);
49 49
                 // render view in context and output buffer scope, context can be accessed using $this->context
50 50
                 require $this->view->getFilename();
51 51
             });
52
-        } catch (Throwable $e) {
53
-            while (ob_get_level() >= $__outputLevel__) {
52
+        }catch (Throwable $e){
53
+            while (ob_get_level() >= $__outputLevel__){
54 54
                 ob_end_clean();
55 55
             }
56 56
 
57 57
             throw new RenderException($e);
58
-        } finally {
58
+        }finally{
59 59
             //Closing all nested buffers
60
-            while (ob_get_level() > $__outputLevel__) {
60
+            while (ob_get_level() > $__outputLevel__){
61 61
                 ob_end_clean();
62 62
             }
63 63
         }
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -43,21 +43,28 @@
 block discarded – undo
43 43
         ob_start();
44 44
         $__outputLevel__ = ob_get_level();
45 45
 
46
-        try {
46
+        try
47
+        {
47 48
             ContainerScope::runScope($this->container, function () use ($data): void {
48 49
                 extract($data, EXTR_OVERWRITE);
49 50
                 // render view in context and output buffer scope, context can be accessed using $this->context
50 51
                 require $this->view->getFilename();
51 52
             });
52
-        } catch (Throwable $e) {
53
-            while (ob_get_level() >= $__outputLevel__) {
53
+        }
54
+        catch (Throwable $e)
55
+        {
56
+            while (ob_get_level() >= $__outputLevel__)
57
+            {
54 58
                 ob_end_clean();
55 59
             }
56 60
 
57 61
             throw new RenderException($e);
58
-        } finally {
62
+        }
63
+        finally
64
+        {
59 65
             //Closing all nested buffers
60
-            while (ob_get_level() > $__outputLevel__) {
66
+            while (ob_get_level() > $__outputLevel__)
67
+            {
61 68
                 ob_end_clean();
62 69
             }
63 70
         }
Please login to merge, or discard this patch.
src/Views/src/ViewManager.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
             'namespaces' => $config->getNamespaces(),
37 37
         ]);
38 38
 
39
-        foreach ($this->config->getDependencies() as $dependency) {
39
+        foreach ($this->config->getDependencies() as $dependency){
40 40
             $this->addDependency($dependency->resolve($factory));
41 41
         }
42 42
 
43
-        foreach ($this->config->getEngines() as $engine) {
43
+        foreach ($this->config->getEngines() as $engine){
44 44
             $this->addEngine($engine->resolve($factory));
45 45
         }
46 46
 
47
-        if ($this->config->isCacheEnabled()) {
47
+        if ($this->config->isCacheEnabled()){
48 48
             $this->cache = new ViewCache();
49 49
         }
50 50
     }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      */
97 97
     public function compile(string $path): void
98 98
     {
99
-        if ($this->cache !== null) {
99
+        if ($this->cache !== null){
100 100
             $this->cache->resetPath($path);
101 101
         }
102 102
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
         // Rotate all possible context variants and warm up cache
106 106
         $generator = new ContextGenerator($this->context);
107
-        foreach ($generator->generate() as $context) {
107
+        foreach ($generator->generate() as $context){
108 108
             $engine->reset($path, $context);
109 109
             $engine->compile($path, $context);
110 110
         }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public function reset(string $path): void
117 117
     {
118
-        if ($this->cache !== null) {
118
+        if ($this->cache !== null){
119 119
             $this->cache->resetPath($path);
120 120
         }
121 121
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
         // Rotate all possible context variants and warm up cache
125 125
         $generator = new ContextGenerator($this->context);
126
-        foreach ($generator->generate() as $context) {
126
+        foreach ($generator->generate() as $context){
127 127
             $engine->reset($path, $context);
128 128
         }
129 129
     }
@@ -136,13 +136,13 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function get(string $path): ViewInterface
138 138
     {
139
-        if ($this->cache !== null && $this->cache->has($this->context, $path)) {
139
+        if ($this->cache !== null && $this->cache->has($this->context, $path)){
140 140
             return $this->cache->get($this->context, $path);
141 141
         }
142 142
 
143 143
         $view = $this->findEngine($path)->get($path, $this->context);
144 144
 
145
-        if ($this->cache !== null) {
145
+        if ($this->cache !== null){
146 146
             $this->cache->set($this->context, $path, $view);
147 147
         }
148 148
 
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
      */
165 165
     private function findEngine(string $path): EngineInterface
166 166
     {
167
-        foreach ($this->engines as $engine) {
168
-            if ($engine->getLoader()->exists($path)) {
167
+        foreach ($this->engines as $engine){
168
+            if ($engine->getLoader()->exists($path)){
169 169
                 return $engine;
170 170
             }
171 171
         }
Please login to merge, or discard this patch.
Braces   +22 added lines, -11 removed lines patch added patch discarded remove patch
@@ -36,15 +36,18 @@  discard block
 block discarded – undo
36 36
             'namespaces' => $config->getNamespaces(),
37 37
         ]);
38 38
 
39
-        foreach ($this->config->getDependencies() as $dependency) {
39
+        foreach ($this->config->getDependencies() as $dependency)
40
+        {
40 41
             $this->addDependency($dependency->resolve($factory));
41 42
         }
42 43
 
43
-        foreach ($this->config->getEngines() as $engine) {
44
+        foreach ($this->config->getEngines() as $engine)
45
+        {
44 46
             $this->addEngine($engine->resolve($factory));
45 47
         }
46 48
 
47
-        if ($this->config->isCacheEnabled()) {
49
+        if ($this->config->isCacheEnabled())
50
+        {
48 51
             $this->cache = new ViewCache();
49 52
         }
50 53
     }
@@ -96,7 +99,8 @@  discard block
 block discarded – undo
96 99
      */
97 100
     public function compile(string $path): void
98 101
     {
99
-        if ($this->cache !== null) {
102
+        if ($this->cache !== null)
103
+        {
100 104
             $this->cache->resetPath($path);
101 105
         }
102 106
 
@@ -104,7 +108,8 @@  discard block
 block discarded – undo
104 108
 
105 109
         // Rotate all possible context variants and warm up cache
106 110
         $generator = new ContextGenerator($this->context);
107
-        foreach ($generator->generate() as $context) {
111
+        foreach ($generator->generate() as $context)
112
+        {
108 113
             $engine->reset($path, $context);
109 114
             $engine->compile($path, $context);
110 115
         }
@@ -115,7 +120,8 @@  discard block
 block discarded – undo
115 120
      */
116 121
     public function reset(string $path): void
117 122
     {
118
-        if ($this->cache !== null) {
123
+        if ($this->cache !== null)
124
+        {
119 125
             $this->cache->resetPath($path);
120 126
         }
121 127
 
@@ -123,7 +129,8 @@  discard block
 block discarded – undo
123 129
 
124 130
         // Rotate all possible context variants and warm up cache
125 131
         $generator = new ContextGenerator($this->context);
126
-        foreach ($generator->generate() as $context) {
132
+        foreach ($generator->generate() as $context)
133
+        {
127 134
             $engine->reset($path, $context);
128 135
         }
129 136
     }
@@ -136,13 +143,15 @@  discard block
 block discarded – undo
136 143
      */
137 144
     public function get(string $path): ViewInterface
138 145
     {
139
-        if ($this->cache !== null && $this->cache->has($this->context, $path)) {
146
+        if ($this->cache !== null && $this->cache->has($this->context, $path))
147
+        {
140 148
             return $this->cache->get($this->context, $path);
141 149
         }
142 150
 
143 151
         $view = $this->findEngine($path)->get($path, $this->context);
144 152
 
145
-        if ($this->cache !== null) {
153
+        if ($this->cache !== null)
154
+        {
146 155
             $this->cache->set($this->context, $path, $view);
147 156
         }
148 157
 
@@ -164,8 +173,10 @@  discard block
 block discarded – undo
164 173
      */
165 174
     private function findEngine(string $path): EngineInterface
166 175
     {
167
-        foreach ($this->engines as $engine) {
168
-            if ($engine->getLoader()->exists($path)) {
176
+        foreach ($this->engines as $engine)
177
+        {
178
+            if ($engine->getLoader()->exists($path))
179
+            {
169 180
                 return $engine;
170 181
             }
171 182
         }
Please login to merge, or discard this patch.
src/SendIt/src/Bootloader/MailerBootloader.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
     public function start(Container $container): void
71 71
     {
72
-        if ($container->has(JobRegistry::class)) {
72
+        if ($container->has(JobRegistry::class)){
73 73
             // Will be removed since v3.0
74 74
             $registry = $container->get(JobRegistry::class);
75 75
             $registry->setHandler(MailQueue::JOB_NAME, MailJob::class);
@@ -77,16 +77,16 @@  discard block
 block discarded – undo
77 77
             $container->bindSingleton(
78 78
                 MailerInterface::class,
79 79
                 static function (MailerConfig $config) use ($container) {
80
-                    if ($config->getQueueConnection() === 'sync') {
80
+                    if ($config->getQueueConnection() === 'sync'){
81 81
                         $queue = $container->get(ShortCircuit::class);
82
-                    } else {
82
+                    }else{
83 83
                         $queue = $container->get(QueueInterface::class);
84 84
                     }
85 85
 
86 86
                     return new MailQueue($config, $queue);
87 87
                 }
88 88
             );
89
-        } else {
89
+        }else{
90 90
             $container->bindSingleton(
91 91
                 MailerInterface::class,
92 92
                 static fn(MailerConfig $config, QueueConnectionProviderInterface $provider) => new MailQueue(
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             );
97 97
         }
98 98
 
99
-        if ($container->has(HandlerRegistryInterface::class)) {
99
+        if ($container->has(HandlerRegistryInterface::class)){
100 100
             $registry = $container->get(HandlerRegistryInterface::class);
101 101
             $registry->setHandler(MailQueue::JOB_NAME, MailJob::class);
102 102
         }
Please login to merge, or discard this patch.
Braces   +14 added lines, -6 removed lines patch added patch discarded remove patch
@@ -69,24 +69,31 @@  discard block
 block discarded – undo
69 69
 
70 70
     public function start(Container $container): void
71 71
     {
72
-        if ($container->has(JobRegistry::class)) {
72
+        if ($container->has(JobRegistry::class))
73
+        {
73 74
             // Will be removed since v3.0
74 75
             $registry = $container->get(JobRegistry::class);
75 76
             $registry->setHandler(MailQueue::JOB_NAME, MailJob::class);
76 77
             $registry->setSerializer(MailQueue::JOB_NAME, MessageSerializer::class);
77 78
             $container->bindSingleton(
78 79
                 MailerInterface::class,
79
-                static function (MailerConfig $config) use ($container) {
80
-                    if ($config->getQueueConnection() === 'sync') {
80
+                static function (MailerConfig $config) use ($container)
81
+                {
82
+                    if ($config->getQueueConnection() === 'sync')
83
+                    {
81 84
                         $queue = $container->get(ShortCircuit::class);
82
-                    } else {
85
+                    }
86
+                    else
87
+                    {
83 88
                         $queue = $container->get(QueueInterface::class);
84 89
                     }
85 90
 
86 91
                     return new MailQueue($config, $queue);
87 92
                 }
88 93
             );
89
-        } else {
94
+        }
95
+        else
96
+        {
90 97
             $container->bindSingleton(
91 98
                 MailerInterface::class,
92 99
                 static fn(MailerConfig $config, QueueConnectionProviderInterface $provider) => new MailQueue(
@@ -96,7 +103,8 @@  discard block
 block discarded – undo
96 103
             );
97 104
         }
98 105
 
99
-        if ($container->has(HandlerRegistryInterface::class)) {
106
+        if ($container->has(HandlerRegistryInterface::class))
107
+        {
100 108
             $registry = $container->get(HandlerRegistryInterface::class);
101 109
             $registry->setHandler(MailQueue::JOB_NAME, MailJob::class);
102 110
         }
Please login to merge, or discard this patch.
src/SendIt/src/MailJob.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function handle(string $name, string $id, $payload): void
47 47
     {
48
-        if (\is_string($payload)) {
48
+        if (\is_string($payload)){
49 49
             $payload = json_decode($payload, true, 512, JSON_THROW_ON_ERROR);
50 50
         }
51 51
 
52
-        if (!\is_array($payload)) {
52
+        if (!\is_array($payload)){
53 53
             throw new InvalidArgumentException('Mail job payload should be an array.');
54 54
         }
55 55
 
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
 
58 58
         $email = $this->renderer->render($message);
59 59
 
60
-        if ($email->getFrom() === []) {
60
+        if ($email->getFrom() === []){
61 61
             $email->from(Address::create($this->config->getFromAddress()));
62 62
         }
63 63
 
64 64
         $recipients = $this->getRecipients($email);
65 65
 
66
-        try {
66
+        try{
67 67
             $this->mailer->send($email);
68
-        } catch (TransportExceptionInterface $e) {
68
+        }catch (TransportExceptionInterface $e){
69 69
             $this->getLogger()->error(
70 70
                 sprintf(
71 71
                     'Failed to send `%s` to "%s": %s',
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
         $addresses = array_merge($message->getTo(), $message->getCc(), $message->getBcc());
97 97
 
98
-        foreach ($addresses as $address) {
98
+        foreach ($addresses as $address){
99 99
             $emails[] = $address->toString();
100 100
         }
101 101
 
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -45,11 +45,13 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function handle(string $name, string $id, $payload): void
47 47
     {
48
-        if (\is_string($payload)) {
48
+        if (\is_string($payload))
49
+        {
49 50
             $payload = json_decode($payload, true, 512, JSON_THROW_ON_ERROR);
50 51
         }
51 52
 
52
-        if (!\is_array($payload)) {
53
+        if (!\is_array($payload))
54
+        {
53 55
             throw new InvalidArgumentException('Mail job payload should be an array.');
54 56
         }
55 57
 
@@ -57,15 +59,19 @@  discard block
 block discarded – undo
57 59
 
58 60
         $email = $this->renderer->render($message);
59 61
 
60
-        if ($email->getFrom() === []) {
62
+        if ($email->getFrom() === [])
63
+        {
61 64
             $email->from(Address::create($this->config->getFromAddress()));
62 65
         }
63 66
 
64 67
         $recipients = $this->getRecipients($email);
65 68
 
66
-        try {
69
+        try
70
+        {
67 71
             $this->mailer->send($email);
68
-        } catch (TransportExceptionInterface $e) {
72
+        }
73
+        catch (TransportExceptionInterface $e)
74
+        {
69 75
             $this->getLogger()->error(
70 76
                 sprintf(
71 77
                     'Failed to send `%s` to "%s": %s',
@@ -95,7 +101,8 @@  discard block
 block discarded – undo
95 101
 
96 102
         $addresses = array_merge($message->getTo(), $message->getCc(), $message->getBcc());
97 103
 
98
-        foreach ($addresses as $address) {
104
+        foreach ($addresses as $address)
105
+        {
99 106
             $emails[] = $address->toString();
100 107
         }
101 108
 
Please login to merge, or discard this patch.
src/AnnotatedRoutes/src/RouteLocator.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
     public function findDeclarations(): array
46 46
     {
47 47
         $result = [];
48
-        foreach ($this->locator->getScopedClasses('routes') as $class) {
49
-            foreach ($class->getMethods() as $method) {
48
+        foreach ($this->locator->getScopedClasses('routes') as $class){
49
+            foreach ($class->getMethods() as $method){
50 50
                 $route = $this->reader->firstFunctionMetadata($method, Route::class);
51 51
 
52
-                if ($route === null) {
52
+                if ($route === null){
53 53
                     continue;
54 54
                 }
55 55
 
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
                     'controller' => $class->getName(),
60 60
                     'action'     => $method->getName(),
61 61
                     'group'      => $route->group,
62
-                    'verbs'      => (array) $route->methods,
62
+                    'verbs'      => (array)$route->methods,
63 63
                     'defaults'   => $route->defaults,
64
-                    'middleware' => (array) $route->middleware,
64
+                    'middleware' => (array)$route->middleware,
65 65
                     'priority'   => $route->priority,
66 66
                 ];
67 67
             }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,11 +45,14 @@
 block discarded – undo
45 45
     public function findDeclarations(): array
46 46
     {
47 47
         $result = [];
48
-        foreach ($this->locator->getScopedClasses('routes') as $class) {
49
-            foreach ($class->getMethods() as $method) {
48
+        foreach ($this->locator->getScopedClasses('routes') as $class)
49
+        {
50
+            foreach ($class->getMethods() as $method)
51
+            {
50 52
                 $route = $this->reader->firstFunctionMetadata($method, Route::class);
51 53
 
52
-                if ($route === null) {
54
+                if ($route === null)
55
+                {
53 56
                     continue;
54 57
                 }
55 58
 
Please login to merge, or discard this patch.
src/Queue/src/Bootloader/QueueBootloader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
             $registry = $container->get(HandlerRegistryInterface::class);
58 58
             $config = $container->get(QueueConfig::class);
59 59
 
60
-            foreach ($config->getRegistryHandlers() as $jobType => $handler) {
60
+            foreach ($config->getRegistryHandlers() as $jobType => $handler){
61 61
                 $registry->setHandler($jobType, $handler);
62 62
             }
63 63
         });
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,8 @@
 block discarded – undo
57 57
             $registry = $container->get(HandlerRegistryInterface::class);
58 58
             $config = $container->get(QueueConfig::class);
59 59
 
60
-            foreach ($config->getRegistryHandlers() as $jobType => $handler) {
60
+            foreach ($config->getRegistryHandlers() as $jobType => $handler)
61
+            {
61 62
                 $registry->setHandler($jobType, $handler);
62 63
             }
63 64
         });
Please login to merge, or discard this patch.