Passed
Push — master ( 2291e3...cd7158 )
by Anton
03:34
created
src/Framework/Http/SapiDispatcher.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -62,12 +62,12 @@  discard block
 block discarded – undo
62 62
         $http = $this->container->get(Http::class);
63 63
         $emitter = $emitter ?? $this->container->get(EmitterInterface::class);
64 64
 
65
-        try {
65
+        try{
66 66
             $response = $http->handle($this->initRequest());
67 67
             $emitter->emit($response);
68
-        } catch (\Throwable $e) {
68
+        }catch (\Throwable $e){
69 69
             $this->handleException($emitter, $e);
70
-        } finally {
70
+        }finally{
71 71
             $this->finalizer->finalize(false);
72 72
         }
73 73
     }
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
     {
89 89
         $handler = new HtmlHandler();
90 90
 
91
-        try {
91
+        try{
92 92
             /** @var SnapshotInterface $snapshot */
93 93
             $this->container->get(SnapshotterInterface::class)->register($e);
94 94
 
95 95
             // on demand
96 96
             $state = $this->container->get(StateInterface::class);
97
-            if ($state !== null) {
97
+            if ($state !== null){
98 98
                 $handler = $handler->withState($state);
99 99
             }
100
-        } catch (\Throwable | ContainerExceptionInterface $se) {
100
+        }catch (\Throwable | ContainerExceptionInterface $se){
101 101
             // nothing to report
102 102
         }
103 103
 
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -62,12 +62,17 @@  discard block
 block discarded – undo
62 62
         $http = $this->container->get(Http::class);
63 63
         $emitter = $emitter ?? $this->container->get(EmitterInterface::class);
64 64
 
65
-        try {
65
+        try
66
+        {
66 67
             $response = $http->handle($this->initRequest());
67 68
             $emitter->emit($response);
68
-        } catch (\Throwable $e) {
69
+        }
70
+        catch (\Throwable $e)
71
+        {
69 72
             $this->handleException($emitter, $e);
70
-        } finally {
73
+        }
74
+        finally
75
+        {
71 76
             $this->finalizer->finalize(false);
72 77
         }
73 78
     }
@@ -88,16 +93,20 @@  discard block
 block discarded – undo
88 93
     {
89 94
         $handler = new HtmlHandler();
90 95
 
91
-        try {
96
+        try
97
+        {
92 98
             /** @var SnapshotInterface $snapshot */
93 99
             $this->container->get(SnapshotterInterface::class)->register($e);
94 100
 
95 101
             // on demand
96 102
             $state = $this->container->get(StateInterface::class);
97
-            if ($state !== null) {
103
+            if ($state !== null)
104
+            {
98 105
                 $handler = $handler->withState($state);
99 106
             }
100
-        } catch (\Throwable | ContainerExceptionInterface $se) {
107
+        }
108
+        catch (\Throwable | ContainerExceptionInterface $se)
109
+        {
101 110
             // nothing to report
102 111
         }
103 112
 
Please login to merge, or discard this patch.
src/Framework/Http/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.
src/Framework/Http/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/Framework/Http/PaginationFactory.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface
48 48
     {
49
-        if (!$this->container->has(ServerRequestInterface::class)) {
49
+        if (!$this->container->has(ServerRequestInterface::class)){
50 50
             throw new ScopeException('Unable to create paginator, no request scope found');
51 51
         }
52 52
         /**
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
         //Getting page number
58 58
         $page = 0;
59
-        if (!empty($query[$parameter]) && is_scalar($query[$parameter])) {
59
+        if (!empty($query[$parameter]) && is_scalar($query[$parameter])){
60 60
             $page = (int)$query[$parameter];
61 61
         }
62 62
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,8 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface
48 48
     {
49
-        if (!$this->container->has(ServerRequestInterface::class)) {
49
+        if (!$this->container->has(ServerRequestInterface::class))
50
+        {
50 51
             throw new ScopeException('Unable to create paginator, no request scope found');
51 52
         }
52 53
         /**
@@ -56,7 +57,8 @@  discard block
 block discarded – undo
56 57
 
57 58
         //Getting page number
58 59
         $page = 0;
59
-        if (!empty($query[$parameter]) && is_scalar($query[$parameter])) {
60
+        if (!empty($query[$parameter]) && is_scalar($query[$parameter]))
61
+        {
60 62
             $page = (int)$query[$parameter];
61 63
         }
62 64
 
Please login to merge, or discard this patch.
src/Framework/Http/RrDispatcher.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         FinalizerInterface $finalizer,
50 50
         ContainerInterface $container,
51 51
         FactoryInterface $factory
52
-    ) {
52
+    ){
53 53
         $this->env = $env;
54 54
         $this->finalizer = $finalizer;
55 55
         $this->container = $container;
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
 
76 76
         /** @var Http $http */
77 77
         $http = $this->container->get(Http::class);
78
-        while ($request = $client->acceptRequest()) {
79
-            try {
78
+        while ($request = $client->acceptRequest()){
79
+            try{
80 80
                 $client->respond($http->handle($request));
81
-            } catch (\Throwable $e) {
81
+            }catch (\Throwable $e){
82 82
                 $this->handleException($client, $e);
83
-            } finally {
83
+            }finally{
84 84
                 $this->finalizer->finalize(false);
85 85
             }
86 86
         }
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
     {
95 95
         $handler = new HtmlHandler();
96 96
 
97
-        try {
97
+        try{
98 98
             /** @var SnapshotInterface $snapshot */
99 99
             $snapshot = $this->container->get(SnapshotterInterface::class)->register($e);
100 100
             error_log($snapshot->getMessage());
101 101
 
102 102
             // on demand
103 103
             $state = $this->container->get(StateInterface::class);
104
-            if ($state !== null) {
104
+            if ($state !== null){
105 105
                 $handler = $handler->withState($state);
106 106
             }
107
-        } catch (\Throwable | ContainerExceptionInterface $se) {
107
+        }catch (\Throwable | ContainerExceptionInterface $se){
108 108
             error_log((string)$e);
109 109
         }
110 110
 
Please login to merge, or discard this patch.
Braces   +17 added lines, -7 removed lines patch added patch discarded remove patch
@@ -75,12 +75,18 @@  discard block
 block discarded – undo
75 75
 
76 76
         /** @var Http $http */
77 77
         $http = $this->container->get(Http::class);
78
-        while ($request = $client->acceptRequest()) {
79
-            try {
78
+        while ($request = $client->acceptRequest())
79
+        {
80
+            try
81
+            {
80 82
                 $client->respond($http->handle($request));
81
-            } catch (\Throwable $e) {
83
+            }
84
+            catch (\Throwable $e)
85
+            {
82 86
                 $this->handleException($client, $e);
83
-            } finally {
87
+            }
88
+            finally
89
+            {
84 90
                 $this->finalizer->finalize(false);
85 91
             }
86 92
         }
@@ -94,17 +100,21 @@  discard block
 block discarded – undo
94 100
     {
95 101
         $handler = new HtmlHandler();
96 102
 
97
-        try {
103
+        try
104
+        {
98 105
             /** @var SnapshotInterface $snapshot */
99 106
             $snapshot = $this->container->get(SnapshotterInterface::class)->register($e);
100 107
             error_log($snapshot->getMessage());
101 108
 
102 109
             // on demand
103 110
             $state = $this->container->get(StateInterface::class);
104
-            if ($state !== null) {
111
+            if ($state !== null)
112
+            {
105 113
                 $handler = $handler->withState($state);
106 114
             }
107
-        } catch (\Throwable | ContainerExceptionInterface $se) {
115
+        }
116
+        catch (\Throwable | ContainerExceptionInterface $se)
117
+        {
108 118
             error_log((string)$e);
109 119
         }
110 120
 
Please login to merge, or discard this patch.
src/Framework/Http/Middleware/JsonPayloadMiddleware.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
45 45
     {
46
-        if ($this->isJsonPayload($request)) {
46
+        if ($this->isJsonPayload($request)){
47 47
             $body = (string)$request->getBody();
48
-            if ($body !== '') {
48
+            if ($body !== ''){
49 49
                 $request = $request->withParsedBody(json_decode($body, true));
50
-                if (json_last_error() !== 0) {
50
+                if (json_last_error() !== 0){
51 51
                     throw new ClientException(400, 'invalid json payload');
52 52
                 }
53 53
             }
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
     {
65 65
         $contentType = $request->getHeaderLine('Content-Type');
66 66
 
67
-        foreach ($this->config->getContentTypes() as $allowedType) {
68
-            if (stripos($contentType, $allowedType) === 0) {
67
+        foreach ($this->config->getContentTypes() as $allowedType){
68
+            if (stripos($contentType, $allowedType) === 0){
69 69
                 return true;
70 70
             }
71 71
         }
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -43,11 +43,14 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
45 45
     {
46
-        if ($this->isJsonPayload($request)) {
46
+        if ($this->isJsonPayload($request))
47
+        {
47 48
             $body = (string)$request->getBody();
48
-            if ($body !== '') {
49
+            if ($body !== '')
50
+            {
49 51
                 $request = $request->withParsedBody(json_decode($body, true));
50
-                if (json_last_error() !== 0) {
52
+                if (json_last_error() !== 0)
53
+                {
51 54
                     throw new ClientException(400, 'invalid json payload');
52 55
                 }
53 56
             }
@@ -64,8 +67,10 @@  discard block
 block discarded – undo
64 67
     {
65 68
         $contentType = $request->getHeaderLine('Content-Type');
66 69
 
67
-        foreach ($this->config->getContentTypes() as $allowedType) {
68
-            if (stripos($contentType, $allowedType) === 0) {
70
+        foreach ($this->config->getContentTypes() as $allowedType)
71
+        {
72
+            if (stripos($contentType, $allowedType) === 0)
73
+            {
69 74
                 return true;
70 75
             }
71 76
         }
Please login to merge, or discard this patch.
src/Framework/Http/Middleware/ErrorHandlerMiddleware.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         RendererInterface $renderer,
58 58
         ResponseFactoryInterface $responseFactory,
59 59
         ContainerInterface $container
60
-    ) {
60
+    ){
61 61
         $this->suppressErrors = $suppressErrors;
62 62
         $this->renderer = $renderer;
63 63
         $this->responseFactory = $responseFactory;
@@ -71,22 +71,22 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function process(Request $request, Handler $handler): Response
73 73
     {
74
-        try {
74
+        try{
75 75
             return $handler->handle($request);
76
-        } catch (ClientException | RouterException $e) {
77
-            if ($e instanceof ClientException) {
76
+        }catch (ClientException | RouterException $e){
77
+            if ($e instanceof ClientException){
78 78
                 $code = $e->getCode();
79
-            } else {
79
+            }else{
80 80
                 $code = 404;
81 81
             }
82
-        } catch (\Throwable $e) {
82
+        }catch (\Throwable $e){
83 83
             $snapshotter = $this->getOptional(SnapshotterInterface::class);
84
-            if ($snapshotter !== null) {
84
+            if ($snapshotter !== null){
85 85
                 /** @var SnapshotterInterface $snapshotter */
86 86
                 $snapshotter->register($e);
87 87
             }
88 88
 
89
-            if (!$this->suppressErrors) {
89
+            if (!$this->suppressErrors){
90 90
                 return $this->renderError($request, $e);
91 91
             }
92 92
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     {
110 110
         $response = $this->responseFactory->createResponse(500);
111 111
 
112
-        if ($request->getHeaderLine('Accept') == 'application/json') {
112
+        if ($request->getHeaderLine('Accept') == 'application/json'){
113 113
             $response = $response->withHeader('Content-Type', 'application/json');
114 114
             $handler = new JsonHandler();
115 115
             $response->getBody()->write(
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
                     )
122 122
                 )
123 123
             );
124
-        } else {
124
+        }else{
125 125
             $handler = new HtmlHandler();
126 126
             $state = $this->getOptional(StateInterface::class);
127
-            if ($state !== null) {
127
+            if ($state !== null){
128 128
                 $handler = $handler->withState($state);
129 129
             }
130 130
 
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
      */
161 161
     private function getOptional(string $class)
162 162
     {
163
-        try {
163
+        try{
164 164
             return $this->container->get($class);
165
-        } catch (\Throwable | ContainerExceptionInterface $se) {
165
+        }catch (\Throwable | ContainerExceptionInterface $se){
166 166
             return null;
167 167
         }
168 168
     }
Please login to merge, or discard this patch.
Braces   +29 added lines, -12 removed lines patch added patch discarded remove patch
@@ -71,22 +71,32 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function process(Request $request, Handler $handler): Response
73 73
     {
74
-        try {
74
+        try
75
+        {
75 76
             return $handler->handle($request);
76
-        } catch (ClientException | RouterException $e) {
77
-            if ($e instanceof ClientException) {
77
+        }
78
+        catch (ClientException | RouterException $e)
79
+        {
80
+            if ($e instanceof ClientException)
81
+            {
78 82
                 $code = $e->getCode();
79
-            } else {
83
+            }
84
+            else
85
+            {
80 86
                 $code = 404;
81 87
             }
82
-        } catch (\Throwable $e) {
88
+        }
89
+        catch (\Throwable $e)
90
+        {
83 91
             $snapshotter = $this->getOptional(SnapshotterInterface::class);
84
-            if ($snapshotter !== null) {
92
+            if ($snapshotter !== null)
93
+            {
85 94
                 /** @var SnapshotterInterface $snapshotter */
86 95
                 $snapshotter->register($e);
87 96
             }
88 97
 
89
-            if (!$this->suppressErrors) {
98
+            if (!$this->suppressErrors)
99
+            {
90 100
                 return $this->renderError($request, $e);
91 101
             }
92 102
 
@@ -109,7 +119,8 @@  discard block
 block discarded – undo
109 119
     {
110 120
         $response = $this->responseFactory->createResponse(500);
111 121
 
112
-        if ($request->getHeaderLine('Accept') == 'application/json') {
122
+        if ($request->getHeaderLine('Accept') == 'application/json')
123
+        {
113 124
             $response = $response->withHeader('Content-Type', 'application/json');
114 125
             $handler = new JsonHandler();
115 126
             $response->getBody()->write(
@@ -121,10 +132,13 @@  discard block
 block discarded – undo
121 132
                     )
122 133
                 )
123 134
             );
124
-        } else {
135
+        }
136
+        else
137
+        {
125 138
             $handler = new HtmlHandler();
126 139
             $state = $this->getOptional(StateInterface::class);
127
-            if ($state !== null) {
140
+            if ($state !== null)
141
+            {
128 142
                 $handler = $handler->withState($state);
129 143
             }
130 144
 
@@ -160,9 +174,12 @@  discard block
 block discarded – undo
160 174
      */
161 175
     private function getOptional(string $class)
162 176
     {
163
-        try {
177
+        try
178
+        {
164 179
             return $this->container->get($class);
165
-        } catch (\Throwable | ContainerExceptionInterface $se) {
180
+        }
181
+        catch (\Throwable | ContainerExceptionInterface $se)
182
+        {
166 183
             return null;
167 184
         }
168 185
     }
Please login to merge, or discard this patch.
src/Framework/Jobs/JobDispatcher.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         EnvironmentInterface $env,
40 40
         FinalizerInterface $finalizer,
41 41
         ContainerInterface $container
42
-    ) {
42
+    ){
43 43
         $this->env = $env;
44 44
         $this->finalizer = $finalizer;
45 45
         $this->container = $container;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         $consumer->serve(
71 71
             $worker,
72 72
             function (\Throwable $e = null): void {
73
-                if ($e !== null) {
73
+                if ($e !== null){
74 74
                     $this->handleException($e);
75 75
                 }
76 76
 
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
      */
85 85
     protected function handleException(\Throwable $e): void
86 86
     {
87
-        try {
87
+        try{
88 88
             $this->container->get(SnapshotterInterface::class)->register($e);
89
-        } catch (\Throwable | ContainerExceptionInterface $se) {
89
+        }catch (\Throwable | ContainerExceptionInterface $se){
90 90
             // no need to notify when unable to register an exception
91 91
         }
92 92
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -70,7 +70,8 @@  discard block
 block discarded – undo
70 70
         $consumer->serve(
71 71
             $worker,
72 72
             function (\Throwable $e = null): void {
73
-                if ($e !== null) {
73
+                if ($e !== null)
74
+                {
74 75
                     $this->handleException($e);
75 76
                 }
76 77
 
@@ -84,9 +85,12 @@  discard block
 block discarded – undo
84 85
      */
85 86
     protected function handleException(\Throwable $e): void
86 87
     {
87
-        try {
88
+        try
89
+        {
88 90
             $this->container->get(SnapshotterInterface::class)->register($e);
89
-        } catch (\Throwable | ContainerExceptionInterface $se) {
91
+        }
92
+        catch (\Throwable | ContainerExceptionInterface $se)
93
+        {
90 94
             // no need to notify when unable to register an exception
91 95
         }
92 96
     }
Please login to merge, or discard this patch.
src/Framework/Jobs/JobQueue.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@
 block discarded – undo
42 42
      */
43 43
     public function push(string $jobType, array $payload = [], Options $options = null): string
44 44
     {
45
-        if ($options === null) {
45
+        if ($options === null){
46 46
             $options = new Options();
47 47
         }
48 48
 
49 49
         $pipeline = $this->registry->getPipeline($jobType);
50
-        if ($pipeline !== null && $options->getPipeline() === null) {
50
+        if ($pipeline !== null && $options->getPipeline() === null){
51 51
             $options = $options->withPipeline($pipeline);
52 52
         }
53 53
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,12 +42,14 @@
 block discarded – undo
42 42
      */
43 43
     public function push(string $jobType, array $payload = [], Options $options = null): string
44 44
     {
45
-        if ($options === null) {
45
+        if ($options === null)
46
+        {
46 47
             $options = new Options();
47 48
         }
48 49
 
49 50
         $pipeline = $this->registry->getPipeline($jobType);
50
-        if ($pipeline !== null && $options->getPipeline() === null) {
51
+        if ($pipeline !== null && $options->getPipeline() === null)
52
+        {
51 53
             $options = $options->withPipeline($pipeline);
52 54
         }
53 55
 
Please login to merge, or discard this patch.