@@ -1,15 +1,15 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return array ( |
4 | - 'index' => |
|
5 | - array ( |
|
4 | + 'index' => |
|
5 | + array ( |
|
6 | 6 | 'pattern' => '/', |
7 | 7 | 'controller' => 'Spiral\\Tests\\Router\\App\\Controller\\HomeController', |
8 | 8 | 'action' => 'index', |
9 | 9 | 'group' => 'default', |
10 | 10 | 'verbs' => |
11 | 11 | array ( |
12 | - 0 => 'GET', |
|
12 | + 0 => 'GET', |
|
13 | 13 | ), |
14 | 14 | 'defaults' => |
15 | 15 | array ( |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | 'middleware' => |
18 | 18 | array ( |
19 | 19 | ), |
20 | - ), |
|
21 | - 'method' => |
|
22 | - array ( |
|
20 | + ), |
|
21 | + 'method' => |
|
22 | + array ( |
|
23 | 23 | 'pattern' => '/', |
24 | 24 | 'controller' => 'Spiral\\Tests\\Router\\App\\Controller\\HomeController', |
25 | 25 | 'action' => 'method', |
26 | 26 | 'group' => 'default', |
27 | 27 | 'verbs' => |
28 | 28 | array ( |
29 | - 0 => 'POST', |
|
29 | + 0 => 'POST', |
|
30 | 30 | ), |
31 | 31 | 'defaults' => |
32 | 32 | array ( |
@@ -34,5 +34,5 @@ discard block |
||
34 | 34 | 'middleware' => |
35 | 35 | array ( |
36 | 36 | ), |
37 | - ), |
|
37 | + ), |
|
38 | 38 | ); |
@@ -1,38 +1,38 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -return array ( |
|
3 | +return array( |
|
4 | 4 | 'index' => |
5 | - array ( |
|
5 | + array( |
|
6 | 6 | 'pattern' => '/', |
7 | 7 | 'controller' => 'Spiral\\Tests\\Router\\App\\Controller\\HomeController', |
8 | 8 | 'action' => 'index', |
9 | 9 | 'group' => 'default', |
10 | 10 | 'verbs' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 0 => 'GET', |
13 | 13 | ), |
14 | 14 | 'defaults' => |
15 | - array ( |
|
15 | + array( |
|
16 | 16 | ), |
17 | 17 | 'middleware' => |
18 | - array ( |
|
18 | + array( |
|
19 | 19 | ), |
20 | 20 | ), |
21 | 21 | 'method' => |
22 | - array ( |
|
22 | + array( |
|
23 | 23 | 'pattern' => '/', |
24 | 24 | 'controller' => 'Spiral\\Tests\\Router\\App\\Controller\\HomeController', |
25 | 25 | 'action' => 'method', |
26 | 26 | 'group' => 'default', |
27 | 27 | 'verbs' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | 0 => 'POST', |
30 | 30 | ), |
31 | 31 | 'defaults' => |
32 | - array ( |
|
32 | + array( |
|
33 | 33 | ), |
34 | 34 | 'middleware' => |
35 | - array ( |
|
35 | + array( |
|
36 | 36 | ), |
37 | 37 | ), |
38 | 38 | ); |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | $vendorDir = dirname(dirname($vendorDir)); |
11 | 11 | $vendorID = null; |
12 | 12 | $vendorCount = 0; |
13 | -foreach ($stacktrace as $index => $trace) { |
|
13 | +foreach ($stacktrace as $index => $trace){ |
|
14 | 14 | $args = []; |
15 | - if (isset($trace['args'])) { |
|
15 | + if (isset($trace['args'])){ |
|
16 | 16 | $args = $valueWrapper->wrap($trace['args']); |
17 | 17 | } |
18 | 18 | |
19 | - $function = '<strong>' . $trace['function'] . '</strong>'; |
|
20 | - if (isset($trace['type']) && isset($trace['class'])) { |
|
19 | + $function = '<strong>'.$trace['function'].'</strong>'; |
|
20 | + if (isset($trace['type']) && isset($trace['class'])){ |
|
21 | 21 | $reflection = new ReflectionClass($trace['class']); |
22 | 22 | $function = sprintf( |
23 | 23 | '<span title="%s">%s</span>%s%s', |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | ); |
29 | 29 | } |
30 | 30 | |
31 | - if (!isset($trace['file']) || !file_exists($trace['file'])) { ?> |
|
31 | + if (!isset($trace['file']) || !file_exists($trace['file'])){ ?> |
|
32 | 32 | <div class="container no-trace"> |
33 | 33 | <?= $function ?>(<span class="arguments"><?= implode(', ', $args) ?></span>) |
34 | 34 | </div> |
@@ -37,21 +37,21 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | $isVendor = strpos($trace['file'], $vendorDir) === 0 && $index > 1; |
40 | - if ($isVendor) { |
|
41 | - if ($vendorID === null) { |
|
40 | + if ($isVendor){ |
|
41 | + if ($vendorID === null){ |
|
42 | 42 | $vendorID = $index; |
43 | 43 | $vendorCount++; |
44 | 44 | echo sprintf('<span id="hidden-trace-%s" style="display: none;">', $vendorID); |
45 | - } else { |
|
45 | + }else{ |
|
46 | 46 | $vendorCount++; |
47 | 47 | } |
48 | - } elseif ($vendorID !== null) { |
|
48 | + } elseif ($vendorID !== null){ |
|
49 | 49 | echo '</span>'; |
50 | 50 | echo sprintf( |
51 | 51 | '<div id="%s" class="container" style="cursor: pointer;" onclick="toggle(\'%s\'); toggle(\'%s\');">+ %s vendor frame(s)...</div>', |
52 | - 'toggle-trace-' . $vendorID, |
|
53 | - 'toggle-trace-' . $vendorID, |
|
54 | - 'hidden-trace-' . $vendorID, |
|
52 | + 'toggle-trace-'.$vendorID, |
|
53 | + 'toggle-trace-'.$vendorID, |
|
54 | + 'hidden-trace-'.$vendorID, |
|
55 | 55 | $vendorCount |
56 | 56 | ); |
57 | 57 | $vendorID = null; |
@@ -72,6 +72,6 @@ discard block |
||
72 | 72 | <?php |
73 | 73 | } |
74 | 74 | |
75 | -if ($vendorID !== null) { |
|
75 | +if ($vendorID !== null){ |
|
76 | 76 | echo '</span>'; |
77 | 77 | } |
@@ -10,14 +10,17 @@ discard block |
||
10 | 10 | $vendorDir = dirname(dirname($vendorDir)); |
11 | 11 | $vendorID = null; |
12 | 12 | $vendorCount = 0; |
13 | -foreach ($stacktrace as $index => $trace) { |
|
13 | +foreach ($stacktrace as $index => $trace) |
|
14 | +{ |
|
14 | 15 | $args = []; |
15 | - if (isset($trace['args'])) { |
|
16 | + if (isset($trace['args'])) |
|
17 | + { |
|
16 | 18 | $args = $valueWrapper->wrap($trace['args']); |
17 | 19 | } |
18 | 20 | |
19 | 21 | $function = '<strong>' . $trace['function'] . '</strong>'; |
20 | - if (isset($trace['type']) && isset($trace['class'])) { |
|
22 | + if (isset($trace['type']) && isset($trace['class'])) |
|
23 | + { |
|
21 | 24 | $reflection = new ReflectionClass($trace['class']); |
22 | 25 | $function = sprintf( |
23 | 26 | '<span title="%s">%s</span>%s%s', |
@@ -28,7 +31,9 @@ discard block |
||
28 | 31 | ); |
29 | 32 | } |
30 | 33 | |
31 | - if (!isset($trace['file']) || !file_exists($trace['file'])) { ?> |
|
34 | + if (!isset($trace['file']) || !file_exists($trace['file'])) |
|
35 | + { |
|
36 | +?> |
|
32 | 37 | <div class="container no-trace"> |
33 | 38 | <?= $function ?>(<span class="arguments"><?= implode(', ', $args) ?></span>) |
34 | 39 | </div> |
@@ -37,15 +42,21 @@ discard block |
||
37 | 42 | } |
38 | 43 | |
39 | 44 | $isVendor = strpos($trace['file'], $vendorDir) === 0 && $index > 1; |
40 | - if ($isVendor) { |
|
41 | - if ($vendorID === null) { |
|
45 | + if ($isVendor) |
|
46 | + { |
|
47 | + if ($vendorID === null) |
|
48 | + { |
|
42 | 49 | $vendorID = $index; |
43 | 50 | $vendorCount++; |
44 | 51 | echo sprintf('<span id="hidden-trace-%s" style="display: none;">', $vendorID); |
45 | - } else { |
|
52 | + } |
|
53 | + else |
|
54 | + { |
|
46 | 55 | $vendorCount++; |
47 | 56 | } |
48 | - } elseif ($vendorID !== null) { |
|
57 | + } |
|
58 | + elseif ($vendorID !== null) |
|
59 | + { |
|
49 | 60 | echo '</span>'; |
50 | 61 | echo sprintf( |
51 | 62 | '<div id="%s" class="container" style="cursor: pointer;" onclick="toggle(\'%s\'); toggle(\'%s\');">+ %s vendor frame(s)...</div>', |
@@ -72,6 +83,7 @@ discard block |
||
72 | 83 | <?php |
73 | 84 | } |
74 | 85 | |
75 | -if ($vendorID !== null) { |
|
86 | +if ($vendorID !== null) |
|
87 | +{ |
|
76 | 88 | echo '</span>'; |
77 | 89 | } |
@@ -24,19 +24,19 @@ |
||
24 | 24 | */ |
25 | 25 | public function leaveNode(Node $node): void |
26 | 26 | { |
27 | - if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct') { |
|
28 | - foreach ($node->params as $param) { |
|
29 | - if ($param->type instanceof Node\NullableType) { |
|
30 | - if ($param->type->type instanceof Node\Identifier) { |
|
27 | + if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct'){ |
|
28 | + foreach ($node->params as $param){ |
|
29 | + if ($param->type instanceof Node\NullableType){ |
|
30 | + if ($param->type->type instanceof Node\Identifier){ |
|
31 | 31 | $type = $param->type->type->name; |
32 | - } else { |
|
32 | + }else{ |
|
33 | 33 | $type = implode('\\', $param->type->type->parts); |
34 | 34 | } |
35 | 35 | |
36 | 36 | $type = "?$type"; |
37 | - } elseif ($param->type instanceof Node\Name) { |
|
37 | + } elseif ($param->type instanceof Node\Name){ |
|
38 | 38 | $type = implode('\\', $param->type->parts); |
39 | - } else { |
|
39 | + }else{ |
|
40 | 40 | $type = $param->type->name ?? null; |
41 | 41 | } |
42 | 42 |
@@ -24,19 +24,29 @@ |
||
24 | 24 | */ |
25 | 25 | public function leaveNode(Node $node): void |
26 | 26 | { |
27 | - if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct') { |
|
28 | - foreach ($node->params as $param) { |
|
29 | - if ($param->type instanceof Node\NullableType) { |
|
30 | - if ($param->type->type instanceof Node\Identifier) { |
|
27 | + if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct') |
|
28 | + { |
|
29 | + foreach ($node->params as $param) |
|
30 | + { |
|
31 | + if ($param->type instanceof Node\NullableType) |
|
32 | + { |
|
33 | + if ($param->type->type instanceof Node\Identifier) |
|
34 | + { |
|
31 | 35 | $type = $param->type->type->name; |
32 | - } else { |
|
36 | + } |
|
37 | + else |
|
38 | + { |
|
33 | 39 | $type = implode('\\', $param->type->type->parts); |
34 | 40 | } |
35 | 41 | |
36 | 42 | $type = "?$type"; |
37 | - } elseif ($param->type instanceof Node\Name) { |
|
43 | + } |
|
44 | + elseif ($param->type instanceof Node\Name) |
|
45 | + { |
|
38 | 46 | $type = implode('\\', $param->type->parts); |
39 | - } else { |
|
47 | + } |
|
48 | + else |
|
49 | + { |
|
40 | 50 | $type = $param->type->name ?? null; |
41 | 51 | } |
42 | 52 |
@@ -26,22 +26,22 @@ discard block |
||
26 | 26 | { |
27 | 27 | $lines = explode("\n", $comment); |
28 | 28 | |
29 | - foreach ($lines as $line) { |
|
29 | + foreach ($lines as $line){ |
|
30 | 30 | // strip up comment prefix |
31 | 31 | $line = preg_replace('/[\t ]*[\/]?\*[\/]? ?/', '', $line); |
32 | 32 | |
33 | - if (preg_match('/ *@([^ ]+) (.*)/u', $line, $matches)) { |
|
33 | + if (preg_match('/ *@([^ ]+) (.*)/u', $line, $matches)){ |
|
34 | 34 | $this->lines[] = new Line($matches[2], $matches[1]); |
35 | - } else { |
|
35 | + }else{ |
|
36 | 36 | $this->lines[] = new Line($line); |
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | - if (isset($this->lines[0]) && $this->lines[0]->isEmpty()) { |
|
40 | + if (isset($this->lines[0]) && $this->lines[0]->isEmpty()){ |
|
41 | 41 | array_shift($this->lines); |
42 | 42 | } |
43 | 43 | |
44 | - if (isset($this->lines[count($this->lines) - 1]) && $this->lines[count($this->lines) - 1]->isEmpty()) { |
|
44 | + if (isset($this->lines[count($this->lines) - 1]) && $this->lines[count($this->lines) - 1]->isEmpty()){ |
|
45 | 45 | array_pop($this->lines); |
46 | 46 | } |
47 | 47 | } |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | $result[] = '/**'; |
56 | 56 | |
57 | 57 | // skip first and last tokens |
58 | - foreach ($this->lines as $line) { |
|
59 | - if ($line->type === null) { |
|
58 | + foreach ($this->lines as $line){ |
|
59 | + if ($line->type === null){ |
|
60 | 60 | $result[] = sprintf(' * %s', $line->value); |
61 | 61 | continue; |
62 | 62 | } |
@@ -26,22 +26,28 @@ discard block |
||
26 | 26 | { |
27 | 27 | $lines = explode("\n", $comment); |
28 | 28 | |
29 | - foreach ($lines as $line) { |
|
29 | + foreach ($lines as $line) |
|
30 | + { |
|
30 | 31 | // strip up comment prefix |
31 | 32 | $line = preg_replace('/[\t ]*[\/]?\*[\/]? ?/', '', $line); |
32 | 33 | |
33 | - if (preg_match('/ *@([^ ]+) (.*)/u', $line, $matches)) { |
|
34 | + if (preg_match('/ *@([^ ]+) (.*)/u', $line, $matches)) |
|
35 | + { |
|
34 | 36 | $this->lines[] = new Line($matches[2], $matches[1]); |
35 | - } else { |
|
37 | + } |
|
38 | + else |
|
39 | + { |
|
36 | 40 | $this->lines[] = new Line($line); |
37 | 41 | } |
38 | 42 | } |
39 | 43 | |
40 | - if (isset($this->lines[0]) && $this->lines[0]->isEmpty()) { |
|
44 | + if (isset($this->lines[0]) && $this->lines[0]->isEmpty()) |
|
45 | + { |
|
41 | 46 | array_shift($this->lines); |
42 | 47 | } |
43 | 48 | |
44 | - if (isset($this->lines[count($this->lines) - 1]) && $this->lines[count($this->lines) - 1]->isEmpty()) { |
|
49 | + if (isset($this->lines[count($this->lines) - 1]) && $this->lines[count($this->lines) - 1]->isEmpty()) |
|
50 | + { |
|
45 | 51 | array_pop($this->lines); |
46 | 52 | } |
47 | 53 | } |
@@ -55,8 +61,10 @@ discard block |
||
55 | 61 | $result[] = '/**'; |
56 | 62 | |
57 | 63 | // skip first and last tokens |
58 | - foreach ($this->lines as $line) { |
|
59 | - if ($line->type === null) { |
|
64 | + foreach ($this->lines as $line) |
|
65 | + { |
|
66 | + if ($line->type === null) |
|
67 | + { |
|
60 | 68 | $result[] = sprintf(' * %s', $line->value); |
61 | 69 | continue; |
62 | 70 | } |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function enterNode(Node $node) |
30 | 30 | { |
31 | - if ($node instanceof Node\Stmt\Use_) { |
|
32 | - foreach ($node->uses as $use) { |
|
31 | + if ($node instanceof Node\Stmt\Use_){ |
|
32 | + foreach ($node->uses as $use){ |
|
33 | 33 | $this->imports[] = [ |
34 | 34 | 'name' => implode('\\', $use->name->parts), |
35 | 35 | 'alias' => !empty($use->alias) ? $use->alias->name : null, |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | - if ($node instanceof Node\Stmt\Class_) { |
|
41 | - foreach ($node->stmts as $stmt) { |
|
42 | - if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct') { |
|
40 | + if ($node instanceof Node\Stmt\Class_){ |
|
41 | + foreach ($node->stmts as $stmt){ |
|
42 | + if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct'){ |
|
43 | 43 | return $stmt; |
44 | 44 | } |
45 | 45 | } |
@@ -28,8 +28,10 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function enterNode(Node $node) |
30 | 30 | { |
31 | - if ($node instanceof Node\Stmt\Use_) { |
|
32 | - foreach ($node->uses as $use) { |
|
31 | + if ($node instanceof Node\Stmt\Use_) |
|
32 | + { |
|
33 | + foreach ($node->uses as $use) |
|
34 | + { |
|
33 | 35 | $this->imports[] = [ |
34 | 36 | 'name' => implode('\\', $use->name->parts), |
35 | 37 | 'alias' => !empty($use->alias) ? $use->alias->name : null, |
@@ -37,9 +39,12 @@ discard block |
||
37 | 39 | } |
38 | 40 | } |
39 | 41 | |
40 | - if ($node instanceof Node\Stmt\Class_) { |
|
41 | - foreach ($node->stmts as $stmt) { |
|
42 | - if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct') { |
|
42 | + if ($node instanceof Node\Stmt\Class_) |
|
43 | + { |
|
44 | + foreach ($node->stmts as $stmt) |
|
45 | + { |
|
46 | + if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct') |
|
47 | + { |
|
43 | 48 | return $stmt; |
44 | 49 | } |
45 | 50 | } |
@@ -26,11 +26,11 @@ |
||
26 | 26 | */ |
27 | 27 | public function enterNode(Node $node) |
28 | 28 | { |
29 | - if ($node instanceof Node\Stmt\Namespace_) { |
|
29 | + if ($node instanceof Node\Stmt\Namespace_){ |
|
30 | 30 | $this->namespace = implode('\\', $node->name->parts); |
31 | 31 | } |
32 | 32 | |
33 | - if ($node instanceof Node\Stmt\Class_) { |
|
33 | + if ($node instanceof Node\Stmt\Class_){ |
|
34 | 34 | $this->class = $node->name->name; |
35 | 35 | |
36 | 36 | return NodeTraverser::STOP_TRAVERSAL; |
@@ -26,11 +26,13 @@ |
||
26 | 26 | */ |
27 | 27 | public function enterNode(Node $node) |
28 | 28 | { |
29 | - if ($node instanceof Node\Stmt\Namespace_) { |
|
29 | + if ($node instanceof Node\Stmt\Namespace_) |
|
30 | + { |
|
30 | 31 | $this->namespace = implode('\\', $node->name->parts); |
31 | 32 | } |
32 | 33 | |
33 | - if ($node instanceof Node\Stmt\Class_) { |
|
34 | + if ($node instanceof Node\Stmt\Class_) |
|
35 | + { |
|
34 | 36 | $this->class = $node->name->name; |
35 | 37 | |
36 | 38 | return NodeTraverser::STOP_TRAVERSAL; |
@@ -28,26 +28,26 @@ |
||
28 | 28 | */ |
29 | 29 | public function leaveNode(Node $node) |
30 | 30 | { |
31 | - if (!$node instanceof Node\Stmt\TraitUse) { |
|
31 | + if (!$node instanceof Node\Stmt\TraitUse){ |
|
32 | 32 | return null; |
33 | 33 | } |
34 | 34 | |
35 | - foreach ($node->traits as $index => $use) { |
|
36 | - if ($use instanceof Node\Name) { |
|
35 | + foreach ($node->traits as $index => $use){ |
|
36 | + if ($use instanceof Node\Name){ |
|
37 | 37 | $name = $this->trimSlashes(implode('\\', $use->parts)); |
38 | 38 | if ( |
39 | 39 | in_array($name, [ |
40 | 40 | $this->trimSlashes(PrototypeTrait::class), |
41 | 41 | Utils::shortName(PrototypeTrait::class), |
42 | 42 | ], true) |
43 | - ) { |
|
43 | + ){ |
|
44 | 44 | unset($node->traits[$index]); |
45 | 45 | } |
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | 49 | $node->traits = array_values($node->traits); |
50 | - if (empty($node->traits)) { |
|
50 | + if (empty($node->traits)){ |
|
51 | 51 | return NodeTraverser::REMOVE_NODE; |
52 | 52 | } |
53 | 53 |
@@ -28,12 +28,15 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function leaveNode(Node $node) |
30 | 30 | { |
31 | - if (!$node instanceof Node\Stmt\TraitUse) { |
|
31 | + if (!$node instanceof Node\Stmt\TraitUse) |
|
32 | + { |
|
32 | 33 | return null; |
33 | 34 | } |
34 | 35 | |
35 | - foreach ($node->traits as $index => $use) { |
|
36 | - if ($use instanceof Node\Name) { |
|
36 | + foreach ($node->traits as $index => $use) |
|
37 | + { |
|
38 | + if ($use instanceof Node\Name) |
|
39 | + { |
|
37 | 40 | $name = $this->trimSlashes(implode('\\', $use->parts)); |
38 | 41 | if ( |
39 | 42 | in_array($name, [ |
@@ -47,7 +50,8 @@ discard block |
||
47 | 50 | } |
48 | 51 | |
49 | 52 | $node->traits = array_values($node->traits); |
50 | - if (empty($node->traits)) { |
|
53 | + if (empty($node->traits)) |
|
54 | + { |
|
51 | 55 | return NodeTraverser::REMOVE_NODE; |
52 | 56 | } |
53 | 57 |