@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public static function isCLI(): bool |
26 | 26 | { |
27 | - if (!empty(getenv('RR'))) { |
|
27 | + if (!empty(getenv('RR'))){ |
|
28 | 28 | // Do not treat RoadRunner as CLI. |
29 | 29 | return false; |
30 | 30 | } |
31 | 31 | |
32 | - if (php_sapi_name() === 'cli') { |
|
32 | + if (php_sapi_name() === 'cli'){ |
|
33 | 33 | return true; |
34 | 34 | } |
35 | 35 | |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public static function isColorsSupported($stream = STDOUT): bool |
48 | 48 | { |
49 | - if ('Hyper' === getenv('TERM_PROGRAM')) { |
|
49 | + if ('Hyper' === getenv('TERM_PROGRAM')){ |
|
50 | 50 | return true; |
51 | 51 | } |
52 | 52 | |
53 | - try { |
|
54 | - if (\DIRECTORY_SEPARATOR === '\\') { |
|
53 | + try{ |
|
54 | + if (\DIRECTORY_SEPARATOR === '\\'){ |
|
55 | 55 | return ( |
56 | 56 | function_exists('sapi_windows_vt100_support') |
57 | 57 | && @sapi_windows_vt100_support($stream) |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | || getenv('TERM') == 'xterm'; |
61 | 61 | } |
62 | 62 | |
63 | - if (\function_exists('stream_isatty')) { |
|
63 | + if (\function_exists('stream_isatty')){ |
|
64 | 64 | return @stream_isatty($stream); |
65 | 65 | } |
66 | 66 | |
67 | - if (\function_exists('posix_isatty')) { |
|
67 | + if (\function_exists('posix_isatty')){ |
|
68 | 68 | return @posix_isatty($stream); |
69 | 69 | } |
70 | 70 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | // Check if formatted mode is S_IFCHR |
74 | 74 | return $stat ? 0020000 === ($stat['mode'] & 0170000) : false; |
75 | - } catch (\Throwable $e) { |
|
75 | + }catch (\Throwable $e){ |
|
76 | 76 | return false; |
77 | 77 | } |
78 | 78 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | use Spiral\Debug\Dumper; |
13 | 13 | |
14 | -if (! function_exists('dump')) { |
|
14 | +if (!function_exists('dump')){ |
|
15 | 15 | /** |
16 | 16 | * Dump value. |
17 | 17 | * |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function dump($value, int $output = Dumper::OUTPUT): ?string |
24 | 24 | { |
25 | - if (! class_exists(\Spiral\Core\ContainerScope::class)) { |
|
25 | + if (!class_exists(\Spiral\Core\ContainerScope::class)){ |
|
26 | 26 | return (new Dumper())->dump($value, $output); |
27 | 27 | } |
28 | 28 | |
29 | 29 | $container = \Spiral\Core\ContainerScope::getContainer(); |
30 | - if (is_null($container) || ! $container->has(Dumper::class)) { |
|
30 | + if (is_null($container) || !$container->has(Dumper::class)){ |
|
31 | 31 | $dumper = new Dumper(); |
32 | 32 | |
33 | 33 | return $dumper->dump($value, $output); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function __construct(LoggerInterface $logger = null) |
60 | 60 | { |
61 | - if (!empty($logger)) { |
|
61 | + if (!empty($logger)){ |
|
62 | 62 | $this->setLogger($logger); |
63 | 63 | } |
64 | 64 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $r = $this->getRenderer($target); |
87 | 87 | $dump = $r->wrapContent($this->renderValue($r, $value)); |
88 | 88 | |
89 | - switch ($target) { |
|
89 | + switch ($target){ |
|
90 | 90 | case self::OUTPUT: |
91 | 91 | echo $dump; |
92 | 92 | break; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | return $dump; |
96 | 96 | |
97 | 97 | case self::LOGGER: |
98 | - if ($this->logger == null) { |
|
98 | + if ($this->logger == null){ |
|
99 | 99 | throw new DumperException('Unable to dump value to log, no associated LoggerInterface'); |
100 | 100 | } |
101 | 101 | $this->logger->debug($dump); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function setRenderer(int $target, RendererInterface $renderer): Dumper |
121 | 121 | { |
122 | - if (!isset($this->targets[$target])) { |
|
122 | + if (!isset($this->targets[$target])){ |
|
123 | 123 | throw new DumperException(sprintf('Undefined dump target %d', $target)); |
124 | 124 | } |
125 | 125 | |
@@ -138,19 +138,19 @@ discard block |
||
138 | 138 | */ |
139 | 139 | private function getRenderer(int $target): RendererInterface |
140 | 140 | { |
141 | - if ($target == self::OUTPUT && System::isCLI()) { |
|
142 | - if (System::isColorsSupported(STDOUT)) { |
|
141 | + if ($target == self::OUTPUT && System::isCLI()){ |
|
142 | + if (System::isColorsSupported(STDOUT)){ |
|
143 | 143 | $target = self::OUTPUT_CLI_COLORS; |
144 | - } else { |
|
144 | + }else{ |
|
145 | 145 | $target = self::OUTPUT_CLI; |
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | - if (!isset($this->targets[$target])) { |
|
149 | + if (!isset($this->targets[$target])){ |
|
150 | 150 | throw new DumperException(sprintf('Undefined dump target %d', $target)); |
151 | 151 | } |
152 | 152 | |
153 | - if (is_string($this->targets[$target])) { |
|
153 | + if (is_string($this->targets[$target])){ |
|
154 | 154 | $this->targets[$target] = new $this->targets[$target](); |
155 | 155 | } |
156 | 156 | |
@@ -175,32 +175,32 @@ discard block |
||
175 | 175 | int $level = 0, |
176 | 176 | bool $hideHeader = false |
177 | 177 | ): string { |
178 | - if (!$hideHeader && !empty($name)) { |
|
179 | - $header = $r->indent($level) . $r->apply($name, 'name') . $r->apply(' = ', 'syntax', '='); |
|
180 | - } else { |
|
178 | + if (!$hideHeader && !empty($name)){ |
|
179 | + $header = $r->indent($level).$r->apply($name, 'name').$r->apply(' = ', 'syntax', '='); |
|
180 | + }else{ |
|
181 | 181 | $header = $r->indent($level); |
182 | 182 | } |
183 | 183 | |
184 | - if ($level > $this->maxLevel) { |
|
184 | + if ($level > $this->maxLevel){ |
|
185 | 185 | //Renderer is not reference based, we can't dump too deep values |
186 | - return $r->indent($level) . $r->apply('-too deep-', 'maxLevel') . "\n"; |
|
186 | + return $r->indent($level).$r->apply('-too deep-', 'maxLevel')."\n"; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | $type = strtolower(gettype($value)); |
190 | 190 | |
191 | - if ($type == 'array') { |
|
192 | - return $header . $this->renderArray($r, $value, $level, $hideHeader); |
|
191 | + if ($type == 'array'){ |
|
192 | + return $header.$this->renderArray($r, $value, $level, $hideHeader); |
|
193 | 193 | } |
194 | 194 | |
195 | - if ($type == 'object') { |
|
196 | - return $header . $this->renderObject($r, $value, $level, $hideHeader); |
|
195 | + if ($type == 'object'){ |
|
196 | + return $header.$this->renderObject($r, $value, $level, $hideHeader); |
|
197 | 197 | } |
198 | 198 | |
199 | - if ($type == 'resource') { |
|
199 | + if ($type == 'resource'){ |
|
200 | 200 | //No need to dump resource value |
201 | - $element = get_resource_type($value) . ' resource '; |
|
201 | + $element = get_resource_type($value).' resource '; |
|
202 | 202 | |
203 | - return $header . $r->apply($element, 'type', 'resource') . "\n"; |
|
203 | + return $header.$r->apply($element, 'type', 'resource')."\n"; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | //Value length |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $header .= $r->apply("{$type}({$length})", 'type', $type); |
211 | 211 | |
212 | 212 | $element = null; |
213 | - switch ($type) { |
|
213 | + switch ($type){ |
|
214 | 214 | case 'string': |
215 | 215 | $element = $r->escapeStrings() ? htmlspecialchars($value) : $value; |
216 | 216 | break; |
@@ -220,14 +220,14 @@ discard block |
||
220 | 220 | break; |
221 | 221 | |
222 | 222 | default: |
223 | - if ($value !== null) { |
|
223 | + if ($value !== null){ |
|
224 | 224 | //Not showing null value, type is enough |
225 | 225 | $element = var_export($value, true); |
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | 229 | //Including value |
230 | - return $header . ' ' . $r->apply($element, 'value', $type) . "\n"; |
|
230 | + return $header.' '.$r->apply($element, 'value', $type)."\n"; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -240,19 +240,19 @@ discard block |
||
240 | 240 | */ |
241 | 241 | private function renderArray(RendererInterface $r, array $array, int $level, bool $hideHeader = false): string |
242 | 242 | { |
243 | - if (!$hideHeader) { |
|
243 | + if (!$hideHeader){ |
|
244 | 244 | $count = count($array); |
245 | 245 | |
246 | 246 | //Array size and scope |
247 | - $output = $r->apply("array({$count})", 'type', 'array') . "\n"; |
|
248 | - $output .= $r->indent($level) . $r->apply('[', 'syntax', '[') . "\n"; |
|
249 | - } else { |
|
247 | + $output = $r->apply("array({$count})", 'type', 'array')."\n"; |
|
248 | + $output .= $r->indent($level).$r->apply('[', 'syntax', '[')."\n"; |
|
249 | + }else{ |
|
250 | 250 | $output = ''; |
251 | 251 | } |
252 | 252 | |
253 | - foreach ($array as $key => $value) { |
|
254 | - if (!is_numeric($key)) { |
|
255 | - if (is_string($key) && $r->escapeStrings()) { |
|
253 | + foreach ($array as $key => $value){ |
|
254 | + if (!is_numeric($key)){ |
|
255 | + if (is_string($key) && $r->escapeStrings()){ |
|
256 | 256 | $key = htmlspecialchars($key); |
257 | 257 | } |
258 | 258 | |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | $output .= $this->renderValue($r, $value, "[{$key}]", $level + 1); |
263 | 263 | } |
264 | 264 | |
265 | - if (!$hideHeader) { |
|
265 | + if (!$hideHeader){ |
|
266 | 266 | //Closing array scope |
267 | - $output .= $r->indent($level) . $r->apply(']', 'syntax', ']') . "\n"; |
|
267 | + $output .= $r->indent($level).$r->apply(']', 'syntax', ']')."\n"; |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | return $output; |
@@ -286,47 +286,47 @@ discard block |
||
286 | 286 | bool $hideHeader = false, |
287 | 287 | string $class = '' |
288 | 288 | ): string { |
289 | - if (!$hideHeader) { |
|
290 | - $type = ($class ?: get_class($value)) . ' object '; |
|
289 | + if (!$hideHeader){ |
|
290 | + $type = ($class ?: get_class($value)).' object '; |
|
291 | 291 | |
292 | - $header = $r->apply($type, 'type', 'object') . "\n"; |
|
293 | - $header .= $r->indent($level) . $r->apply('(', 'syntax', '(') . "\n"; |
|
294 | - } else { |
|
292 | + $header = $r->apply($type, 'type', 'object')."\n"; |
|
293 | + $header .= $r->indent($level).$r->apply('(', 'syntax', '(')."\n"; |
|
294 | + }else{ |
|
295 | 295 | $header = ''; |
296 | 296 | } |
297 | 297 | |
298 | 298 | //Let's use method specifically created for dumping |
299 | - if (method_exists($value, '__debugInfo') || $value instanceof \Closure) { |
|
300 | - if ($value instanceof \Closure) { |
|
299 | + if (method_exists($value, '__debugInfo') || $value instanceof \Closure){ |
|
300 | + if ($value instanceof \Closure){ |
|
301 | 301 | $debugInfo = $this->describeClosure($value); |
302 | - } else { |
|
302 | + }else{ |
|
303 | 303 | $debugInfo = $value->__debugInfo(); |
304 | 304 | } |
305 | 305 | |
306 | - if (is_array($debugInfo)) { |
|
306 | + if (is_array($debugInfo)){ |
|
307 | 307 | //Pretty view |
308 | 308 | $debugInfo = (object)$debugInfo; |
309 | 309 | } |
310 | 310 | |
311 | - if (is_object($debugInfo)) { |
|
311 | + if (is_object($debugInfo)){ |
|
312 | 312 | //We are not including syntax elements here |
313 | 313 | return $this->renderObject($r, $debugInfo, $level, false, get_class($value)); |
314 | 314 | } |
315 | 315 | |
316 | 316 | return $header |
317 | 317 | . $this->renderValue($r, $debugInfo, '', $level + (is_scalar($value)), true) |
318 | - . $r->indent($level) . $r->apply(')', 'syntax', ')') . "\n"; |
|
318 | + . $r->indent($level).$r->apply(')', 'syntax', ')')."\n"; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | $refection = new \ReflectionObject($value); |
322 | 322 | |
323 | 323 | $output = ''; |
324 | - foreach ($refection->getProperties() as $property) { |
|
324 | + foreach ($refection->getProperties() as $property){ |
|
325 | 325 | $output .= $this->renderProperty($r, $value, $property, $level); |
326 | 326 | } |
327 | 327 | |
328 | 328 | //Header, content, footer |
329 | - return $header . $output . $r->indent($level) . $r->apply(')', 'syntax', ')') . "\n"; |
|
329 | + return $header.$output.$r->indent($level).$r->apply(')', 'syntax', ')')."\n"; |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | */ |
340 | 340 | private function renderProperty(RendererInterface $r, $value, \ReflectionProperty $p, int $level): string |
341 | 341 | { |
342 | - if ($p->isStatic()) { |
|
342 | + if ($p->isStatic()){ |
|
343 | 343 | return ''; |
344 | 344 | } |
345 | 345 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | !($value instanceof \stdClass) |
348 | 348 | && is_string($p->getDocComment()) |
349 | 349 | && strpos($p->getDocComment(), '@internal') !== false |
350 | - ) { |
|
350 | + ){ |
|
351 | 351 | // Memory loop while reading doc comment for stdClass variables? |
352 | 352 | // Report a PHP bug about treating comment INSIDE property declaration as doc comment. |
353 | 353 | return ''; |
@@ -359,11 +359,11 @@ discard block |
||
359 | 359 | //To read private and protected properties |
360 | 360 | $p->setAccessible(true); |
361 | 361 | |
362 | - if ($value instanceof \stdClass) { |
|
362 | + if ($value instanceof \stdClass){ |
|
363 | 363 | $name = $r->apply($p->getName(), 'dynamic'); |
364 | - } else { |
|
364 | + }else{ |
|
365 | 365 | //Property name includes access level |
366 | - $name = $p->getName() . $r->apply(':' . $access, 'access', $access); |
|
366 | + $name = $p->getName().$r->apply(':'.$access, 'access', $access); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | return $this->renderValue($r, $p->getValue($value), $name, $level + 1); |
@@ -377,14 +377,14 @@ discard block |
||
377 | 377 | */ |
378 | 378 | private function describeClosure(\Closure $closure): array |
379 | 379 | { |
380 | - try { |
|
380 | + try{ |
|
381 | 381 | $r = new \ReflectionFunction($closure); |
382 | - } catch (\ReflectionException $e) { |
|
382 | + }catch (\ReflectionException $e){ |
|
383 | 383 | return ['closure' => 'unable to resolve']; |
384 | 384 | } |
385 | 385 | |
386 | 386 | return [ |
387 | - 'name' => $r->getName() . " (lines {$r->getStartLine()}:{$r->getEndLine()})", |
|
387 | + 'name' => $r->getName()." (lines {$r->getStartLine()}:{$r->getEndLine()})", |
|
388 | 388 | 'file' => $r->getFileName(), |
389 | 389 | 'this' => $r->getClosureThis() |
390 | 390 | ]; |
@@ -399,9 +399,9 @@ discard block |
||
399 | 399 | */ |
400 | 400 | private function getAccess(\ReflectionProperty $p): string |
401 | 401 | { |
402 | - if ($p->isPrivate()) { |
|
402 | + if ($p->isPrivate()){ |
|
403 | 403 | return 'private'; |
404 | - } elseif ($p->isProtected()) { |
|
404 | + } elseif ($p->isProtected()){ |
|
405 | 405 | return 'protected'; |
406 | 406 | } |
407 | 407 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @var string |
25 | 25 | */ |
26 | - protected $element = '%s%s' . Color::RESET; |
|
26 | + protected $element = '%s%s'.Color::RESET; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Set of styles associated with different dumping properties. |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function apply($element, string $type, string $context = ''): string |
64 | 64 | { |
65 | - if (!empty($style = $this->getStyle($type, $context))) { |
|
65 | + if (!empty($style = $this->getStyle($type, $context))){ |
|
66 | 66 | return sprintf($this->element, $style, $element); |
67 | 67 | } |
68 | 68 | |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | */ |
88 | 88 | private function getStyle(string $type, string $context): string |
89 | 89 | { |
90 | - if (isset($this->styles[$type][$context])) { |
|
90 | + if (isset($this->styles[$type][$context])){ |
|
91 | 91 | return $this->styles[$type][$context]; |
92 | 92 | } |
93 | 93 | |
94 | - if (isset($this->styles[$type]['common'])) { |
|
94 | + if (isset($this->styles[$type]['common'])){ |
|
95 | 95 | return $this->styles[$type]['common']; |
96 | 96 | } |
97 | 97 | |
98 | - if (isset($this->styles[$type]) && is_string($this->styles[$type])) { |
|
98 | + if (isset($this->styles[$type]) && is_string($this->styles[$type])){ |
|
99 | 99 | return $this->styles[$type]; |
100 | 100 | } |
101 | 101 |
@@ -42,7 +42,7 @@ |
||
42 | 42 | */ |
43 | 43 | public function indent(int $level): string |
44 | 44 | { |
45 | - if ($level == 0) { |
|
45 | + if ($level == 0){ |
|
46 | 46 | return ''; |
47 | 47 | } |
48 | 48 |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function apply($element, string $type, string $context = ''): string |
118 | 118 | { |
119 | - if (!empty($style = $this->getStyle($type, $context))) { |
|
120 | - if (!empty($style = $this->getStyle($type, $context))) { |
|
119 | + if (!empty($style = $this->getStyle($type, $context))){ |
|
120 | + if (!empty($style = $this->getStyle($type, $context))){ |
|
121 | 121 | return sprintf($this->style['element'], $style, $element); |
122 | 122 | } |
123 | 123 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function indent(int $level): string |
140 | 140 | { |
141 | - if ($level == 0) { |
|
141 | + if ($level == 0){ |
|
142 | 142 | return ''; |
143 | 143 | } |
144 | 144 | |
@@ -163,15 +163,15 @@ discard block |
||
163 | 163 | */ |
164 | 164 | private function getStyle(string $type, string $context): string |
165 | 165 | { |
166 | - if (isset($this->style[$type][$context])) { |
|
166 | + if (isset($this->style[$type][$context])){ |
|
167 | 167 | return $this->style[$type][$context]; |
168 | 168 | } |
169 | 169 | |
170 | - if (isset($this->style[$type]['common'])) { |
|
170 | + if (isset($this->style[$type]['common'])){ |
|
171 | 171 | return $this->style[$type]['common']; |
172 | 172 | } |
173 | 173 | |
174 | - if (isset($this->style[$type]) && is_string($this->style[$type])) { |
|
174 | + if (isset($this->style[$type]) && is_string($this->style[$type])){ |
|
175 | 175 | return $this->style[$type]; |
176 | 176 | } |
177 | 177 |