@@ -17,12 +17,12 @@ |
||
17 | 17 | |
18 | 18 | public function __toString(): string |
19 | 19 | { |
20 | - return (string) $this->value; |
|
20 | + return (string)$this->value; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function setValue(mixed $data): self |
24 | 24 | { |
25 | - $this->value = strtoupper((string) $data); |
|
25 | + $this->value = strtoupper((string)$data); |
|
26 | 26 | |
27 | 27 | return $this; |
28 | 28 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $class = $this->classify($name); |
69 | 69 | $postfix = $this->elementPostfix($element); |
70 | 70 | |
71 | - return \str_ends_with($class, $postfix) ? $class : $class . $postfix; |
|
71 | + return \str_ends_with($class, $postfix) ? $class : $class.$postfix; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function classNamespace(string $element, string $name = ''): string |
78 | 78 | { |
79 | - $localNamespace = \trim((string) $this->getOption($element, 'namespace', ''), '\\'); |
|
79 | + $localNamespace = \trim((string)$this->getOption($element, 'namespace', ''), '\\'); |
|
80 | 80 | ['namespace' => $namespace] = $this->parseName($name); |
81 | 81 | |
82 | - if (!empty($namespace)) { |
|
83 | - $localNamespace .= '\\' . $this->classify($namespace); |
|
82 | + if (!empty($namespace)){ |
|
83 | + $localNamespace .= '\\'.$this->classify($namespace); |
|
84 | 84 | } |
85 | 85 | |
86 | - if (empty($this->baseNamespace($element))) { |
|
86 | + if (empty($this->baseNamespace($element))){ |
|
87 | 87 | return $localNamespace; |
88 | 88 | } |
89 | 89 | |
90 | - return \trim($this->baseNamespace($element) . '\\' . $localNamespace, '\\'); |
|
90 | + return \trim($this->baseNamespace($element).'\\'.$localNamespace, '\\'); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | return $this->joinPathChunks([ |
105 | 105 | $this->declarationDirectory($element), |
106 | 106 | \str_replace('\\', '/', $elementNamespace), |
107 | - $this->className($element, $name) . '.php', |
|
107 | + $this->className($element, $name).'.php', |
|
108 | 108 | ], '/'); |
109 | 109 | } |
110 | 110 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | { |
118 | 118 | $class = $this->getOption($element, 'class'); |
119 | 119 | |
120 | - if (empty($class)) { |
|
120 | + if (empty($class)){ |
|
121 | 121 | throw new ScaffolderException( |
122 | 122 | \sprintf("Unable to scaffold '%s', no declaration class found", $element), |
123 | 123 | ); |
@@ -165,11 +165,11 @@ discard block |
||
165 | 165 | { |
166 | 166 | $declaration = $this->getDeclaration($element); |
167 | 167 | |
168 | - if ($declaration === []) { |
|
168 | + if ($declaration === []){ |
|
169 | 169 | throw new ScaffolderException(\sprintf("Undefined declaration '%s'.", $element)); |
170 | 170 | } |
171 | 171 | |
172 | - if (\array_key_exists($section, $declaration)) { |
|
172 | + if (\array_key_exists($section, $declaration)){ |
|
173 | 173 | return $declaration[$section]; |
174 | 174 | } |
175 | 175 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | { |
188 | 188 | $name = \str_replace('/', '\\', $name); |
189 | 189 | |
190 | - if (str_contains($name, '\\')) { |
|
190 | + if (str_contains($name, '\\')){ |
|
191 | 191 | $names = \explode('\\', $name); |
192 | 192 | $class = \array_pop($names); |
193 | 193 | |
@@ -205,23 +205,23 @@ discard block |
||
205 | 205 | { |
206 | 206 | $declaration = $this->getDeclaration($element); |
207 | 207 | |
208 | - if (\array_key_exists('baseNamespace', $declaration)) { |
|
208 | + if (\array_key_exists('baseNamespace', $declaration)){ |
|
209 | 209 | return \trim((string)$this->getOption($element, 'baseNamespace', ''), '\\'); |
210 | 210 | } |
211 | 211 | |
212 | - return \trim((string) $this->config['namespace'], '\\'); |
|
212 | + return \trim((string)$this->config['namespace'], '\\'); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | private function joinPathChunks(array $chunks, string $joint): string |
216 | 216 | { |
217 | 217 | $firstChunkIterated = false; |
218 | 218 | $joinedPath = ''; |
219 | - foreach ($chunks as $chunk) { |
|
220 | - if (!$firstChunkIterated) { |
|
219 | + foreach ($chunks as $chunk){ |
|
220 | + if (!$firstChunkIterated){ |
|
221 | 221 | $firstChunkIterated = true; |
222 | 222 | $joinedPath = $chunk; |
223 | - } else { |
|
224 | - $joinedPath = \rtrim((string) $joinedPath, $joint) . $joint . \ltrim((string) $chunk, $joint); |
|
223 | + }else{ |
|
224 | + $joinedPath = \rtrim((string)$joinedPath, $joint).$joint.\ltrim((string)$chunk, $joint); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 |
@@ -79,11 +79,13 @@ discard block |
||
79 | 79 | $localNamespace = \trim((string) $this->getOption($element, 'namespace', ''), '\\'); |
80 | 80 | ['namespace' => $namespace] = $this->parseName($name); |
81 | 81 | |
82 | - if (!empty($namespace)) { |
|
82 | + if (!empty($namespace)) |
|
83 | + { |
|
83 | 84 | $localNamespace .= '\\' . $this->classify($namespace); |
84 | 85 | } |
85 | 86 | |
86 | - if (empty($this->baseNamespace($element))) { |
|
87 | + if (empty($this->baseNamespace($element))) |
|
88 | + { |
|
87 | 89 | return $localNamespace; |
88 | 90 | } |
89 | 91 | |
@@ -117,7 +119,8 @@ discard block |
||
117 | 119 | { |
118 | 120 | $class = $this->getOption($element, 'class'); |
119 | 121 | |
120 | - if (empty($class)) { |
|
122 | + if (empty($class)) |
|
123 | + { |
|
121 | 124 | throw new ScaffolderException( |
122 | 125 | \sprintf("Unable to scaffold '%s', no declaration class found", $element), |
123 | 126 | ); |
@@ -165,11 +168,13 @@ discard block |
||
165 | 168 | { |
166 | 169 | $declaration = $this->getDeclaration($element); |
167 | 170 | |
168 | - if ($declaration === []) { |
|
171 | + if ($declaration === []) |
|
172 | + { |
|
169 | 173 | throw new ScaffolderException(\sprintf("Undefined declaration '%s'.", $element)); |
170 | 174 | } |
171 | 175 | |
172 | - if (\array_key_exists($section, $declaration)) { |
|
176 | + if (\array_key_exists($section, $declaration)) |
|
177 | + { |
|
173 | 178 | return $declaration[$section]; |
174 | 179 | } |
175 | 180 | |
@@ -187,7 +192,8 @@ discard block |
||
187 | 192 | { |
188 | 193 | $name = \str_replace('/', '\\', $name); |
189 | 194 | |
190 | - if (str_contains($name, '\\')) { |
|
195 | + if (str_contains($name, '\\')) |
|
196 | + { |
|
191 | 197 | $names = \explode('\\', $name); |
192 | 198 | $class = \array_pop($names); |
193 | 199 | |
@@ -205,7 +211,8 @@ discard block |
||
205 | 211 | { |
206 | 212 | $declaration = $this->getDeclaration($element); |
207 | 213 | |
208 | - if (\array_key_exists('baseNamespace', $declaration)) { |
|
214 | + if (\array_key_exists('baseNamespace', $declaration)) |
|
215 | + { |
|
209 | 216 | return \trim((string)$this->getOption($element, 'baseNamespace', ''), '\\'); |
210 | 217 | } |
211 | 218 | |
@@ -216,11 +223,15 @@ discard block |
||
216 | 223 | { |
217 | 224 | $firstChunkIterated = false; |
218 | 225 | $joinedPath = ''; |
219 | - foreach ($chunks as $chunk) { |
|
220 | - if (!$firstChunkIterated) { |
|
226 | + foreach ($chunks as $chunk) |
|
227 | + { |
|
228 | + if (!$firstChunkIterated) |
|
229 | + { |
|
221 | 230 | $firstChunkIterated = true; |
222 | 231 | $joinedPath = $chunk; |
223 | - } else { |
|
232 | + } |
|
233 | + else |
|
234 | + { |
|
224 | 235 | $joinedPath = \rtrim((string) $joinedPath, $joint) . $joint . \ltrim((string) $chunk, $joint); |
225 | 236 | } |
226 | 237 | } |
@@ -39,14 +39,14 @@ |
||
39 | 39 | { |
40 | 40 | $declaration = $this->createDeclaration(CommandDeclaration::class, [ |
41 | 41 | 'description' => $this->description, |
42 | - 'alias' => $this->alias ?? \strtolower((string) \preg_replace('/(?<!^)[A-Z]/', ':$0', $this->name)), |
|
42 | + 'alias' => $this->alias ?? \strtolower((string)\preg_replace('/(?<!^)[A-Z]/', ':$0', $this->name)), |
|
43 | 43 | ]); |
44 | 44 | |
45 | - foreach ($this->arguments as $argument) { |
|
45 | + foreach ($this->arguments as $argument){ |
|
46 | 46 | $declaration->addArgument($argument); |
47 | 47 | } |
48 | 48 | |
49 | - foreach ($this->options as $option) { |
|
49 | + foreach ($this->options as $option){ |
|
50 | 50 | $declaration->addOption($option); |
51 | 51 | } |
52 | 52 |
@@ -42,11 +42,13 @@ |
||
42 | 42 | 'alias' => $this->alias ?? \strtolower((string) \preg_replace('/(?<!^)[A-Z]/', ':$0', $this->name)), |
43 | 43 | ]); |
44 | 44 | |
45 | - foreach ($this->arguments as $argument) { |
|
45 | + foreach ($this->arguments as $argument) |
|
46 | + { |
|
46 | 47 | $declaration->addArgument($argument); |
47 | 48 | } |
48 | 49 | |
49 | - foreach ($this->options as $option) { |
|
50 | + foreach ($this->options as $option) |
|
51 | + { |
|
50 | 52 | $declaration->addOption($option); |
51 | 53 | } |
52 | 54 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | ): string { |
23 | 23 | $verbosity ??= $this->defaultVerbosity; |
24 | 24 | $exceptions = [$exception]; |
25 | - while ($exception = $exception->getPrevious()) { |
|
25 | + while ($exception = $exception->getPrevious()){ |
|
26 | 26 | $exceptions[] = $exception; |
27 | 27 | } |
28 | 28 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $result = []; |
32 | 32 | $rootDir = \getcwd(); |
33 | 33 | |
34 | - foreach ($exceptions as $exception) { |
|
34 | + foreach ($exceptions as $exception){ |
|
35 | 35 | $file = \str_starts_with($exception->getFile(), $rootDir) |
36 | 36 | ? \substr($exception->getFile(), \strlen($rootDir) + 1) |
37 | 37 | : $exception->getFile(); |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | $exception->getLine(), |
45 | 45 | ); |
46 | 46 | |
47 | - if ($verbosity->value >= Verbosity::DEBUG->value) { |
|
47 | + if ($verbosity->value >= Verbosity::DEBUG->value){ |
|
48 | 48 | $row .= $this->renderTrace($exception, new Highlighter(new PlainStyle())); |
49 | - } elseif ($verbosity->value >= Verbosity::VERBOSE->value) { |
|
49 | + } elseif ($verbosity->value >= Verbosity::VERBOSE->value){ |
|
50 | 50 | $row .= $this->renderTrace($exception); |
51 | 51 | } |
52 | 52 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | private function renderTrace(\Throwable $e, Highlighter $h = null): string |
65 | 65 | { |
66 | 66 | $stacktrace = $this->getStacktrace($e); |
67 | - if ($stacktrace === []) { |
|
67 | + if ($stacktrace === []){ |
|
68 | 68 | return ''; |
69 | 69 | } |
70 | 70 | |
@@ -73,46 +73,46 @@ discard block |
||
73 | 73 | |
74 | 74 | $pad = \strlen((string)\count($stacktrace)); |
75 | 75 | |
76 | - foreach ($stacktrace as $i => $trace) { |
|
77 | - if (isset($trace['type'], $trace['class'])) { |
|
76 | + foreach ($stacktrace as $i => $trace){ |
|
77 | + if (isset($trace['type'], $trace['class'])){ |
|
78 | 78 | $line = \sprintf( |
79 | 79 | '%s. %s%s%s()', |
80 | - \str_pad((string)((int) $i + 1), $pad, ' ', \STR_PAD_LEFT), |
|
80 | + \str_pad((string)((int)$i + 1), $pad, ' ', \STR_PAD_LEFT), |
|
81 | 81 | $trace['class'], |
82 | 82 | $trace['type'], |
83 | 83 | $trace['function'] |
84 | 84 | ); |
85 | - } else { |
|
85 | + }else{ |
|
86 | 86 | $line = $trace['function']; |
87 | 87 | } |
88 | 88 | |
89 | - if (isset($trace['file'])) { |
|
90 | - $file = \str_starts_with((string) $trace['file'], $rootDir) |
|
91 | - ? \substr((string) $trace['file'], \strlen($rootDir) + 1) |
|
89 | + if (isset($trace['file'])){ |
|
90 | + $file = \str_starts_with((string)$trace['file'], $rootDir) |
|
91 | + ? \substr((string)$trace['file'], \strlen($rootDir) + 1) |
|
92 | 92 | : $trace['file']; |
93 | 93 | |
94 | 94 | $line .= \sprintf(' at %s:%s', $file, $trace['line']); |
95 | 95 | } |
96 | 96 | |
97 | - if (\in_array($line, $this->lines, true)) { |
|
97 | + if (\in_array($line, $this->lines, true)){ |
|
98 | 98 | continue; |
99 | 99 | } |
100 | 100 | |
101 | 101 | $this->lines[] = $line; |
102 | 102 | |
103 | - $result .= $line . "\n"; |
|
103 | + $result .= $line."\n"; |
|
104 | 104 | |
105 | - if ($h !== null && !empty($trace['file']) && \is_file($trace['file'])) { |
|
105 | + if ($h !== null && !empty($trace['file']) && \is_file($trace['file'])){ |
|
106 | 106 | $str = @\file_get_contents($trace['file']); |
107 | 107 | $result .= $h->highlightLines( |
108 | 108 | $str, |
109 | 109 | $trace['line'], |
110 | 110 | self::SHOW_LINES |
111 | - ) . "\n"; |
|
111 | + )."\n"; |
|
112 | 112 | unset($str); |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | - return $result . "\n"; |
|
116 | + return $result."\n"; |
|
117 | 117 | } |
118 | 118 | } |
@@ -22,7 +22,8 @@ discard block |
||
22 | 22 | ): string { |
23 | 23 | $verbosity ??= $this->defaultVerbosity; |
24 | 24 | $exceptions = [$exception]; |
25 | - while ($exception = $exception->getPrevious()) { |
|
25 | + while ($exception = $exception->getPrevious()) |
|
26 | + { |
|
26 | 27 | $exceptions[] = $exception; |
27 | 28 | } |
28 | 29 | |
@@ -31,7 +32,8 @@ discard block |
||
31 | 32 | $result = []; |
32 | 33 | $rootDir = \getcwd(); |
33 | 34 | |
34 | - foreach ($exceptions as $exception) { |
|
35 | + foreach ($exceptions as $exception) |
|
36 | + { |
|
35 | 37 | $file = \str_starts_with($exception->getFile(), $rootDir) |
36 | 38 | ? \substr($exception->getFile(), \strlen($rootDir) + 1) |
37 | 39 | : $exception->getFile(); |
@@ -44,9 +46,12 @@ discard block |
||
44 | 46 | $exception->getLine(), |
45 | 47 | ); |
46 | 48 | |
47 | - if ($verbosity->value >= Verbosity::DEBUG->value) { |
|
49 | + if ($verbosity->value >= Verbosity::DEBUG->value) |
|
50 | + { |
|
48 | 51 | $row .= $this->renderTrace($exception, new Highlighter(new PlainStyle())); |
49 | - } elseif ($verbosity->value >= Verbosity::VERBOSE->value) { |
|
52 | + } |
|
53 | + elseif ($verbosity->value >= Verbosity::VERBOSE->value) |
|
54 | + { |
|
50 | 55 | $row .= $this->renderTrace($exception); |
51 | 56 | } |
52 | 57 | |
@@ -64,7 +69,8 @@ discard block |
||
64 | 69 | private function renderTrace(\Throwable $e, Highlighter $h = null): string |
65 | 70 | { |
66 | 71 | $stacktrace = $this->getStacktrace($e); |
67 | - if ($stacktrace === []) { |
|
72 | + if ($stacktrace === []) |
|
73 | + { |
|
68 | 74 | return ''; |
69 | 75 | } |
70 | 76 | |
@@ -73,8 +79,10 @@ discard block |
||
73 | 79 | |
74 | 80 | $pad = \strlen((string)\count($stacktrace)); |
75 | 81 | |
76 | - foreach ($stacktrace as $i => $trace) { |
|
77 | - if (isset($trace['type'], $trace['class'])) { |
|
82 | + foreach ($stacktrace as $i => $trace) |
|
83 | + { |
|
84 | + if (isset($trace['type'], $trace['class'])) |
|
85 | + { |
|
78 | 86 | $line = \sprintf( |
79 | 87 | '%s. %s%s%s()', |
80 | 88 | \str_pad((string)((int) $i + 1), $pad, ' ', \STR_PAD_LEFT), |
@@ -82,11 +90,14 @@ discard block |
||
82 | 90 | $trace['type'], |
83 | 91 | $trace['function'] |
84 | 92 | ); |
85 | - } else { |
|
93 | + } |
|
94 | + else |
|
95 | + { |
|
86 | 96 | $line = $trace['function']; |
87 | 97 | } |
88 | 98 | |
89 | - if (isset($trace['file'])) { |
|
99 | + if (isset($trace['file'])) |
|
100 | + { |
|
90 | 101 | $file = \str_starts_with((string) $trace['file'], $rootDir) |
91 | 102 | ? \substr((string) $trace['file'], \strlen($rootDir) + 1) |
92 | 103 | : $trace['file']; |
@@ -94,7 +105,8 @@ discard block |
||
94 | 105 | $line .= \sprintf(' at %s:%s', $file, $trace['line']); |
95 | 106 | } |
96 | 107 | |
97 | - if (\in_array($line, $this->lines, true)) { |
|
108 | + if (\in_array($line, $this->lines, true)) |
|
109 | + { |
|
98 | 110 | continue; |
99 | 111 | } |
100 | 112 | |
@@ -102,7 +114,8 @@ discard block |
||
102 | 114 | |
103 | 115 | $result .= $line . "\n"; |
104 | 116 | |
105 | - if ($h !== null && !empty($trace['file']) && \is_file($trace['file'])) { |
|
117 | + if ($h !== null && !empty($trace['file']) && \is_file($trace['file'])) |
|
118 | + { |
|
106 | 119 | $str = @\file_get_contents($trace['file']); |
107 | 120 | $result .= $h->highlightLines( |
108 | 121 | $str, |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | { |
14 | 14 | public function __construct( |
15 | 15 | private readonly StyleInterface $renderer |
16 | - ) { |
|
16 | + ){ |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | $lines = \explode("\n", \str_replace("\r\n", "\n", $this->highlight($source))); |
25 | 25 | |
26 | 26 | $result = ''; |
27 | - foreach ($lines as $number => $code) { |
|
27 | + foreach ($lines as $number => $code){ |
|
28 | 28 | $human = $number + 1; |
29 | - if (!empty($around) && ($human < $line - $around || $human >= $line + $around + 1)) { |
|
29 | + if (!empty($around) && ($human < $line - $around || $human >= $line + $around + 1)){ |
|
30 | 30 | //Not included in a range |
31 | 31 | continue; |
32 | 32 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | $result = ''; |
46 | 46 | $previous = []; |
47 | - foreach ($this->getTokens($source) as $token) { |
|
47 | + foreach ($this->getTokens($source) as $token){ |
|
48 | 48 | $result .= $this->renderer->token($token, $previous); |
49 | 49 | $previous = $token; |
50 | 50 | } |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | $tokens = []; |
61 | 61 | $line = 0; |
62 | 62 | |
63 | - foreach (\token_get_all($source) as $token) { |
|
64 | - if (isset($token[2])) { |
|
63 | + foreach (\token_get_all($source) as $token){ |
|
64 | + if (isset($token[2])){ |
|
65 | 65 | $line = $token[2]; |
66 | 66 | } |
67 | 67 | |
68 | - if (!\is_array($token)) { |
|
68 | + if (!\is_array($token)){ |
|
69 | 69 | $token = [$token, $token, $line]; |
70 | 70 | } |
71 | 71 |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $exceptions = [$exception]; |
69 | 69 | $currentE = $exception; |
70 | 70 | |
71 | - while ($exception = $exception->getPrevious()) { |
|
71 | + while ($exception = $exception->getPrevious()){ |
|
72 | 72 | $exceptions[] = $exception; |
73 | 73 | } |
74 | 74 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $result = []; |
78 | 78 | $rootDir = \getcwd(); |
79 | 79 | |
80 | - foreach ($exceptions as $exception) { |
|
80 | + foreach ($exceptions as $exception){ |
|
81 | 81 | $prefix = $currentE === $exception ? '' : 'Previous: '; |
82 | 82 | $row = $this->renderHeader( |
83 | 83 | \sprintf("%s[%s]\n%s", $prefix, $exception::class, $exception->getMessage()), |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | $exception->getLine() |
95 | 95 | ); |
96 | 96 | |
97 | - if ($verbosity->value >= Verbosity::DEBUG->value) { |
|
97 | + if ($verbosity->value >= Verbosity::DEBUG->value){ |
|
98 | 98 | $row .= $this->renderTrace( |
99 | 99 | $exception, |
100 | 100 | new Highlighter( |
101 | 101 | $this->colorsSupport ? new ConsoleStyle() : new PlainStyle() |
102 | 102 | ) |
103 | 103 | ); |
104 | - } elseif ($verbosity->value >= Verbosity::VERBOSE->value) { |
|
104 | + } elseif ($verbosity->value >= Verbosity::VERBOSE->value){ |
|
105 | 105 | $row .= $this->renderTrace($exception); |
106 | 106 | } |
107 | 107 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | $length += $padding; |
134 | 134 | |
135 | - foreach ($lines as $line) { |
|
135 | + foreach ($lines as $line){ |
|
136 | 136 | $result .= $this->format( |
137 | 137 | "<{$style}>%s%s%s</reset>\n", |
138 | 138 | \str_repeat('', $padding + 1), |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | private function renderTrace(\Throwable $e, Highlighter $h = null): string |
151 | 151 | { |
152 | 152 | $stacktrace = $this->getStacktrace($e); |
153 | - if (empty($stacktrace)) { |
|
153 | + if (empty($stacktrace)){ |
|
154 | 154 | return ''; |
155 | 155 | } |
156 | 156 | |
@@ -159,19 +159,19 @@ discard block |
||
159 | 159 | |
160 | 160 | $pad = \strlen((string)\count($stacktrace)); |
161 | 161 | |
162 | - foreach ($stacktrace as $i => $trace) { |
|
162 | + foreach ($stacktrace as $i => $trace){ |
|
163 | 163 | $file = null; |
164 | 164 | $classColor = 'while'; |
165 | 165 | |
166 | - if (isset($trace['file'])) { |
|
167 | - $file = \str_starts_with((string) $trace['file'], $rootDir) |
|
168 | - ? \substr((string) $trace['file'], \strlen($rootDir) + 1) |
|
166 | + if (isset($trace['file'])){ |
|
167 | + $file = \str_starts_with((string)$trace['file'], $rootDir) |
|
168 | + ? \substr((string)$trace['file'], \strlen($rootDir) + 1) |
|
169 | 169 | : $trace['file']; |
170 | 170 | |
171 | - $classColor = \str_starts_with((string) $file, 'vendor/') ? 'gray' : 'white'; |
|
171 | + $classColor = \str_starts_with((string)$file, 'vendor/') ? 'gray' : 'white'; |
|
172 | 172 | } |
173 | 173 | |
174 | - if (isset($trace['type'], $trace['class'])) { |
|
174 | + if (isset($trace['type'], $trace['class'])){ |
|
175 | 175 | $line = $this->format( |
176 | 176 | "<$classColor>%s.</reset> <white>%s%s%s()</reset>", |
177 | 177 | \str_pad((string)((int)$i + 1), $pad, ' ', \STR_PAD_LEFT), |
@@ -179,13 +179,13 @@ discard block |
||
179 | 179 | $trace['type'], |
180 | 180 | $trace['function'] |
181 | 181 | ); |
182 | - } else { |
|
182 | + }else{ |
|
183 | 183 | $line = $this->format( |
184 | 184 | ' <white>%s()</reset>', |
185 | 185 | $trace['function'] |
186 | 186 | ); |
187 | 187 | } |
188 | - if ($file !== null) { |
|
188 | + if ($file !== null){ |
|
189 | 189 | $line .= $this->format( |
190 | 190 | ' <yellow>at</reset> <green>%s</reset><yellow>:</reset><white>%s</reset>', |
191 | 191 | $file, |
@@ -193,21 +193,21 @@ discard block |
||
193 | 193 | ); |
194 | 194 | } |
195 | 195 | |
196 | - if (\in_array($line, $this->lines, true)) { |
|
196 | + if (\in_array($line, $this->lines, true)){ |
|
197 | 197 | continue; |
198 | 198 | } |
199 | 199 | |
200 | 200 | $this->lines[] = $line; |
201 | 201 | |
202 | - $result .= $line . "\n"; |
|
202 | + $result .= $line."\n"; |
|
203 | 203 | |
204 | - if ($h !== null && !empty($trace['file'])) { |
|
204 | + if ($h !== null && !empty($trace['file'])){ |
|
205 | 205 | $str = @\file_get_contents($trace['file']); |
206 | 206 | $result .= $h->highlightLines( |
207 | 207 | $str, |
208 | 208 | $trace['line'], |
209 | 209 | static::SHOW_LINES |
210 | - ) . "\n"; |
|
210 | + )."\n"; |
|
211 | 211 | unset($str); |
212 | 212 | } |
213 | 213 | } |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | */ |
221 | 221 | private function format(string $format, mixed ...$args): string |
222 | 222 | { |
223 | - if (!$this->colorsSupport) { |
|
223 | + if (!$this->colorsSupport){ |
|
224 | 224 | $format = \preg_replace('/<[^>]+>/', '', $format); |
225 | - } else { |
|
226 | - $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial) { |
|
225 | + }else{ |
|
226 | + $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial){ |
|
227 | 227 | $style = ''; |
228 | - foreach (\explode(',', \trim($partial[2], '/')) as $color) { |
|
229 | - if (isset(self::COLORS[$color])) { |
|
228 | + foreach (\explode(',', \trim($partial[2], '/')) as $color){ |
|
229 | + if (isset(self::COLORS[$color])){ |
|
230 | 230 | $style .= self::COLORS[$color]; |
231 | 231 | } |
232 | 232 | } |
@@ -245,12 +245,12 @@ discard block |
||
245 | 245 | */ |
246 | 246 | private function isColorsSupported(mixed $stream = STDOUT): bool |
247 | 247 | { |
248 | - if ('Hyper' === \getenv('TERM_PROGRAM')) { |
|
248 | + if ('Hyper' === \getenv('TERM_PROGRAM')){ |
|
249 | 249 | return true; |
250 | 250 | } |
251 | 251 | |
252 | - try { |
|
253 | - if (\DIRECTORY_SEPARATOR === '\\') { |
|
252 | + try{ |
|
253 | + if (\DIRECTORY_SEPARATOR === '\\'){ |
|
254 | 254 | return (\function_exists('sapi_windows_vt100_support') && @\sapi_windows_vt100_support($stream)) |
255 | 255 | || \getenv('ANSICON') !== false |
256 | 256 | || \getenv('ConEmuANSI') === 'ON' |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | return @\stream_isatty($stream); |
261 | - } catch (\Throwable) { |
|
261 | + }catch (\Throwable){ |
|
262 | 262 | return false; |
263 | 263 | } |
264 | 264 | } |
@@ -68,7 +68,8 @@ discard block |
||
68 | 68 | $exceptions = [$exception]; |
69 | 69 | $currentE = $exception; |
70 | 70 | |
71 | - while ($exception = $exception->getPrevious()) { |
|
71 | + while ($exception = $exception->getPrevious()) |
|
72 | + { |
|
72 | 73 | $exceptions[] = $exception; |
73 | 74 | } |
74 | 75 | |
@@ -77,7 +78,8 @@ discard block |
||
77 | 78 | $result = []; |
78 | 79 | $rootDir = \getcwd(); |
79 | 80 | |
80 | - foreach ($exceptions as $exception) { |
|
81 | + foreach ($exceptions as $exception) |
|
82 | + { |
|
81 | 83 | $prefix = $currentE === $exception ? '' : 'Previous: '; |
82 | 84 | $row = $this->renderHeader( |
83 | 85 | \sprintf("%s[%s]\n%s", $prefix, $exception::class, $exception->getMessage()), |
@@ -94,14 +96,17 @@ discard block |
||
94 | 96 | $exception->getLine() |
95 | 97 | ); |
96 | 98 | |
97 | - if ($verbosity->value >= Verbosity::DEBUG->value) { |
|
99 | + if ($verbosity->value >= Verbosity::DEBUG->value) |
|
100 | + { |
|
98 | 101 | $row .= $this->renderTrace( |
99 | 102 | $exception, |
100 | 103 | new Highlighter( |
101 | 104 | $this->colorsSupport ? new ConsoleStyle() : new PlainStyle() |
102 | 105 | ) |
103 | 106 | ); |
104 | - } elseif ($verbosity->value >= Verbosity::VERBOSE->value) { |
|
107 | + } |
|
108 | + elseif ($verbosity->value >= Verbosity::VERBOSE->value) |
|
109 | + { |
|
105 | 110 | $row .= $this->renderTrace($exception); |
106 | 111 | } |
107 | 112 | |
@@ -132,7 +137,8 @@ discard block |
||
132 | 137 | |
133 | 138 | $length += $padding; |
134 | 139 | |
135 | - foreach ($lines as $line) { |
|
140 | + foreach ($lines as $line) |
|
141 | + { |
|
136 | 142 | $result .= $this->format( |
137 | 143 | "<{$style}>%s%s%s</reset>\n", |
138 | 144 | \str_repeat('', $padding + 1), |
@@ -150,7 +156,8 @@ discard block |
||
150 | 156 | private function renderTrace(\Throwable $e, Highlighter $h = null): string |
151 | 157 | { |
152 | 158 | $stacktrace = $this->getStacktrace($e); |
153 | - if (empty($stacktrace)) { |
|
159 | + if (empty($stacktrace)) |
|
160 | + { |
|
154 | 161 | return ''; |
155 | 162 | } |
156 | 163 | |
@@ -159,11 +166,13 @@ discard block |
||
159 | 166 | |
160 | 167 | $pad = \strlen((string)\count($stacktrace)); |
161 | 168 | |
162 | - foreach ($stacktrace as $i => $trace) { |
|
169 | + foreach ($stacktrace as $i => $trace) |
|
170 | + { |
|
163 | 171 | $file = null; |
164 | 172 | $classColor = 'while'; |
165 | 173 | |
166 | - if (isset($trace['file'])) { |
|
174 | + if (isset($trace['file'])) |
|
175 | + { |
|
167 | 176 | $file = \str_starts_with((string) $trace['file'], $rootDir) |
168 | 177 | ? \substr((string) $trace['file'], \strlen($rootDir) + 1) |
169 | 178 | : $trace['file']; |
@@ -171,7 +180,8 @@ discard block |
||
171 | 180 | $classColor = \str_starts_with((string) $file, 'vendor/') ? 'gray' : 'white'; |
172 | 181 | } |
173 | 182 | |
174 | - if (isset($trace['type'], $trace['class'])) { |
|
183 | + if (isset($trace['type'], $trace['class'])) |
|
184 | + { |
|
175 | 185 | $line = $this->format( |
176 | 186 | "<$classColor>%s.</reset> <white>%s%s%s()</reset>", |
177 | 187 | \str_pad((string)((int)$i + 1), $pad, ' ', \STR_PAD_LEFT), |
@@ -179,13 +189,16 @@ discard block |
||
179 | 189 | $trace['type'], |
180 | 190 | $trace['function'] |
181 | 191 | ); |
182 | - } else { |
|
192 | + } |
|
193 | + else |
|
194 | + { |
|
183 | 195 | $line = $this->format( |
184 | 196 | ' <white>%s()</reset>', |
185 | 197 | $trace['function'] |
186 | 198 | ); |
187 | 199 | } |
188 | - if ($file !== null) { |
|
200 | + if ($file !== null) |
|
201 | + { |
|
189 | 202 | $line .= $this->format( |
190 | 203 | ' <yellow>at</reset> <green>%s</reset><yellow>:</reset><white>%s</reset>', |
191 | 204 | $file, |
@@ -193,7 +206,8 @@ discard block |
||
193 | 206 | ); |
194 | 207 | } |
195 | 208 | |
196 | - if (\in_array($line, $this->lines, true)) { |
|
209 | + if (\in_array($line, $this->lines, true)) |
|
210 | + { |
|
197 | 211 | continue; |
198 | 212 | } |
199 | 213 | |
@@ -201,7 +215,8 @@ discard block |
||
201 | 215 | |
202 | 216 | $result .= $line . "\n"; |
203 | 217 | |
204 | - if ($h !== null && !empty($trace['file'])) { |
|
218 | + if ($h !== null && !empty($trace['file'])) |
|
219 | + { |
|
205 | 220 | $str = @\file_get_contents($trace['file']); |
206 | 221 | $result .= $h->highlightLines( |
207 | 222 | $str, |
@@ -220,13 +235,19 @@ discard block |
||
220 | 235 | */ |
221 | 236 | private function format(string $format, mixed ...$args): string |
222 | 237 | { |
223 | - if (!$this->colorsSupport) { |
|
238 | + if (!$this->colorsSupport) |
|
239 | + { |
|
224 | 240 | $format = \preg_replace('/<[^>]+>/', '', $format); |
225 | - } else { |
|
226 | - $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial) { |
|
241 | + } |
|
242 | + else |
|
243 | + { |
|
244 | + $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial) |
|
245 | + { |
|
227 | 246 | $style = ''; |
228 | - foreach (\explode(',', \trim($partial[2], '/')) as $color) { |
|
229 | - if (isset(self::COLORS[$color])) { |
|
247 | + foreach (\explode(',', \trim($partial[2], '/')) as $color) |
|
248 | + { |
|
249 | + if (isset(self::COLORS[$color])) |
|
250 | + { |
|
230 | 251 | $style .= self::COLORS[$color]; |
231 | 252 | } |
232 | 253 | } |
@@ -245,12 +266,15 @@ discard block |
||
245 | 266 | */ |
246 | 267 | private function isColorsSupported(mixed $stream = STDOUT): bool |
247 | 268 | { |
248 | - if ('Hyper' === \getenv('TERM_PROGRAM')) { |
|
269 | + if ('Hyper' === \getenv('TERM_PROGRAM')) |
|
270 | + { |
|
249 | 271 | return true; |
250 | 272 | } |
251 | 273 | |
252 | - try { |
|
253 | - if (\DIRECTORY_SEPARATOR === '\\') { |
|
274 | + try |
|
275 | + { |
|
276 | + if (\DIRECTORY_SEPARATOR === '\\') |
|
277 | + { |
|
254 | 278 | return (\function_exists('sapi_windows_vt100_support') && @\sapi_windows_vt100_support($stream)) |
255 | 279 | || \getenv('ANSICON') !== false |
256 | 280 | || \getenv('ConEmuANSI') === 'ON' |
@@ -258,7 +282,9 @@ discard block |
||
258 | 282 | } |
259 | 283 | |
260 | 284 | return @\stream_isatty($stream); |
261 | - } catch (\Throwable) { |
|
285 | + } |
|
286 | + catch (\Throwable) |
|
287 | + { |
|
262 | 288 | return false; |
263 | 289 | } |
264 | 290 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | { |
13 | 13 | public function __construct( |
14 | 14 | private readonly LoggerInterface $logger = new NullLogger() |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public function report(\Throwable $exception): void |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | private readonly Verbosity $verbosity, |
20 | 20 | private readonly ExceptionRendererInterface $renderer, |
21 | 21 | private readonly FilesInterface $files |
22 | - ) { |
|
22 | + ){ |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function create(\Throwable $e): SnapshotInterface |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | ); |
56 | 56 | |
57 | 57 | $count = 0; |
58 | - foreach ($finder as $file) { |
|
58 | + foreach ($finder as $file){ |
|
59 | 59 | $count++; |
60 | - if ($count > $this->maxFiles) { |
|
61 | - try { |
|
60 | + if ($count > $this->maxFiles){ |
|
61 | + try{ |
|
62 | 62 | $this->files->delete($file->getRealPath()); |
63 | - } catch (FilesException) { |
|
63 | + }catch (FilesException){ |
|
64 | 64 | // ignore |
65 | 65 | } |
66 | 66 | } |
@@ -18,22 +18,22 @@ discard block |
||
18 | 18 | { |
19 | 19 | $lines = \explode("\n", $comment); |
20 | 20 | |
21 | - foreach ($lines as $line) { |
|
21 | + foreach ($lines as $line){ |
|
22 | 22 | // strip up comment prefix |
23 | 23 | $line = \preg_replace('/[\t ]*[\/]?\*[\/]? ?/', '', $line); |
24 | 24 | |
25 | - if (\preg_match('/ *@([^ ]+) (.*)/u', (string) $line, $matches)) { |
|
25 | + if (\preg_match('/ *@([^ ]+) (.*)/u', (string)$line, $matches)){ |
|
26 | 26 | $this->lines[] = new Line($matches[2], $matches[1]); |
27 | - } else { |
|
27 | + }else{ |
|
28 | 28 | $this->lines[] = new Line($line); |
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | - if (isset($this->lines[0]) && $this->lines[0]->isEmpty()) { |
|
32 | + if (isset($this->lines[0]) && $this->lines[0]->isEmpty()){ |
|
33 | 33 | \array_shift($this->lines); |
34 | 34 | } |
35 | 35 | |
36 | - if (isset($this->lines[\count($this->lines) - 1]) && $this->lines[\count($this->lines) - 1]->isEmpty()) { |
|
36 | + if (isset($this->lines[\count($this->lines) - 1]) && $this->lines[\count($this->lines) - 1]->isEmpty()){ |
|
37 | 37 | \array_pop($this->lines); |
38 | 38 | } |
39 | 39 | } |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | $result[] = '/**'; |
45 | 45 | |
46 | 46 | // skip first and last tokens |
47 | - foreach ($this->lines as $line) { |
|
48 | - if ($line->type === null) { |
|
47 | + foreach ($this->lines as $line){ |
|
48 | + if ($line->type === null){ |
|
49 | 49 | $result[] = \sprintf(' * %s', $line->value); |
50 | 50 | continue; |
51 | 51 | } |
@@ -18,22 +18,28 @@ discard block |
||
18 | 18 | { |
19 | 19 | $lines = \explode("\n", $comment); |
20 | 20 | |
21 | - foreach ($lines as $line) { |
|
21 | + foreach ($lines as $line) |
|
22 | + { |
|
22 | 23 | // strip up comment prefix |
23 | 24 | $line = \preg_replace('/[\t ]*[\/]?\*[\/]? ?/', '', $line); |
24 | 25 | |
25 | - if (\preg_match('/ *@([^ ]+) (.*)/u', (string) $line, $matches)) { |
|
26 | + if (\preg_match('/ *@([^ ]+) (.*)/u', (string) $line, $matches)) |
|
27 | + { |
|
26 | 28 | $this->lines[] = new Line($matches[2], $matches[1]); |
27 | - } else { |
|
29 | + } |
|
30 | + else |
|
31 | + { |
|
28 | 32 | $this->lines[] = new Line($line); |
29 | 33 | } |
30 | 34 | } |
31 | 35 | |
32 | - if (isset($this->lines[0]) && $this->lines[0]->isEmpty()) { |
|
36 | + if (isset($this->lines[0]) && $this->lines[0]->isEmpty()) |
|
37 | + { |
|
33 | 38 | \array_shift($this->lines); |
34 | 39 | } |
35 | 40 | |
36 | - if (isset($this->lines[\count($this->lines) - 1]) && $this->lines[\count($this->lines) - 1]->isEmpty()) { |
|
41 | + if (isset($this->lines[\count($this->lines) - 1]) && $this->lines[\count($this->lines) - 1]->isEmpty()) |
|
42 | + { |
|
37 | 43 | \array_pop($this->lines); |
38 | 44 | } |
39 | 45 | } |
@@ -44,8 +50,10 @@ discard block |
||
44 | 50 | $result[] = '/**'; |
45 | 51 | |
46 | 52 | // skip first and last tokens |
47 | - foreach ($this->lines as $line) { |
|
48 | - if ($line->type === null) { |
|
53 | + foreach ($this->lines as $line) |
|
54 | + { |
|
55 | + if ($line->type === null) |
|
56 | + { |
|
49 | 57 | $result[] = \sprintf(' * %s', $line->value); |
50 | 58 | continue; |
51 | 59 | } |