Test Failed
Pull Request — master (#1190)
by butschster
10:27
created
src/Framework/Auth/Config/AuthConfig.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@
 block discarded – undo
39 39
      * @return TokenStorageInterface|class-string<TokenStorageInterface>|Autowire
40 40
      * @throws InvalidArgumentException
41 41
      */
42
-    public function getStorage(string $name): TokenStorageInterface|string|Autowire
42
+    public function getStorage(string $name): TokenStorageInterface | string | Autowire
43 43
     {
44
-        if (!isset($this->config['storages'][$name])) {
44
+        if (!isset($this->config['storages'][$name])){
45 45
             throw new InvalidArgumentException(
46 46
                 \sprintf('Token storage `%s` is not defined.', $name)
47 47
             );
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,8 @@
 block discarded – undo
41 41
      */
42 42
     public function getStorage(string $name): TokenStorageInterface|string|Autowire
43 43
     {
44
-        if (!isset($this->config['storages'][$name])) {
44
+        if (!isset($this->config['storages'][$name]))
45
+        {
45 46
             throw new InvalidArgumentException(
46 47
                 \sprintf('Token storage `%s` is not defined.', $name)
47 48
             );
Please login to merge, or discard this patch.
src/AuthHttp/src/Middleware/AuthTransportWithStorageMiddleware.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
         TransportRegistry $transportRegistry,
30 30
         ?EventDispatcherInterface $eventDispatcher = null,
31 31
         ?string $storage = null
32
-    ) {
32
+    ){
33 33
         $this->authMiddleware = new AuthTransportMiddleware(
34 34
             $transportName,
35 35
             $scope,
Please login to merge, or discard this patch.
src/Auth/src/TokenStorageProvider.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
     public function __construct(
17 17
         private readonly AuthConfig $config,
18 18
         private readonly FactoryInterface $factory
19
-    ) {
19
+    ){
20 20
     }
21 21
 
22 22
     public function getStorage(?string $name = null): TokenStorageInterface
23 23
     {
24 24
         $name ??= $this->config->getDefaultStorage();
25 25
 
26
-        if (isset($this->storages[$name])) {
26
+        if (isset($this->storages[$name])){
27 27
             return $this->storages[$name];
28 28
         }
29 29
 
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
     {
35 35
         $storage = $this->config->getStorage($name);
36 36
 
37
-        if ($storage instanceof TokenStorageInterface) {
37
+        if ($storage instanceof TokenStorageInterface){
38 38
             return $storage;
39 39
         }
40 40
 
41
-        if ($storage instanceof Autowire) {
41
+        if ($storage instanceof Autowire){
42 42
             return $storage->resolve($this->factory);
43 43
         }
44 44
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,8 @@  discard block
 block discarded – undo
23 23
     {
24 24
         $name ??= $this->config->getDefaultStorage();
25 25
 
26
-        if (isset($this->storages[$name])) {
26
+        if (isset($this->storages[$name]))
27
+        {
27 28
             return $this->storages[$name];
28 29
         }
29 30
 
@@ -34,11 +35,13 @@  discard block
 block discarded – undo
34 35
     {
35 36
         $storage = $this->config->getStorage($name);
36 37
 
37
-        if ($storage instanceof TokenStorageInterface) {
38
+        if ($storage instanceof TokenStorageInterface)
39
+        {
38 40
             return $storage;
39 41
         }
40 42
 
41
-        if ($storage instanceof Autowire) {
43
+        if ($storage instanceof Autowire)
44
+        {
42 45
             return $storage->resolve($this->factory);
43 46
         }
44 47
 
Please login to merge, or discard this patch.
src/AuthHttp/tests/Middleware/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/src/Middleware/Firewall/RedirectFirewall.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@
 block discarded – undo
16 16
         protected readonly UriInterface $uri,
17 17
         protected readonly ResponseFactoryInterface $responseFactory,
18 18
         protected readonly int $status = 302
19
-    ) {
19
+    ){
20 20
     }
21 21
 
22 22
     protected function denyAccess(Request $request, RequestHandlerInterface $handler): Response
23 23
     {
24
-        return $this->responseFactory->createResponse($this->status)->withHeader('Location', (string) $this->uri);
24
+        return $this->responseFactory->createResponse($this->status)->withHeader('Location', (string)$this->uri);
25 25
     }
26 26
 }
Please login to merge, or discard this patch.
src/AnnotatedRoutes/src/Annotation/Route.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,11 +41,11 @@
 block discarded – undo
41 41
     public function __construct(
42 42
         public readonly string $route,
43 43
         public readonly ?string $name = null,
44
-        public readonly array|string $methods = \Spiral\Router\Route::VERBS,
44
+        public readonly array | string $methods = \Spiral\Router\Route::VERBS,
45 45
         public readonly array $defaults = [],
46 46
         public readonly ?string $group = null,
47 47
         public readonly array $middleware = [],
48 48
         public readonly int $priority = 0
49
-    ) {
49
+    ){
50 50
     }
51 51
 }
Please login to merge, or discard this patch.
src/AnnotatedRoutes/src/RouteLocatorListener.php 2 patches
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,10 +24,12 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function listen(ReflectionClass $class): void
26 26
     {
27
-        foreach ($class->getMethods() as $method) {
27
+        foreach ($class->getMethods() as $method)
28
+        {
28 29
             $route = $this->reader->firstFunctionMetadata($method, Route::class);
29 30
 
30
-            if ($route === null) {
31
+            if ($route === null)
32
+            {
31 33
                 continue;
32 34
             }
33 35
 
@@ -40,7 +42,8 @@  discard block
 block discarded – undo
40 42
         $defaultGroup = $this->groups->getDefaultGroup();
41 43
 
42 44
         $routes = [];
43
-        foreach ($this->attributes as $classes) {
45
+        foreach ($this->attributes as $classes)
46
+        {
44 47
             [$method, $route] = $classes;
45 48
             $class = $method->getDeclaringClass();
46 49
 
@@ -64,7 +67,8 @@  discard block
 block discarded – undo
64 67
 
65 68
     private function configureRoutes(array $routes): void
66 69
     {
67
-        foreach ($routes as $name => $schema) {
70
+        foreach ($routes as $name => $schema)
71
+        {
68 72
             $route = new \Spiral\Router\Route(
69 73
                 $schema['pattern'],
70 74
                 new Action($schema['controller'], $schema['action']),
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,15 +21,15 @@  discard block
 block discarded – undo
21 21
     public function __construct(
22 22
         private readonly ReaderInterface $reader,
23 23
         private readonly GroupRegistry $groups,
24
-    ) {
24
+    ){
25 25
     }
26 26
 
27 27
     public function listen(ReflectionClass $class): void
28 28
     {
29
-        foreach ($class->getMethods() as $method) {
29
+        foreach ($class->getMethods() as $method){
30 30
             $route = $this->reader->firstFunctionMetadata($method, Route::class);
31 31
 
32
-            if ($route === null) {
32
+            if ($route === null){
33 33
                 continue;
34 34
             }
35 35
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         $defaultGroup = $this->groups->getDefaultGroup();
43 43
 
44 44
         $routes = [];
45
-        foreach ($this->attributes as $classes) {
45
+        foreach ($this->attributes as $classes){
46 46
             [$method, $route] = $classes;
47 47
             $class = $method->getDeclaringClass();
48 48
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
     private function configureRoutes(array $routes): void
68 68
     {
69
-        foreach ($routes as $name => $schema) {
69
+        foreach ($routes as $name => $schema){
70 70
             $route = new \Spiral\Router\Route(
71 71
                 $schema['pattern'],
72 72
                 new Action($schema['controller'], $schema['action']),
Please login to merge, or discard this patch.
src/Http/src/ErrorHandler/PlainRenderer.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 {
17 17
     public function __construct(
18 18
         private readonly ResponseFactoryInterface $responseFactory
19
-    ) {
19
+    ){
20 20
     }
21 21
 
22 22
     public function renderException(Request $request, int $code, \Throwable $exception): Response
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
         $acceptItems = AcceptHeader::fromString($request->getHeaderLine('Accept'))->getAll();
26 26
 
27 27
         $response = $this->responseFactory->createResponse($code);
28
-        if ($acceptItems && $acceptItems[0]->getValue() === 'application/json') {
28
+        if ($acceptItems && $acceptItems[0]->getValue() === 'application/json'){
29 29
             $response = $response->withHeader('Content-Type', 'application/json; charset=UTF-8');
30 30
             $response->getBody()->write(\json_encode(['status' => $code]));
31
-        } else {
31
+        }else{
32 32
             $response->getBody()->write("Error code: {$code}");
33 33
         }
34 34
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,10 +25,13 @@
 block discarded – undo
25 25
         $acceptItems = AcceptHeader::fromString($request->getHeaderLine('Accept'))->getAll();
26 26
 
27 27
         $response = $this->responseFactory->createResponse($code);
28
-        if ($acceptItems && $acceptItems[0]->getValue() === 'application/json') {
28
+        if ($acceptItems && $acceptItems[0]->getValue() === 'application/json')
29
+        {
29 30
             $response = $response->withHeader('Content-Type', 'application/json; charset=UTF-8');
30 31
             $response->getBody()->write(\json_encode(['status' => $code]));
31
-        } else {
32
+        }
33
+        else
34
+        {
32 35
             $response->getBody()->write("Error code: {$code}");
33 36
         }
34 37
 
Please login to merge, or discard this patch.
src/Http/src/Middleware/ErrorHandlerMiddleware.php 2 patches
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -39,17 +39,23 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function process(Request $request, Handler $handler): Response
41 41
     {
42
-        try {
42
+        try
43
+        {
43 44
             return $handler->handle($request);
44
-        } catch (ClientException|RouterException $e) {
45
+        }
46
+        catch (ClientException|RouterException $e)
47
+        {
45 48
             $code = $e instanceof ClientException ? $e->getCode() : 404;
46
-        } catch (\Throwable $e) {
49
+        }
50
+        catch (\Throwable $e)
51
+        {
47 52
             $code = 500;
48 53
         }
49 54
 
50 55
         $this->errorHandler->report($e);
51 56
 
52
-        if (!$this->suppressErrors->suppressed()) {
57
+        if (!$this->suppressErrors->suppressed())
58
+        {
53 59
             return $this->renderError($request, $e, $code);
54 60
         }
55 61
 
@@ -67,7 +73,8 @@  discard block
 block discarded – undo
67 73
 
68 74
         [$format, $renderer] = $this->getRenderer($this->errorHandler, $request);
69 75
 
70
-        if ($format !== null) {
76
+        if ($format !== null)
77
+        {
71 78
             $response = $response->withHeader('Content-Type', $format . '; charset=UTF-8');
72 79
         }
73 80
 
@@ -87,12 +94,15 @@  discard block
 block discarded – undo
87 94
      */
88 95
     private function getRenderer(ExceptionHandlerInterface $handler, Request $request): array
89 96
     {
90
-        if ($request->hasHeader('Accept')) {
97
+        if ($request->hasHeader('Accept'))
98
+        {
91 99
             $acceptItems = AcceptHeader::fromString($request->getHeaderLine('Accept'))->getAll();
92
-            foreach ($acceptItems as $item) {
100
+            foreach ($acceptItems as $item)
101
+            {
93 102
                 $format = $item->getValue();
94 103
                 $renderer = $handler->getRenderer($format);
95
-                if ($renderer !== null) {
104
+                if ($renderer !== null)
105
+                {
96 106
                     return [$format, $renderer];
97 107
                 }
98 108
             }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         private readonly ResponseFactoryInterface $responseFactory,
33 33
         private readonly ExceptionHandlerInterface $errorHandler,
34 34
         private readonly Verbosity $verbosity = Verbosity::VERBOSE,
35
-    ) {
35
+    ){
36 36
     }
37 37
 
38 38
     /**
@@ -41,17 +41,17 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function process(Request $request, Handler $handler): Response
43 43
     {
44
-        try {
44
+        try{
45 45
             return $handler->handle($request);
46
-        } catch (ClientException|RouterException $e) {
46
+        }catch (ClientException | RouterException $e){
47 47
             $code = $e instanceof ClientException ? $e->getCode() : 404;
48
-        } catch (\Throwable $e) {
48
+        }catch (\Throwable $e){
49 49
             $code = 500;
50 50
         }
51 51
 
52 52
         $this->errorHandler->report($e);
53 53
 
54
-        if (!$this->suppressErrors->suppressed()) {
54
+        if (!$this->suppressErrors->suppressed()){
55 55
             return $this->renderError($request, $e, $code);
56 56
         }
57 57
 
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 
70 70
         [$format, $renderer] = $this->getRenderer($this->errorHandler, $request);
71 71
 
72
-        if ($format !== null) {
73
-            $response = $response->withHeader('Content-Type', $format . '; charset=UTF-8');
72
+        if ($format !== null){
73
+            $response = $response->withHeader('Content-Type', $format.'; charset=UTF-8');
74 74
         }
75 75
 
76 76
         $response->getBody()->write(
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
      */
90 90
     private function getRenderer(ExceptionHandlerInterface $handler, Request $request): array
91 91
     {
92
-        if ($request->hasHeader('Accept')) {
92
+        if ($request->hasHeader('Accept')){
93 93
             $acceptItems = AcceptHeader::fromString($request->getHeaderLine('Accept'))->getAll();
94
-            foreach ($acceptItems as $item) {
94
+            foreach ($acceptItems as $item){
95 95
                 $format = $item->getValue();
96 96
                 $renderer = $handler->getRenderer($format);
97
-                if ($renderer !== null) {
97
+                if ($renderer !== null){
98 98
                     return [$format, $renderer];
99 99
                 }
100 100
             }
Please login to merge, or discard this patch.