Test Failed
Push — master ( 36f795...9f6bee )
by Aleksei
03:35 queued 16s
created
src/Exceptions/tests/ErrorReportingTest.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         #[ExpectedValues(values: [\E_USER_NOTICE, \E_USER_WARNING, \E_USER_ERROR])]
69 69
         int $type
70 70
     ): ?Throwable {
71
-        $handler = (new class extends ExceptionHandler {
71
+        $handler = (new class extends ExceptionHandler{
72 72
             public function handleError(int $errno, string $errstr, string $errfile = '', int $errline = 0): bool
73 73
             {
74 74
                 return parent::handleError($errno, $errstr, $errfile, $errline);
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
             {
79 79
             }
80 80
         });
81
-        try {
81
+        try{
82 82
             $handler->handleError(...\array_values($this->generateErrorArray($type)));
83
-        } catch (Throwable $e) {
83
+        }catch (Throwable $e){
84 84
             return $e;
85 85
         }
86 86
         return null;
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -68,7 +68,8 @@  discard block
 block discarded – undo
68 68
         #[ExpectedValues(values: [\E_USER_NOTICE, \E_USER_WARNING, \E_USER_ERROR])]
69 69
         int $type
70 70
     ): ?Throwable {
71
-        $handler = (new class extends ExceptionHandler {
71
+        $handler = (new class extends ExceptionHandler
72
+        {
72 73
             public function handleError(int $errno, string $errstr, string $errfile = '', int $errline = 0): bool
73 74
             {
74 75
                 return parent::handleError($errno, $errstr, $errfile, $errline);
@@ -78,9 +79,12 @@  discard block
 block discarded – undo
78 79
             {
79 80
             }
80 81
         });
81
-        try {
82
+        try
83
+        {
82 84
             $handler->handleError(...\array_values($this->generateErrorArray($type)));
83
-        } catch (Throwable $e) {
85
+        }
86
+        catch (Throwable $e)
87
+        {
84 88
             return $e;
85 89
         }
86 90
         return null;
Please login to merge, or discard this patch.
src/Exceptions/src/ExceptionHandler.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 
41 41
     public function getRenderer(?string $format = null): ?ExceptionRendererInterface
42 42
     {
43
-        if ($format !== null) {
44
-            foreach ($this->renderers as $renderer) {
45
-                if ($renderer->canRender($format)) {
43
+        if ($format !== null){
44
+            foreach ($this->renderers as $renderer){
45
+                if ($renderer->canRender($format)){
46 46
                     return $renderer;
47 47
                 }
48 48
             }
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 
66 66
     public function report(\Throwable $exception): void
67 67
     {
68
-        foreach ($this->reporters as $reporter) {
69
-            try {
70
-                if ($reporter instanceof ExceptionReporterInterface) {
68
+        foreach ($this->reporters as $reporter){
69
+            try{
70
+                if ($reporter instanceof ExceptionReporterInterface){
71 71
                     $reporter->report($exception);
72
-                } else {
72
+                }else{
73 73
                     $reporter($exception);
74 74
                 }
75
-            } catch (\Throwable) {
75
+            }catch (\Throwable){
76 76
                 // Do nothing
77 77
             }
78 78
         }
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 
81 81
     public function handleGlobalException(\Throwable $e): void
82 82
     {
83
-        if (\in_array(PHP_SAPI, ['cli', 'cli-server'], true)) {
83
+        if (\in_array(PHP_SAPI, ['cli', 'cli-server'], true)){
84 84
             $this->output ??= \defined('STDERR') ? \STDERR : \fopen('php://stderr', 'wb+');
85 85
             $format = 'cli';
86
-        } else {
86
+        }else{
87 87
             $this->output ??= \defined('STDOUT') ? \STDOUT : \fopen('php://stdout', 'wb+');
88 88
             $format = 'html';
89 89
         }
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
         $this->report($e);
93 93
 
94 94
         // There is possible an exception on the application termination
95
-        try {
95
+        try{
96 96
             \fwrite($this->output, $this->render($e, verbosity: $this->verbosity, format: $format));
97
-        } catch (\Throwable) {
97
+        }catch (\Throwable){
98 98
             $this->output = null;
99 99
         }
100 100
     }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     /**
111 111
      * @param ExceptionReporterInterface|Closure(\Throwable):void $reporter
112 112
      */
113
-    public function addReporter(ExceptionReporterInterface|Closure $reporter): void
113
+    public function addReporter(ExceptionReporterInterface | Closure $reporter): void
114 114
     {
115 115
         $this->reporters[] = $reporter;
116 116
     }
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
      */
129 129
     protected function handleShutdown(): void
130 130
     {
131
-        if (empty($error = \error_get_last())) {
131
+        if (empty($error = \error_get_last())){
132 132
             return;
133 133
         }
134 134
 
135
-        try {
135
+        try{
136 136
             $this->handleError($error['type'], $error['message'], $error['file'], $error['line']);
137
-        } catch (\Throwable $e) {
137
+        }catch (\Throwable $e){
138 138
             $this->handleGlobalException($e);
139 139
         }
140 140
     }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         string $errfile = '',
151 151
         int $errline = 0,
152 152
     ): bool {
153
-        if (!(\error_reporting() & $errno)) {
153
+        if (!(\error_reporting() & $errno)){
154 154
             return false;
155 155
         }
156 156
 
Please login to merge, or discard this patch.
Braces   +37 added lines, -16 removed lines patch added patch discarded remove patch
@@ -40,9 +40,12 @@  discard block
 block discarded – undo
40 40
 
41 41
     public function getRenderer(?string $format = null): ?ExceptionRendererInterface
42 42
     {
43
-        if ($format !== null) {
44
-            foreach ($this->renderers as $renderer) {
45
-                if ($renderer->canRender($format)) {
43
+        if ($format !== null)
44
+        {
45
+            foreach ($this->renderers as $renderer)
46
+            {
47
+                if ($renderer->canRender($format))
48
+                {
46 49
                     return $renderer;
47 50
                 }
48 51
             }
@@ -65,14 +68,21 @@  discard block
 block discarded – undo
65 68
 
66 69
     public function report(\Throwable $exception): void
67 70
     {
68
-        foreach ($this->reporters as $reporter) {
69
-            try {
70
-                if ($reporter instanceof ExceptionReporterInterface) {
71
+        foreach ($this->reporters as $reporter)
72
+        {
73
+            try
74
+            {
75
+                if ($reporter instanceof ExceptionReporterInterface)
76
+                {
71 77
                     $reporter->report($exception);
72
-                } else {
78
+                }
79
+                else
80
+                {
73 81
                     $reporter($exception);
74 82
                 }
75
-            } catch (\Throwable) {
83
+            }
84
+            catch (\Throwable)
85
+            {
76 86
                 // Do nothing
77 87
             }
78 88
         }
@@ -80,10 +90,13 @@  discard block
 block discarded – undo
80 90
 
81 91
     public function handleGlobalException(\Throwable $e): void
82 92
     {
83
-        if (\in_array(PHP_SAPI, ['cli', 'cli-server'], true)) {
93
+        if (\in_array(PHP_SAPI, ['cli', 'cli-server'], true))
94
+        {
84 95
             $this->output ??= \defined('STDERR') ? \STDERR : \fopen('php://stderr', 'wb+');
85 96
             $format = 'cli';
86
-        } else {
97
+        }
98
+        else
99
+        {
87 100
             $this->output ??= \defined('STDOUT') ? \STDOUT : \fopen('php://stdout', 'wb+');
88 101
             $format = 'html';
89 102
         }
@@ -92,9 +105,12 @@  discard block
 block discarded – undo
92 105
         $this->report($e);
93 106
 
94 107
         // There is possible an exception on the application termination
95
-        try {
108
+        try
109
+        {
96 110
             \fwrite($this->output, $this->render($e, verbosity: $this->verbosity, format: $format));
97
-        } catch (\Throwable) {
111
+        }
112
+        catch (\Throwable)
113
+        {
98 114
             $this->output = null;
99 115
         }
100 116
     }
@@ -128,13 +144,17 @@  discard block
 block discarded – undo
128 144
      */
129 145
     protected function handleShutdown(): void
130 146
     {
131
-        if (empty($error = \error_get_last())) {
147
+        if (empty($error = \error_get_last()))
148
+        {
132 149
             return;
133 150
         }
134 151
 
135
-        try {
152
+        try
153
+        {
136 154
             $this->handleError($error['type'], $error['message'], $error['file'], $error['line']);
137
-        } catch (\Throwable $e) {
155
+        }
156
+        catch (\Throwable $e)
157
+        {
138 158
             $this->handleGlobalException($e);
139 159
         }
140 160
     }
@@ -150,7 +170,8 @@  discard block
 block discarded – undo
150 170
         string $errfile = '',
151 171
         int $errline = 0,
152 172
     ): bool {
153
-        if (!(\error_reporting() & $errno)) {
173
+        if (!(\error_reporting() & $errno))
174
+        {
154 175
             return false;
155 176
         }
156 177
 
Please login to merge, or discard this patch.