@@ -29,7 +29,7 @@ |
||
29 | 29 | */ |
30 | 30 | public function finalize(bool $terminate = false): void |
31 | 31 | { |
32 | - foreach ($this->finalizers as $finalizer) { |
|
32 | + foreach ($this->finalizers as $finalizer){ |
|
33 | 33 | call_user_func($finalizer, $terminate); |
34 | 34 | } |
35 | 35 | } |
@@ -29,7 +29,8 @@ |
||
29 | 29 | */ |
30 | 30 | public function finalize(bool $terminate = false): void |
31 | 31 | { |
32 | - foreach ($this->finalizers as $finalizer) { |
|
32 | + foreach ($this->finalizers as $finalizer) |
|
33 | + { |
|
33 | 34 | call_user_func($finalizer, $terminate); |
34 | 35 | } |
35 | 36 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function __construct(array $directories) |
25 | 25 | { |
26 | - foreach ($directories as $name => $directory) { |
|
26 | + foreach ($directories as $name => $directory){ |
|
27 | 27 | $this->set($name, $directory); |
28 | 28 | } |
29 | 29 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | public function set(string $name, string $path): DirectoriesInterface |
43 | 43 | { |
44 | 44 | $path = str_replace(['\\', '//'], '/', $path); |
45 | - $this->directories[$name] = rtrim($path, '/') . '/'; |
|
45 | + $this->directories[$name] = rtrim($path, '/').'/'; |
|
46 | 46 | |
47 | 47 | return $this; |
48 | 48 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function get(string $name): string |
54 | 54 | { |
55 | - if (!$this->has($name)) { |
|
55 | + if (!$this->has($name)){ |
|
56 | 56 | throw new DirectoryException("Undefined directory '{$name}'"); |
57 | 57 | } |
58 | 58 |
@@ -23,7 +23,8 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function __construct(array $directories) |
25 | 25 | { |
26 | - foreach ($directories as $name => $directory) { |
|
26 | + foreach ($directories as $name => $directory) |
|
27 | + { |
|
27 | 28 | $this->set($name, $directory); |
28 | 29 | } |
29 | 30 | } |
@@ -52,7 +53,8 @@ discard block |
||
52 | 53 | */ |
53 | 54 | public function get(string $name): string |
54 | 55 | { |
55 | - if (!$this->has($name)) { |
|
56 | + if (!$this->has($name)) |
|
57 | + { |
|
56 | 58 | throw new DirectoryException("Undefined directory '{$name}'"); |
57 | 59 | } |
58 | 60 |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | { |
45 | 45 | $filename = $this->getFilename($section); |
46 | 46 | |
47 | - if (!file_exists($filename)) { |
|
47 | + if (!file_exists($filename)){ |
|
48 | 48 | return null; |
49 | 49 | } |
50 | 50 | |
51 | - try { |
|
51 | + try{ |
|
52 | 52 | return include($filename); |
53 | - } catch (\Throwable $e) { |
|
53 | + }catch (\Throwable $e){ |
|
54 | 54 | return null; |
55 | 55 | } |
56 | 56 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | $this->files->write( |
64 | 64 | $this->getFilename($section), |
65 | - '<?php return ' . var_export($data, true) . ';', |
|
65 | + '<?php return '.var_export($data, true).';', |
|
66 | 66 | FilesInterface::RUNTIME, |
67 | 67 | true |
68 | 68 | ); |
@@ -44,13 +44,17 @@ |
||
44 | 44 | { |
45 | 45 | $filename = $this->getFilename($section); |
46 | 46 | |
47 | - if (!file_exists($filename)) { |
|
47 | + if (!file_exists($filename)) |
|
48 | + { |
|
48 | 49 | return null; |
49 | 50 | } |
50 | 51 | |
51 | - try { |
|
52 | + try |
|
53 | + { |
|
52 | 54 | return include($filename); |
53 | - } catch (\Throwable $e) { |
|
55 | + } |
|
56 | + catch (\Throwable $e) |
|
57 | + { |
|
54 | 58 | return null; |
55 | 59 | } |
56 | 60 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public static function handleShutdown(): void |
52 | 52 | { |
53 | - if (!empty($error = error_get_last())) { |
|
53 | + if (!empty($error = error_get_last())){ |
|
54 | 54 | self::handleException( |
55 | 55 | new FatalException( |
56 | 56 | $error['message'], |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function handleException(\Throwable $e): void |
87 | 87 | { |
88 | - if (php_sapi_name() == 'cli') { |
|
88 | + if (php_sapi_name() == 'cli'){ |
|
89 | 89 | $handler = new ConsoleHandler(self::$output); |
90 | - } else { |
|
90 | + }else{ |
|
91 | 91 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
92 | 92 | } |
93 | 93 |
@@ -50,7 +50,8 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public static function handleShutdown(): void |
52 | 52 | { |
53 | - if (!empty($error = error_get_last())) { |
|
53 | + if (!empty($error = error_get_last())) |
|
54 | + { |
|
54 | 55 | self::handleException( |
55 | 56 | new FatalException( |
56 | 57 | $error['message'], |
@@ -85,9 +86,12 @@ discard block |
||
85 | 86 | */ |
86 | 87 | public static function handleException(\Throwable $e): void |
87 | 88 | { |
88 | - if (php_sapi_name() == 'cli') { |
|
89 | + if (php_sapi_name() == 'cli') |
|
90 | + { |
|
89 | 91 | $handler = new ConsoleHandler(self::$output); |
90 | - } else { |
|
92 | + } |
|
93 | + else |
|
94 | + { |
|
91 | 95 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
92 | 96 | } |
93 | 97 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | use Spiral\Core\ContainerScope; |
17 | 17 | use Spiral\Core\Exception\ScopeException; |
18 | 18 | |
19 | -if (!function_exists('spiral')) { |
|
19 | +if (!function_exists('spiral')){ |
|
20 | 20 | /** |
21 | 21 | * Resolve given alias in current IoC scope. |
22 | 22 | * |
@@ -27,19 +27,19 @@ discard block |
||
27 | 27 | */ |
28 | 28 | function spiral(string $alias) |
29 | 29 | { |
30 | - if (ContainerScope::getContainer() === null) { |
|
30 | + if (ContainerScope::getContainer() === null){ |
|
31 | 31 | throw new ScopeException('Container scope was not set.'); |
32 | 32 | } |
33 | 33 | |
34 | - try { |
|
34 | + try{ |
|
35 | 35 | return ContainerScope::getContainer()->get($alias); |
36 | - } catch (ContainerExceptionInterface $e) { |
|
36 | + }catch (ContainerExceptionInterface $e){ |
|
37 | 37 | throw new ScopeException($e->getMessage(), $e->getCode(), $e); |
38 | 38 | } |
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | -if (!function_exists('directory')) { |
|
42 | +if (!function_exists('directory')){ |
|
43 | 43 | /** |
44 | 44 | * Get directory alias value. Uses application core from the current global scope. |
45 | 45 | * |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | -if (!function_exists('env')) { |
|
58 | +if (!function_exists('env')){ |
|
59 | 59 | /** |
60 | 60 | * Gets the value of an environment variable. Uses application core from the current global scope. |
61 | 61 | * |
@@ -16,7 +16,8 @@ discard block |
||
16 | 16 | use Spiral\Core\ContainerScope; |
17 | 17 | use Spiral\Core\Exception\ScopeException; |
18 | 18 | |
19 | -if (!function_exists('spiral')) { |
|
19 | +if (!function_exists('spiral')) |
|
20 | +{ |
|
20 | 21 | /** |
21 | 22 | * Resolve given alias in current IoC scope. |
22 | 23 | * |
@@ -27,19 +28,24 @@ discard block |
||
27 | 28 | */ |
28 | 29 | function spiral(string $alias) |
29 | 30 | { |
30 | - if (ContainerScope::getContainer() === null) { |
|
31 | + if (ContainerScope::getContainer() === null) |
|
32 | + { |
|
31 | 33 | throw new ScopeException('Container scope was not set.'); |
32 | 34 | } |
33 | 35 | |
34 | - try { |
|
36 | + try |
|
37 | + { |
|
35 | 38 | return ContainerScope::getContainer()->get($alias); |
36 | - } catch (ContainerExceptionInterface $e) { |
|
39 | + } |
|
40 | + catch (ContainerExceptionInterface $e) |
|
41 | + { |
|
37 | 42 | throw new ScopeException($e->getMessage(), $e->getCode(), $e); |
38 | 43 | } |
39 | 44 | } |
40 | 45 | } |
41 | 46 | |
42 | -if (!function_exists('directory')) { |
|
47 | +if (!function_exists('directory')) |
|
48 | +{ |
|
43 | 49 | /** |
44 | 50 | * Get directory alias value. Uses application core from the current global scope. |
45 | 51 | * |
@@ -55,7 +61,8 @@ discard block |
||
55 | 61 | } |
56 | 62 | } |
57 | 63 | |
58 | -if (!function_exists('env')) { |
|
64 | +if (!function_exists('env')) |
|
65 | +{ |
|
59 | 66 | /** |
60 | 67 | * Gets the value of an environment variable. Uses application core from the current global scope. |
61 | 68 | * |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function serve() |
99 | 99 | { |
100 | - foreach ($this->dispatchers as $dispatcher) { |
|
101 | - if ($dispatcher->canServe()) { |
|
100 | + foreach ($this->dispatchers as $dispatcher){ |
|
101 | + if ($dispatcher->canServe()){ |
|
102 | 102 | return $this->container->runScope( |
103 | 103 | [DispatcherInterface::class => $dispatcher], |
104 | 104 | [$dispatcher, 'serve'] |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | EnvironmentInterface $environment = null, |
125 | 125 | bool $handleErrors = true |
126 | 126 | ): ?self { |
127 | - if ($handleErrors) { |
|
127 | + if ($handleErrors){ |
|
128 | 128 | ExceptionHandler::register(); |
129 | 129 | } |
130 | 130 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $core = new static(new Container(), $directories); |
134 | 134 | $core->container->bindSingleton(EnvironmentInterface::class, $environment); |
135 | 135 | |
136 | - try { |
|
136 | + try{ |
|
137 | 137 | // will protect any against env overwrite action |
138 | 138 | $core->container->runScope( |
139 | 139 | [EnvironmentInterface::class => $environment], |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $core->bootstrap(); |
143 | 143 | } |
144 | 144 | ); |
145 | - } catch (\Throwable $e) { |
|
145 | + }catch (\Throwable $e){ |
|
146 | 146 | ExceptionHandler::handleException($e); |
147 | 147 | |
148 | 148 | return null; |
@@ -97,8 +97,10 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function serve() |
99 | 99 | { |
100 | - foreach ($this->dispatchers as $dispatcher) { |
|
101 | - if ($dispatcher->canServe()) { |
|
100 | + foreach ($this->dispatchers as $dispatcher) |
|
101 | + { |
|
102 | + if ($dispatcher->canServe()) |
|
103 | + { |
|
102 | 104 | return $this->container->runScope( |
103 | 105 | [DispatcherInterface::class => $dispatcher], |
104 | 106 | [$dispatcher, 'serve'] |
@@ -124,7 +126,8 @@ discard block |
||
124 | 126 | EnvironmentInterface $environment = null, |
125 | 127 | bool $handleErrors = true |
126 | 128 | ): ?self { |
127 | - if ($handleErrors) { |
|
129 | + if ($handleErrors) |
|
130 | + { |
|
128 | 131 | ExceptionHandler::register(); |
129 | 132 | } |
130 | 133 | |
@@ -133,7 +136,8 @@ discard block |
||
133 | 136 | $core = new static(new Container(), $directories); |
134 | 137 | $core->container->bindSingleton(EnvironmentInterface::class, $environment); |
135 | 138 | |
136 | - try { |
|
139 | + try |
|
140 | + { |
|
137 | 141 | // will protect any against env overwrite action |
138 | 142 | $core->container->runScope( |
139 | 143 | [EnvironmentInterface::class => $environment], |
@@ -142,7 +146,9 @@ discard block |
||
142 | 146 | $core->bootstrap(); |
143 | 147 | } |
144 | 148 | ); |
145 | - } catch (\Throwable $e) { |
|
149 | + } |
|
150 | + catch (\Throwable $e) |
|
151 | + { |
|
146 | 152 | ExceptionHandler::handleException($e); |
147 | 153 | |
148 | 154 | return null; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | public function testHtmlHighlighter(): void |
30 | 30 | { |
31 | - $highlighter = new Highlighter(new HtmlStyle(HtmlStyle::DEFAULT)); |
|
31 | + $highlighter = new Highlighter(new HtmlStyle(HtmlStyle::default)); |
|
32 | 32 | |
33 | 33 | $this->assertStringContainsString('HighlighterTest', $highlighter->highlight(file_get_contents(__FILE__))); |
34 | 34 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | public function testHtmlHighlighterLines(): void |
61 | 61 | { |
62 | - $highlighter = new Highlighter(new HtmlStyle(HtmlStyle::DEFAULT)); |
|
62 | + $highlighter = new Highlighter(new HtmlStyle(HtmlStyle::default)); |
|
63 | 63 | |
64 | 64 | $this->assertStringContainsString( |
65 | 65 | 'HighlighterTest', |
@@ -197,9 +197,9 @@ discard block |
||
197 | 197 | $handler = new ConsoleHandler(); |
198 | 198 | $handler->setColorsSupport(true); |
199 | 199 | |
200 | - try { |
|
200 | + try{ |
|
201 | 201 | $this->makeException(); |
202 | - } catch (\Throwable $e) { |
|
202 | + }catch (\Throwable $e){ |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | $result = $handler->renderException($e, HandlerInterface::VERBOSITY_DEBUG); |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | { |
214 | 214 | $handler = new PlainHandler(); |
215 | 215 | |
216 | - try { |
|
216 | + try{ |
|
217 | 217 | $this->makeException(); |
218 | - } catch (\Throwable $e) { |
|
218 | + }catch (\Throwable $e){ |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | $result = $handler->renderException($e, HandlerInterface::VERBOSITY_DEBUG); |
@@ -228,9 +228,9 @@ discard block |
||
228 | 228 | { |
229 | 229 | $handler = new JsonHandler(); |
230 | 230 | |
231 | - try { |
|
231 | + try{ |
|
232 | 232 | $this->makeException(); |
233 | - } catch (\Throwable $e) { |
|
233 | + }catch (\Throwable $e){ |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | $result = $handler->renderException($e, HandlerInterface::VERBOSITY_DEBUG); |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | { |
244 | 244 | $handler = new HtmlHandler(HtmlHandler::DEFAULT); |
245 | 245 | |
246 | - try { |
|
246 | + try{ |
|
247 | 247 | $this->makeException(); |
248 | - } catch (\Throwable $e) { |
|
248 | + }catch (\Throwable $e){ |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | $result = $handler->renderException($e, HandlerInterface::VERBOSITY_DEBUG); |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | { |
260 | 260 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
261 | 261 | |
262 | - try { |
|
262 | + try{ |
|
263 | 263 | $this->makeException(); |
264 | - } catch (\Throwable $e) { |
|
264 | + }catch (\Throwable $e){ |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | $result = $handler->renderException($e, HandlerInterface::VERBOSITY_DEBUG); |
@@ -273,13 +273,13 @@ discard block |
||
273 | 273 | |
274 | 274 | public function makeException(): void |
275 | 275 | { |
276 | - try { |
|
276 | + try{ |
|
277 | 277 | $f = function (): void { |
278 | 278 | throw new \RuntimeException('error'); |
279 | 279 | }; |
280 | 280 | |
281 | 281 | $f(); |
282 | - } catch (\Throwable $e) { |
|
282 | + }catch (\Throwable $e){ |
|
283 | 283 | throw new \LogicException('error', 0, $e); |
284 | 284 | } |
285 | 285 | } |
@@ -197,9 +197,12 @@ discard block |
||
197 | 197 | $handler = new ConsoleHandler(); |
198 | 198 | $handler->setColorsSupport(true); |
199 | 199 | |
200 | - try { |
|
200 | + try |
|
201 | + { |
|
201 | 202 | $this->makeException(); |
202 | - } catch (\Throwable $e) { |
|
203 | + } |
|
204 | + catch (\Throwable $e) |
|
205 | + { |
|
203 | 206 | } |
204 | 207 | |
205 | 208 | $result = $handler->renderException($e, HandlerInterface::VERBOSITY_DEBUG); |
@@ -213,9 +216,12 @@ discard block |
||
213 | 216 | { |
214 | 217 | $handler = new PlainHandler(); |
215 | 218 | |
216 | - try { |
|
219 | + try |
|
220 | + { |
|
217 | 221 | $this->makeException(); |
218 | - } catch (\Throwable $e) { |
|
222 | + } |
|
223 | + catch (\Throwable $e) |
|
224 | + { |
|
219 | 225 | } |
220 | 226 | |
221 | 227 | $result = $handler->renderException($e, HandlerInterface::VERBOSITY_DEBUG); |
@@ -228,9 +234,12 @@ discard block |
||
228 | 234 | { |
229 | 235 | $handler = new JsonHandler(); |
230 | 236 | |
231 | - try { |
|
237 | + try |
|
238 | + { |
|
232 | 239 | $this->makeException(); |
233 | - } catch (\Throwable $e) { |
|
240 | + } |
|
241 | + catch (\Throwable $e) |
|
242 | + { |
|
234 | 243 | } |
235 | 244 | |
236 | 245 | $result = $handler->renderException($e, HandlerInterface::VERBOSITY_DEBUG); |
@@ -243,9 +252,12 @@ discard block |
||
243 | 252 | { |
244 | 253 | $handler = new HtmlHandler(HtmlHandler::DEFAULT); |
245 | 254 | |
246 | - try { |
|
255 | + try |
|
256 | + { |
|
247 | 257 | $this->makeException(); |
248 | - } catch (\Throwable $e) { |
|
258 | + } |
|
259 | + catch (\Throwable $e) |
|
260 | + { |
|
249 | 261 | } |
250 | 262 | |
251 | 263 | $result = $handler->renderException($e, HandlerInterface::VERBOSITY_DEBUG); |
@@ -259,9 +271,12 @@ discard block |
||
259 | 271 | { |
260 | 272 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
261 | 273 | |
262 | - try { |
|
274 | + try |
|
275 | + { |
|
263 | 276 | $this->makeException(); |
264 | - } catch (\Throwable $e) { |
|
277 | + } |
|
278 | + catch (\Throwable $e) |
|
279 | + { |
|
265 | 280 | } |
266 | 281 | |
267 | 282 | $result = $handler->renderException($e, HandlerInterface::VERBOSITY_DEBUG); |
@@ -273,13 +288,16 @@ discard block |
||
273 | 288 | |
274 | 289 | public function makeException(): void |
275 | 290 | { |
276 | - try { |
|
291 | + try |
|
292 | + { |
|
277 | 293 | $f = function (): void { |
278 | 294 | throw new \RuntimeException('error'); |
279 | 295 | }; |
280 | 296 | |
281 | 297 | $f(); |
282 | - } catch (\Throwable $e) { |
|
298 | + } |
|
299 | + catch (\Throwable $e) |
|
300 | + { |
|
283 | 301 | throw new \LogicException('error', 0, $e); |
284 | 302 | } |
285 | 303 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | public function testHtmlHandlerDefaultBasic(): void |
115 | 115 | { |
116 | - $handler = new HtmlHandler(HtmlHandler::DEFAULT); |
|
116 | + $handler = new HtmlHandler(HtmlHandler::default); |
|
117 | 117 | |
118 | 118 | $result = $handler->renderException(new Error( |
119 | 119 | 'message', |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | public function testHtmlHandlerDefaultDebug(): void |
164 | 164 | { |
165 | - $handler = new HtmlHandler(HtmlHandler::DEFAULT); |
|
165 | + $handler = new HtmlHandler(HtmlHandler::default); |
|
166 | 166 | |
167 | 167 | $result = $handler->renderException(new Error( |
168 | 168 | 'message', |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | public function testHtmlHandlerStacktrace(): void |
243 | 243 | { |
244 | - $handler = new HtmlHandler(HtmlHandler::DEFAULT); |
|
244 | + $handler = new HtmlHandler(HtmlHandler::default); |
|
245 | 245 | |
246 | 246 | try { |
247 | 247 | $this->makeException(); |
@@ -47,7 +47,7 @@ |
||
47 | 47 | </div> |
48 | 48 | </div> |
49 | 49 | <?php |
50 | - foreach ($valueWrapper->getValues() as $id => $content) { |
|
50 | + foreach ($valueWrapper->getValues() as $id => $content){ |
|
51 | 51 | echo "<div id=\"argument-{$id}\" style=\"display: none\">{$content}</div>"; |
52 | 52 | } |
53 | 53 | ?> |
@@ -47,7 +47,8 @@ |
||
47 | 47 | </div> |
48 | 48 | </div> |
49 | 49 | <?php |
50 | - foreach ($valueWrapper->getValues() as $id => $content) { |
|
50 | + foreach ($valueWrapper->getValues() as $id => $content) |
|
51 | + { |
|
51 | 52 | echo "<div id=\"argument-{$id}\" style=\"display: none\">{$content}</div>"; |
52 | 53 | } |
53 | 54 | ?> |