@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function enterNode($node, VisitorContext $ctx) |
32 | 32 | { |
33 | - if ($node instanceof Tag && strpos($node->name, $this->stackKeyword) === 0) { |
|
33 | + if ($node instanceof Tag && strpos($node->name, $this->stackKeyword) === 0){ |
|
34 | 34 | return $this->registerAggregate(StackContext::on($ctx), $node); |
35 | 35 | } |
36 | 36 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | private function registerAggregate(StackContext $ctx, Tag $node) |
53 | 53 | { |
54 | 54 | $name = $this->stackName($node); |
55 | - if ($name === null) { |
|
55 | + if ($name === null){ |
|
56 | 56 | return $node; |
57 | 57 | } |
58 | 58 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | private function stackName(Tag $tag): ?string |
73 | 73 | { |
74 | 74 | $options = []; |
75 | - foreach ($tag->attrs as $attr) { |
|
76 | - if (is_string($attr->value)) { |
|
75 | + foreach ($tag->attrs as $attr){ |
|
76 | + if (is_string($attr->value)){ |
|
77 | 77 | $options[$attr->name] = trim($attr->value, '\'"'); |
78 | 78 | } |
79 | 79 | } |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | private function stackLevel(Tag $tag): int |
89 | 89 | { |
90 | 90 | $options = []; |
91 | - foreach ($tag->attrs as $attr) { |
|
92 | - if (is_string($attr->value)) { |
|
91 | + foreach ($tag->attrs as $attr){ |
|
92 | + if (is_string($attr->value)){ |
|
93 | 93 | $options[$attr->name] = trim($attr->value, '\'"'); |
94 | 94 | } |
95 | 95 | } |
@@ -30,7 +30,8 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function enterNode($node, VisitorContext $ctx) |
32 | 32 | { |
33 | - if ($node instanceof Tag && strpos($node->name, $this->stackKeyword) === 0) { |
|
33 | + if ($node instanceof Tag && strpos($node->name, $this->stackKeyword) === 0) |
|
34 | + { |
|
34 | 35 | return $this->registerAggregate(StackContext::on($ctx), $node); |
35 | 36 | } |
36 | 37 | |
@@ -52,7 +53,8 @@ discard block |
||
52 | 53 | private function registerAggregate(StackContext $ctx, Tag $node) |
53 | 54 | { |
54 | 55 | $name = $this->stackName($node); |
55 | - if ($name === null) { |
|
56 | + if ($name === null) |
|
57 | + { |
|
56 | 58 | return $node; |
57 | 59 | } |
58 | 60 | |
@@ -72,8 +74,10 @@ discard block |
||
72 | 74 | private function stackName(Tag $tag): ?string |
73 | 75 | { |
74 | 76 | $options = []; |
75 | - foreach ($tag->attrs as $attr) { |
|
76 | - if (is_string($attr->value)) { |
|
77 | + foreach ($tag->attrs as $attr) |
|
78 | + { |
|
79 | + if (is_string($attr->value)) |
|
80 | + { |
|
77 | 81 | $options[$attr->name] = trim($attr->value, '\'"'); |
78 | 82 | } |
79 | 83 | } |
@@ -88,8 +92,10 @@ discard block |
||
88 | 92 | private function stackLevel(Tag $tag): int |
89 | 93 | { |
90 | 94 | $options = []; |
91 | - foreach ($tag->attrs as $attr) { |
|
92 | - if (is_string($attr->value)) { |
|
95 | + foreach ($tag->attrs as $attr) |
|
96 | + { |
|
97 | + if (is_string($attr->value)) |
|
98 | + { |
|
93 | 99 | $options[$attr->name] = trim($attr->value, '\'"'); |
94 | 100 | } |
95 | 101 | } |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function enterNode($node, VisitorContext $ctx) |
35 | 35 | { |
36 | - if ($node instanceof Tag) { |
|
36 | + if ($node instanceof Tag){ |
|
37 | 37 | return $this->makeBlock($node); |
38 | 38 | } |
39 | 39 | |
40 | - if ($node instanceof Inline) { |
|
40 | + if ($node instanceof Inline){ |
|
41 | 41 | $block = new Block($node->name, $node->getContext()); |
42 | - if ($node->value !== null) { |
|
42 | + if ($node->value !== null){ |
|
43 | 43 | $block->nodes[] = new Raw($node->value); |
44 | 44 | } |
45 | 45 | |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | private function makeBlock(Tag $node): ?NodeInterface |
66 | 66 | { |
67 | 67 | $name = null; |
68 | - foreach ($this->prefix as $prefix) { |
|
69 | - if (strpos($node->name, $prefix) === 0) { |
|
68 | + foreach ($this->prefix as $prefix){ |
|
69 | + if (strpos($node->name, $prefix) === 0){ |
|
70 | 70 | $name = substr($node->name, strlen($prefix)); |
71 | 71 | break; |
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - if ($name === null) { |
|
75 | + if ($name === null){ |
|
76 | 76 | return null; |
77 | 77 | } |
78 | 78 |
@@ -33,13 +33,16 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function enterNode($node, VisitorContext $ctx) |
35 | 35 | { |
36 | - if ($node instanceof Tag) { |
|
36 | + if ($node instanceof Tag) |
|
37 | + { |
|
37 | 38 | return $this->makeBlock($node); |
38 | 39 | } |
39 | 40 | |
40 | - if ($node instanceof Inline) { |
|
41 | + if ($node instanceof Inline) |
|
42 | + { |
|
41 | 43 | $block = new Block($node->name, $node->getContext()); |
42 | - if ($node->value !== null) { |
|
44 | + if ($node->value !== null) |
|
45 | + { |
|
43 | 46 | $block->nodes[] = new Raw($node->value); |
44 | 47 | } |
45 | 48 | |
@@ -65,14 +68,17 @@ discard block |
||
65 | 68 | private function makeBlock(Tag $node): ?NodeInterface |
66 | 69 | { |
67 | 70 | $name = null; |
68 | - foreach ($this->prefix as $prefix) { |
|
69 | - if (strpos($node->name, $prefix) === 0) { |
|
71 | + foreach ($this->prefix as $prefix) |
|
72 | + { |
|
73 | + if (strpos($node->name, $prefix) === 0) |
|
74 | + { |
|
70 | 75 | $name = substr($node->name, strlen($prefix)); |
71 | 76 | break; |
72 | 77 | } |
73 | 78 | } |
74 | 79 | |
75 | - if ($name === null) { |
|
80 | + if ($name === null) |
|
81 | + { |
|
76 | 82 | return null; |
77 | 83 | } |
78 | 84 |
@@ -33,7 +33,7 @@ |
||
33 | 33 | */ |
34 | 34 | public function leaveNode($node, VisitorContext $ctx) |
35 | 35 | { |
36 | - if ($node instanceof Tag && strpos($node->name, $this->hiddenKeyword) === 0) { |
|
36 | + if ($node instanceof Tag && strpos($node->name, $this->hiddenKeyword) === 0){ |
|
37 | 37 | return new Hidden([$node]); |
38 | 38 | } |
39 | 39 |
@@ -33,7 +33,8 @@ |
||
33 | 33 | */ |
34 | 34 | public function leaveNode($node, VisitorContext $ctx) |
35 | 35 | { |
36 | - if ($node instanceof Tag && strpos($node->name, $this->hiddenKeyword) === 0) { |
|
36 | + if ($node instanceof Tag && strpos($node->name, $this->hiddenKeyword) === 0) |
|
37 | + { |
|
37 | 38 | return new Hidden([$node]); |
38 | 39 | } |
39 | 40 |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | public function render(Compiler $compiler, Compiler\Result $result, NodeInterface $node): bool |
25 | 25 | { |
26 | - if ($node instanceof PHP) { |
|
26 | + if ($node instanceof PHP){ |
|
27 | 27 | $result->push($node->content, $node->getContext()); |
28 | 28 | return true; |
29 | 29 | } |
@@ -23,7 +23,8 @@ |
||
23 | 23 | */ |
24 | 24 | public function render(Compiler $compiler, Compiler\Result $result, NodeInterface $node): bool |
25 | 25 | { |
26 | - if ($node instanceof PHP) { |
|
26 | + if ($node instanceof PHP) |
|
27 | + { |
|
27 | 28 | $result->push($node->content, $node->getContext()); |
28 | 29 | return true; |
29 | 30 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function render(Compiler $compiler, Compiler\Result $result, NodeInterface $node): bool |
29 | 29 | { |
30 | - switch (true) { |
|
30 | + switch (true){ |
|
31 | 31 | case $node instanceof Tag: |
32 | 32 | $this->tag($compiler, $result, $node); |
33 | 33 | return true; |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | { |
52 | 52 | $result->push(sprintf('<%s', $node->name), $node->getContext()); |
53 | 53 | |
54 | - foreach ($node->attrs as $attr) { |
|
55 | - if (!$attr instanceof Attribute) { |
|
54 | + foreach ($node->attrs as $attr){ |
|
55 | + if (!$attr instanceof Attribute){ |
|
56 | 56 | $compiler->compile($attr, $result); |
57 | 57 | continue; |
58 | 58 | } |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | |
63 | 63 | $result->push(sprintf('%s>', $node->void ? '/' : ''), null); |
64 | 64 | |
65 | - foreach ($node->nodes as $child) { |
|
65 | + foreach ($node->nodes as $child){ |
|
66 | 66 | $compiler->compile($child, $result); |
67 | 67 | } |
68 | 68 | |
69 | - if (!$node->void) { |
|
69 | + if (!$node->void){ |
|
70 | 70 | $result->push(sprintf('</%s>', $node->name), null); |
71 | 71 | } |
72 | 72 | } |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | */ |
79 | 79 | private function attribute(Compiler $compiler, Compiler\Result $result, Attr $node): void |
80 | 80 | { |
81 | - if ($node->name instanceof NodeInterface) { |
|
81 | + if ($node->name instanceof NodeInterface){ |
|
82 | 82 | $result->push(' ', null); |
83 | 83 | $compiler->compile($node->name, $result); |
84 | - } else { |
|
84 | + }else{ |
|
85 | 85 | $result->push(sprintf(' %s', $node->name), $node->getContext()); |
86 | 86 | } |
87 | 87 | |
88 | 88 | $value = $node->value; |
89 | - if ($value instanceof Nil) { |
|
89 | + if ($value instanceof Nil){ |
|
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
93 | - if ($value instanceof NodeInterface) { |
|
93 | + if ($value instanceof NodeInterface){ |
|
94 | 94 | $result->push('=', null); |
95 | 95 | $compiler->compile($value, $result); |
96 | 96 | return; |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | */ |
107 | 107 | private function verbatim(Compiler $compiler, Compiler\Result $result, Verbatim $node): void |
108 | 108 | { |
109 | - foreach ($node->nodes as $child) { |
|
110 | - if (is_string($child)) { |
|
109 | + foreach ($node->nodes as $child){ |
|
110 | + if (is_string($child)){ |
|
111 | 111 | $result->push($child, null); |
112 | 112 | continue; |
113 | 113 | } |
@@ -27,7 +27,8 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function render(Compiler $compiler, Compiler\Result $result, NodeInterface $node): bool |
29 | 29 | { |
30 | - switch (true) { |
|
30 | + switch (true) |
|
31 | + { |
|
31 | 32 | case $node instanceof Tag: |
32 | 33 | $this->tag($compiler, $result, $node); |
33 | 34 | return true; |
@@ -51,8 +52,10 @@ discard block |
||
51 | 52 | { |
52 | 53 | $result->push(sprintf('<%s', $node->name), $node->getContext()); |
53 | 54 | |
54 | - foreach ($node->attrs as $attr) { |
|
55 | - if (!$attr instanceof Attribute) { |
|
55 | + foreach ($node->attrs as $attr) |
|
56 | + { |
|
57 | + if (!$attr instanceof Attribute) |
|
58 | + { |
|
56 | 59 | $compiler->compile($attr, $result); |
57 | 60 | continue; |
58 | 61 | } |
@@ -62,11 +65,13 @@ discard block |
||
62 | 65 | |
63 | 66 | $result->push(sprintf('%s>', $node->void ? '/' : ''), null); |
64 | 67 | |
65 | - foreach ($node->nodes as $child) { |
|
68 | + foreach ($node->nodes as $child) |
|
69 | + { |
|
66 | 70 | $compiler->compile($child, $result); |
67 | 71 | } |
68 | 72 | |
69 | - if (!$node->void) { |
|
73 | + if (!$node->void) |
|
74 | + { |
|
70 | 75 | $result->push(sprintf('</%s>', $node->name), null); |
71 | 76 | } |
72 | 77 | } |
@@ -78,19 +83,24 @@ discard block |
||
78 | 83 | */ |
79 | 84 | private function attribute(Compiler $compiler, Compiler\Result $result, Attr $node): void |
80 | 85 | { |
81 | - if ($node->name instanceof NodeInterface) { |
|
86 | + if ($node->name instanceof NodeInterface) |
|
87 | + { |
|
82 | 88 | $result->push(' ', null); |
83 | 89 | $compiler->compile($node->name, $result); |
84 | - } else { |
|
90 | + } |
|
91 | + else |
|
92 | + { |
|
85 | 93 | $result->push(sprintf(' %s', $node->name), $node->getContext()); |
86 | 94 | } |
87 | 95 | |
88 | 96 | $value = $node->value; |
89 | - if ($value instanceof Nil) { |
|
97 | + if ($value instanceof Nil) |
|
98 | + { |
|
90 | 99 | return; |
91 | 100 | } |
92 | 101 | |
93 | - if ($value instanceof NodeInterface) { |
|
102 | + if ($value instanceof NodeInterface) |
|
103 | + { |
|
94 | 104 | $result->push('=', null); |
95 | 105 | $compiler->compile($value, $result); |
96 | 106 | return; |
@@ -106,8 +116,10 @@ discard block |
||
106 | 116 | */ |
107 | 117 | private function verbatim(Compiler $compiler, Compiler\Result $result, Verbatim $node): void |
108 | 118 | { |
109 | - foreach ($node->nodes as $child) { |
|
110 | - if (is_string($child)) { |
|
119 | + foreach ($node->nodes as $child) |
|
120 | + { |
|
121 | + if (is_string($child)) |
|
122 | + { |
|
111 | 123 | $result->push($child, null); |
112 | 124 | continue; |
113 | 125 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function __construct( |
37 | 37 | DirectiveRendererInterface $directiveRenderer = null, |
38 | 38 | string $defaultFilter = self::DEFAULT_FILTER |
39 | - ) { |
|
39 | + ){ |
|
40 | 40 | $this->directiveRenderer = $directiveRenderer; |
41 | 41 | $this->defaultFilter = $defaultFilter; |
42 | 42 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function render(Compiler $compiler, Compiler\Result $result, NodeInterface $node): bool |
48 | 48 | { |
49 | - switch (true) { |
|
49 | + switch (true){ |
|
50 | 50 | case $node instanceof Output: |
51 | 51 | $this->output($result, $node); |
52 | 52 | return true; |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | */ |
67 | 67 | private function directive(Compiler\Result $source, Directive $directive): void |
68 | 68 | { |
69 | - if ($this->directiveRenderer !== null) { |
|
69 | + if ($this->directiveRenderer !== null){ |
|
70 | 70 | $result = $this->directiveRenderer->render($directive); |
71 | - if ($result !== null) { |
|
71 | + if ($result !== null){ |
|
72 | 72 | $source->push($result, $directive->getContext()); |
73 | 73 | return; |
74 | 74 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | private function output(Compiler\Result $source, Output $output): void |
88 | 88 | { |
89 | - if ($output->rawOutput) { |
|
89 | + if ($output->rawOutput){ |
|
90 | 90 | $source->push(sprintf('<?php echo %s; ?>', trim($output->body)), $output->getContext()); |
91 | 91 | return; |
92 | 92 | } |
@@ -46,7 +46,8 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function render(Compiler $compiler, Compiler\Result $result, NodeInterface $node): bool |
48 | 48 | { |
49 | - switch (true) { |
|
49 | + switch (true) |
|
50 | + { |
|
50 | 51 | case $node instanceof Output: |
51 | 52 | $this->output($result, $node); |
52 | 53 | return true; |
@@ -66,9 +67,11 @@ discard block |
||
66 | 67 | */ |
67 | 68 | private function directive(Compiler\Result $source, Directive $directive): void |
68 | 69 | { |
69 | - if ($this->directiveRenderer !== null) { |
|
70 | + if ($this->directiveRenderer !== null) |
|
71 | + { |
|
70 | 72 | $result = $this->directiveRenderer->render($directive); |
71 | - if ($result !== null) { |
|
73 | + if ($result !== null) |
|
74 | + { |
|
72 | 75 | $source->push($result, $directive->getContext()); |
73 | 76 | return; |
74 | 77 | } |
@@ -86,7 +89,8 @@ discard block |
||
86 | 89 | */ |
87 | 90 | private function output(Compiler\Result $source, Output $output): void |
88 | 91 | { |
89 | - if ($output->rawOutput) { |
|
92 | + if ($output->rawOutput) |
|
93 | + { |
|
90 | 94 | $source->push(sprintf('<?php echo %s; ?>', trim($output->body)), $output->getContext()); |
91 | 95 | return; |
92 | 96 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | Compiler\Result $result, |
32 | 32 | NodeInterface $node |
33 | 33 | ): bool { |
34 | - switch (true) { |
|
34 | + switch (true){ |
|
35 | 35 | case $node instanceof Hidden: |
36 | 36 | return true; |
37 | 37 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $result->withinContext( |
40 | 40 | $node->getContext(), |
41 | 41 | function (Compiler\Result $source) use ($node, $compiler): void { |
42 | - foreach ($node->nodes as $child) { |
|
42 | + foreach ($node->nodes as $child){ |
|
43 | 43 | $compiler->compile($child, $source); |
44 | 44 | } |
45 | 45 | } |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | $result->withinContext( |
52 | 52 | $node->getContext(), |
53 | 53 | function (Compiler\Result $source) use ($node, $compiler): void { |
54 | - foreach ($node->nodes as $child) { |
|
55 | - if (is_string($child)) { |
|
54 | + foreach ($node->nodes as $child){ |
|
55 | + if (is_string($child)){ |
|
56 | 56 | $source->push($child, null); |
57 | 57 | continue; |
58 | 58 | } |
@@ -31,7 +31,8 @@ discard block |
||
31 | 31 | Compiler\Result $result, |
32 | 32 | NodeInterface $node |
33 | 33 | ): bool { |
34 | - switch (true) { |
|
34 | + switch (true) |
|
35 | + { |
|
35 | 36 | case $node instanceof Hidden: |
36 | 37 | return true; |
37 | 38 | |
@@ -39,7 +40,8 @@ discard block |
||
39 | 40 | $result->withinContext( |
40 | 41 | $node->getContext(), |
41 | 42 | function (Compiler\Result $source) use ($node, $compiler): void { |
42 | - foreach ($node->nodes as $child) { |
|
43 | + foreach ($node->nodes as $child) |
|
44 | + { |
|
43 | 45 | $compiler->compile($child, $source); |
44 | 46 | } |
45 | 47 | } |
@@ -51,8 +53,10 @@ discard block |
||
51 | 53 | $result->withinContext( |
52 | 54 | $node->getContext(), |
53 | 55 | function (Compiler\Result $source) use ($node, $compiler): void { |
54 | - foreach ($node->nodes as $child) { |
|
55 | - if (is_string($child)) { |
|
56 | + foreach ($node->nodes as $child) |
|
57 | + { |
|
58 | + if (is_string($child)) |
|
59 | + { |
|
56 | 60 | $source->push($child, null); |
57 | 61 | continue; |
58 | 62 | } |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | // We can scan top level only |
41 | 41 | |
42 | 42 | /** @var Location $loc */ |
43 | - foreach ($this->lines as $line) { |
|
44 | - if (!in_array($this->paths[$line[0]], $paths, true)) { |
|
43 | + foreach ($this->lines as $line){ |
|
44 | + if (!in_array($this->paths[$line[0]], $paths, true)){ |
|
45 | 45 | $paths[] = $this->paths[$line[0]]; |
46 | 46 | } |
47 | 47 | } |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | public function getStack(int $line): array |
60 | 60 | { |
61 | 61 | $found = null; |
62 | - foreach ($this->lines as $linen => $ctx) { |
|
63 | - if ($linen <= $line) { |
|
62 | + foreach ($this->lines as $linen => $ctx){ |
|
63 | + if ($linen <= $line){ |
|
64 | 64 | $found = $ctx; |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - if ($found === null) { |
|
68 | + if ($found === null){ |
|
69 | 69 | return []; |
70 | 70 | } |
71 | 71 | |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | { |
110 | 110 | $map = new self(); |
111 | 111 | |
112 | - foreach ($locations as $offset => $location) { |
|
112 | + foreach ($locations as $offset => $location){ |
|
113 | 113 | $line = Source::resolveLine($content, $offset); |
114 | - if (!isset($map->lines[$line])) { |
|
114 | + if (!isset($map->lines[$line])){ |
|
115 | 115 | $map->lines[$line] = $map->calculateLine($location, $loader); |
116 | 116 | } |
117 | 117 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | 'line' => $line[1], |
133 | 133 | ]; |
134 | 134 | |
135 | - if ($line[2] !== null) { |
|
135 | + if ($line[2] !== null){ |
|
136 | 136 | $this->unpack($result, $line[2]); |
137 | 137 | } |
138 | 138 | } |
@@ -144,12 +144,12 @@ discard block |
||
144 | 144 | */ |
145 | 145 | private function calculateLine(Location $location, LoaderInterface $loader): array |
146 | 146 | { |
147 | - if (!isset($this->sourceCache[$location->path])) { |
|
147 | + if (!isset($this->sourceCache[$location->path])){ |
|
148 | 148 | $this->sourceCache[$location->path] = $loader->load($location->path); |
149 | 149 | } |
150 | 150 | $path = $this->sourceCache[$location->path]->getFilename(); |
151 | 151 | |
152 | - if (!in_array($path, $this->paths, true)) { |
|
152 | + if (!in_array($path, $this->paths, true)){ |
|
153 | 153 | $this->paths[] = $path; |
154 | 154 | } |
155 | 155 |
@@ -40,8 +40,10 @@ discard block |
||
40 | 40 | // We can scan top level only |
41 | 41 | |
42 | 42 | /** @var Location $loc */ |
43 | - foreach ($this->lines as $line) { |
|
44 | - if (!in_array($this->paths[$line[0]], $paths, true)) { |
|
43 | + foreach ($this->lines as $line) |
|
44 | + { |
|
45 | + if (!in_array($this->paths[$line[0]], $paths, true)) |
|
46 | + { |
|
45 | 47 | $paths[] = $this->paths[$line[0]]; |
46 | 48 | } |
47 | 49 | } |
@@ -59,13 +61,16 @@ discard block |
||
59 | 61 | public function getStack(int $line): array |
60 | 62 | { |
61 | 63 | $found = null; |
62 | - foreach ($this->lines as $linen => $ctx) { |
|
63 | - if ($linen <= $line) { |
|
64 | + foreach ($this->lines as $linen => $ctx) |
|
65 | + { |
|
66 | + if ($linen <= $line) |
|
67 | + { |
|
64 | 68 | $found = $ctx; |
65 | 69 | } |
66 | 70 | } |
67 | 71 | |
68 | - if ($found === null) { |
|
72 | + if ($found === null) |
|
73 | + { |
|
69 | 74 | return []; |
70 | 75 | } |
71 | 76 | |
@@ -109,9 +114,11 @@ discard block |
||
109 | 114 | { |
110 | 115 | $map = new self(); |
111 | 116 | |
112 | - foreach ($locations as $offset => $location) { |
|
117 | + foreach ($locations as $offset => $location) |
|
118 | + { |
|
113 | 119 | $line = Source::resolveLine($content, $offset); |
114 | - if (!isset($map->lines[$line])) { |
|
120 | + if (!isset($map->lines[$line])) |
|
121 | + { |
|
115 | 122 | $map->lines[$line] = $map->calculateLine($location, $loader); |
116 | 123 | } |
117 | 124 | } |
@@ -132,7 +139,8 @@ discard block |
||
132 | 139 | 'line' => $line[1], |
133 | 140 | ]; |
134 | 141 | |
135 | - if ($line[2] !== null) { |
|
142 | + if ($line[2] !== null) |
|
143 | + { |
|
136 | 144 | $this->unpack($result, $line[2]); |
137 | 145 | } |
138 | 146 | } |
@@ -144,12 +152,14 @@ discard block |
||
144 | 152 | */ |
145 | 153 | private function calculateLine(Location $location, LoaderInterface $loader): array |
146 | 154 | { |
147 | - if (!isset($this->sourceCache[$location->path])) { |
|
155 | + if (!isset($this->sourceCache[$location->path])) |
|
156 | + { |
|
148 | 157 | $this->sourceCache[$location->path] = $loader->load($location->path); |
149 | 158 | } |
150 | 159 | $path = $this->sourceCache[$location->path]->getFilename(); |
151 | 160 | |
152 | - if (!in_array($path, $this->paths, true)) { |
|
161 | + if (!in_array($path, $this->paths, true)) |
|
162 | + { |
|
153 | 163 | $this->paths[] = $path; |
154 | 164 | } |
155 | 165 |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function accepts(string $name): ?string |
51 | 51 | { |
52 | - if ($this->pattern === '' || $this->pattern === '*') { |
|
52 | + if ($this->pattern === '' || $this->pattern === '*'){ |
|
53 | 53 | // accept everything |
54 | 54 | return $name; |
55 | 55 | } |
56 | 56 | |
57 | 57 | $conditions = []; |
58 | - foreach (explode(';', $this->pattern) as $condition) { |
|
59 | - if (strpos($condition, ':') === false) { |
|
58 | + foreach (explode(';', $this->pattern) as $condition){ |
|
59 | + if (strpos($condition, ':') === false){ |
|
60 | 60 | //Invalid |
61 | 61 | continue; |
62 | 62 | } |
@@ -65,27 +65,27 @@ discard block |
||
65 | 65 | $conditions[$option] = $value; |
66 | 66 | } |
67 | 67 | |
68 | - if (isset($conditions['include'])) { |
|
68 | + if (isset($conditions['include'])){ |
|
69 | 69 | $include = explode(',', $conditions['include']); |
70 | - if (in_array($name, $include)) { |
|
70 | + if (in_array($name, $include)){ |
|
71 | 71 | return $name; |
72 | 72 | } |
73 | 73 | |
74 | 74 | return null; |
75 | 75 | } |
76 | 76 | |
77 | - if (isset($conditions['exclude'])) { |
|
77 | + if (isset($conditions['exclude'])){ |
|
78 | 78 | $exclude = explode(',', $conditions['exclude']); |
79 | - if (in_array($name, $exclude)) { |
|
79 | + if (in_array($name, $exclude)){ |
|
80 | 80 | return null; |
81 | 81 | } |
82 | 82 | |
83 | 83 | return $name; |
84 | 84 | } |
85 | 85 | |
86 | - if (isset($conditions['prefix'])) { |
|
86 | + if (isset($conditions['prefix'])){ |
|
87 | 87 | $conditions['prefix'] = rtrim($conditions['prefix'], ' *'); |
88 | - if (strpos($name, $conditions['prefix']) === 0) { |
|
88 | + if (strpos($name, $conditions['prefix']) === 0){ |
|
89 | 89 | return substr($name, strlen($conditions['prefix'])); |
90 | 90 | } |
91 | 91 |
@@ -49,14 +49,17 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function accepts(string $name): ?string |
51 | 51 | { |
52 | - if ($this->pattern === '' || $this->pattern === '*') { |
|
52 | + if ($this->pattern === '' || $this->pattern === '*') |
|
53 | + { |
|
53 | 54 | // accept everything |
54 | 55 | return $name; |
55 | 56 | } |
56 | 57 | |
57 | 58 | $conditions = []; |
58 | - foreach (explode(';', $this->pattern) as $condition) { |
|
59 | - if (strpos($condition, ':') === false) { |
|
59 | + foreach (explode(';', $this->pattern) as $condition) |
|
60 | + { |
|
61 | + if (strpos($condition, ':') === false) |
|
62 | + { |
|
60 | 63 | //Invalid |
61 | 64 | continue; |
62 | 65 | } |
@@ -65,27 +68,33 @@ discard block |
||
65 | 68 | $conditions[$option] = $value; |
66 | 69 | } |
67 | 70 | |
68 | - if (isset($conditions['include'])) { |
|
71 | + if (isset($conditions['include'])) |
|
72 | + { |
|
69 | 73 | $include = explode(',', $conditions['include']); |
70 | - if (in_array($name, $include)) { |
|
74 | + if (in_array($name, $include)) |
|
75 | + { |
|
71 | 76 | return $name; |
72 | 77 | } |
73 | 78 | |
74 | 79 | return null; |
75 | 80 | } |
76 | 81 | |
77 | - if (isset($conditions['exclude'])) { |
|
82 | + if (isset($conditions['exclude'])) |
|
83 | + { |
|
78 | 84 | $exclude = explode(',', $conditions['exclude']); |
79 | - if (in_array($name, $exclude)) { |
|
85 | + if (in_array($name, $exclude)) |
|
86 | + { |
|
80 | 87 | return null; |
81 | 88 | } |
82 | 89 | |
83 | 90 | return $name; |
84 | 91 | } |
85 | 92 | |
86 | - if (isset($conditions['prefix'])) { |
|
93 | + if (isset($conditions['prefix'])) |
|
94 | + { |
|
87 | 95 | $conditions['prefix'] = rtrim($conditions['prefix'], ' *'); |
88 | - if (strpos($name, $conditions['prefix']) === 0) { |
|
96 | + if (strpos($name, $conditions['prefix']) === 0) |
|
97 | + { |
|
89 | 98 | return substr($name, strlen($conditions['prefix'])); |
90 | 99 | } |
91 | 100 |