@@ -68,11 +68,11 @@ |
||
68 | 68 | */ |
69 | 69 | public function getActor(): ?object |
70 | 70 | { |
71 | - if ($this->closed) { |
|
71 | + if ($this->closed){ |
|
72 | 72 | return null; |
73 | 73 | } |
74 | 74 | |
75 | - if ($this->actor === null && $this->token !== null) { |
|
75 | + if ($this->actor === null && $this->token !== null){ |
|
76 | 76 | $this->actor = $this->actorProvider->getActor($this->token); |
77 | 77 | } |
78 | 78 |
@@ -68,11 +68,13 @@ |
||
68 | 68 | */ |
69 | 69 | public function getActor(): ?object |
70 | 70 | { |
71 | - if ($this->closed) { |
|
71 | + if ($this->closed) |
|
72 | + { |
|
72 | 73 | return null; |
73 | 74 | } |
74 | 75 | |
75 | - if ($this->actor === null && $this->token !== null) { |
|
76 | + if ($this->actor === null && $this->token !== null) |
|
77 | + { |
|
76 | 78 | $this->actor = $this->actorProvider->getActor($this->token); |
77 | 79 | } |
78 | 80 |
@@ -89,7 +89,8 @@ discard block |
||
89 | 89 | { |
90 | 90 | $d = $this->makeDumper(); |
91 | 91 | |
92 | - $result = $d->dump(new class() { |
|
92 | + $result = $d->dump(new class() |
|
93 | + { |
|
93 | 94 | private $name = 'Test'; |
94 | 95 | }, Dumper::RETURN); |
95 | 96 | |
@@ -151,7 +152,8 @@ discard block |
||
151 | 152 | public function testDebugInfo(): void |
152 | 153 | { |
153 | 154 | $d = $this->makeDumper(); |
154 | - $result = $d->dump(new class() { |
|
155 | + $result = $d->dump(new class() |
|
156 | + { |
|
155 | 157 | protected $inner = '_kk_'; |
156 | 158 | |
157 | 159 | public function __debugInfo() |
@@ -171,7 +173,8 @@ discard block |
||
171 | 173 | public function testinternal(): void |
172 | 174 | { |
173 | 175 | $d = $this->makeDumper(); |
174 | - $result = $d->dump(new class() { |
|
176 | + $result = $d->dump(new class() |
|
177 | + { |
|
175 | 178 | protected $visible = '_kk_'; |
176 | 179 | |
177 | 180 | /** @internal */ |
@@ -198,7 +201,8 @@ discard block |
||
198 | 201 | $d = $this->makeDumper(); |
199 | 202 | $d->setRenderer(Dumper::RETURN, new HtmlRenderer()); |
200 | 203 | |
201 | - $result = $d->dump(new class() { |
|
204 | + $result = $d->dump(new class() |
|
205 | + { |
|
202 | 206 | protected static $static = 'yes'; |
203 | 207 | |
204 | 208 | private $value = 123; |
@@ -222,7 +226,8 @@ discard block |
||
222 | 226 | $d->setRenderer(Dumper::RETURN, new HtmlRenderer(HtmlRenderer::INVERTED)); |
223 | 227 | $d->setMaxLevel(5); |
224 | 228 | |
225 | - $result = $d->dump(new class() { |
|
229 | + $result = $d->dump(new class() |
|
230 | + { |
|
226 | 231 | private $value = 123; |
227 | 232 | |
228 | 233 | protected $visible = '_kk_'; |
@@ -246,7 +251,8 @@ discard block |
||
246 | 251 | $d->setRenderer(Dumper::RETURN, new ConsoleRenderer()); |
247 | 252 | $d->setMaxLevel(5); |
248 | 253 | |
249 | - $result = $d->dump(new class() { |
|
254 | + $result = $d->dump(new class() |
|
255 | + { |
|
250 | 256 | private $value = 123; |
251 | 257 | |
252 | 258 | protected $visible = '_kk_'; |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | $d->dump(1); |
30 | 30 | $result = ob_get_clean(); |
31 | 31 | |
32 | - $this->assertSame($d->dump(1, Dumper::RETURN), $result); |
|
32 | + $this->assertSame($d->dump(1, Dumper::return), $result); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | private function makeDumper(LoggerInterface $logger = null) |
36 | 36 | { |
37 | 37 | $d = new Dumper($logger); |
38 | 38 | $d->setRenderer(Dumper::OUTPUT, new PlainRenderer()); |
39 | - $d->setRenderer(Dumper::RETURN, new PlainRenderer()); |
|
39 | + $d->setRenderer(Dumper::return, new PlainRenderer()); |
|
40 | 40 | $d->setRenderer(Dumper::OUTPUT_CLI_COLORS, new PlainRenderer()); |
41 | 41 | |
42 | 42 | return $d; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public function testScalar(): void |
46 | 46 | { |
47 | 47 | $d = $this->makeDumper(); |
48 | - $result = $d->dump(123, Dumper::RETURN); |
|
48 | + $result = $d->dump(123, Dumper::return); |
|
49 | 49 | |
50 | 50 | $this->assertStringContainsString('123', $result); |
51 | 51 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public function testString(): void |
54 | 54 | { |
55 | 55 | $d = $this->makeDumper(); |
56 | - $result = $d->dump('hello world', Dumper::RETURN); |
|
56 | + $result = $d->dump('hello world', Dumper::return); |
|
57 | 57 | |
58 | 58 | $this->assertStringContainsString('hello world', $result); |
59 | 59 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | public function testResource(): void |
62 | 62 | { |
63 | 63 | $d = $this->makeDumper(); |
64 | - $result = $d->dump(STDOUT, Dumper::RETURN); |
|
64 | + $result = $d->dump(STDOUT, Dumper::return); |
|
65 | 65 | |
66 | 66 | $this->assertStringContainsString('resource', $result); |
67 | 67 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | public function testHTML(): void |
70 | 70 | { |
71 | 71 | $d = $this->makeDumper(); |
72 | - $result = $d->dump('hello <br/>world', Dumper::RETURN); |
|
72 | + $result = $d->dump('hello <br/>world', Dumper::return); |
|
73 | 73 | |
74 | 74 | $this->assertStringContainsString('hello <br/>world', $result); |
75 | 75 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | public function testArray(): void |
78 | 78 | { |
79 | 79 | $d = $this->makeDumper(); |
80 | - $result = $d->dump(['G', 'B', 'N'], Dumper::RETURN); |
|
80 | + $result = $d->dump(['G', 'B', 'N'], Dumper::return); |
|
81 | 81 | |
82 | 82 | $this->assertStringContainsString('array', $result); |
83 | 83 | $this->assertStringContainsString('G', $result); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $result = $d->dump(new class() { |
93 | 93 | private $name = 'Test'; |
94 | - }, Dumper::RETURN); |
|
94 | + }, Dumper::return); |
|
95 | 95 | |
96 | 96 | $this->assertStringContainsString('object', $result); |
97 | 97 | $this->assertStringContainsString('private', $result); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | $result = $d->dump(static function (): void { |
108 | 108 | echo 'hello world'; |
109 | - }, Dumper::RETURN); |
|
109 | + }, Dumper::return); |
|
110 | 110 | |
111 | 111 | $this->assertStringContainsString('Closure', $result); |
112 | 112 | $this->assertStringContainsString('DumperTest.php', $result); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $mock = $this->createMock(LoggerInterface::class); |
118 | 118 | $d = $this->makeDumper($mock); |
119 | 119 | |
120 | - $mock->method('debug')->with($d->dump('abc', Dumper::RETURN)); |
|
120 | + $mock->method('debug')->with($d->dump('abc', Dumper::return)); |
|
121 | 121 | $this->assertNull($d->dump('abc', Dumper::LOGGER)); |
122 | 122 | } |
123 | 123 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | '_magic_' => '_value_', |
161 | 161 | ]; |
162 | 162 | } |
163 | - }, Dumper::RETURN); |
|
163 | + }, Dumper::return); |
|
164 | 164 | |
165 | 165 | $this->assertStringContainsString('_magic_', $result); |
166 | 166 | $this->assertStringContainsString('_value_', $result); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | /** @internal */ |
178 | 178 | protected $internal = '_ok_'; |
179 | - }, Dumper::RETURN); |
|
179 | + }, Dumper::return); |
|
180 | 180 | |
181 | 181 | $this->assertStringContainsString('visible', $result); |
182 | 182 | $this->assertStringContainsString('_kk_', $result); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | public function testHtmlRenderer(): void |
197 | 197 | { |
198 | 198 | $d = $this->makeDumper(); |
199 | - $d->setRenderer(Dumper::RETURN, new HtmlRenderer()); |
|
199 | + $d->setRenderer(Dumper::return, new HtmlRenderer()); |
|
200 | 200 | |
201 | 201 | $result = $d->dump(new class() { |
202 | 202 | protected static $static = 'yes'; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | /** @internal */ |
209 | 209 | protected $internal = '_ok_'; |
210 | - }, Dumper::RETURN); |
|
210 | + }, Dumper::return); |
|
211 | 211 | |
212 | 212 | $this->assertStringContainsString('visible', $result); |
213 | 213 | $this->assertStringContainsString('_kk_', $result); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | public function testInvertedRenderer(): void |
220 | 220 | { |
221 | 221 | $d = $this->makeDumper(); |
222 | - $d->setRenderer(Dumper::RETURN, new HtmlRenderer(HtmlRenderer::INVERTED)); |
|
222 | + $d->setRenderer(Dumper::return, new HtmlRenderer(HtmlRenderer::INVERTED)); |
|
223 | 223 | $d->setMaxLevel(5); |
224 | 224 | |
225 | 225 | $result = $d->dump(new class() { |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | /** @internal */ |
233 | 233 | protected $internal = '_ok_'; |
234 | - }, Dumper::RETURN); |
|
234 | + }, Dumper::return); |
|
235 | 235 | |
236 | 236 | $this->assertStringContainsString('visible', $result); |
237 | 237 | $this->assertStringContainsString('_kk_', $result); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | public function testConsoleRenderer(): void |
244 | 244 | { |
245 | 245 | $d = $this->makeDumper(); |
246 | - $d->setRenderer(Dumper::RETURN, new ConsoleRenderer()); |
|
246 | + $d->setRenderer(Dumper::return, new ConsoleRenderer()); |
|
247 | 247 | $d->setMaxLevel(5); |
248 | 248 | |
249 | 249 | $result = $d->dump(new class() { |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | |
256 | 256 | /** @internal */ |
257 | 257 | protected $internal = '_ok_'; |
258 | - }, Dumper::RETURN); |
|
258 | + }, Dumper::return); |
|
259 | 259 | |
260 | 260 | $this->assertStringContainsString('visible', $result); |
261 | 261 | $this->assertStringContainsString('_kk_', $result); |
@@ -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 | } |
@@ -24,12 +24,14 @@ 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 | 29 | // Do not treat RoadRunner as CLI. |
29 | 30 | return false; |
30 | 31 | } |
31 | 32 | |
32 | - if (php_sapi_name() === 'cli') { |
|
33 | + if (php_sapi_name() === 'cli') |
|
34 | + { |
|
33 | 35 | return true; |
34 | 36 | } |
35 | 37 | |
@@ -46,12 +48,15 @@ discard block |
||
46 | 48 | */ |
47 | 49 | public static function isColorsSupported($stream = STDOUT): bool |
48 | 50 | { |
49 | - if ('Hyper' === getenv('TERM_PROGRAM')) { |
|
51 | + if ('Hyper' === getenv('TERM_PROGRAM')) |
|
52 | + { |
|
50 | 53 | return true; |
51 | 54 | } |
52 | 55 | |
53 | - try { |
|
54 | - if (\DIRECTORY_SEPARATOR === '\\') { |
|
56 | + try |
|
57 | + { |
|
58 | + if (\DIRECTORY_SEPARATOR === '\\') |
|
59 | + { |
|
55 | 60 | return ( |
56 | 61 | function_exists('sapi_windows_vt100_support') |
57 | 62 | && @sapi_windows_vt100_support($stream) |
@@ -60,11 +65,13 @@ discard block |
||
60 | 65 | || getenv('TERM') == 'xterm'; |
61 | 66 | } |
62 | 67 | |
63 | - if (\function_exists('stream_isatty')) { |
|
68 | + if (\function_exists('stream_isatty')) |
|
69 | + { |
|
64 | 70 | return @stream_isatty($stream); |
65 | 71 | } |
66 | 72 | |
67 | - if (\function_exists('posix_isatty')) { |
|
73 | + if (\function_exists('posix_isatty')) |
|
74 | + { |
|
68 | 75 | return @posix_isatty($stream); |
69 | 76 | } |
70 | 77 | |
@@ -72,7 +79,9 @@ discard block |
||
72 | 79 | |
73 | 80 | // Check if formatted mode is S_IFCHR |
74 | 81 | return $stat ? 0020000 === ($stat['mode'] & 0170000) : false; |
75 | - } catch (\Throwable $e) { |
|
82 | + } |
|
83 | + catch (\Throwable $e) |
|
84 | + { |
|
76 | 85 | return false; |
77 | 86 | } |
78 | 87 | } |
@@ -58,7 +58,8 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function __construct(LoggerInterface $logger = null) |
60 | 60 | { |
61 | - if (!empty($logger)) { |
|
61 | + if (!empty($logger)) |
|
62 | + { |
|
62 | 63 | $this->setLogger($logger); |
63 | 64 | } |
64 | 65 | } |
@@ -86,7 +87,8 @@ discard block |
||
86 | 87 | $r = $this->getRenderer($target); |
87 | 88 | $dump = $r->wrapContent($this->renderValue($r, $value)); |
88 | 89 | |
89 | - switch ($target) { |
|
90 | + switch ($target) |
|
91 | + { |
|
90 | 92 | case self::OUTPUT: |
91 | 93 | echo $dump; |
92 | 94 | break; |
@@ -95,7 +97,8 @@ discard block |
||
95 | 97 | return $dump; |
96 | 98 | |
97 | 99 | case self::LOGGER: |
98 | - if ($this->logger == null) { |
|
100 | + if ($this->logger == null) |
|
101 | + { |
|
99 | 102 | throw new DumperException('Unable to dump value to log, no associated LoggerInterface'); |
100 | 103 | } |
101 | 104 | $this->logger->debug($dump); |
@@ -119,7 +122,8 @@ discard block |
||
119 | 122 | */ |
120 | 123 | public function setRenderer(int $target, RendererInterface $renderer): Dumper |
121 | 124 | { |
122 | - if (!isset($this->targets[$target])) { |
|
125 | + if (!isset($this->targets[$target])) |
|
126 | + { |
|
123 | 127 | throw new DumperException(sprintf('Undefined dump target %d', $target)); |
124 | 128 | } |
125 | 129 | |
@@ -138,19 +142,25 @@ discard block |
||
138 | 142 | */ |
139 | 143 | private function getRenderer(int $target): RendererInterface |
140 | 144 | { |
141 | - if ($target == self::OUTPUT && System::isCLI()) { |
|
142 | - if (System::isColorsSupported(STDOUT)) { |
|
145 | + if ($target == self::OUTPUT && System::isCLI()) |
|
146 | + { |
|
147 | + if (System::isColorsSupported(STDOUT)) |
|
148 | + { |
|
143 | 149 | $target = self::OUTPUT_CLI_COLORS; |
144 | - } else { |
|
150 | + } |
|
151 | + else |
|
152 | + { |
|
145 | 153 | $target = self::OUTPUT_CLI; |
146 | 154 | } |
147 | 155 | } |
148 | 156 | |
149 | - if (!isset($this->targets[$target])) { |
|
157 | + if (!isset($this->targets[$target])) |
|
158 | + { |
|
150 | 159 | throw new DumperException(sprintf('Undefined dump target %d', $target)); |
151 | 160 | } |
152 | 161 | |
153 | - if (is_string($this->targets[$target])) { |
|
162 | + if (is_string($this->targets[$target])) |
|
163 | + { |
|
154 | 164 | $this->targets[$target] = new $this->targets[$target](); |
155 | 165 | } |
156 | 166 | |
@@ -175,28 +185,35 @@ discard block |
||
175 | 185 | int $level = 0, |
176 | 186 | bool $hideHeader = false |
177 | 187 | ): string { |
178 | - if (!$hideHeader && !empty($name)) { |
|
188 | + if (!$hideHeader && !empty($name)) |
|
189 | + { |
|
179 | 190 | $header = $r->indent($level) . $r->apply($name, 'name') . $r->apply(' = ', 'syntax', '='); |
180 | - } else { |
|
191 | + } |
|
192 | + else |
|
193 | + { |
|
181 | 194 | $header = $r->indent($level); |
182 | 195 | } |
183 | 196 | |
184 | - if ($level > $this->maxLevel) { |
|
197 | + if ($level > $this->maxLevel) |
|
198 | + { |
|
185 | 199 | //Renderer is not reference based, we can't dump too deep values |
186 | 200 | return $r->indent($level) . $r->apply('-too deep-', 'maxLevel') . "\n"; |
187 | 201 | } |
188 | 202 | |
189 | 203 | $type = strtolower(gettype($value)); |
190 | 204 | |
191 | - if ($type == 'array') { |
|
205 | + if ($type == 'array') |
|
206 | + { |
|
192 | 207 | return $header . $this->renderArray($r, $value, $level, $hideHeader); |
193 | 208 | } |
194 | 209 | |
195 | - if ($type == 'object') { |
|
210 | + if ($type == 'object') |
|
211 | + { |
|
196 | 212 | return $header . $this->renderObject($r, $value, $level, $hideHeader); |
197 | 213 | } |
198 | 214 | |
199 | - if ($type == 'resource') { |
|
215 | + if ($type == 'resource') |
|
216 | + { |
|
200 | 217 | //No need to dump resource value |
201 | 218 | $element = get_resource_type($value) . ' resource '; |
202 | 219 | |
@@ -210,7 +227,8 @@ discard block |
||
210 | 227 | $header .= $r->apply("{$type}({$length})", 'type', $type); |
211 | 228 | |
212 | 229 | $element = null; |
213 | - switch ($type) { |
|
230 | + switch ($type) |
|
231 | + { |
|
214 | 232 | case 'string': |
215 | 233 | $element = $r->escapeStrings() ? htmlspecialchars($value) : $value; |
216 | 234 | break; |
@@ -220,7 +238,8 @@ discard block |
||
220 | 238 | break; |
221 | 239 | |
222 | 240 | default: |
223 | - if ($value !== null) { |
|
241 | + if ($value !== null) |
|
242 | + { |
|
224 | 243 | //Not showing null value, type is enough |
225 | 244 | $element = var_export($value, true); |
226 | 245 | } |
@@ -240,19 +259,25 @@ discard block |
||
240 | 259 | */ |
241 | 260 | private function renderArray(RendererInterface $r, array $array, int $level, bool $hideHeader = false): string |
242 | 261 | { |
243 | - if (!$hideHeader) { |
|
262 | + if (!$hideHeader) |
|
263 | + { |
|
244 | 264 | $count = count($array); |
245 | 265 | |
246 | 266 | //Array size and scope |
247 | 267 | $output = $r->apply("array({$count})", 'type', 'array') . "\n"; |
248 | 268 | $output .= $r->indent($level) . $r->apply('[', 'syntax', '[') . "\n"; |
249 | - } else { |
|
269 | + } |
|
270 | + else |
|
271 | + { |
|
250 | 272 | $output = ''; |
251 | 273 | } |
252 | 274 | |
253 | - foreach ($array as $key => $value) { |
|
254 | - if (!is_numeric($key)) { |
|
255 | - if (is_string($key) && $r->escapeStrings()) { |
|
275 | + foreach ($array as $key => $value) |
|
276 | + { |
|
277 | + if (!is_numeric($key)) |
|
278 | + { |
|
279 | + if (is_string($key) && $r->escapeStrings()) |
|
280 | + { |
|
256 | 281 | $key = htmlspecialchars($key); |
257 | 282 | } |
258 | 283 | |
@@ -262,7 +287,8 @@ discard block |
||
262 | 287 | $output .= $this->renderValue($r, $value, "[{$key}]", $level + 1); |
263 | 288 | } |
264 | 289 | |
265 | - if (!$hideHeader) { |
|
290 | + if (!$hideHeader) |
|
291 | + { |
|
266 | 292 | //Closing array scope |
267 | 293 | $output .= $r->indent($level) . $r->apply(']', 'syntax', ']') . "\n"; |
268 | 294 | } |
@@ -286,29 +312,38 @@ discard block |
||
286 | 312 | bool $hideHeader = false, |
287 | 313 | string $class = '' |
288 | 314 | ): string { |
289 | - if (!$hideHeader) { |
|
315 | + if (!$hideHeader) |
|
316 | + { |
|
290 | 317 | $type = ($class ?: get_class($value)) . ' object '; |
291 | 318 | |
292 | 319 | $header = $r->apply($type, 'type', 'object') . "\n"; |
293 | 320 | $header .= $r->indent($level) . $r->apply('(', 'syntax', '(') . "\n"; |
294 | - } else { |
|
321 | + } |
|
322 | + else |
|
323 | + { |
|
295 | 324 | $header = ''; |
296 | 325 | } |
297 | 326 | |
298 | 327 | //Let's use method specifically created for dumping |
299 | - if (method_exists($value, '__debugInfo') || $value instanceof \Closure) { |
|
300 | - if ($value instanceof \Closure) { |
|
328 | + if (method_exists($value, '__debugInfo') || $value instanceof \Closure) |
|
329 | + { |
|
330 | + if ($value instanceof \Closure) |
|
331 | + { |
|
301 | 332 | $debugInfo = $this->describeClosure($value); |
302 | - } else { |
|
333 | + } |
|
334 | + else |
|
335 | + { |
|
303 | 336 | $debugInfo = $value->__debugInfo(); |
304 | 337 | } |
305 | 338 | |
306 | - if (is_array($debugInfo)) { |
|
339 | + if (is_array($debugInfo)) |
|
340 | + { |
|
307 | 341 | //Pretty view |
308 | 342 | $debugInfo = (object)$debugInfo; |
309 | 343 | } |
310 | 344 | |
311 | - if (is_object($debugInfo)) { |
|
345 | + if (is_object($debugInfo)) |
|
346 | + { |
|
312 | 347 | //We are not including syntax elements here |
313 | 348 | return $this->renderObject($r, $debugInfo, $level, false, get_class($value)); |
314 | 349 | } |
@@ -321,7 +356,8 @@ discard block |
||
321 | 356 | $refection = new \ReflectionObject($value); |
322 | 357 | |
323 | 358 | $output = ''; |
324 | - foreach ($refection->getProperties() as $property) { |
|
359 | + foreach ($refection->getProperties() as $property) |
|
360 | + { |
|
325 | 361 | $output .= $this->renderProperty($r, $value, $property, $level); |
326 | 362 | } |
327 | 363 | |
@@ -339,7 +375,8 @@ discard block |
||
339 | 375 | */ |
340 | 376 | private function renderProperty(RendererInterface $r, $value, \ReflectionProperty $p, int $level): string |
341 | 377 | { |
342 | - if ($p->isStatic()) { |
|
378 | + if ($p->isStatic()) |
|
379 | + { |
|
343 | 380 | return ''; |
344 | 381 | } |
345 | 382 | |
@@ -359,9 +396,12 @@ discard block |
||
359 | 396 | //To read private and protected properties |
360 | 397 | $p->setAccessible(true); |
361 | 398 | |
362 | - if ($value instanceof \stdClass) { |
|
399 | + if ($value instanceof \stdClass) |
|
400 | + { |
|
363 | 401 | $name = $r->apply($p->getName(), 'dynamic'); |
364 | - } else { |
|
402 | + } |
|
403 | + else |
|
404 | + { |
|
365 | 405 | //Property name includes access level |
366 | 406 | $name = $p->getName() . $r->apply(':' . $access, 'access', $access); |
367 | 407 | } |
@@ -377,9 +417,12 @@ discard block |
||
377 | 417 | */ |
378 | 418 | private function describeClosure(\Closure $closure): array |
379 | 419 | { |
380 | - try { |
|
420 | + try |
|
421 | + { |
|
381 | 422 | $r = new \ReflectionFunction($closure); |
382 | - } catch (\ReflectionException $e) { |
|
423 | + } |
|
424 | + catch (\ReflectionException $e) |
|
425 | + { |
|
383 | 426 | return ['closure' => 'unable to resolve']; |
384 | 427 | } |
385 | 428 | |
@@ -399,9 +442,12 @@ discard block |
||
399 | 442 | */ |
400 | 443 | private function getAccess(\ReflectionProperty $p): string |
401 | 444 | { |
402 | - if ($p->isPrivate()) { |
|
445 | + if ($p->isPrivate()) |
|
446 | + { |
|
403 | 447 | return 'private'; |
404 | - } elseif ($p->isProtected()) { |
|
448 | + } |
|
449 | + elseif ($p->isProtected()) |
|
450 | + { |
|
405 | 451 | return 'protected'; |
406 | 452 | } |
407 | 453 |
@@ -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 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * Directives for dump output forwarding. |
31 | 31 | */ |
32 | 32 | public const OUTPUT = 0; |
33 | - public const RETURN = 1; |
|
33 | + public const return = 1; |
|
34 | 34 | public const LOGGER = 2; |
35 | 35 | public const ERROR_LOG = 3; |
36 | 36 | public const OUTPUT_CLI = 4; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | self::OUTPUT => HtmlRenderer::class, |
50 | 50 | self::OUTPUT_CLI => PlainRenderer::class, |
51 | 51 | self::OUTPUT_CLI_COLORS => ConsoleRenderer::class, |
52 | - self::RETURN => HtmlRenderer::class, |
|
52 | + self::return => HtmlRenderer::class, |
|
53 | 53 | self::LOGGER => PlainRenderer::class, |
54 | 54 | self::ERROR_LOG => PlainRenderer::class, |
55 | 55 | self::ROADRUNNER => PlainRenderer::class, |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | break; |
95 | 95 | |
96 | 96 | case self::ROADRUNNER: |
97 | - case self::RETURN: |
|
97 | + case self::return: |
|
98 | 98 | return $dump; |
99 | 99 | |
100 | 100 | case self::LOGGER: |
@@ -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 |
@@ -62,7 +62,8 @@ 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 | 67 | return sprintf($this->element, $style, $element); |
67 | 68 | } |
68 | 69 | |
@@ -87,15 +88,18 @@ discard block |
||
87 | 88 | */ |
88 | 89 | private function getStyle(string $type, string $context): string |
89 | 90 | { |
90 | - if (isset($this->styles[$type][$context])) { |
|
91 | + if (isset($this->styles[$type][$context])) |
|
92 | + { |
|
91 | 93 | return $this->styles[$type][$context]; |
92 | 94 | } |
93 | 95 | |
94 | - if (isset($this->styles[$type]['common'])) { |
|
96 | + if (isset($this->styles[$type]['common'])) |
|
97 | + { |
|
95 | 98 | return $this->styles[$type]['common']; |
96 | 99 | } |
97 | 100 | |
98 | - if (isset($this->styles[$type]) && is_string($this->styles[$type])) { |
|
101 | + if (isset($this->styles[$type]) && is_string($this->styles[$type])) |
|
102 | + { |
|
99 | 103 | return $this->styles[$type]; |
100 | 104 | } |
101 | 105 |
@@ -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 |
@@ -42,7 +42,8 @@ |
||
42 | 42 | */ |
43 | 43 | public function indent(int $level): string |
44 | 44 | { |
45 | - if ($level == 0) { |
|
45 | + if ($level == 0) |
|
46 | + { |
|
46 | 47 | return ''; |
47 | 48 | } |
48 | 49 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * Default coloring schema. |
23 | 23 | */ |
24 | - public const DEFAULT = [ |
|
24 | + public const default = [ |
|
25 | 25 | 'body' => '<pre style="background-color: white; font-family: monospace;">%s</pre>', |
26 | 26 | 'element' => '<span style="%s;">%s</span>', |
27 | 27 | 'indent' => '· ', |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @var array |
103 | 103 | */ |
104 | - protected $style = self::DEFAULT; |
|
104 | + protected $style = self::default; |
|
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @param array $style |
108 | 108 | */ |
109 | - public function __construct(array $style = self::DEFAULT) |
|
109 | + public function __construct(array $style = self::default) |
|
110 | 110 | { |
111 | 111 | $this->style = $style; |
112 | 112 | } |
@@ -116,7 +116,7 @@ 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))) { |
|
119 | + if (!empty($style = $this->getStyle($type, $context))){ |
|
120 | 120 | return sprintf($this->style['element'], $style, $element); |
121 | 121 | } |
122 | 122 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function indent(int $level): string |
138 | 138 | { |
139 | - if ($level == 0) { |
|
139 | + if ($level == 0){ |
|
140 | 140 | return ''; |
141 | 141 | } |
142 | 142 | |
@@ -161,15 +161,15 @@ discard block |
||
161 | 161 | */ |
162 | 162 | private function getStyle(string $type, string $context): string |
163 | 163 | { |
164 | - if (isset($this->style[$type][$context])) { |
|
164 | + if (isset($this->style[$type][$context])){ |
|
165 | 165 | return $this->style[$type][$context]; |
166 | 166 | } |
167 | 167 | |
168 | - if (isset($this->style[$type]['common'])) { |
|
168 | + if (isset($this->style[$type]['common'])){ |
|
169 | 169 | return $this->style[$type]['common']; |
170 | 170 | } |
171 | 171 | |
172 | - if (isset($this->style[$type]) && is_string($this->style[$type])) { |
|
172 | + if (isset($this->style[$type]) && is_string($this->style[$type])){ |
|
173 | 173 | return $this->style[$type]; |
174 | 174 | } |
175 | 175 |
@@ -116,7 +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))) { |
|
119 | + if (!empty($style = $this->getStyle($type, $context))) |
|
120 | + { |
|
120 | 121 | return sprintf($this->style['element'], $style, $element); |
121 | 122 | } |
122 | 123 | |
@@ -136,7 +137,8 @@ discard block |
||
136 | 137 | */ |
137 | 138 | public function indent(int $level): string |
138 | 139 | { |
139 | - if ($level == 0) { |
|
140 | + if ($level == 0) |
|
141 | + { |
|
140 | 142 | return ''; |
141 | 143 | } |
142 | 144 | |
@@ -161,15 +163,18 @@ discard block |
||
161 | 163 | */ |
162 | 164 | private function getStyle(string $type, string $context): string |
163 | 165 | { |
164 | - if (isset($this->style[$type][$context])) { |
|
166 | + if (isset($this->style[$type][$context])) |
|
167 | + { |
|
165 | 168 | return $this->style[$type][$context]; |
166 | 169 | } |
167 | 170 | |
168 | - if (isset($this->style[$type]['common'])) { |
|
171 | + if (isset($this->style[$type]['common'])) |
|
172 | + { |
|
169 | 173 | return $this->style[$type]['common']; |
170 | 174 | } |
171 | 175 | |
172 | - if (isset($this->style[$type]) && is_string($this->style[$type])) { |
|
176 | + if (isset($this->style[$type]) && is_string($this->style[$type])) |
|
177 | + { |
|
173 | 178 | return $this->style[$type]; |
174 | 179 | } |
175 | 180 |
@@ -55,7 +55,7 @@ |
||
55 | 55 | $context |
56 | 56 | ); |
57 | 57 | |
58 | - foreach ($this->listenedRegistry->getListeners() as $listener) { |
|
58 | + foreach ($this->listenedRegistry->getListeners() as $listener){ |
|
59 | 59 | call_user_func($listener, $e); |
60 | 60 | } |
61 | 61 | } |
@@ -55,7 +55,8 @@ |
||
55 | 55 | $context |
56 | 56 | ); |
57 | 57 | |
58 | - foreach ($this->listenedRegistry->getListeners() as $listener) { |
|
58 | + foreach ($this->listenedRegistry->getListeners() as $listener) |
|
59 | + { |
|
59 | 60 | call_user_func($listener, $e); |
60 | 61 | } |
61 | 62 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function addListener(callable $listener): void |
26 | 26 | { |
27 | - if (!array_search($listener, $this->listeners, true)) { |
|
27 | + if (!array_search($listener, $this->listeners, true)){ |
|
28 | 28 | $this->listeners[] = $listener; |
29 | 29 | } |
30 | 30 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public function removeListener(callable $listener): void |
36 | 36 | { |
37 | 37 | $key = array_search($listener, $this->listeners, true); |
38 | - if ($key !== null) { |
|
38 | + if ($key !== null){ |
|
39 | 39 | unset($this->listeners[$key]); |
40 | 40 | } |
41 | 41 | } |
@@ -24,7 +24,8 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function addListener(callable $listener): void |
26 | 26 | { |
27 | - if (!array_search($listener, $this->listeners, true)) { |
|
27 | + if (!array_search($listener, $this->listeners, true)) |
|
28 | + { |
|
28 | 29 | $this->listeners[] = $listener; |
29 | 30 | } |
30 | 31 | } |
@@ -35,7 +36,8 @@ discard block |
||
35 | 36 | public function removeListener(callable $listener): void |
36 | 37 | { |
37 | 38 | $key = array_search($listener, $this->listeners, true); |
38 | - if ($key !== null) { |
|
39 | + if ($key !== null) |
|
40 | + { |
|
39 | 41 | unset($this->listeners[$key]); |
40 | 42 | } |
41 | 43 | } |