Passed
Push — master ( 48358c...5b4064 )
by Valentin
13:24 queued 08:47
created
tests/Framework/GRPC/ListTest.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     public function setUp(): void
22 22
     {
23 23
         exec('protoc 2>&1', $out);
24
-        if (strpos(implode("\n", $out), '--php_out') === false) {
24
+        if (strpos(implode("\n", $out), '--php_out') === false){
25 25
             $this->markTestSkipped('Protoc binary is missing');
26 26
             return;
27 27
         }
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         parent::setUp();
30 30
 
31 31
         $fs = new Files();
32
-        $this->proto = $fs->normalizePath($this->app->dir('app') . 'proto/service.proto');
32
+        $this->proto = $fs->normalizePath($this->app->dir('app').'proto/service.proto');
33 33
 
34 34
         // protoc can't figure relative paths
35 35
         $this->proto = str_replace('Framework/../', '', $this->proto);
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 
42 42
         $fs = new Files();
43 43
 
44
-        if ($fs->isDirectory($this->app->dir('app') . 'src/Service')) {
45
-            $fs->deleteDirectory($this->app->dir('app') . 'src/Service');
44
+        if ($fs->isDirectory($this->app->dir('app').'src/Service')){
45
+            $fs->deleteDirectory($this->app->dir('app').'src/Service');
46 46
         }
47 47
 
48
-        if ($fs->isDirectory($this->app->dir('app') . 'src/GPBMetadata')) {
49
-            $fs->deleteDirectory($this->app->dir('app') . 'src/GPBMetadata');
48
+        if ($fs->isDirectory($this->app->dir('app').'src/GPBMetadata')){
49
+            $fs->deleteDirectory($this->app->dir('app').'src/GPBMetadata');
50 50
         }
51 51
     }
52 52
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
             'proto' => $this->proto
64 64
         ]);
65 65
 
66
-        $output = $this->app->dir('app') . 'src/Service/EchoService.php';
66
+        $output = $this->app->dir('app').'src/Service/EchoService.php';
67 67
         file_put_contents($output, GenerateTest::SERVICE);
68 68
 
69 69
         $out = $this->runCommandDebug('grpc:services');
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@  discard block
 block discarded – undo
21 21
     public function setUp(): void
22 22
     {
23 23
         exec('protoc 2>&1', $out);
24
-        if (strpos(implode("\n", $out), '--php_out') === false) {
24
+        if (strpos(implode("\n", $out), '--php_out') === false)
25
+        {
25 26
             $this->markTestSkipped('Protoc binary is missing');
26 27
             return;
27 28
         }
@@ -41,11 +42,13 @@  discard block
 block discarded – undo
41 42
 
42 43
         $fs = new Files();
43 44
 
44
-        if ($fs->isDirectory($this->app->dir('app') . 'src/Service')) {
45
+        if ($fs->isDirectory($this->app->dir('app') . 'src/Service'))
46
+        {
45 47
             $fs->deleteDirectory($this->app->dir('app') . 'src/Service');
46 48
         }
47 49
 
48
-        if ($fs->isDirectory($this->app->dir('app') . 'src/GPBMetadata')) {
50
+        if ($fs->isDirectory($this->app->dir('app') . 'src/GPBMetadata'))
51
+        {
49 52
             $fs->deleteDirectory($this->app->dir('app') . 'src/GPBMetadata');
50 53
         }
51 54
     }
Please login to merge, or discard this patch.
src/Cookies/tests/CookieTest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -127,9 +127,9 @@
 block discarded – undo
127 127
         $cookie = new Cookie('', '', 0, '', '', $secure, false, $sameSite);
128 128
         $this->assertSame($expected, $cookie->getSameSite());
129 129
 
130
-        if ($expected === null) {
130
+        if ($expected === null){
131 131
             $this->assertStringNotContainsString('SameSite=', $cookie->createHeader());
132
-        } else {
132
+        }else{
133 133
             $this->assertStringContainsString("SameSite=$expected", $cookie->createHeader());
134 134
         }
135 135
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -127,9 +127,12 @@
 block discarded – undo
127 127
         $cookie = new Cookie('', '', 0, '', '', $secure, false, $sameSite);
128 128
         $this->assertSame($expected, $cookie->getSameSite());
129 129
 
130
-        if ($expected === null) {
130
+        if ($expected === null)
131
+        {
131 132
             $this->assertStringNotContainsString('SameSite=', $cookie->createHeader());
132
-        } else {
133
+        }
134
+        else
135
+        {
133 136
             $this->assertStringContainsString("SameSite=$expected", $cookie->createHeader());
134 137
         }
135 138
     }
Please login to merge, or discard this patch.
src/Cookies/tests/CookiesTest.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     public function testScope(): void
57 57
     {
58 58
         $core = $this->httpCore([CookiesMiddleware::class]);
59
-        $core->setHandler(function ($r) {
59
+        $core->setHandler(function ($r){
60 60
             $this->assertInstanceOf(
61 61
                 CookieQueue::class,
62 62
                 $this->container->get(ServerRequestInterface::class)
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     public function testSetEncryptedCookie(): void
81 81
     {
82 82
         $core = $this->httpCore([CookiesMiddleware::class]);
83
-        $core->setHandler(function ($r) {
83
+        $core->setHandler(function ($r){
84 84
             $this->container->get(ServerRequestInterface::class)
85 85
                 ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value');
86 86
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     public function testSetNotProtectedCookie(): void
103 103
     {
104 104
         $core = $this->httpCore([CookiesMiddleware::class]);
105
-        $core->setHandler(function ($r) {
105
+        $core->setHandler(function ($r){
106 106
             $this->container->get(ServerRequestInterface::class)
107 107
                 ->getAttribute(CookieQueue::ATTRIBUTE)->set('PHPSESSID', 'value');
108 108
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     public function testDecrypt(): void
122 122
     {
123 123
         $core = $this->httpCore([CookiesMiddleware::class]);
124
-        $core->setHandler(function ($r) {
124
+        $core->setHandler(function ($r){
125 125
 
126 126
             /**
127 127
              * @var ServerRequest $r
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     public function testDecryptArray(): void
140 140
     {
141 141
         $core = $this->httpCore([CookiesMiddleware::class]);
142
-        $core->setHandler(function ($r) {
142
+        $core->setHandler(function ($r){
143 143
 
144 144
             /**
145 145
              * @var ServerRequest $r
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     public function testDecryptBroken(): void
158 158
     {
159 159
         $core = $this->httpCore([CookiesMiddleware::class]);
160
-        $core->setHandler(function ($r) {
160
+        $core->setHandler(function ($r){
161 161
 
162 162
             /**
163 163
              * @var ServerRequest $r
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
             return $r->getCookieParams()['name'];
166 166
         });
167 167
 
168
-        $value = $this->container->get(EncrypterInterface::class)->encrypt('cookie-value') . 'BROKEN';
168
+        $value = $this->container->get(EncrypterInterface::class)->encrypt('cookie-value').'BROKEN';
169 169
 
170 170
         $response = $this->get($core, '/', [], [], ['name' => $value]);
171 171
         $this->assertSame(200, $response->getStatusCode());
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
     public function testDelete(): void
176 176
     {
177 177
         $core = $this->httpCore([CookiesMiddleware::class]);
178
-        $core->setHandler(function ($r) {
178
+        $core->setHandler(function ($r){
179 179
             $this->container->get(ServerRequestInterface::class)
180 180
                 ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value');
181 181
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
         ]));
204 204
 
205 205
         $core = $this->httpCore([CookiesMiddleware::class]);
206
-        $core->setHandler(function ($r) {
206
+        $core->setHandler(function ($r){
207 207
             $this->container->get(ServerRequestInterface::class)
208 208
                 ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value');
209 209
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
         ]));
229 229
 
230 230
         $core = $this->httpCore([CookiesMiddleware::class]);
231
-        $core->setHandler(function ($r) {
231
+        $core->setHandler(function ($r){
232 232
 
233 233
             /**
234 234
              * @var ServerRequest $r
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         ]));
253 253
 
254 254
         $core = $this->httpCore([CookiesMiddleware::class]);
255
-        $core->setHandler(function ($r) {
255
+        $core->setHandler(function ($r){
256 256
             $this->container->get(ServerRequestInterface::class)
257 257
                 ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value');
258 258
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
         $cookies = $this->fetchCookies($response);
267 267
         $this->assertArrayHasKey('name', $cookies);
268 268
 
269
-        $core->setHandler(function ($r) {
269
+        $core->setHandler(function ($r){
270 270
             return $r->getCookieParams()['name'];
271 271
         });
272 272
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
     {
327 327
         $result = [];
328 328
 
329
-        foreach ($response->getHeaders() as $line) {
329
+        foreach ($response->getHeaders() as $line){
330 330
             $cookie = explode('=', implode('', $line));
331 331
             $result[$cookie[0]] = rawurldecode(substr(
332 332
                 (string)$cookie[1],
Please login to merge, or discard this patch.
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -56,7 +56,8 @@  discard block
 block discarded – undo
56 56
     public function testScope(): void
57 57
     {
58 58
         $core = $this->httpCore([CookiesMiddleware::class]);
59
-        $core->setHandler(function ($r) {
59
+        $core->setHandler(function ($r)
60
+        {
60 61
             $this->assertInstanceOf(
61 62
                 CookieQueue::class,
62 63
                 $this->container->get(ServerRequestInterface::class)
@@ -80,7 +81,8 @@  discard block
 block discarded – undo
80 81
     public function testSetEncryptedCookie(): void
81 82
     {
82 83
         $core = $this->httpCore([CookiesMiddleware::class]);
83
-        $core->setHandler(function ($r) {
84
+        $core->setHandler(function ($r)
85
+        {
84 86
             $this->container->get(ServerRequestInterface::class)
85 87
                 ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value');
86 88
 
@@ -102,7 +104,8 @@  discard block
 block discarded – undo
102 104
     public function testSetNotProtectedCookie(): void
103 105
     {
104 106
         $core = $this->httpCore([CookiesMiddleware::class]);
105
-        $core->setHandler(function ($r) {
107
+        $core->setHandler(function ($r)
108
+        {
106 109
             $this->container->get(ServerRequestInterface::class)
107 110
                 ->getAttribute(CookieQueue::ATTRIBUTE)->set('PHPSESSID', 'value');
108 111
 
@@ -121,7 +124,8 @@  discard block
 block discarded – undo
121 124
     public function testDecrypt(): void
122 125
     {
123 126
         $core = $this->httpCore([CookiesMiddleware::class]);
124
-        $core->setHandler(function ($r) {
127
+        $core->setHandler(function ($r)
128
+        {
125 129
 
126 130
             /**
127 131
              * @var ServerRequest $r
@@ -139,7 +143,8 @@  discard block
 block discarded – undo
139 143
     public function testDecryptArray(): void
140 144
     {
141 145
         $core = $this->httpCore([CookiesMiddleware::class]);
142
-        $core->setHandler(function ($r) {
146
+        $core->setHandler(function ($r)
147
+        {
143 148
 
144 149
             /**
145 150
              * @var ServerRequest $r
@@ -157,7 +162,8 @@  discard block
 block discarded – undo
157 162
     public function testDecryptBroken(): void
158 163
     {
159 164
         $core = $this->httpCore([CookiesMiddleware::class]);
160
-        $core->setHandler(function ($r) {
165
+        $core->setHandler(function ($r)
166
+        {
161 167
 
162 168
             /**
163 169
              * @var ServerRequest $r
@@ -175,7 +181,8 @@  discard block
 block discarded – undo
175 181
     public function testDelete(): void
176 182
     {
177 183
         $core = $this->httpCore([CookiesMiddleware::class]);
178
-        $core->setHandler(function ($r) {
184
+        $core->setHandler(function ($r)
185
+        {
179 186
             $this->container->get(ServerRequestInterface::class)
180 187
                 ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value');
181 188
 
@@ -203,7 +210,8 @@  discard block
 block discarded – undo
203 210
         ]));
204 211
 
205 212
         $core = $this->httpCore([CookiesMiddleware::class]);
206
-        $core->setHandler(function ($r) {
213
+        $core->setHandler(function ($r)
214
+        {
207 215
             $this->container->get(ServerRequestInterface::class)
208 216
                 ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value');
209 217
 
@@ -228,7 +236,8 @@  discard block
 block discarded – undo
228 236
         ]));
229 237
 
230 238
         $core = $this->httpCore([CookiesMiddleware::class]);
231
-        $core->setHandler(function ($r) {
239
+        $core->setHandler(function ($r)
240
+        {
232 241
 
233 242
             /**
234 243
              * @var ServerRequest $r
@@ -252,7 +261,8 @@  discard block
 block discarded – undo
252 261
         ]));
253 262
 
254 263
         $core = $this->httpCore([CookiesMiddleware::class]);
255
-        $core->setHandler(function ($r) {
264
+        $core->setHandler(function ($r)
265
+        {
256 266
             $this->container->get(ServerRequestInterface::class)
257 267
                 ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value');
258 268
 
@@ -266,7 +276,8 @@  discard block
 block discarded – undo
266 276
         $cookies = $this->fetchCookies($response);
267 277
         $this->assertArrayHasKey('name', $cookies);
268 278
 
269
-        $core->setHandler(function ($r) {
279
+        $core->setHandler(function ($r)
280
+        {
270 281
             return $r->getCookieParams()['name'];
271 282
         });
272 283
 
@@ -326,7 +337,8 @@  discard block
 block discarded – undo
326 337
     {
327 338
         $result = [];
328 339
 
329
-        foreach ($response->getHeaders() as $line) {
340
+        foreach ($response->getHeaders() as $line)
341
+        {
330 342
             $cookie = explode('=', implode('', $line));
331 343
             $result[$cookie[0]] = rawurldecode(substr(
332 344
                 (string)$cookie[1],
Please login to merge, or discard this patch.
src/Cookies/tests/TestResponseFactory.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
         $response = new Response('php://memory', $code, []);
38 38
         $response = $response->withStatus($code, $reasonPhrase);
39 39
 
40
-        foreach ($this->config->getBaseHeaders() as $header => $value) {
40
+        foreach ($this->config->getBaseHeaders() as $header => $value){
41 41
             $response = $response->withAddedHeader($header, $value);
42 42
         }
43 43
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,8 @@
 block discarded – undo
37 37
         $response = new Response('php://memory', $code, []);
38 38
         $response = $response->withStatus($code, $reasonPhrase);
39 39
 
40
-        foreach ($this->config->getBaseHeaders() as $header => $value) {
40
+        foreach ($this->config->getBaseHeaders() as $header => $value)
41
+        {
41 42
             $response = $response->withAddedHeader($header, $value);
42 43
         }
43 44
 
Please login to merge, or discard this patch.
src/Cookies/src/Cookie.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
         bool $secure = false,
130 130
         bool $httpOnly = true,
131 131
         ?string $sameSite = null
132
-    ) {
132
+    ){
133 133
         $this->name = $name;
134 134
         $this->value = $value;
135 135
         $this->lifetime = $lifetime;
@@ -253,30 +253,30 @@  discard block
 block discarded – undo
253 253
      */
254 254
     public function createHeader(): string
255 255
     {
256
-        $header = [rawurlencode($this->name) . '=' . rawurlencode((string)$this->value)];
256
+        $header = [rawurlencode($this->name).'='.rawurlencode((string)$this->value)];
257 257
 
258
-        if ($this->lifetime !== null) {
259
-            $header[] = 'Expires=' . gmdate(\DateTime::COOKIE, $this->getExpires());
258
+        if ($this->lifetime !== null){
259
+            $header[] = 'Expires='.gmdate(\DateTime::COOKIE, $this->getExpires());
260 260
             $header[] = "Max-Age={$this->lifetime}";
261 261
         }
262 262
 
263
-        if (!empty($this->path)) {
263
+        if (!empty($this->path)){
264 264
             $header[] = "Path={$this->path}";
265 265
         }
266 266
 
267
-        if (!empty($this->domain)) {
267
+        if (!empty($this->domain)){
268 268
             $header[] = "Domain={$this->domain}";
269 269
         }
270 270
 
271
-        if ($this->secure) {
271
+        if ($this->secure){
272 272
             $header[] = 'Secure';
273 273
         }
274 274
 
275
-        if ($this->httpOnly) {
275
+        if ($this->httpOnly){
276 276
             $header[] = 'HttpOnly';
277 277
         }
278 278
 
279
-        if ($this->sameSite->get() !== null) {
279
+        if ($this->sameSite->get() !== null){
280 280
             $header[] = "SameSite={$this->sameSite->get()}";
281 281
         }
282 282
 
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
      */
293 293
     public function getExpires(): ?int
294 294
     {
295
-        if ($this->lifetime === null) {
295
+        if ($this->lifetime === null){
296 296
             return null;
297 297
         }
298 298
 
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -255,28 +255,34 @@  discard block
 block discarded – undo
255 255
     {
256 256
         $header = [rawurlencode($this->name) . '=' . rawurlencode((string)$this->value)];
257 257
 
258
-        if ($this->lifetime !== null) {
258
+        if ($this->lifetime !== null)
259
+        {
259 260
             $header[] = 'Expires=' . gmdate(\DateTime::COOKIE, $this->getExpires());
260 261
             $header[] = "Max-Age={$this->lifetime}";
261 262
         }
262 263
 
263
-        if (!empty($this->path)) {
264
+        if (!empty($this->path))
265
+        {
264 266
             $header[] = "Path={$this->path}";
265 267
         }
266 268
 
267
-        if (!empty($this->domain)) {
269
+        if (!empty($this->domain))
270
+        {
268 271
             $header[] = "Domain={$this->domain}";
269 272
         }
270 273
 
271
-        if ($this->secure) {
274
+        if ($this->secure)
275
+        {
272 276
             $header[] = 'Secure';
273 277
         }
274 278
 
275
-        if ($this->httpOnly) {
279
+        if ($this->httpOnly)
280
+        {
276 281
             $header[] = 'HttpOnly';
277 282
         }
278 283
 
279
-        if ($this->sameSite->get() !== null) {
284
+        if ($this->sameSite->get() !== null)
285
+        {
280 286
             $header[] = "SameSite={$this->sameSite->get()}";
281 287
         }
282 288
 
@@ -292,7 +298,8 @@  discard block
 block discarded – undo
292 298
      */
293 299
     public function getExpires(): ?int
294 300
     {
295
-        if ($this->lifetime === null) {
301
+        if ($this->lifetime === null)
302
+        {
296 303
             return null;
297 304
         }
298 305
 
Please login to merge, or discard this patch.
src/Cookies/src/CookieQueue.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
         bool $httpOnly = true,
93 93
         ?string $sameSite = null
94 94
     ): self {
95
-        if (is_null($domain)) {
95
+        if (is_null($domain)){
96 96
             //Let's resolve domain via config
97 97
             $domain = $this->domain;
98 98
         }
99 99
 
100
-        if (is_null($secure)) {
100
+        if (is_null($secure)){
101 101
             $secure = $this->secure;
102 102
         }
103 103
 
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function delete(string $name): void
129 129
     {
130
-        foreach ($this->scheduled as $index => $cookie) {
131
-            if ($cookie->getName() === $name) {
130
+        foreach ($this->scheduled as $index => $cookie){
131
+            if ($cookie->getName() === $name){
132 132
                 unset($this->scheduled[$index]);
133 133
             }
134 134
         }
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,12 +92,14 @@  discard block
 block discarded – undo
92 92
         bool $httpOnly = true,
93 93
         ?string $sameSite = null
94 94
     ): self {
95
-        if (is_null($domain)) {
95
+        if (is_null($domain))
96
+        {
96 97
             //Let's resolve domain via config
97 98
             $domain = $this->domain;
98 99
         }
99 100
 
100
-        if (is_null($secure)) {
101
+        if (is_null($secure))
102
+        {
101 103
             $secure = $this->secure;
102 104
         }
103 105
 
@@ -127,8 +129,10 @@  discard block
 block discarded – undo
127 129
      */
128 130
     public function delete(string $name): void
129 131
     {
130
-        foreach ($this->scheduled as $index => $cookie) {
131
-            if ($cookie->getName() === $name) {
132
+        foreach ($this->scheduled as $index => $cookie)
133
+        {
134
+            if ($cookie->getName() === $name)
135
+            {
132 136
                 unset($this->scheduled[$index]);
133 137
             }
134 138
         }
Please login to merge, or discard this patch.
src/Cookies/src/Middleware/CookiesMiddleware.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
     {
74 74
         $cookies = $request->getCookieParams();
75 75
 
76
-        foreach ($cookies as $name => $cookie) {
77
-            if (!$this->isProtected($name)) {
76
+        foreach ($cookies as $name => $cookie){
77
+            if (!$this->isProtected($name)){
78 78
                 continue;
79 79
             }
80 80
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     protected function isProtected(string $cookie): bool
94 94
     {
95
-        if (in_array($cookie, $this->config->getExcludedCookies(), true)) {
95
+        if (in_array($cookie, $this->config->getExcludedCookies(), true)){
96 96
             //Excluded
97 97
             return false;
98 98
         }
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
      */
112 112
     protected function packCookies(Response $response, CookieQueue $queue): Response
113 113
     {
114
-        if (empty($queue->getScheduled())) {
114
+        if (empty($queue->getScheduled())){
115 115
             return $response;
116 116
         }
117 117
 
118 118
         $cookies = $response->getHeader('Set-Cookie');
119 119
 
120
-        foreach ($queue->getScheduled() as $cookie) {
121
-            if (empty($cookie->getValue()) || !$this->isProtected($cookie->getName())) {
120
+        foreach ($queue->getScheduled() as $cookie){
121
+            if (empty($cookie->getValue()) || !$this->isProtected($cookie->getName())){
122 122
                 $cookies[] = $cookie->createHeader();
123 123
                 continue;
124 124
             }
@@ -135,26 +135,26 @@  discard block
 block discarded – undo
135 135
      */
136 136
     private function decodeCookie($cookie)
137 137
     {
138
-        try {
139
-            if (is_array($cookie)) {
138
+        try{
139
+            if (is_array($cookie)){
140 140
                 return array_map([$this, 'decodeCookie'], $cookie);
141 141
             }
142
-        } catch (DecryptException $exception) {
142
+        }catch (DecryptException $exception){
143 143
             return null;
144 144
         }
145 145
 
146
-        switch ($this->config->getProtectionMethod()) {
146
+        switch ($this->config->getProtectionMethod()){
147 147
             case CookiesConfig::COOKIE_ENCRYPT:
148
-                try {
148
+                try{
149 149
                     return $this->encryption->getEncrypter()->decrypt($cookie);
150
-                } catch (DecryptException $e) {
150
+                }catch (DecryptException $e){
151 151
                 }
152 152
                 return null;
153 153
             case CookiesConfig::COOKIE_HMAC:
154 154
                 $hmac = substr($cookie, -1 * CookiesConfig::MAC_LENGTH);
155 155
                 $value = substr($cookie, 0, strlen($cookie) - strlen($hmac));
156 156
 
157
-                if (hash_equals($this->hmacSign($value), $hmac)) {
157
+                if (hash_equals($this->hmacSign($value), $hmac)){
158 158
                     return $value;
159 159
                 }
160 160
         }
@@ -183,13 +183,13 @@  discard block
 block discarded – undo
183 183
      */
184 184
     private function encodeCookie(Cookie $cookie): Cookie
185 185
     {
186
-        if ($this->config->getProtectionMethod() === CookiesConfig::COOKIE_ENCRYPT) {
186
+        if ($this->config->getProtectionMethod() === CookiesConfig::COOKIE_ENCRYPT){
187 187
             $encryptor = $this->encryption->getEncrypter();
188 188
 
189 189
             return $cookie->withValue($encryptor->encrypt($cookie->getValue()));
190 190
         }
191 191
 
192 192
         //VALUE.HMAC
193
-        return $cookie->withValue($cookie->getValue() . $this->hmacSign($cookie->getValue()));
193
+        return $cookie->withValue($cookie->getValue().$this->hmacSign($cookie->getValue()));
194 194
     }
195 195
 }
Please login to merge, or discard this patch.
Braces   +30 added lines, -14 removed lines patch added patch discarded remove patch
@@ -73,8 +73,10 @@  discard block
 block discarded – undo
73 73
     {
74 74
         $cookies = $request->getCookieParams();
75 75
 
76
-        foreach ($cookies as $name => $cookie) {
77
-            if (!$this->isProtected($name)) {
76
+        foreach ($cookies as $name => $cookie)
77
+        {
78
+            if (!$this->isProtected($name))
79
+            {
78 80
                 continue;
79 81
             }
80 82
 
@@ -92,7 +94,8 @@  discard block
 block discarded – undo
92 94
      */
93 95
     protected function isProtected(string $cookie): bool
94 96
     {
95
-        if (in_array($cookie, $this->config->getExcludedCookies(), true)) {
97
+        if (in_array($cookie, $this->config->getExcludedCookies(), true))
98
+        {
96 99
             //Excluded
97 100
             return false;
98 101
         }
@@ -111,14 +114,17 @@  discard block
 block discarded – undo
111 114
      */
112 115
     protected function packCookies(Response $response, CookieQueue $queue): Response
113 116
     {
114
-        if (empty($queue->getScheduled())) {
117
+        if (empty($queue->getScheduled()))
118
+        {
115 119
             return $response;
116 120
         }
117 121
 
118 122
         $cookies = $response->getHeader('Set-Cookie');
119 123
 
120
-        foreach ($queue->getScheduled() as $cookie) {
121
-            if (empty($cookie->getValue()) || !$this->isProtected($cookie->getName())) {
124
+        foreach ($queue->getScheduled() as $cookie)
125
+        {
126
+            if (empty($cookie->getValue()) || !$this->isProtected($cookie->getName()))
127
+            {
122 128
                 $cookies[] = $cookie->createHeader();
123 129
                 continue;
124 130
             }
@@ -135,26 +141,35 @@  discard block
 block discarded – undo
135 141
      */
136 142
     private function decodeCookie($cookie)
137 143
     {
138
-        try {
139
-            if (is_array($cookie)) {
144
+        try
145
+        {
146
+            if (is_array($cookie))
147
+            {
140 148
                 return array_map([$this, 'decodeCookie'], $cookie);
141 149
             }
142
-        } catch (DecryptException $exception) {
150
+        }
151
+        catch (DecryptException $exception)
152
+        {
143 153
             return null;
144 154
         }
145 155
 
146
-        switch ($this->config->getProtectionMethod()) {
156
+        switch ($this->config->getProtectionMethod())
157
+        {
147 158
             case CookiesConfig::COOKIE_ENCRYPT:
148
-                try {
159
+                try
160
+                {
149 161
                     return $this->encryption->getEncrypter()->decrypt($cookie);
150
-                } catch (DecryptException $e) {
162
+                }
163
+                catch (DecryptException $e)
164
+                {
151 165
                 }
152 166
                 return null;
153 167
             case CookiesConfig::COOKIE_HMAC:
154 168
                 $hmac = substr($cookie, -1 * CookiesConfig::MAC_LENGTH);
155 169
                 $value = substr($cookie, 0, strlen($cookie) - strlen($hmac));
156 170
 
157
-                if (hash_equals($this->hmacSign($value), $hmac)) {
171
+                if (hash_equals($this->hmacSign($value), $hmac))
172
+                {
158 173
                     return $value;
159 174
                 }
160 175
         }
@@ -183,7 +198,8 @@  discard block
 block discarded – undo
183 198
      */
184 199
     private function encodeCookie(Cookie $cookie): Cookie
185 200
     {
186
-        if ($this->config->getProtectionMethod() === CookiesConfig::COOKIE_ENCRYPT) {
201
+        if ($this->config->getProtectionMethod() === CookiesConfig::COOKIE_ENCRYPT)
202
+        {
187 203
             $encryptor = $this->encryption->getEncrypter();
188 204
 
189 205
             return $cookie->withValue($encryptor->encrypt($cookie->getValue()));
Please login to merge, or discard this patch.
src/Cookies/src/Config/CookiesConfig.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,22 +53,22 @@
 block discarded – undo
53 53
     public function resolveDomain(UriInterface $uri): ?string
54 54
     {
55 55
         $host = $uri->getHost();
56
-        if (empty($host)) {
56
+        if (empty($host)){
57 57
             return null;
58 58
         }
59 59
 
60 60
         $pattern = $this->config['domain'];
61
-        if (preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches)) {
61
+        if (preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches)){
62 62
             // remove port
63 63
             $host = $matches[1];
64 64
         }
65 65
 
66
-        if ($host === 'localhost' || filter_var($host, FILTER_VALIDATE_IP)) {
66
+        if ($host === 'localhost' || filter_var($host, FILTER_VALIDATE_IP)){
67 67
             //We can't use sub-domains when website required by IP
68 68
             $pattern = ltrim($pattern, '.');
69 69
         }
70 70
 
71
-        if (strpos($pattern, '%s') === false) {
71
+        if (strpos($pattern, '%s') === false){
72 72
             //Forced domain
73 73
             return $pattern;
74 74
         }
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,22 +53,26 @@
 block discarded – undo
53 53
     public function resolveDomain(UriInterface $uri): ?string
54 54
     {
55 55
         $host = $uri->getHost();
56
-        if (empty($host)) {
56
+        if (empty($host))
57
+        {
57 58
             return null;
58 59
         }
59 60
 
60 61
         $pattern = $this->config['domain'];
61
-        if (preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches)) {
62
+        if (preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches))
63
+        {
62 64
             // remove port
63 65
             $host = $matches[1];
64 66
         }
65 67
 
66
-        if ($host === 'localhost' || filter_var($host, FILTER_VALIDATE_IP)) {
68
+        if ($host === 'localhost' || filter_var($host, FILTER_VALIDATE_IP))
69
+        {
67 70
             //We can't use sub-domains when website required by IP
68 71
             $pattern = ltrim($pattern, '.');
69 72
         }
70 73
 
71
-        if (strpos($pattern, '%s') === false) {
74
+        if (strpos($pattern, '%s') === false)
75
+        {
72 76
             //Forced domain
73 77
             return $pattern;
74 78
         }
Please login to merge, or discard this patch.
src/Cookies/src/Cookie/SameSite.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,12 +33,12 @@
 block discarded – undo
33 33
      */
34 34
     private function defineValue(?string $sameSite, bool $secure): ?string
35 35
     {
36
-        if ($sameSite === null) {
36
+        if ($sameSite === null){
37 37
             return null;
38 38
         }
39 39
 
40 40
         $sameSite = ucfirst(strtolower($sameSite));
41
-        if (!in_array($sameSite, self::VALUES, true)) {
41
+        if (!in_array($sameSite, self::VALUES, true)){
42 42
             return null;
43 43
         }
44 44
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,12 +33,14 @@
 block discarded – undo
33 33
      */
34 34
     private function defineValue(?string $sameSite, bool $secure): ?string
35 35
     {
36
-        if ($sameSite === null) {
36
+        if ($sameSite === null)
37
+        {
37 38
             return null;
38 39
         }
39 40
 
40 41
         $sameSite = ucfirst(strtolower($sameSite));
41
-        if (!in_array($sameSite, self::VALUES, true)) {
42
+        if (!in_array($sameSite, self::VALUES, true))
43
+        {
42 44
             return null;
43 45
         }
44 46
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
     public const NONE   = 'None';
12 12
 
13 13
     private const VALUES  = [self::STRICT, self::LAX, self::NONE];
14
-    private const DEFAULT = self::LAX;
14
+    private const default = self::LAX;
15 15
 
16 16
     /** @var string|null */
17 17
     private $sameSite;
@@ -42,6 +42,6 @@  discard block
 block discarded – undo
42 42
             return null;
43 43
         }
44 44
 
45
-        return ($sameSite === self::NONE && !$secure) ? self::DEFAULT : $sameSite;
45
+        return ($sameSite === self::NONE && !$secure) ? self::default : $sameSite;
46 46
     }
47 47
 }
Please login to merge, or discard this patch.