@@ -35,14 +35,17 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function accepts(string $name): ?string |
37 | 37 | { |
38 | - if ($this->pattern === '' || $this->pattern === '*') { |
|
38 | + if ($this->pattern === '' || $this->pattern === '*') |
|
39 | + { |
|
39 | 40 | // accept everything |
40 | 41 | return $name; |
41 | 42 | } |
42 | 43 | |
43 | 44 | $conditions = []; |
44 | - foreach (\explode(';', $this->pattern) as $condition) { |
|
45 | - if (!\str_contains($condition, ':')) { |
|
45 | + foreach (\explode(';', $this->pattern) as $condition) |
|
46 | + { |
|
47 | + if (!\str_contains($condition, ':')) |
|
48 | + { |
|
46 | 49 | //Invalid |
47 | 50 | continue; |
48 | 51 | } |
@@ -51,27 +54,33 @@ discard block |
||
51 | 54 | $conditions[$option] = $value; |
52 | 55 | } |
53 | 56 | |
54 | - if (isset($conditions['include'])) { |
|
57 | + if (isset($conditions['include'])) |
|
58 | + { |
|
55 | 59 | $include = \explode(',', $conditions['include']); |
56 | - if (\in_array($name, $include)) { |
|
60 | + if (\in_array($name, $include)) |
|
61 | + { |
|
57 | 62 | return $name; |
58 | 63 | } |
59 | 64 | |
60 | 65 | return null; |
61 | 66 | } |
62 | 67 | |
63 | - if (isset($conditions['exclude'])) { |
|
68 | + if (isset($conditions['exclude'])) |
|
69 | + { |
|
64 | 70 | $exclude = \explode(',', $conditions['exclude']); |
65 | - if (\in_array($name, $exclude)) { |
|
71 | + if (\in_array($name, $exclude)) |
|
72 | + { |
|
66 | 73 | return null; |
67 | 74 | } |
68 | 75 | |
69 | 76 | return $name; |
70 | 77 | } |
71 | 78 | |
72 | - if (isset($conditions['prefix'])) { |
|
79 | + if (isset($conditions['prefix'])) |
|
80 | + { |
|
73 | 81 | $conditions['prefix'] = \rtrim($conditions['prefix'], ' *'); |
74 | - if (\str_starts_with($name, $conditions['prefix'])) { |
|
82 | + if (\str_starts_with($name, $conditions['prefix'])) |
|
83 | + { |
|
75 | 84 | return substr($name, \strlen($conditions['prefix'])); |
76 | 85 | } |
77 | 86 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | public function __construct( |
26 | 26 | ?Context $context = null, |
27 | 27 | public string $pattern = '*', |
28 | - ) { |
|
28 | + ){ |
|
29 | 29 | $this->context = $context; |
30 | 30 | } |
31 | 31 | |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function accepts(string $name): ?string |
37 | 37 | { |
38 | - if ($this->pattern === '' || $this->pattern === '*') { |
|
38 | + if ($this->pattern === '' || $this->pattern === '*'){ |
|
39 | 39 | // accept everything |
40 | 40 | return $name; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $conditions = []; |
44 | - foreach (\explode(';', $this->pattern) as $condition) { |
|
45 | - if (!\str_contains($condition, ':')) { |
|
44 | + foreach (\explode(';', $this->pattern) as $condition){ |
|
45 | + if (!\str_contains($condition, ':')){ |
|
46 | 46 | //Invalid |
47 | 47 | continue; |
48 | 48 | } |
@@ -51,27 +51,27 @@ discard block |
||
51 | 51 | $conditions[$option] = $value; |
52 | 52 | } |
53 | 53 | |
54 | - if (isset($conditions['include'])) { |
|
54 | + if (isset($conditions['include'])){ |
|
55 | 55 | $include = \explode(',', $conditions['include']); |
56 | - if (\in_array($name, $include)) { |
|
56 | + if (\in_array($name, $include)){ |
|
57 | 57 | return $name; |
58 | 58 | } |
59 | 59 | |
60 | 60 | return null; |
61 | 61 | } |
62 | 62 | |
63 | - if (isset($conditions['exclude'])) { |
|
63 | + if (isset($conditions['exclude'])){ |
|
64 | 64 | $exclude = \explode(',', $conditions['exclude']); |
65 | - if (\in_array($name, $exclude)) { |
|
65 | + if (\in_array($name, $exclude)){ |
|
66 | 66 | return null; |
67 | 67 | } |
68 | 68 | |
69 | 69 | return $name; |
70 | 70 | } |
71 | 71 | |
72 | - if (isset($conditions['prefix'])) { |
|
72 | + if (isset($conditions['prefix'])){ |
|
73 | 73 | $conditions['prefix'] = \rtrim($conditions['prefix'], ' *'); |
74 | - if (\str_starts_with($name, $conditions['prefix'])) { |
|
74 | + if (\str_starts_with($name, $conditions['prefix'])){ |
|
75 | 75 | return substr($name, \strlen($conditions['prefix'])); |
76 | 76 | } |
77 | 77 |
@@ -12,10 +12,10 @@ |
||
12 | 12 | |
13 | 13 | trait MixinTrait |
14 | 14 | { |
15 | - private function parseToken(Parser $parser, Token $token): Mixin|Raw|string |
|
15 | + private function parseToken(Parser $parser, Token $token): Mixin | Raw | string |
|
16 | 16 | { |
17 | - if ($token->tokens === []) { |
|
18 | - if ($token->type === Token::TYPE_RAW) { |
|
17 | + if ($token->tokens === []){ |
|
18 | + if ($token->type === Token::TYPE_RAW){ |
|
19 | 19 | return new Raw($token->content); |
20 | 20 | } |
21 | 21 |
@@ -14,8 +14,10 @@ |
||
14 | 14 | { |
15 | 15 | private function parseToken(Parser $parser, Token $token): Mixin|Raw|string |
16 | 16 | { |
17 | - if ($token->tokens === []) { |
|
18 | - if ($token->type === Token::TYPE_RAW) { |
|
17 | + if ($token->tokens === []) |
|
18 | + { |
|
19 | + if ($token->type === Token::TYPE_RAW) |
|
20 | + { |
|
19 | 21 | return new Raw($token->content); |
20 | 22 | } |
21 | 23 |
@@ -19,7 +19,7 @@ |
||
19 | 19 | |
20 | 20 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
21 | 21 | { |
22 | - switch ($token->type) { |
|
22 | + switch ($token->type){ |
|
23 | 23 | case InlineGrammar::TYPE_OPEN_TAG: |
24 | 24 | $this->inline = new Inline(new Parser\Context($token, $parser->getPath())); |
25 | 25 | $asm->push($this->inline); |
@@ -19,7 +19,8 @@ |
||
19 | 19 | |
20 | 20 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
21 | 21 | { |
22 | - switch ($token->type) { |
|
22 | + switch ($token->type) |
|
23 | + { |
|
23 | 24 | case InlineGrammar::TYPE_OPEN_TAG: |
24 | 25 | $this->inline = new Inline(new Parser\Context($token, $parser->getPath())); |
25 | 26 | $asm->push($this->inline); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
56 | 56 | { |
57 | - switch ($token->type) { |
|
57 | + switch ($token->type){ |
|
58 | 58 | case HTMLGrammar::TYPE_OPEN: |
59 | 59 | case HTMLGrammar::TYPE_OPEN_SHORT: |
60 | 60 | $this->node = new Tag(new Parser\Context($token, $parser->getPath())); |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | break; |
64 | 64 | |
65 | 65 | case HTMLGrammar::TYPE_KEYWORD: |
66 | - if ($this->node->name === null) { |
|
66 | + if ($this->node->name === null){ |
|
67 | 67 | $this->node->name = $this->parseToken($parser, $token); |
68 | 68 | return; |
69 | 69 | } |
70 | 70 | |
71 | - if ($this->attr !== null && !$this->attr->value instanceof Nil) { |
|
71 | + if ($this->attr !== null && !$this->attr->value instanceof Nil){ |
|
72 | 72 | $this->attr->value = $this->parseToken($parser, $token); |
73 | 73 | $this->attr = null; |
74 | 74 | break; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | break; |
85 | 85 | |
86 | 86 | case HTMLGrammar::TYPE_EQUAL: |
87 | - if ($this->attr === null) { |
|
87 | + if ($this->attr === null){ |
|
88 | 88 | throw new SyntaxException('unexpected attribute token', $token); |
89 | 89 | } |
90 | 90 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | break; |
94 | 94 | |
95 | 95 | case HTMLGrammar::TYPE_ATTRIBUTE: |
96 | - if ($this->attr === null) { |
|
96 | + if ($this->attr === null){ |
|
97 | 97 | throw new SyntaxException('unexpected attribute token', $token); |
98 | 98 | } |
99 | 99 | |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | \str_starts_with($this->attr->name, 'on') |
104 | 104 | || \in_array($this->attr->name, self::VERBATIM_ATTRIBUTES, true) |
105 | 105 | ) |
106 | - ) { |
|
106 | + ){ |
|
107 | 107 | $this->attr->value = $this->parseVerbatim($parser, $token); |
108 | - } else { |
|
108 | + }else{ |
|
109 | 109 | $this->attr->value = $this->parseToken($parser, $token); |
110 | 110 | } |
111 | 111 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | break; |
120 | 120 | |
121 | 121 | case HTMLGrammar::TYPE_CLOSE: |
122 | - if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) { |
|
123 | - if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) { |
|
122 | + if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT){ |
|
123 | + if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name){ |
|
124 | 124 | /** |
125 | 125 | * TODO issue #767 |
126 | 126 | * @link https://github.com/spiral/framework/issues/767 |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | $asm->close(); |
136 | - } elseif (\in_array($this->node->name, self::VOID_TAGS)) { |
|
136 | + } elseif (\in_array($this->node->name, self::VOID_TAGS)){ |
|
137 | 137 | $this->node->void = true; |
138 | 138 | $asm->push($this->node); |
139 | - } else { |
|
139 | + }else{ |
|
140 | 140 | $asm->open($this->node, 'nodes'); |
141 | 141 | } |
142 | 142 | $this->flush(); |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | break; |
149 | 149 | |
150 | 150 | default: |
151 | - if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) { |
|
151 | + if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim){ |
|
152 | 152 | $node = $this->parseToken($parser, $token); |
153 | - if (\is_string($node)) { |
|
153 | + if (\is_string($node)){ |
|
154 | 154 | $node = new Raw($node, new Parser\Context($token, $parser->getPath())); |
155 | 155 | } |
156 | 156 | |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | { |
174 | 174 | $verbatim = new Verbatim(new Parser\Context($token, $parser->getPath())); |
175 | 175 | |
176 | - if ($token->tokens === []) { |
|
177 | - if ($token->content) { |
|
176 | + if ($token->tokens === []){ |
|
177 | + if ($token->content){ |
|
178 | 178 | $verbatim->nodes[] = $token->content; |
179 | 179 | } |
180 | - } else { |
|
180 | + }else{ |
|
181 | 181 | /** |
182 | 182 | * TODO issue #767 |
183 | 183 | * @link https://github.com/spiral/framework/issues/767 |
@@ -54,7 +54,8 @@ discard block |
||
54 | 54 | |
55 | 55 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
56 | 56 | { |
57 | - switch ($token->type) { |
|
57 | + switch ($token->type) |
|
58 | + { |
|
58 | 59 | case HTMLGrammar::TYPE_OPEN: |
59 | 60 | case HTMLGrammar::TYPE_OPEN_SHORT: |
60 | 61 | $this->node = new Tag(new Parser\Context($token, $parser->getPath())); |
@@ -63,12 +64,14 @@ discard block |
||
63 | 64 | break; |
64 | 65 | |
65 | 66 | case HTMLGrammar::TYPE_KEYWORD: |
66 | - if ($this->node->name === null) { |
|
67 | + if ($this->node->name === null) |
|
68 | + { |
|
67 | 69 | $this->node->name = $this->parseToken($parser, $token); |
68 | 70 | return; |
69 | 71 | } |
70 | 72 | |
71 | - if ($this->attr !== null && !$this->attr->value instanceof Nil) { |
|
73 | + if ($this->attr !== null && !$this->attr->value instanceof Nil) |
|
74 | + { |
|
72 | 75 | $this->attr->value = $this->parseToken($parser, $token); |
73 | 76 | $this->attr = null; |
74 | 77 | break; |
@@ -84,7 +87,8 @@ discard block |
||
84 | 87 | break; |
85 | 88 | |
86 | 89 | case HTMLGrammar::TYPE_EQUAL: |
87 | - if ($this->attr === null) { |
|
90 | + if ($this->attr === null) |
|
91 | + { |
|
88 | 92 | throw new SyntaxException('unexpected attribute token', $token); |
89 | 93 | } |
90 | 94 | |
@@ -93,7 +97,8 @@ discard block |
||
93 | 97 | break; |
94 | 98 | |
95 | 99 | case HTMLGrammar::TYPE_ATTRIBUTE: |
96 | - if ($this->attr === null) { |
|
100 | + if ($this->attr === null) |
|
101 | + { |
|
97 | 102 | throw new SyntaxException('unexpected attribute token', $token); |
98 | 103 | } |
99 | 104 | |
@@ -105,7 +110,9 @@ discard block |
||
105 | 110 | ) |
106 | 111 | ) { |
107 | 112 | $this->attr->value = $this->parseVerbatim($parser, $token); |
108 | - } else { |
|
113 | + } |
|
114 | + else |
|
115 | + { |
|
109 | 116 | $this->attr->value = $this->parseToken($parser, $token); |
110 | 117 | } |
111 | 118 | |
@@ -119,8 +126,10 @@ discard block |
||
119 | 126 | break; |
120 | 127 | |
121 | 128 | case HTMLGrammar::TYPE_CLOSE: |
122 | - if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) { |
|
123 | - if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) { |
|
129 | + if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) |
|
130 | + { |
|
131 | + if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) |
|
132 | + { |
|
124 | 133 | /** |
125 | 134 | * TODO issue #767 |
126 | 135 | * @link https://github.com/spiral/framework/issues/767 |
@@ -133,10 +142,14 @@ discard block |
||
133 | 142 | } |
134 | 143 | |
135 | 144 | $asm->close(); |
136 | - } elseif (\in_array($this->node->name, self::VOID_TAGS)) { |
|
145 | + } |
|
146 | + elseif (\in_array($this->node->name, self::VOID_TAGS)) |
|
147 | + { |
|
137 | 148 | $this->node->void = true; |
138 | 149 | $asm->push($this->node); |
139 | - } else { |
|
150 | + } |
|
151 | + else |
|
152 | + { |
|
140 | 153 | $asm->open($this->node, 'nodes'); |
141 | 154 | } |
142 | 155 | $this->flush(); |
@@ -148,9 +161,11 @@ discard block |
||
148 | 161 | break; |
149 | 162 | |
150 | 163 | default: |
151 | - if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) { |
|
164 | + if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) |
|
165 | + { |
|
152 | 166 | $node = $this->parseToken($parser, $token); |
153 | - if (\is_string($node)) { |
|
167 | + if (\is_string($node)) |
|
168 | + { |
|
154 | 169 | $node = new Raw($node, new Parser\Context($token, $parser->getPath())); |
155 | 170 | } |
156 | 171 | |
@@ -173,11 +188,15 @@ discard block |
||
173 | 188 | { |
174 | 189 | $verbatim = new Verbatim(new Parser\Context($token, $parser->getPath())); |
175 | 190 | |
176 | - if ($token->tokens === []) { |
|
177 | - if ($token->content) { |
|
191 | + if ($token->tokens === []) |
|
192 | + { |
|
193 | + if ($token->content) |
|
194 | + { |
|
178 | 195 | $verbatim->nodes[] = $token->content; |
179 | 196 | } |
180 | - } else { |
|
197 | + } |
|
198 | + else |
|
199 | + { |
|
181 | 200 | /** |
182 | 201 | * TODO issue #767 |
183 | 202 | * @link https://github.com/spiral/framework/issues/767 |
@@ -26,16 +26,20 @@ |
||
26 | 26 | { |
27 | 27 | $result ??= new Result(); |
28 | 28 | |
29 | - if (\is_array($node)) { |
|
30 | - foreach ($node as $child) { |
|
29 | + if (\is_array($node)) |
|
30 | + { |
|
31 | + foreach ($node as $child) |
|
32 | + { |
|
31 | 33 | $this->compile($child, $result); |
32 | 34 | } |
33 | 35 | |
34 | 36 | return $result; |
35 | 37 | } |
36 | 38 | |
37 | - foreach ($this->renders as $renderer) { |
|
38 | - if ($renderer->render($this, $result, $node)) { |
|
39 | + foreach ($this->renders as $renderer) |
|
40 | + { |
|
41 | + if ($renderer->render($this, $result, $node)) |
|
42 | + { |
|
39 | 43 | return $result; |
40 | 44 | } |
41 | 45 | } |
@@ -22,20 +22,20 @@ |
||
22 | 22 | $this->renders[] = $renderer; |
23 | 23 | } |
24 | 24 | |
25 | - public function compile(array|NodeInterface $node, ?Result $result = null): Result |
|
25 | + public function compile(array | NodeInterface $node, ?Result $result = null): Result |
|
26 | 26 | { |
27 | 27 | $result ??= new Result(); |
28 | 28 | |
29 | - if (\is_array($node)) { |
|
30 | - foreach ($node as $child) { |
|
29 | + if (\is_array($node)){ |
|
30 | + foreach ($node as $child){ |
|
31 | 31 | $this->compile($child, $result); |
32 | 32 | } |
33 | 33 | |
34 | 34 | return $result; |
35 | 35 | } |
36 | 36 | |
37 | - foreach ($this->renders as $renderer) { |
|
38 | - if ($renderer->render($this, $result, $node)) { |
|
37 | + foreach ($this->renders as $renderer){ |
|
38 | + if ($renderer->render($this, $result, $node)){ |
|
39 | 39 | return $result; |
40 | 40 | } |
41 | 41 | } |
@@ -69,7 +69,7 @@ |
||
69 | 69 | protected function traverse(array $nodes, VisitorInterface ...$visitors): array |
70 | 70 | { |
71 | 71 | $traverser = new Traverser(); |
72 | - foreach ($visitors as $visitor) { |
|
72 | + foreach ($visitors as $visitor){ |
|
73 | 73 | $traverser->addVisitor($visitor); |
74 | 74 | } |
75 | 75 |
@@ -69,7 +69,8 @@ |
||
69 | 69 | protected function traverse(array $nodes, VisitorInterface ...$visitors): array |
70 | 70 | { |
71 | 71 | $traverser = new Traverser(); |
72 | - foreach ($visitors as $visitor) { |
|
72 | + foreach ($visitors as $visitor) |
|
73 | + { |
|
73 | 74 | $traverser->addVisitor($visitor); |
74 | 75 | } |
75 | 76 |
@@ -25,33 +25,33 @@ discard block |
||
25 | 25 | |
26 | 26 | public function leaveNode(mixed $node, VisitorContext $ctx): mixed |
27 | 27 | { |
28 | - if ($node instanceof Tag && \str_starts_with($node->name, $this->pushKeyword)) { |
|
28 | + if ($node instanceof Tag && \str_starts_with($node->name, $this->pushKeyword)){ |
|
29 | 29 | return $this->registerPush(StackContext::on($ctx), $node); |
30 | 30 | } |
31 | 31 | |
32 | - if ($node instanceof Tag && \str_starts_with($node->name, $this->prependKeyword)) { |
|
32 | + if ($node instanceof Tag && \str_starts_with($node->name, $this->prependKeyword)){ |
|
33 | 33 | return $this->registerPrepend(StackContext::on($ctx), $node); |
34 | 34 | } |
35 | 35 | |
36 | 36 | return null; |
37 | 37 | } |
38 | 38 | |
39 | - private function registerPush(StackContext $ctx, Tag $node): int|Tag|null |
|
39 | + private function registerPush(StackContext $ctx, Tag $node): int | Tag | null |
|
40 | 40 | { |
41 | 41 | $name = $this->stackName($node); |
42 | 42 | |
43 | - if ($name === null || !$ctx->push($name, $node, $this->uniqueID($node))) { |
|
43 | + if ($name === null || !$ctx->push($name, $node, $this->uniqueID($node))){ |
|
44 | 44 | return null; |
45 | 45 | } |
46 | 46 | |
47 | 47 | return self::REMOVE_NODE; |
48 | 48 | } |
49 | 49 | |
50 | - private function registerPrepend(StackContext $ctx, Tag $node): int|Tag|null |
|
50 | + private function registerPrepend(StackContext $ctx, Tag $node): int | Tag | null |
|
51 | 51 | { |
52 | 52 | $name = $this->stackName($node); |
53 | 53 | |
54 | - if ($name === null || !$ctx->prepend($name, $node, $this->uniqueID($node))) { |
|
54 | + if ($name === null || !$ctx->prepend($name, $node, $this->uniqueID($node))){ |
|
55 | 55 | return null; |
56 | 56 | } |
57 | 57 | |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | |
61 | 61 | private function stackName(Tag $tag): ?string |
62 | 62 | { |
63 | - foreach ($tag->attrs as $attr) { |
|
64 | - if (\is_string($attr->value) && $attr->name === 'name') { |
|
63 | + foreach ($tag->attrs as $attr){ |
|
64 | + if (\is_string($attr->value) && $attr->name === 'name'){ |
|
65 | 65 | return \trim($attr->value, '\'"'); |
66 | 66 | } |
67 | 67 | } |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | |
72 | 72 | private function uniqueID(Tag $tag): ?string |
73 | 73 | { |
74 | - foreach ($tag->attrs as $attr) { |
|
75 | - if (\is_string($attr->value) && $attr->name === 'unique-id') { |
|
74 | + foreach ($tag->attrs as $attr){ |
|
75 | + if (\is_string($attr->value) && $attr->name === 'unique-id'){ |
|
76 | 76 | return \trim($attr->value, '\'"'); |
77 | 77 | } |
78 | 78 | } |
@@ -25,11 +25,13 @@ discard block |
||
25 | 25 | |
26 | 26 | public function leaveNode(mixed $node, VisitorContext $ctx): mixed |
27 | 27 | { |
28 | - if ($node instanceof Tag && \str_starts_with($node->name, $this->pushKeyword)) { |
|
28 | + if ($node instanceof Tag && \str_starts_with($node->name, $this->pushKeyword)) |
|
29 | + { |
|
29 | 30 | return $this->registerPush(StackContext::on($ctx), $node); |
30 | 31 | } |
31 | 32 | |
32 | - if ($node instanceof Tag && \str_starts_with($node->name, $this->prependKeyword)) { |
|
33 | + if ($node instanceof Tag && \str_starts_with($node->name, $this->prependKeyword)) |
|
34 | + { |
|
33 | 35 | return $this->registerPrepend(StackContext::on($ctx), $node); |
34 | 36 | } |
35 | 37 | |
@@ -40,7 +42,8 @@ discard block |
||
40 | 42 | { |
41 | 43 | $name = $this->stackName($node); |
42 | 44 | |
43 | - if ($name === null || !$ctx->push($name, $node, $this->uniqueID($node))) { |
|
45 | + if ($name === null || !$ctx->push($name, $node, $this->uniqueID($node))) |
|
46 | + { |
|
44 | 47 | return null; |
45 | 48 | } |
46 | 49 | |
@@ -51,7 +54,8 @@ discard block |
||
51 | 54 | { |
52 | 55 | $name = $this->stackName($node); |
53 | 56 | |
54 | - if ($name === null || !$ctx->prepend($name, $node, $this->uniqueID($node))) { |
|
57 | + if ($name === null || !$ctx->prepend($name, $node, $this->uniqueID($node))) |
|
58 | + { |
|
55 | 59 | return null; |
56 | 60 | } |
57 | 61 | |
@@ -60,8 +64,10 @@ discard block |
||
60 | 64 | |
61 | 65 | private function stackName(Tag $tag): ?string |
62 | 66 | { |
63 | - foreach ($tag->attrs as $attr) { |
|
64 | - if (\is_string($attr->value) && $attr->name === 'name') { |
|
67 | + foreach ($tag->attrs as $attr) |
|
68 | + { |
|
69 | + if (\is_string($attr->value) && $attr->name === 'name') |
|
70 | + { |
|
65 | 71 | return \trim($attr->value, '\'"'); |
66 | 72 | } |
67 | 73 | } |
@@ -71,8 +77,10 @@ discard block |
||
71 | 77 | |
72 | 78 | private function uniqueID(Tag $tag): ?string |
73 | 79 | { |
74 | - foreach ($tag->attrs as $attr) { |
|
75 | - if (\is_string($attr->value) && $attr->name === 'unique-id') { |
|
80 | + foreach ($tag->attrs as $attr) |
|
81 | + { |
|
82 | + if (\is_string($attr->value) && $attr->name === 'unique-id') |
|
83 | + { |
|
76 | 84 | return \trim($attr->value, '\'"'); |
77 | 85 | } |
78 | 86 | } |
@@ -20,15 +20,15 @@ |
||
20 | 20 | |
21 | 21 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
22 | 22 | { |
23 | - if (!$node instanceof Attr || $node->name !== self::AGGREGATE_ATTRIBUTE) { |
|
23 | + if (!$node instanceof Attr || $node->name !== self::AGGREGATE_ATTRIBUTE){ |
|
24 | 24 | return null; |
25 | 25 | } |
26 | 26 | |
27 | - if ($node->value instanceof Nil) { |
|
27 | + if ($node->value instanceof Nil){ |
|
28 | 28 | return new Aggregate($node->getContext()); |
29 | 29 | } |
30 | 30 | |
31 | - if (!\is_string($node->value)) { |
|
31 | + if (!\is_string($node->value)){ |
|
32 | 32 | return null; |
33 | 33 | } |
34 | 34 |
@@ -20,15 +20,18 @@ |
||
20 | 20 | |
21 | 21 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
22 | 22 | { |
23 | - if (!$node instanceof Attr || $node->name !== self::AGGREGATE_ATTRIBUTE) { |
|
23 | + if (!$node instanceof Attr || $node->name !== self::AGGREGATE_ATTRIBUTE) |
|
24 | + { |
|
24 | 25 | return null; |
25 | 26 | } |
26 | 27 | |
27 | - if ($node->value instanceof Nil) { |
|
28 | + if ($node->value instanceof Nil) |
|
29 | + { |
|
28 | 30 | return new Aggregate($node->getContext()); |
29 | 31 | } |
30 | 32 | |
31 | - if (!\is_string($node->value)) { |
|
33 | + if (!\is_string($node->value)) |
|
34 | + { |
|
32 | 35 | return null; |
33 | 36 | } |
34 | 37 |
@@ -19,7 +19,8 @@ discard block |
||
19 | 19 | |
20 | 20 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
21 | 21 | { |
22 | - if ($node instanceof Tag && \str_starts_with($node->name, $this->stackKeyword)) { |
|
22 | + if ($node instanceof Tag && \str_starts_with($node->name, $this->stackKeyword)) |
|
23 | + { |
|
23 | 24 | return $this->registerAggregate(StackContext::on($ctx), $node); |
24 | 25 | } |
25 | 26 | |
@@ -34,7 +35,8 @@ discard block |
||
34 | 35 | private function registerAggregate(StackContext $ctx, Tag $node): Aggregate|Tag |
35 | 36 | { |
36 | 37 | $name = $this->stackName($node); |
37 | - if ($name === null) { |
|
38 | + if ($name === null) |
|
39 | + { |
|
38 | 40 | return $node; |
39 | 41 | } |
40 | 42 | |
@@ -50,8 +52,10 @@ discard block |
||
50 | 52 | private function stackName(Tag $tag): ?string |
51 | 53 | { |
52 | 54 | $options = []; |
53 | - foreach ($tag->attrs as $attr) { |
|
54 | - if (\is_string($attr->value)) { |
|
55 | + foreach ($tag->attrs as $attr) |
|
56 | + { |
|
57 | + if (\is_string($attr->value)) |
|
58 | + { |
|
55 | 59 | $options[$attr->name] = \trim($attr->value, '\'"'); |
56 | 60 | } |
57 | 61 | } |
@@ -62,8 +66,10 @@ discard block |
||
62 | 66 | private function stackLevel(Tag $tag): int |
63 | 67 | { |
64 | 68 | $options = []; |
65 | - foreach ($tag->attrs as $attr) { |
|
66 | - if (\is_string($attr->value)) { |
|
69 | + foreach ($tag->attrs as $attr) |
|
70 | + { |
|
71 | + if (\is_string($attr->value)) |
|
72 | + { |
|
67 | 73 | $options[$attr->name] = \trim($attr->value, '\'"'); |
68 | 74 | } |
69 | 75 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
21 | 21 | { |
22 | - if ($node instanceof Tag && \str_starts_with($node->name, $this->stackKeyword)) { |
|
22 | + if ($node instanceof Tag && \str_starts_with($node->name, $this->stackKeyword)){ |
|
23 | 23 | return $this->registerAggregate(StackContext::on($ctx), $node); |
24 | 24 | } |
25 | 25 | |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | return null; |
32 | 32 | } |
33 | 33 | |
34 | - private function registerAggregate(StackContext $ctx, Tag $node): Aggregate|Tag |
|
34 | + private function registerAggregate(StackContext $ctx, Tag $node): Aggregate | Tag |
|
35 | 35 | { |
36 | 36 | $name = $this->stackName($node); |
37 | - if ($name === null) { |
|
37 | + if ($name === null){ |
|
38 | 38 | return $node; |
39 | 39 | } |
40 | 40 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | private function stackName(Tag $tag): ?string |
51 | 51 | { |
52 | 52 | $options = []; |
53 | - foreach ($tag->attrs as $attr) { |
|
54 | - if (\is_string($attr->value)) { |
|
53 | + foreach ($tag->attrs as $attr){ |
|
54 | + if (\is_string($attr->value)){ |
|
55 | 55 | $options[$attr->name] = \trim($attr->value, '\'"'); |
56 | 56 | } |
57 | 57 | } |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | private function stackLevel(Tag $tag): int |
63 | 63 | { |
64 | 64 | $options = []; |
65 | - foreach ($tag->attrs as $attr) { |
|
66 | - if (\is_string($attr->value)) { |
|
65 | + foreach ($tag->attrs as $attr){ |
|
66 | + if (\is_string($attr->value)){ |
|
67 | 67 | $options[$attr->name] = \trim($attr->value, '\'"'); |
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - return \abs((int) ($options['level'] ?? 0)); |
|
71 | + return \abs((int)($options['level'] ?? 0)); |
|
72 | 72 | } |
73 | 73 | } |