@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | protected function getStacktrace(\Throwable $e): array |
34 | 34 | { |
35 | 35 | $stacktrace = $e->getTrace(); |
36 | - if (empty($stacktrace)) { |
|
36 | + if (empty($stacktrace)){ |
|
37 | 37 | return []; |
38 | 38 | } |
39 | 39 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | 'line' => $e->getLine(), |
44 | 44 | ] + $stacktrace[0]; |
45 | 45 | |
46 | - if ($stacktrace[0] != $header) { |
|
46 | + if ($stacktrace[0] != $header){ |
|
47 | 47 | array_unshift($stacktrace, $header); |
48 | 48 | } |
49 | 49 |
@@ -33,7 +33,8 @@ discard block |
||
33 | 33 | protected function getStacktrace(\Throwable $e): array |
34 | 34 | { |
35 | 35 | $stacktrace = $e->getTrace(); |
36 | - if (empty($stacktrace)) { |
|
36 | + if (empty($stacktrace)) |
|
37 | + { |
|
37 | 38 | return []; |
38 | 39 | } |
39 | 40 | |
@@ -43,7 +44,8 @@ discard block |
||
43 | 44 | 'line' => $e->getLine(), |
44 | 45 | ] + $stacktrace[0]; |
45 | 46 | |
46 | - if ($stacktrace[0] != $header) { |
|
47 | + if ($stacktrace[0] != $header) |
|
48 | + { |
|
47 | 49 | array_unshift($stacktrace, $header); |
48 | 50 | } |
49 | 51 |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | $this->style = $style; |
51 | 51 | $this->dumper = new Dumper(); |
52 | 52 | |
53 | - if ($style == self::INVERTED) { |
|
53 | + if ($style == self::INVERTED){ |
|
54 | 54 | $this->renderer = new HtmlRenderer(HtmlRenderer::INVERTED); |
55 | 55 | $this->highlighter = new Highlighter(new HtmlStyle(HtmlStyle::INVERTED)); |
56 | - } else { |
|
56 | + }else{ |
|
57 | 57 | $this->renderer = new HtmlRenderer(HtmlRenderer::DEFAULT); |
58 | 58 | $this->highlighter = new Highlighter(new HtmlStyle(HtmlStyle::DEFAULT)); |
59 | 59 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'message' => $this->getMessage($e), |
83 | 83 | 'exception' => $e, |
84 | 84 | 'valueWrapper' => new ValueWrapper($this->dumper, $this->renderer, $verbosity), |
85 | - 'style' => $this->render('styles/' . $this->style), |
|
85 | + 'style' => $this->render('styles/'.$this->style), |
|
86 | 86 | 'footer' => $this->render('partials/footer'), |
87 | 87 | 'variables' => '', |
88 | 88 | 'logs' => '', |
@@ -105,20 +105,20 @@ discard block |
||
105 | 105 | 'valueWrapper' => $options['valueWrapper'], |
106 | 106 | ]); |
107 | 107 | |
108 | - if ($this->state !== null) { |
|
109 | - if ($this->state->getTags() !== []) { |
|
108 | + if ($this->state !== null){ |
|
109 | + if ($this->state->getTags() !== []){ |
|
110 | 110 | $options['tags'] = $this->render('partials/tags', [ |
111 | 111 | 'tags' => $this->state->getTags(), |
112 | 112 | ]); |
113 | 113 | } |
114 | 114 | |
115 | - if ($this->state->getLogEvents() !== []) { |
|
115 | + if ($this->state->getLogEvents() !== []){ |
|
116 | 116 | $options['logs'] = $this->render('partials/logs', [ |
117 | 117 | 'logEvents' => $this->state->getLogEvents(), |
118 | 118 | ]); |
119 | 119 | } |
120 | 120 | |
121 | - if ($this->state->getVariables() !== []) { |
|
121 | + if ($this->state->getVariables() !== []){ |
|
122 | 122 | $options['variables'] = $this->render('partials/variables', [ |
123 | 123 | 'variables' => $this->state->getVariables(), |
124 | 124 | ]); |
@@ -50,10 +50,13 @@ discard block |
||
50 | 50 | $this->style = $style; |
51 | 51 | $this->dumper = new Dumper(); |
52 | 52 | |
53 | - if ($style == self::INVERTED) { |
|
53 | + if ($style == self::INVERTED) |
|
54 | + { |
|
54 | 55 | $this->renderer = new HtmlRenderer(HtmlRenderer::INVERTED); |
55 | 56 | $this->highlighter = new Highlighter(new HtmlStyle(HtmlStyle::INVERTED)); |
56 | - } else { |
|
57 | + } |
|
58 | + else |
|
59 | + { |
|
57 | 60 | $this->renderer = new HtmlRenderer(HtmlRenderer::DEFAULT); |
58 | 61 | $this->highlighter = new Highlighter(new HtmlStyle(HtmlStyle::DEFAULT)); |
59 | 62 | } |
@@ -105,20 +108,24 @@ discard block |
||
105 | 108 | 'valueWrapper' => $options['valueWrapper'], |
106 | 109 | ]); |
107 | 110 | |
108 | - if ($this->state !== null) { |
|
109 | - if ($this->state->getTags() !== []) { |
|
111 | + if ($this->state !== null) |
|
112 | + { |
|
113 | + if ($this->state->getTags() !== []) |
|
114 | + { |
|
110 | 115 | $options['tags'] = $this->render('partials/tags', [ |
111 | 116 | 'tags' => $this->state->getTags(), |
112 | 117 | ]); |
113 | 118 | } |
114 | 119 | |
115 | - if ($this->state->getLogEvents() !== []) { |
|
120 | + if ($this->state->getLogEvents() !== []) |
|
121 | + { |
|
116 | 122 | $options['logs'] = $this->render('partials/logs', [ |
117 | 123 | 'logEvents' => $this->state->getLogEvents(), |
118 | 124 | ]); |
119 | 125 | } |
120 | 126 | |
121 | - if ($this->state->getVariables() !== []) { |
|
127 | + if ($this->state->getVariables() !== []) |
|
128 | + { |
|
122 | 129 | $options['variables'] = $this->render('partials/variables', [ |
123 | 130 | 'variables' => $this->state->getVariables(), |
124 | 131 | ]); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * Visual styles. |
26 | 26 | */ |
27 | - public const DEFAULT = 'default'; |
|
27 | + public const default = 'default'; |
|
28 | 28 | public const INVERTED = 'inverted'; |
29 | 29 | |
30 | 30 | /** @var HtmlRenderer */ |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | protected $highlighter; |
35 | 35 | |
36 | 36 | /** @var string */ |
37 | - protected $style = self::DEFAULT; |
|
37 | + protected $style = self::default; |
|
38 | 38 | |
39 | 39 | /** @var Dumper */ |
40 | 40 | protected $dumper; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | /** @var StateInterface|null */ |
43 | 43 | protected $state; |
44 | 44 | |
45 | - public function __construct(string $style = self::DEFAULT) |
|
45 | + public function __construct(string $style = self::default) |
|
46 | 46 | { |
47 | 47 | $this->style = $style; |
48 | 48 | $this->dumper = new Dumper(); |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | $this->renderer = new HtmlRenderer(HtmlRenderer::INVERTED); |
52 | 52 | $this->highlighter = new Highlighter(new HtmlStyle(HtmlStyle::INVERTED)); |
53 | 53 | } else { |
54 | - $this->renderer = new HtmlRenderer(HtmlRenderer::DEFAULT); |
|
55 | - $this->highlighter = new Highlighter(new HtmlStyle(HtmlStyle::DEFAULT)); |
|
54 | + $this->renderer = new HtmlRenderer(HtmlRenderer::default); |
|
55 | + $this->highlighter = new Highlighter(new HtmlStyle(HtmlStyle::default)); |
|
56 | 56 | } |
57 | 57 | |
58 | - $this->dumper->setRenderer(Dumper::RETURN, $this->renderer); |
|
58 | + $this->dumper->setRenderer(Dumper::return, $this->renderer); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | public function withState(StateInterface $state): HandlerInterface |
@@ -50,18 +50,21 @@ |
||
50 | 50 | public function execute(ContainerInterface $container, OutputInterface $output): void |
51 | 51 | { |
52 | 52 | $function = $this->function; |
53 | - if (is_string($function) && strpos($function, ':') !== false) { |
|
53 | + if (is_string($function) && strpos($function, ':') !== false) |
|
54 | + { |
|
54 | 55 | $function = explode(':', str_replace('::', ':', $function)); |
55 | 56 | } |
56 | 57 | |
57 | - if (is_array($function) && isset($function[0]) && !is_object($function[0])) { |
|
58 | + if (is_array($function) && isset($function[0]) && !is_object($function[0])) |
|
59 | + { |
|
58 | 60 | $function[0] = $container->get($function[0]); |
59 | 61 | } |
60 | 62 | |
61 | 63 | /** @var ResolverInterface $resolver */ |
62 | 64 | $resolver = $container->get(ResolverInterface::class); |
63 | 65 | |
64 | - if (is_array($function)) { |
|
66 | + if (is_array($function)) |
|
67 | + { |
|
65 | 68 | $reflection = new \ReflectionMethod($function[0], $function[1]); |
66 | 69 | $reflection->invokeArgs($function[0], $resolver->resolveArguments($reflection, [ |
67 | 70 | 'output' => $output, |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | array $parameters = [], |
32 | 32 | string $header = '', |
33 | 33 | string $footer = '' |
34 | - ) { |
|
34 | + ){ |
|
35 | 35 | $this->function = $function; |
36 | 36 | |
37 | 37 | parent::__construct($header, $footer); |
@@ -43,18 +43,18 @@ discard block |
||
43 | 43 | public function execute(ContainerInterface $container, OutputInterface $output): void |
44 | 44 | { |
45 | 45 | $function = $this->function; |
46 | - if (is_string($function) && strpos($function, ':') !== false) { |
|
46 | + if (is_string($function) && strpos($function, ':') !== false){ |
|
47 | 47 | $function = explode(':', str_replace('::', ':', $function)); |
48 | 48 | } |
49 | 49 | |
50 | - if (is_array($function) && isset($function[0]) && !is_object($function[0])) { |
|
50 | + if (is_array($function) && isset($function[0]) && !is_object($function[0])){ |
|
51 | 51 | $function[0] = $container->get($function[0]); |
52 | 52 | } |
53 | 53 | |
54 | 54 | /** @var ResolverInterface $resolver */ |
55 | 55 | $resolver = $container->get(ResolverInterface::class); |
56 | 56 | |
57 | - if (is_array($function)) { |
|
57 | + if (is_array($function)){ |
|
58 | 58 | $reflection = new \ReflectionMethod($function[0], $function[1]); |
59 | 59 | $reflection->invokeArgs($function[0], $resolver->resolveArguments($reflection, [ |
60 | 60 | 'output' => $output, |
@@ -38,7 +38,7 @@ |
||
38 | 38 | AbstractDeclaration::ACCESS_PROTECTED, |
39 | 39 | AbstractDeclaration::ACCESS_PUBLIC, |
40 | 40 | ], true) |
41 | - ) { |
|
41 | + ){ |
|
42 | 42 | throw new ReactorException("Invalid declaration level '{$access}'"); |
43 | 43 | } |
44 | 44 |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | RendererInterface $renderer, |
60 | 60 | ResponseFactoryInterface $responseFactory, |
61 | 61 | ContainerInterface $container |
62 | - ) { |
|
62 | + ){ |
|
63 | 63 | $this->suppressErrors = $suppressErrors; |
64 | 64 | $this->renderer = $renderer; |
65 | 65 | $this->responseFactory = $responseFactory; |
@@ -73,22 +73,22 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function process(Request $request, Handler $handler): Response |
75 | 75 | { |
76 | - try { |
|
76 | + try{ |
|
77 | 77 | return $handler->handle($request); |
78 | - } catch (ClientException | RouterException $e) { |
|
79 | - if ($e instanceof ClientException) { |
|
78 | + }catch (ClientException | RouterException $e){ |
|
79 | + if ($e instanceof ClientException){ |
|
80 | 80 | $code = $e->getCode(); |
81 | - } else { |
|
81 | + }else{ |
|
82 | 82 | $code = 404; |
83 | 83 | } |
84 | - } catch (\Throwable $e) { |
|
84 | + }catch (\Throwable $e){ |
|
85 | 85 | $snapshotter = $this->getOptional(SnapshotterInterface::class); |
86 | - if ($snapshotter !== null) { |
|
86 | + if ($snapshotter !== null){ |
|
87 | 87 | /** @var SnapshotterInterface $snapshotter */ |
88 | 88 | $snapshotter->register($e); |
89 | 89 | } |
90 | 90 | |
91 | - if (!$this->suppressErrors->suppressed()) { |
|
91 | + if (!$this->suppressErrors->suppressed()){ |
|
92 | 92 | return $this->renderError($request, $e); |
93 | 93 | } |
94 | 94 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | { |
112 | 112 | $response = $this->responseFactory->createResponse(500); |
113 | 113 | |
114 | - if ($request->getHeaderLine('Accept') === 'application/json') { |
|
114 | + if ($request->getHeaderLine('Accept') === 'application/json'){ |
|
115 | 115 | $response = $response->withHeader('Content-Type', 'application/json'); |
116 | 116 | $handler = new JsonHandler(); |
117 | 117 | $response->getBody()->write( |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | ) |
124 | 124 | ) |
125 | 125 | ); |
126 | - } else { |
|
126 | + }else{ |
|
127 | 127 | $handler = new HtmlHandler(); |
128 | 128 | $state = $this->getOptional(StateInterface::class); |
129 | - if ($state !== null) { |
|
129 | + if ($state !== null){ |
|
130 | 130 | $handler = $handler->withState($state); |
131 | 131 | } |
132 | 132 | |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | */ |
163 | 163 | private function getOptional(string $class) |
164 | 164 | { |
165 | - try { |
|
165 | + try{ |
|
166 | 166 | return $this->container->get($class); |
167 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
167 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
168 | 168 | return null; |
169 | 169 | } |
170 | 170 | } |
@@ -73,22 +73,32 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function process(Request $request, Handler $handler): Response |
75 | 75 | { |
76 | - try { |
|
76 | + try |
|
77 | + { |
|
77 | 78 | return $handler->handle($request); |
78 | - } catch (ClientException | RouterException $e) { |
|
79 | - if ($e instanceof ClientException) { |
|
79 | + } |
|
80 | + catch (ClientException | RouterException $e) |
|
81 | + { |
|
82 | + if ($e instanceof ClientException) |
|
83 | + { |
|
80 | 84 | $code = $e->getCode(); |
81 | - } else { |
|
85 | + } |
|
86 | + else |
|
87 | + { |
|
82 | 88 | $code = 404; |
83 | 89 | } |
84 | - } catch (\Throwable $e) { |
|
90 | + } |
|
91 | + catch (\Throwable $e) |
|
92 | + { |
|
85 | 93 | $snapshotter = $this->getOptional(SnapshotterInterface::class); |
86 | - if ($snapshotter !== null) { |
|
94 | + if ($snapshotter !== null) |
|
95 | + { |
|
87 | 96 | /** @var SnapshotterInterface $snapshotter */ |
88 | 97 | $snapshotter->register($e); |
89 | 98 | } |
90 | 99 | |
91 | - if (!$this->suppressErrors->suppressed()) { |
|
100 | + if (!$this->suppressErrors->suppressed()) |
|
101 | + { |
|
92 | 102 | return $this->renderError($request, $e); |
93 | 103 | } |
94 | 104 | |
@@ -111,7 +121,8 @@ discard block |
||
111 | 121 | { |
112 | 122 | $response = $this->responseFactory->createResponse(500); |
113 | 123 | |
114 | - if ($request->getHeaderLine('Accept') === 'application/json') { |
|
124 | + if ($request->getHeaderLine('Accept') === 'application/json') |
|
125 | + { |
|
115 | 126 | $response = $response->withHeader('Content-Type', 'application/json'); |
116 | 127 | $handler = new JsonHandler(); |
117 | 128 | $response->getBody()->write( |
@@ -123,10 +134,13 @@ discard block |
||
123 | 134 | ) |
124 | 135 | ) |
125 | 136 | ); |
126 | - } else { |
|
137 | + } |
|
138 | + else |
|
139 | + { |
|
127 | 140 | $handler = new HtmlHandler(); |
128 | 141 | $state = $this->getOptional(StateInterface::class); |
129 | - if ($state !== null) { |
|
142 | + if ($state !== null) |
|
143 | + { |
|
130 | 144 | $handler = $handler->withState($state); |
131 | 145 | } |
132 | 146 | |
@@ -162,9 +176,12 @@ discard block |
||
162 | 176 | */ |
163 | 177 | private function getOptional(string $class) |
164 | 178 | { |
165 | - try { |
|
179 | + try |
|
180 | + { |
|
166 | 181 | return $this->container->get($class); |
167 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
182 | + } |
|
183 | + catch (\Throwable | ContainerExceptionInterface $se) |
|
184 | + { |
|
168 | 185 | return null; |
169 | 186 | } |
170 | 187 | } |
@@ -54,11 +54,11 @@ |
||
54 | 54 | /** @var ControllerDeclaration $declaration */ |
55 | 55 | $declaration = $this->createDeclaration(); |
56 | 56 | |
57 | - foreach ($this->option('action') as $action) { |
|
57 | + foreach ($this->option('action') as $action){ |
|
58 | 58 | $declaration->addAction($action); |
59 | 59 | } |
60 | 60 | |
61 | - if ((bool)$this->option('prototype')) { |
|
61 | + if ((bool)$this->option('prototype')){ |
|
62 | 62 | $declaration->addPrototypeTrait(); |
63 | 63 | } |
64 | 64 |
@@ -54,11 +54,13 @@ |
||
54 | 54 | /** @var ControllerDeclaration $declaration */ |
55 | 55 | $declaration = $this->createDeclaration(); |
56 | 56 | |
57 | - foreach ($this->option('action') as $action) { |
|
57 | + foreach ($this->option('action') as $action) |
|
58 | + { |
|
58 | 59 | $declaration->addAction($action); |
59 | 60 | } |
60 | 61 | |
61 | - if ((bool)$this->option('prototype')) { |
|
62 | + if ((bool)$this->option('prototype')) |
|
63 | + { |
|
62 | 64 | $declaration->addPrototypeTrait(); |
63 | 65 | } |
64 | 66 |
@@ -60,10 +60,10 @@ |
||
60 | 60 | /** @var MigrationDeclaration $declaration */ |
61 | 61 | $declaration = $this->createDeclaration(); |
62 | 62 | |
63 | - if (!empty($this->option('table'))) { |
|
63 | + if (!empty($this->option('table'))){ |
|
64 | 64 | $fields = []; |
65 | - foreach ($this->option('field') as $field) { |
|
66 | - if (strpos($field, ':') === false) { |
|
65 | + foreach ($this->option('field') as $field){ |
|
66 | + if (strpos($field, ':') === false){ |
|
67 | 67 | throw new ScaffolderException("Field definition must in 'name:type' form"); |
68 | 68 | } |
69 | 69 |
@@ -60,10 +60,13 @@ |
||
60 | 60 | /** @var MigrationDeclaration $declaration */ |
61 | 61 | $declaration = $this->createDeclaration(); |
62 | 62 | |
63 | - if (!empty($this->option('table'))) { |
|
63 | + if (!empty($this->option('table'))) |
|
64 | + { |
|
64 | 65 | $fields = []; |
65 | - foreach ($this->option('field') as $field) { |
|
66 | - if (strpos($field, ':') === false) { |
|
66 | + foreach ($this->option('field') as $field) |
|
67 | + { |
|
68 | + if (strpos($field, ':') === false) |
|
69 | + { |
|
67 | 70 | throw new ScaffolderException("Field definition must in 'name:type' form"); |
68 | 71 | } |
69 | 72 |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | FilesInterface $files, |
52 | 52 | ContainerInterface $container, |
53 | 53 | FactoryInterface $factory |
54 | - ) { |
|
54 | + ){ |
|
55 | 55 | $this->config = $config; |
56 | 56 | $this->files = $files; |
57 | 57 | $this->factory = $factory; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $filename = $this->config->classFilename($type, (string)$this->argument('name')); |
111 | 111 | $filename = $this->files->normalizePath($filename); |
112 | 112 | |
113 | - if ($this->files->exists($filename)) { |
|
113 | + if ($this->files->exists($filename)){ |
|
114 | 114 | $this->writeln( |
115 | 115 | "<fg=red>Unable to create '<comment>{$declaration->getName()}</comment>' declaration, " |
116 | 116 | . "file '<comment>{$filename}</comment>' already exists.</fg=red>" |
@@ -110,7 +110,8 @@ |
||
110 | 110 | $filename = $this->config->classFilename($type, (string)$this->argument('name')); |
111 | 111 | $filename = $this->files->normalizePath($filename); |
112 | 112 | |
113 | - if ($this->files->exists($filename)) { |
|
113 | + if ($this->files->exists($filename)) |
|
114 | + { |
|
114 | 115 | $this->writeln( |
115 | 116 | "<fg=red>Unable to create '<comment>{$declaration->getName()}</comment>' declaration, " |
116 | 117 | . "file '<comment>{$filename}</comment>' already exists.</fg=red>" |
@@ -114,7 +114,7 @@ |
||
114 | 114 | $this->files->write( |
115 | 115 | $filename, |
116 | 116 | $file->render(), |
117 | - FilesInterface::READONLY, |
|
117 | + FilesInterface::readonly, |
|
118 | 118 | true |
119 | 119 | ); |
120 | 120 |
@@ -26,7 +26,7 @@ |
||
26 | 26 | ['name', InputArgument::REQUIRED, 'Command name'], |
27 | 27 | ['alias', InputArgument::OPTIONAL, 'Command id/alias'], |
28 | 28 | ]; |
29 | - protected const OPTIONS = [ |
|
29 | + protected const OPTIONS = [ |
|
30 | 30 | [ |
31 | 31 | 'description', |
32 | 32 | 'd', |