Passed
Push — master ( 400934...9d586b )
by Anton
02:32
created
src/Http/RrDispacher.php 1 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/Http/ErrorHandler/PlainRenderer.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,9 +40,12 @@
 block discarded – undo
40 40
     public function renderException(Request $request, int $code, string $message): Response
41 41
     {
42 42
         $response = $this->responseFactory->createResponse($code);
43
-        if ($request->getHeaderLine('Accept') == 'application/json') {
43
+        if ($request->getHeaderLine('Accept') == 'application/json')
44
+        {
44 45
             $response->getBody()->write(json_encode(['status' => 500, 'error' => $message]));
45
-        } else {
46
+        }
47
+        else
48
+        {
46 49
             $response->getBody()->write("Error code: {$code}");
47 50
         }
48 51
 
Please login to merge, or discard this patch.
src/Http/Middleware/ErrorHandlerMiddleware.php 1 patch
Braces   +29 added lines, -12 removed lines patch added patch discarded remove patch
@@ -71,24 +71,34 @@  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 98
             $code = 500;
90 99
 
91
-            if (!$this->suppressErrors) {
100
+            if (!$this->suppressErrors)
101
+            {
92 102
                 return $this->renderException($request, $e);
93 103
             }
94 104
         }
@@ -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(json_encode(
@@ -119,10 +130,13 @@  discard block
 block discarded – undo
119 130
                     true
120 131
                 )
121 132
             ));
122
-        } else {
133
+        }
134
+        else
135
+        {
123 136
             $handler = new HtmlHandler();
124 137
             $state = $this->getOptional(StateInterface::class);
125
-            if ($state !== null) {
138
+            if ($state !== null)
139
+            {
126 140
                 $handler = $handler->withState($state);
127 141
             }
128 142
 
@@ -156,9 +170,12 @@  discard block
 block discarded – undo
156 170
      */
157 171
     private function getOptional(string $class)
158 172
     {
159
-        try {
173
+        try
174
+        {
160 175
             return $this->container->get($class);
161
-        } catch (\Throwable | ContainerExceptionInterface $se) {
176
+        }
177
+        catch (\Throwable | ContainerExceptionInterface $se)
178
+        {
162 179
             return null;
163 180
         }
164 181
     }
Please login to merge, or discard this patch.
src/Http/SapiDispatcher.php 1 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/Debug/StateCollector/EnvironmentCollector.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,8 +43,10 @@
 block discarded – undo
43 43
     {
44 44
         $state->setTag('php', phpversion());
45 45
 
46
-        if ($this->container->get(DispatcherInterface::class)) {
47
-            switch (get_class($this->container->get(DispatcherInterface::class))) {
46
+        if ($this->container->get(DispatcherInterface::class))
47
+        {
48
+            switch (get_class($this->container->get(DispatcherInterface::class)))
49
+            {
48 50
                 case RrDispacher::class:
49 51
                     $state->setTag('dispatcher', 'roadrunner');
50 52
                     break;
Please login to merge, or discard this patch.
src/Debug/StateCollector/HttpCollector.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,7 +39,8 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function populate(StateInterface $state): void
41 41
     {
42
-        if (!$this->request === null) {
42
+        if (!$this->request === null)
43
+        {
43 44
             return;
44 45
         }
45 46
 
@@ -48,11 +49,13 @@  discard block
 block discarded – undo
48 49
 
49 50
         $state->setVariable('headers', $this->request->getHeaders());
50 51
 
51
-        if ($this->request->getQueryParams() !== []) {
52
+        if ($this->request->getQueryParams() !== [])
53
+        {
52 54
             $state->setVariable('query', $this->request->getQueryParams());
53 55
         }
54 56
 
55
-        if ($this->request->getParsedBody() !== null) {
57
+        if ($this->request->getParsedBody() !== null)
58
+        {
56 59
             $state->setVariable('data', $this->request->getParsedBody());
57 60
         }
58 61
     }
Please login to merge, or discard this patch.
src/Console/Logger/DebugListener.php 1 patch
Braces   +17 added lines, -8 removed lines patch added patch discarded remove patch
@@ -51,11 +51,13 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function __invoke(LogEvent $event): void
53 53
     {
54
-        if (empty($this->output)) {
54
+        if (empty($this->output))
55
+        {
55 56
             return;
56 57
         }
57 58
 
58
-        if ($this->output->getVerbosity() < OutputInterface::VERBOSITY_VERY_VERBOSE) {
59
+        if ($this->output->getVerbosity() < OutputInterface::VERBOSITY_VERY_VERBOSE)
60
+        {
59 61
             return;
60 62
         }
61 63
 
@@ -91,7 +93,8 @@  discard block
 block discarded – undo
91 93
      */
92 94
     public function enable(): self
93 95
     {
94
-        if (!empty($this->listenerRegistry)) {
96
+        if (!empty($this->listenerRegistry))
97
+        {
95 98
             $this->listenerRegistry->addListener($this);
96 99
         }
97 100
 
@@ -105,7 +108,8 @@  discard block
 block discarded – undo
105 108
      */
106 109
     public function disable(): self
107 110
     {
108
-        if (!empty($this->listenerRegistry)) {
111
+        if (!empty($this->listenerRegistry))
112
+        {
109 113
             $this->listenerRegistry->removeListener($this);
110 114
         }
111 115
 
@@ -128,13 +132,17 @@  discard block
 block discarded – undo
128 132
      */
129 133
     private function getChannel(string $channel): string
130 134
     {
131
-        if (!class_exists($channel, false)) {
135
+        if (!class_exists($channel, false))
136
+        {
132 137
             return "[{$channel}]";
133 138
         }
134 139
 
135
-        try {
140
+        try
141
+        {
136 142
             $reflection = new \ReflectionClass($channel);
137
-        } catch (\ReflectionException $e) {
143
+        }
144
+        catch (\ReflectionException $e)
145
+        {
138 146
             return $channel;
139 147
         }
140 148
 
@@ -150,7 +158,8 @@  discard block
 block discarded – undo
150 158
      */
151 159
     private function getMessage(bool $decorated, string $message)
152 160
     {
153
-        if (!$decorated) {
161
+        if (!$decorated)
162
+        {
154 163
             return $message;
155 164
         }
156 165
 
Please login to merge, or discard this patch.
src/Bootloader/DebugBootloader.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -70,16 +70,20 @@
 block discarded – undo
70 70
     {
71 71
         $state = new State();
72 72
 
73
-        foreach ($this->collectors as $collector) {
74
-            if (is_string($collector)) {
73
+        foreach ($this->collectors as $collector)
74
+        {
75
+            if (is_string($collector))
76
+            {
75 77
                 $collector = $this->factory->make($collector);
76 78
             }
77 79
 
78
-            if ($collector instanceof Autowire) {
80
+            if ($collector instanceof Autowire)
81
+            {
79 82
                 $collector = $collector->resolve($this->factory);
80 83
             }
81 84
 
82
-            if (!$collector instanceof StateCollectorInterface) {
85
+            if (!$collector instanceof StateCollectorInterface)
86
+            {
83 87
                 throw new StateException(sprintf(
84 88
                     'Unable to populate state, invalid state collector %s',
85 89
                     is_object($collector) ? get_class($collector) : gettype($collector)
Please login to merge, or discard this patch.