Passed
Pull Request — master (#407)
by Kirill
06:41 queued 01:48
created
src/AuthHttp/src/Transport/CookieTransport.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         bool $secure = false,
57 57
         bool $httpOnly = true,
58 58
         ?string $sameSite = null
59
-    ) {
59
+    ){
60 60
         $this->cookie = $cookie;
61 61
         $this->basePath = $basePath;
62 62
         $this->domain = $domain;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     ): Response {
86 86
         /** @var CookieQueue $cookieQueue */
87 87
         $cookieQueue = $request->getAttribute(CookieQueue::ATTRIBUTE);
88
-        if ($cookieQueue === null) {
88
+        if ($cookieQueue === null){
89 89
             return $response->withAddedHeader(
90 90
                 'Set-Cookie',
91 91
                 Cookie::create(
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
             );
102 102
         }
103 103
 
104
-        if ($tokenID === null) {
104
+        if ($tokenID === null){
105 105
             $cookieQueue->delete($this->cookie);
106
-        } else {
106
+        }else{
107 107
             $cookieQueue->set(
108 108
                 $this->cookie,
109 109
                 $tokenID,
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      */
135 135
     private function getLifetime(\DateTimeInterface $expiresAt = null): ?int
136 136
     {
137
-        if ($expiresAt === null) {
137
+        if ($expiresAt === null){
138 138
             return null;
139 139
         }
140 140
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -85,7 +85,8 @@  discard block
 block discarded – undo
85 85
     ): Response {
86 86
         /** @var CookieQueue $cookieQueue */
87 87
         $cookieQueue = $request->getAttribute(CookieQueue::ATTRIBUTE);
88
-        if ($cookieQueue === null) {
88
+        if ($cookieQueue === null)
89
+        {
89 90
             return $response->withAddedHeader(
90 91
                 'Set-Cookie',
91 92
                 Cookie::create(
@@ -101,9 +102,12 @@  discard block
 block discarded – undo
101 102
             );
102 103
         }
103 104
 
104
-        if ($tokenID === null) {
105
+        if ($tokenID === null)
106
+        {
105 107
             $cookieQueue->delete($this->cookie);
106
-        } else {
108
+        }
109
+        else
110
+        {
107 111
             $cookieQueue->set(
108 112
                 $this->cookie,
109 113
                 $tokenID,
@@ -134,7 +138,8 @@  discard block
 block discarded – undo
134 138
      */
135 139
     private function getLifetime(\DateTimeInterface $expiresAt = null): ?int
136 140
     {
137
-        if ($expiresAt === null) {
141
+        if ($expiresAt === null)
142
+        {
138 143
             return null;
139 144
         }
140 145
 
Please login to merge, or discard this patch.
src/AuthHttp/src/Transport/HeaderTransport.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function fetchToken(Request $request): ?string
38 38
     {
39
-        if ($request->hasHeader($this->header)) {
39
+        if ($request->hasHeader($this->header)){
40 40
             return $request->getHeaderLine($this->header);
41 41
         }
42 42
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         string $tokenID,
53 53
         \DateTimeInterface $expiresAt = null
54 54
     ): Response {
55
-        if ($request->hasHeader($this->header) && $request->getHeaderLine($this->header) === $tokenID) {
55
+        if ($request->hasHeader($this->header) && $request->getHeaderLine($this->header) === $tokenID){
56 56
             return $response;
57 57
         }
58 58
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,8 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function fetchToken(Request $request): ?string
38 38
     {
39
-        if ($request->hasHeader($this->header)) {
39
+        if ($request->hasHeader($this->header))
40
+        {
40 41
             return $request->getHeaderLine($this->header);
41 42
         }
42 43
 
@@ -52,7 +53,8 @@  discard block
 block discarded – undo
52 53
         string $tokenID,
53 54
         \DateTimeInterface $expiresAt = null
54 55
     ): Response {
55
-        if ($request->hasHeader($this->header) && $request->getHeaderLine($this->header) === $tokenID) {
56
+        if ($request->hasHeader($this->header) && $request->getHeaderLine($this->header) === $tokenID)
57
+        {
56 58
             return $response;
57 59
         }
58 60
 
Please login to merge, or discard this patch.
src/AuthHttp/src/Middleware/AuthMiddleware.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         ActorProviderInterface $actorProvider,
55 55
         TokenStorageInterface $tokenStorage,
56 56
         TransportRegistry $transportRegistry
57
-    ) {
57
+    ){
58 58
         $this->scope = $scope;
59 59
         $this->actorProvider = $actorProvider;
60 60
         $this->tokenStorage = $tokenStorage;
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
      */
90 90
     private function initContext(Request $request, AuthContextInterface $authContext): AuthContextInterface
91 91
     {
92
-        foreach ($this->transportRegistry->getTransports() as $name => $transport) {
92
+        foreach ($this->transportRegistry->getTransports() as $name => $transport){
93 93
             $tokenID = $transport->fetchToken($request);
94
-            if ($tokenID === null) {
94
+            if ($tokenID === null){
95 95
                 continue;
96 96
             }
97 97
 
98 98
             $token = $this->tokenStorage->load($tokenID);
99
-            if ($token === null) {
99
+            if ($token === null){
100 100
                 continue;
101 101
             }
102 102
 
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
      */
117 117
     private function closeContext(Request $request, Response $response, AuthContextInterface $authContext): Response
118 118
     {
119
-        if ($authContext->getToken() === null) {
119
+        if ($authContext->getToken() === null){
120 120
             return $response;
121 121
         }
122 122
 
123 123
         $transport = $this->transportRegistry->getTransport($authContext->getTransport());
124 124
 
125
-        if ($authContext->isClosed()) {
125
+        if ($authContext->isClosed()){
126 126
             $this->tokenStorage->delete($authContext->getToken());
127 127
 
128 128
             return $transport->removeToken(
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -74,7 +74,8 @@  discard block
 block discarded – undo
74 74
 
75 75
         $response = $this->scope->runScope(
76 76
             [AuthContextInterface::class => $authContext],
77
-            static function () use ($request, $handler, $authContext) {
77
+            static function () use ($request, $handler, $authContext)
78
+            {
78 79
                 return $handler->handle($request->withAttribute(self::ATTRIBUTE, $authContext));
79 80
             }
80 81
         );
@@ -89,14 +90,17 @@  discard block
 block discarded – undo
89 90
      */
90 91
     private function initContext(Request $request, AuthContextInterface $authContext): AuthContextInterface
91 92
     {
92
-        foreach ($this->transportRegistry->getTransports() as $name => $transport) {
93
+        foreach ($this->transportRegistry->getTransports() as $name => $transport)
94
+        {
93 95
             $tokenID = $transport->fetchToken($request);
94
-            if ($tokenID === null) {
96
+            if ($tokenID === null)
97
+            {
95 98
                 continue;
96 99
             }
97 100
 
98 101
             $token = $this->tokenStorage->load($tokenID);
99
-            if ($token === null) {
102
+            if ($token === null)
103
+            {
100 104
                 continue;
101 105
             }
102 106
 
@@ -116,13 +120,15 @@  discard block
 block discarded – undo
116 120
      */
117 121
     private function closeContext(Request $request, Response $response, AuthContextInterface $authContext): Response
118 122
     {
119
-        if ($authContext->getToken() === null) {
123
+        if ($authContext->getToken() === null)
124
+        {
120 125
             return $response;
121 126
         }
122 127
 
123 128
         $transport = $this->transportRegistry->getTransport($authContext->getTransport());
124 129
 
125
-        if ($authContext->isClosed()) {
130
+        if ($authContext->isClosed())
131
+        {
126 132
             $this->tokenStorage->delete($authContext->getToken());
127 133
 
128 134
             return $transport->removeToken(
Please login to merge, or discard this patch.
src/AuthHttp/src/Middleware/Firewall/AbstractFirewall.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
         /** @var AuthContextInterface $context */
34 34
         $authContext = $request->getAttribute(AuthMiddleware::ATTRIBUTE);
35 35
 
36
-        if ($authContext === null || $authContext->getActor() === null) {
36
+        if ($authContext === null || $authContext->getActor() === null){
37 37
             return $this->denyAccess($request, $handler);
38 38
         }
39 39
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,8 @@
 block discarded – undo
33 33
         /** @var AuthContextInterface $context */
34 34
         $authContext = $request->getAttribute(AuthMiddleware::ATTRIBUTE);
35 35
 
36
-        if ($authContext === null || $authContext->getActor() === null) {
36
+        if ($authContext === null || $authContext->getActor() === null)
37
+        {
37 38
             return $this->denyAccess($request, $handler);
38 39
         }
39 40
 
Please login to merge, or discard this patch.
src/AuthHttp/src/TransportRegistry.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
     {
50 50
         $name = $name ?? $this->default;
51 51
 
52
-        if (!isset($this->transports[$name])) {
52
+        if (!isset($this->transports[$name])){
53 53
             throw new TransportException("Undefined auth transport {$name}");
54 54
         }
55 55
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,8 @@
 block discarded – undo
49 49
     {
50 50
         $name = $name ?? $this->default;
51 51
 
52
-        if (!isset($this->transports[$name])) {
52
+        if (!isset($this->transports[$name]))
53
+        {
53 54
             throw new TransportException("Undefined auth transport {$name}");
54 55
         }
55 56
 
Please login to merge, or discard this patch.
src/AuthHttp/tests/AuthMiddlewareTest.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
 
76 76
         $http->setHandler(
77 77
             static function (ServerRequestInterface $request, ResponseInterface $response): void {
78
-                if ($request->getAttribute('authContext')->getToken() === null) {
78
+                if ($request->getAttribute('authContext')->getToken() === null){
79 79
                     echo 'no token';
80 80
                 }
81 81
             }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,8 @@
 block discarded – undo
75 75
 
76 76
         $http->setHandler(
77 77
             static function (ServerRequestInterface $request, ResponseInterface $response): void {
78
-                if ($request->getAttribute('authContext')->getToken() === null) {
78
+                if ($request->getAttribute('authContext')->getToken() === null)
79
+                {
79 80
                     echo 'no token';
80 81
                 }
81 82
             }
Please login to merge, or discard this patch.
src/AuthHttp/tests/HeaderTransportTest.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 
44 44
         $http->setHandler(
45 45
             static function (ServerRequestInterface $request, ResponseInterface $response): void {
46
-                if ($request->getAttribute('authContext')->getToken() === null) {
46
+                if ($request->getAttribute('authContext')->getToken() === null){
47 47
                     echo 'no token';
48
-                } else {
48
+                }else{
49 49
                     echo $request->getAttribute('authContext')->getToken()->getID();
50 50
                     echo ':';
51 51
                     echo json_encode($request->getAttribute('authContext')->getToken()->getPayload());
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 
68 68
         $http->setHandler(
69 69
             static function (ServerRequestInterface $request, ResponseInterface $response): void {
70
-                if ($request->getAttribute('authContext')->getToken() === null) {
70
+                if ($request->getAttribute('authContext')->getToken() === null){
71 71
                     echo 'no token';
72
-                } else {
72
+                }else{
73 73
                     echo $request->getAttribute('authContext')->getToken()->getID();
74 74
                     echo ':';
75 75
                     echo json_encode($request->getAttribute('authContext')->getToken()->getPayload());
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,9 +43,12 @@  discard block
 block discarded – undo
43 43
 
44 44
         $http->setHandler(
45 45
             static function (ServerRequestInterface $request, ResponseInterface $response): void {
46
-                if ($request->getAttribute('authContext')->getToken() === null) {
46
+                if ($request->getAttribute('authContext')->getToken() === null)
47
+                {
47 48
                     echo 'no token';
48
-                } else {
49
+                }
50
+                else
51
+                {
49 52
                     echo $request->getAttribute('authContext')->getToken()->getID();
50 53
                     echo ':';
51 54
                     echo json_encode($request->getAttribute('authContext')->getToken()->getPayload());
@@ -67,9 +70,12 @@  discard block
 block discarded – undo
67 70
 
68 71
         $http->setHandler(
69 72
             static function (ServerRequestInterface $request, ResponseInterface $response): void {
70
-                if ($request->getAttribute('authContext')->getToken() === null) {
73
+                if ($request->getAttribute('authContext')->getToken() === null)
74
+                {
71 75
                     echo 'no token';
72
-                } else {
76
+                }
77
+                else
78
+                {
73 79
                     echo $request->getAttribute('authContext')->getToken()->getID();
74 80
                     echo ':';
75 81
                     echo json_encode($request->getAttribute('authContext')->getToken()->getPayload());
Please login to merge, or discard this patch.
src/AuthHttp/tests/Diactoros/ResponseFactory.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/AuthHttp/tests/Diactoros/UploadedFileFactory.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
         string $clientFilename = null,
27 27
         string $clientMediaType = null
28 28
     ): UploadedFileInterface {
29
-        if ($size === null) {
29
+        if ($size === null){
30 30
             $size = $stream->getSize();
31 31
         }
32 32
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,8 @@
 block discarded – undo
26 26
         string $clientFilename = null,
27 27
         string $clientMediaType = null
28 28
     ): UploadedFileInterface {
29
-        if ($size === null) {
29
+        if ($size === null)
30
+        {
30 31
             $size = $stream->getSize();
31 32
         }
32 33
 
Please login to merge, or discard this patch.