Passed
Pull Request — master (#656)
by Abdul Malik
11:30 queued 05:15
created
src/Exceptions/tests/HighlighterTest.php 1 patch
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
     public function testHtmlHighlighter(): void
30 30
     {
31
-        $highlighter = new Highlighter(new HtmlStyle(HtmlStyle::DEFAULT));
31
+        $highlighter = new Highlighter(new HtmlStyle(HtmlStyle::default));
32 32
 
33 33
         $this->assertStringContainsString('HighlighterTest', $highlighter->highlight(file_get_contents(__FILE__)));
34 34
     }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
     public function testHtmlHighlighterLines(): void
61 61
     {
62
-        $highlighter = new Highlighter(new HtmlStyle(HtmlStyle::DEFAULT));
62
+        $highlighter = new Highlighter(new HtmlStyle(HtmlStyle::default));
63 63
 
64 64
         $this->assertStringContainsString(
65 65
             'HighlighterTest',
Please login to merge, or discard this patch.
src/Exceptions/views/exception.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
         </div>
48 48
     </div>
49 49
     <?php
50
-    foreach ($valueWrapper->getValues() as $id => $content) {
50
+    foreach ($valueWrapper->getValues() as $id => $content){
51 51
         echo "<div id=\"argument-{$id}\" style=\"display: none\">{$content}</div>";
52 52
     }
53 53
     ?>
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,8 @@
 block discarded – undo
47 47
         </div>
48 48
     </div>
49 49
     <?php
50
-    foreach ($valueWrapper->getValues() as $id => $content) {
50
+    foreach ($valueWrapper->getValues() as $id => $content)
51
+    {
51 52
         echo "<div id=\"argument-{$id}\" style=\"display: none\">{$content}</div>";
52 53
     }
53 54
     ?>
Please login to merge, or discard this patch.
src/Exceptions/views/partials/tags.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <div class="tags">
2 2
     <div class="container">
3 3
         <?php
4
-        foreach ($tags as $tag => $value) {
4
+        foreach ($tags as $tag => $value){
5 5
             echo sprintf(
6 6
                 '<div class="tag"><div class="name">%s</div><div class="value">%s</div></div>',
7 7
                 $tag,
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <div class="tags">
2 2
     <div class="container">
3 3
         <?php
4
-        foreach ($tags as $tag => $value) {
4
+        foreach ($tags as $tag => $value)
5
+        {
5 6
             echo sprintf(
6 7
                 '<div class="tag"><div class="name">%s</div><div class="value">%s</div></div>',
7 8
                 $tag,
Please login to merge, or discard this patch.
src/Exceptions/views/partials/logs.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
             <table>
6 6
                 <?php
7 7
                 /** @var \Spiral\Logger\Event\LogEvent $log */
8
-                foreach ($logEvents as $log) {
8
+                foreach ($logEvents as $log){
9 9
                     echo sprintf(
10 10
                         '<tr><td class="channel">%s</td><td class="message">%s</td></tr>',
11 11
                         $log->getChannel(),
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,8 @@
 block discarded – undo
5 5
             <table>
6 6
                 <?php
7 7
                 /** @var \Spiral\Logger\Event\LogEvent $log */
8
-                foreach ($logEvents as $log) {
8
+                foreach ($logEvents as $log)
9
+                {
9 10
                     echo sprintf(
10 11
                         '<tr><td class="channel">%s</td><td class="message">%s</td></tr>',
11 12
                         $log->getChannel(),
Please login to merge, or discard this patch.
src/Exceptions/views/partials/variables.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,12 +6,12 @@
 block discarded – undo
6 6
             </div>
7 7
             <div class="dump" id="<?= md5($name) ?>-variables" style="display: none;">
8 8
                 <?php
9
-                if (!is_array($content)) {
9
+                if (!is_array($content)){
10 10
                     echo is_scalar($value) ? htmlspecialchars($value) : json_encode($value, JSON_PRETTY_PRINT);
11
-                } else { ?>
11
+                }else{ ?>
12 12
                     <table>
13 13
                         <?php
14
-                        foreach ($content as $key => $value) {
14
+                        foreach ($content as $key => $value){
15 15
                             // todo: values
16 16
                             echo sprintf(
17 17
                                 '<tr><td class="name">%s</td><td>%s</td></tr>',
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,12 +6,17 @@
 block discarded – undo
6 6
             </div>
7 7
             <div class="dump" id="<?= md5($name) ?>-variables" style="display: none;">
8 8
                 <?php
9
-                if (!is_array($content)) {
9
+                if (!is_array($content))
10
+                {
10 11
                     echo is_scalar($value) ? htmlspecialchars($value) : json_encode($value, JSON_PRETTY_PRINT);
11
-                } else { ?>
12
+                }
13
+                else
14
+                {
15
+?>
12 16
                     <table>
13 17
                         <?php
14
-                        foreach ($content as $key => $value) {
18
+                        foreach ($content as $key => $value)
19
+                        {
15 20
                             // todo: values
16 21
                             echo sprintf(
17 22
                                 '<tr><td class="name">%s</td><td>%s</td></tr>',
Please login to merge, or discard this patch.
src/Exceptions/views/partials/chain.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -4,23 +4,23 @@  discard block
 block discarded – undo
4 4
  * @var Throwable                       $exception
5 5
  * @var \Spiral\Exceptions\ValueWrapper $valueWrapper
6 6
  */
7
-foreach ($stacktrace as $index => $trace) {
8
-    if (empty($trace['file']) && isset($stacktrace[$index - 1]['file'])) {
7
+foreach ($stacktrace as $index => $trace){
8
+    if (empty($trace['file']) && isset($stacktrace[$index - 1]['file'])){
9 9
         $trace['file'] = $stacktrace[$index - 1]['file'];
10 10
         $trace['line'] = $stacktrace[$index - 1]['line'];
11 11
     }
12 12
 
13
-    if (!isset($stacktrace[$index + 1])) {
13
+    if (!isset($stacktrace[$index + 1])){
14 14
         $trace['file'] = $exception->getFile();
15 15
         $trace['line'] = $exception->getLine();
16 16
     }
17 17
 
18
-    if (!isset($trace['function']) || !isset($trace['file'])) {
18
+    if (!isset($trace['function']) || !isset($trace['file'])){
19 19
         continue;
20 20
     }
21 21
 
22
-    $function = '<strong>' . $trace['function'] . '</strong>';
23
-    if (isset($trace['type']) && isset($trace['class'])) {
22
+    $function = '<strong>'.$trace['function'].'</strong>';
23
+    if (isset($trace['type']) && isset($trace['class'])){
24 24
         $reflection = new ReflectionClass($trace['class']);
25 25
         $function = sprintf(
26 26
             '<span title="%s">%s</span>%s%s',
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     }
33 33
 
34 34
     $args = [];
35
-    if (isset($trace['args'])) {
35
+    if (isset($trace['args'])){
36 36
         $args = $valueWrapper->wrap($trace['args']);
37 37
     } ?>
38 38
     <div class="call">
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -4,23 +4,28 @@  discard block
 block discarded – undo
4 4
  * @var Throwable                       $exception
5 5
  * @var \Spiral\Exceptions\ValueWrapper $valueWrapper
6 6
  */
7
-foreach ($stacktrace as $index => $trace) {
8
-    if (empty($trace['file']) && isset($stacktrace[$index - 1]['file'])) {
7
+foreach ($stacktrace as $index => $trace)
8
+{
9
+    if (empty($trace['file']) && isset($stacktrace[$index - 1]['file']))
10
+    {
9 11
         $trace['file'] = $stacktrace[$index - 1]['file'];
10 12
         $trace['line'] = $stacktrace[$index - 1]['line'];
11 13
     }
12 14
 
13
-    if (!isset($stacktrace[$index + 1])) {
15
+    if (!isset($stacktrace[$index + 1]))
16
+    {
14 17
         $trace['file'] = $exception->getFile();
15 18
         $trace['line'] = $exception->getLine();
16 19
     }
17 20
 
18
-    if (!isset($trace['function']) || !isset($trace['file'])) {
21
+    if (!isset($trace['function']) || !isset($trace['file']))
22
+    {
19 23
         continue;
20 24
     }
21 25
 
22 26
     $function = '<strong>' . $trace['function'] . '</strong>';
23
-    if (isset($trace['type']) && isset($trace['class'])) {
27
+    if (isset($trace['type']) && isset($trace['class']))
28
+    {
24 29
         $reflection = new ReflectionClass($trace['class']);
25 30
         $function = sprintf(
26 31
             '<span title="%s">%s</span>%s%s',
@@ -32,7 +37,8 @@  discard block
 block discarded – undo
32 37
     }
33 38
 
34 39
     $args = [];
35
-    if (isset($trace['args'])) {
40
+    if (isset($trace['args']))
41
+    {
36 42
         $args = $valueWrapper->wrap($trace['args']);
37 43
     } ?>
38 44
     <div class="call">
Please login to merge, or discard this patch.
src/Exceptions/src/Style/ConsoleStyle.php 2 patches
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -99,12 +99,14 @@  discard block
 block discarded – undo
99 99
     {
100 100
         $style = $this->getStyle($token, $previous);
101 101
 
102
-        if (strpos($token[1], "\n") === false) {
102
+        if (strpos($token[1], "\n") === false)
103
+        {
103 104
             return sprintf($this->templates['token'], $style, $token[1]);
104 105
         }
105 106
 
106 107
         $lines = [];
107
-        foreach (explode("\n", $token[1]) as $line) {
108
+        foreach (explode("\n", $token[1]) as $line)
109
+        {
108 110
             $lines[] = sprintf($this->templates['token'], $style, $line);
109 111
         }
110 112
 
@@ -132,16 +134,21 @@  discard block
 block discarded – undo
132 134
      */
133 135
     private function getStyle(array $token, array $previous): string
134 136
     {
135
-        if (!empty($previous)) {
136
-            foreach ($this->style as $style => $tokens) {
137
-                if (in_array($previous[1] . $token[0], $tokens)) {
137
+        if (!empty($previous))
138
+        {
139
+            foreach ($this->style as $style => $tokens)
140
+            {
141
+                if (in_array($previous[1] . $token[0], $tokens))
142
+                {
138 143
                     return $style;
139 144
                 }
140 145
             }
141 146
         }
142 147
 
143
-        foreach ($this->style as $style => $tokens) {
144
-            if (in_array($token[0], $tokens)) {
148
+        foreach ($this->style as $style => $tokens)
149
+        {
150
+            if (in_array($token[0], $tokens))
151
+            {
145 152
                 return $style;
146 153
             }
147 154
         }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 {
22 22
     /** @var array */
23 23
     protected $templates = [
24
-        'token'  => '%s%s' . Color::RESET,
25
-        'line'   => Color::LIGHT_CYAN . ' %s ' . Color::RESET . " %s\n",
26
-        'active' => Color::BG_RED . ' ' . Color::LIGHT_WHITE . '%s ' . Color::RESET . " %s\n",
24
+        'token'  => '%s%s'.Color::RESET,
25
+        'line'   => Color::LIGHT_CYAN.' %s '.Color::RESET." %s\n",
26
+        'active' => Color::BG_RED.' '.Color::LIGHT_WHITE.'%s '.Color::RESET." %s\n",
27 27
     ];
28 28
 
29 29
     /** @var array */
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
             T_VARIABLE,
88 88
         ],
89 89
         Color::LIGHT_YELLOW  => [
90
-            '->' . T_STRING,
91
-            '::' . T_STRING,
90
+            '->'.T_STRING,
91
+            '::'.T_STRING,
92 92
         ],
93 93
     ];
94 94
 
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
     {
100 100
         $style = $this->getStyle($token, $previous);
101 101
 
102
-        if (strpos($token[1], "\n") === false) {
102
+        if (strpos($token[1], "\n") === false){
103 103
             return sprintf($this->templates['token'], $style, $token[1]);
104 104
         }
105 105
 
106 106
         $lines = [];
107
-        foreach (explode("\n", $token[1]) as $line) {
107
+        foreach (explode("\n", $token[1]) as $line){
108 108
             $lines[] = sprintf($this->templates['token'], $style, $line);
109 109
         }
110 110
 
@@ -132,16 +132,16 @@  discard block
 block discarded – undo
132 132
      */
133 133
     private function getStyle(array $token, array $previous): string
134 134
     {
135
-        if (!empty($previous)) {
136
-            foreach ($this->style as $style => $tokens) {
137
-                if (in_array($previous[1] . $token[0], $tokens)) {
135
+        if (!empty($previous)){
136
+            foreach ($this->style as $style => $tokens){
137
+                if (in_array($previous[1].$token[0], $tokens)){
138 138
                     return $style;
139 139
                 }
140 140
             }
141 141
         }
142 142
 
143
-        foreach ($this->style as $style => $tokens) {
144
-            if (in_array($token[0], $tokens)) {
143
+        foreach ($this->style as $style => $tokens){
144
+            if (in_array($token[0], $tokens)){
145 145
                 return $style;
146 146
             }
147 147
         }
Please login to merge, or discard this patch.
src/Exceptions/src/Style/HtmlStyle.php 3 patches
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -186,12 +186,14 @@  discard block
 block discarded – undo
186 186
     {
187 187
         $style = $this->getStyle($token, $previous);
188 188
 
189
-        if (strpos($token[1], "\n") === false) {
189
+        if (strpos($token[1], "\n") === false)
190
+        {
190 191
             return sprintf($this->templates['token'], $style, htmlspecialchars($token[1]));
191 192
         }
192 193
 
193 194
         $lines = [];
194
-        foreach (explode("\n", $token[1]) as $line) {
195
+        foreach (explode("\n", $token[1]) as $line)
196
+        {
195 197
             $lines[] = sprintf($this->templates['token'], $style, htmlspecialchars($line));
196 198
         }
197 199
 
@@ -215,16 +217,21 @@  discard block
 block discarded – undo
215 217
      */
216 218
     private function getStyle(array $token, array $previous): string
217 219
     {
218
-        if (!empty($previous)) {
219
-            foreach ($this->style as $style => $tokens) {
220
-                if (in_array($previous[1] . $token[0], $tokens)) {
220
+        if (!empty($previous))
221
+        {
222
+            foreach ($this->style as $style => $tokens)
223
+            {
224
+                if (in_array($previous[1] . $token[0], $tokens))
225
+                {
221 226
                     return $style;
222 227
                 }
223 228
             }
224 229
         }
225 230
 
226
-        foreach ($this->style as $style => $tokens) {
227
-            if (in_array($token[0], $tokens)) {
231
+        foreach ($this->style as $style => $tokens)
232
+        {
233
+            if (in_array($token[0], $tokens))
234
+            {
228 235
                 return $style;
229 236
             }
230 237
         }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
             T_VARIABLE,
149 149
         ],
150 150
         'color: #E6D100;'                    => [
151
-            '->' . T_STRING,
152
-            '::' . T_STRING,
151
+            '->'.T_STRING,
152
+            '::'.T_STRING,
153 153
         ],
154 154
     ];
155 155
 
@@ -186,12 +186,12 @@  discard block
 block discarded – undo
186 186
     {
187 187
         $style = $this->getStyle($token, $previous);
188 188
 
189
-        if (strpos($token[1], "\n") === false) {
189
+        if (strpos($token[1], "\n") === false){
190 190
             return sprintf($this->templates['token'], $style, htmlspecialchars($token[1]));
191 191
         }
192 192
 
193 193
         $lines = [];
194
-        foreach (explode("\n", $token[1]) as $line) {
194
+        foreach (explode("\n", $token[1]) as $line){
195 195
             $lines[] = sprintf($this->templates['token'], $style, htmlspecialchars($line));
196 196
         }
197 197
 
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
      */
216 216
     private function getStyle(array $token, array $previous): string
217 217
     {
218
-        if (!empty($previous)) {
219
-            foreach ($this->style as $style => $tokens) {
220
-                if (in_array($previous[1] . $token[0], $tokens)) {
218
+        if (!empty($previous)){
219
+            foreach ($this->style as $style => $tokens){
220
+                if (in_array($previous[1].$token[0], $tokens)){
221 221
                     return $style;
222 222
                 }
223 223
             }
224 224
         }
225 225
 
226
-        foreach ($this->style as $style => $tokens) {
227
-            if (in_array($token[0], $tokens)) {
226
+        foreach ($this->style as $style => $tokens){
227
+            if (in_array($token[0], $tokens)){
228 228
                 return $style;
229 229
             }
230 230
         }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     /**
23 23
      * Default code styles.
24 24
      */
25
-    public const DEFAULT = [
25
+    public const default = [
26 26
         'color: blue; font-weight: bold;'   => [
27 27
             T_STATIC,
28 28
             T_PUBLIC,
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
      *
170 170
      * @var array
171 171
      */
172
-    protected $style = self::DEFAULT;
172
+    protected $style = self::default;
173 173
 
174
-    public function __construct(array $style = self::DEFAULT)
174
+    public function __construct(array $style = self::default)
175 175
     {
176 176
         $this->style = $style;
177 177
     }
Please login to merge, or discard this patch.
src/Exceptions/src/Style/PlainStyle.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
      */
32 32
     public function line(int $number, string $code, bool $target = false): string
33 33
     {
34
-        if ($target) {
34
+        if ($target){
35 35
             return sprintf(
36 36
                 ">%s %s\n",
37 37
                 str_pad((string)$number, 4, ' ', STR_PAD_LEFT),
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,8 @@
 block discarded – undo
31 31
      */
32 32
     public function line(int $number, string $code, bool $target = false): string
33 33
     {
34
-        if ($target) {
34
+        if ($target)
35
+        {
35 36
             return sprintf(
36 37
                 ">%s %s\n",
37 38
                 str_pad((string)$number, 4, ' ', STR_PAD_LEFT),
Please login to merge, or discard this patch.