Passed
Pull Request — master (#1044)
by Maxim
10:08
created
src/Exceptions/src/ExceptionHandler.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 
48 48
     public function getRenderer(?string $format = null): ?ExceptionRendererInterface
49 49
     {
50
-        if ($format !== null) {
51
-            foreach ($this->renderers as $renderer) {
52
-                if ($renderer->canRender($format)) {
50
+        if ($format !== null){
51
+            foreach ($this->renderers as $renderer){
52
+                if ($renderer->canRender($format)){
53 53
                     return $renderer;
54 54
                 }
55 55
             }
@@ -72,18 +72,18 @@  discard block
 block discarded – undo
72 72
 
73 73
     public function report(\Throwable $exception): void
74 74
     {
75
-        if ($this->shouldNotReport($exception)) {
75
+        if ($this->shouldNotReport($exception)){
76 76
             return;
77 77
         }
78 78
 
79
-        foreach ($this->reporters as $reporter) {
80
-            try {
81
-                if ($reporter instanceof ExceptionReporterInterface) {
79
+        foreach ($this->reporters as $reporter){
80
+            try{
81
+                if ($reporter instanceof ExceptionReporterInterface){
82 82
                     $reporter->report($exception);
83
-                } else {
83
+                }else{
84 84
                     $reporter($exception);
85 85
                 }
86
-            } catch (\Throwable) {
86
+            }catch (\Throwable){
87 87
                 // Do nothing
88 88
             }
89 89
         }
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 
92 92
     public function handleGlobalException(\Throwable $e): void
93 93
     {
94
-        if (\in_array(PHP_SAPI, ['cli', 'cli-server'], true)) {
94
+        if (\in_array(PHP_SAPI, ['cli', 'cli-server'], true)){
95 95
             $this->output ??= \defined('STDERR') ? \STDERR : \fopen('php://stderr', 'wb+');
96 96
             $format = 'cli';
97
-        } else {
97
+        }else{
98 98
             $this->output ??= \defined('STDOUT') ? \STDOUT : \fopen('php://stdout', 'wb+');
99 99
             $format = 'html';
100 100
         }
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
         $this->report($e);
104 104
 
105 105
         // There is possible an exception on the application termination
106
-        try {
106
+        try{
107 107
             \fwrite($this->output, $this->render($e, verbosity: $this->verbosity, format: $format));
108
-        } catch (\Throwable) {
108
+        }catch (\Throwable){
109 109
             $this->output = null;
110 110
         }
111 111
     }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     /**
130 130
      * @param ExceptionReporterInterface|Closure(\Throwable):void $reporter
131 131
      */
132
-    public function addReporter(ExceptionReporterInterface|Closure $reporter): void
132
+    public function addReporter(ExceptionReporterInterface | Closure $reporter): void
133 133
     {
134 134
         $this->reporters[] = $reporter;
135 135
     }
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
      */
148 148
     protected function handleShutdown(): void
149 149
     {
150
-        if (empty($error = \error_get_last())) {
150
+        if (empty($error = \error_get_last())){
151 151
             return;
152 152
         }
153 153
 
154
-        try {
154
+        try{
155 155
             $this->handleError($error['type'], $error['message'], $error['file'], $error['line']);
156
-        } catch (\Throwable $e) {
156
+        }catch (\Throwable $e){
157 157
             $this->handleGlobalException($e);
158 158
         }
159 159
     }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         string $errfile = '',
170 170
         int $errline = 0,
171 171
     ): bool {
172
-        if (!(\error_reporting() & $errno)) {
172
+        if (!(\error_reporting() & $errno)){
173 173
             return false;
174 174
         }
175 175
 
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 
184 184
     protected function shouldNotReport(\Throwable $exception): bool
185 185
     {
186
-        foreach ($this->nonReportableExceptions as $nonReportableException) {
187
-            if ($exception instanceof $nonReportableException) {
186
+        foreach ($this->nonReportableExceptions as $nonReportableException){
187
+            if ($exception instanceof $nonReportableException){
188 188
                 return true;
189 189
             }
190 190
         }
Please login to merge, or discard this patch.
src/Exceptions/tests/ExceptionHandlerTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
     private function makeEmptyErrorHandler(): ExceptionHandler
135 135
     {
136
-        return new class extends ExceptionHandler {
136
+        return new class extends ExceptionHandler{
137 137
             protected function bootBasicHandlers(): void
138 138
             {
139 139
             }
@@ -147,17 +147,17 @@  discard block
 block discarded – undo
147 147
 
148 148
     public static function nonReportableExceptionsDataProvider(): \Traversable
149 149
     {
150
-        yield [new class extends ClientException {}];
150
+        yield [new class extends ClientException{}];
151 151
         yield [new NotFoundException()];
152
-        yield [new class extends NotFoundException {}];
152
+        yield [new class extends NotFoundException{}];
153 153
         yield [new ForbiddenException()];
154
-        yield [new class extends ForbiddenException {}];
154
+        yield [new class extends ForbiddenException{}];
155 155
         yield [new UnauthorizedException()];
156
-        yield [new class extends UnauthorizedException {}];
156
+        yield [new class extends UnauthorizedException{}];
157 157
         yield [new AuthorizationException()];
158
-        yield [new class extends AuthorizationException {}];
158
+        yield [new class extends AuthorizationException{}];
159 159
         yield [new ValidationException([])];
160
-        yield [new class([]) extends ValidationException {}];
160
+        yield [new class([]) extends ValidationException{}];
161 161
         yield [new TestException()];
162 162
     }
163 163
 }
Please login to merge, or discard this patch.