@@ -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 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | public function leaveNode(mixed $node, VisitorContext $ctx): ?Hidden |
23 | 23 | { |
24 | - if ($node instanceof Tag && \str_starts_with($node->name, $this->hiddenKeyword)) { |
|
24 | + if ($node instanceof Tag && \str_starts_with($node->name, $this->hiddenKeyword)){ |
|
25 | 25 | return new Hidden([$node]); |
26 | 26 | } |
27 | 27 |
@@ -21,7 +21,8 @@ |
||
21 | 21 | |
22 | 22 | public function leaveNode(mixed $node, VisitorContext $ctx): ?Hidden |
23 | 23 | { |
24 | - if ($node instanceof Tag && \str_starts_with($node->name, $this->hiddenKeyword)) { |
|
24 | + if ($node instanceof Tag && \str_starts_with($node->name, $this->hiddenKeyword)) |
|
25 | + { |
|
25 | 26 | return new Hidden([$node]); |
26 | 27 | } |
27 | 28 |
@@ -26,7 +26,8 @@ |
||
26 | 26 | |
27 | 27 | public function resolve(Builder $builder, string $name): ?Template |
28 | 28 | { |
29 | - if ($name !== $this->name) { |
|
29 | + if ($name !== $this->name) |
|
30 | + { |
|
30 | 31 | return null; |
31 | 32 | } |
32 | 33 |
@@ -20,13 +20,13 @@ |
||
20 | 20 | private readonly string $name, |
21 | 21 | private readonly array $nodes, |
22 | 22 | ?Context $context = null, |
23 | - ) { |
|
23 | + ){ |
|
24 | 24 | $this->context = $context; |
25 | 25 | } |
26 | 26 | |
27 | 27 | public function resolve(Builder $builder, string $name): ?Template |
28 | 28 | { |
29 | - if ($name !== $this->name) { |
|
29 | + if ($name !== $this->name){ |
|
30 | 30 | return null; |
31 | 31 | } |
32 | 32 |
@@ -25,7 +25,8 @@ discard block |
||
25 | 25 | ) { |
26 | 26 | $this->alias = $alias ?? $path; |
27 | 27 | |
28 | - if ($alias === null && \strrpos($this->alias, '/') !== false) { |
|
28 | + if ($alias === null && \strrpos($this->alias, '/') !== false) |
|
29 | + { |
|
29 | 30 | $this->alias = \substr($this->alias, \strrpos($this->alias, '/') + 1); |
30 | 31 | } |
31 | 32 | |
@@ -44,7 +45,8 @@ discard block |
||
44 | 45 | |
45 | 46 | public function resolve(Builder $builder, string $name): ?Template |
46 | 47 | { |
47 | - if ($this->alias !== $name) { |
|
48 | + if ($this->alias !== $name) |
|
49 | + { |
|
48 | 50 | return null; |
49 | 51 | } |
50 | 52 |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | private string $path, |
23 | 23 | ?string $alias = null, |
24 | 24 | ?Context $context = null, |
25 | - ) { |
|
25 | + ){ |
|
26 | 26 | $this->alias = $alias ?? $path; |
27 | 27 | |
28 | - if ($alias === null && \strrpos($this->alias, '/') !== false) { |
|
28 | + if ($alias === null && \strrpos($this->alias, '/') !== false){ |
|
29 | 29 | $this->alias = \substr($this->alias, \strrpos($this->alias, '/') + 1); |
30 | 30 | } |
31 | 31 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | public function resolve(Builder $builder, string $name): ?Template |
46 | 46 | { |
47 | - if ($this->alias !== $name) { |
|
47 | + if ($this->alias !== $name){ |
|
48 | 48 | return null; |
49 | 49 | } |
50 | 50 |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | public function renderCase(Directive $directive): string |
74 | 74 | { |
75 | - if ($this->firstSwitchCase) { |
|
75 | + if ($this->firstSwitchCase){ |
|
76 | 76 | $this->firstSwitchCase = false; |
77 | 77 | |
78 | 78 | return \sprintf('case (%s): ?>', $directive->body); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | public function renderDefault(Directive $directive): string |
85 | 85 | { |
86 | - if ($this->firstSwitchCase) { |
|
86 | + if ($this->firstSwitchCase){ |
|
87 | 87 | $this->firstSwitchCase = false; |
88 | 88 | |
89 | 89 | return 'default: ?>'; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | public function renderBreak(Directive $directive): string |
101 | 101 | { |
102 | - if (isset($directive->values[0])) { |
|
102 | + if (isset($directive->values[0])){ |
|
103 | 103 | return \sprintf('<?php break %s; ?>', $directive->values[0]); |
104 | 104 | } |
105 | 105 |
@@ -72,7 +72,8 @@ discard block |
||
72 | 72 | |
73 | 73 | public function renderCase(Directive $directive): string |
74 | 74 | { |
75 | - if ($this->firstSwitchCase) { |
|
75 | + if ($this->firstSwitchCase) |
|
76 | + { |
|
76 | 77 | $this->firstSwitchCase = false; |
77 | 78 | |
78 | 79 | return \sprintf('case (%s): ?>', $directive->body); |
@@ -83,7 +84,8 @@ discard block |
||
83 | 84 | |
84 | 85 | public function renderDefault(Directive $directive): string |
85 | 86 | { |
86 | - if ($this->firstSwitchCase) { |
|
87 | + if ($this->firstSwitchCase) |
|
88 | + { |
|
87 | 89 | $this->firstSwitchCase = false; |
88 | 90 | |
89 | 91 | return 'default: ?>'; |
@@ -99,7 +101,8 @@ discard block |
||
99 | 101 | |
100 | 102 | public function renderBreak(Directive $directive): string |
101 | 103 | { |
102 | - if (isset($directive->values[0])) { |
|
104 | + if (isset($directive->values[0])) |
|
105 | + { |
|
103 | 106 | return \sprintf('<?php break %s; ?>', $directive->values[0]); |
104 | 107 | } |
105 | 108 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | public function renderBreak(Directive $directive): string |
35 | 35 | { |
36 | - if (isset($directive->values[0])) { |
|
36 | + if (isset($directive->values[0])){ |
|
37 | 37 | return \sprintf('<?php break %s; ?>', $directive->values[0]); |
38 | 38 | } |
39 | 39 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | public function renderContinue(Directive $directive): string |
44 | 44 | { |
45 | - if (isset($directive->values[0])) { |
|
45 | + if (isset($directive->values[0])){ |
|
46 | 46 | return \sprintf('<?php continue %s; ?>', $directive->values[0]); |
47 | 47 | } |
48 | 48 |
@@ -33,7 +33,8 @@ discard block |
||
33 | 33 | |
34 | 34 | public function renderBreak(Directive $directive): string |
35 | 35 | { |
36 | - if (isset($directive->values[0])) { |
|
36 | + if (isset($directive->values[0])) |
|
37 | + { |
|
37 | 38 | return \sprintf('<?php break %s; ?>', $directive->values[0]); |
38 | 39 | } |
39 | 40 | |
@@ -42,7 +43,8 @@ discard block |
||
42 | 43 | |
43 | 44 | public function renderContinue(Directive $directive): string |
44 | 45 | { |
45 | - if (isset($directive->values[0])) { |
|
46 | + if (isset($directive->values[0])) |
|
47 | + { |
|
46 | 48 | return \sprintf('<?php continue %s; ?>', $directive->values[0]); |
47 | 49 | } |
48 | 50 |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | $buffer = null; |
21 | 21 | $bufferOffset = 0; |
22 | 22 | |
23 | - foreach ($inner as $n) { |
|
23 | + foreach ($inner as $n){ |
|
24 | 24 | $token->offset ??= $n->offset; |
25 | 25 | |
26 | - if ($n instanceof Byte) { |
|
27 | - if ($buffer === null) { |
|
26 | + if ($n instanceof Byte){ |
|
27 | + if ($buffer === null){ |
|
28 | 28 | $buffer = ''; |
29 | 29 | $bufferOffset = $n->offset; |
30 | 30 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | continue; |
36 | 36 | } |
37 | 37 | |
38 | - if ($buffer !== null) { |
|
38 | + if ($buffer !== null){ |
|
39 | 39 | $token->tokens[] = new Token( |
40 | 40 | Token::TYPE_RAW, |
41 | 41 | $bufferOffset, |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $token->tokens[] = $n; |
50 | 50 | } |
51 | 51 | |
52 | - if ($buffer !== null) { |
|
52 | + if ($buffer !== null){ |
|
53 | 53 | $token->tokens[] = new Token( |
54 | 54 | Token::TYPE_RAW, |
55 | 55 | $bufferOffset, |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | ); |
59 | 59 | } |
60 | 60 | |
61 | - if (\count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW) { |
|
61 | + if (\count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW){ |
|
62 | 62 | $token->tokens = []; |
63 | 63 | } |
64 | 64 |
@@ -20,11 +20,14 @@ discard block |
||
20 | 20 | $buffer = null; |
21 | 21 | $bufferOffset = 0; |
22 | 22 | |
23 | - foreach ($inner as $n) { |
|
23 | + foreach ($inner as $n) |
|
24 | + { |
|
24 | 25 | $token->offset ??= $n->offset; |
25 | 26 | |
26 | - if ($n instanceof Byte) { |
|
27 | - if ($buffer === null) { |
|
27 | + if ($n instanceof Byte) |
|
28 | + { |
|
29 | + if ($buffer === null) |
|
30 | + { |
|
28 | 31 | $buffer = ''; |
29 | 32 | $bufferOffset = $n->offset; |
30 | 33 | } |
@@ -35,7 +38,8 @@ discard block |
||
35 | 38 | continue; |
36 | 39 | } |
37 | 40 | |
38 | - if ($buffer !== null) { |
|
41 | + if ($buffer !== null) |
|
42 | + { |
|
39 | 43 | $token->tokens[] = new Token( |
40 | 44 | Token::TYPE_RAW, |
41 | 45 | $bufferOffset, |
@@ -49,7 +53,8 @@ discard block |
||
49 | 53 | $token->tokens[] = $n; |
50 | 54 | } |
51 | 55 | |
52 | - if ($buffer !== null) { |
|
56 | + if ($buffer !== null) |
|
57 | + { |
|
53 | 58 | $token->tokens[] = new Token( |
54 | 59 | Token::TYPE_RAW, |
55 | 60 | $bufferOffset, |
@@ -58,7 +63,8 @@ discard block |
||
58 | 63 | ); |
59 | 64 | } |
60 | 65 | |
61 | - if (\count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW) { |
|
66 | + if (\count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW) |
|
67 | + { |
|
62 | 68 | $token->tokens = []; |
63 | 69 | } |
64 | 70 |
@@ -35,19 +35,19 @@ discard block |
||
35 | 35 | public function parse(Buffer $src): \Generator |
36 | 36 | { |
37 | 37 | $quoted = []; |
38 | - while ($n = $src->next()) { |
|
39 | - switch ($n->char) { |
|
38 | + while ($n = $src->next()){ |
|
39 | + switch ($n->char){ |
|
40 | 40 | case '"': |
41 | 41 | case "'": |
42 | - if ($this->keyword !== []) { |
|
42 | + if ($this->keyword !== []){ |
|
43 | 43 | yield $this->packToken($this->keyword, self::TYPE_KEYWORD); |
44 | 44 | $this->keyword = []; |
45 | 45 | } |
46 | 46 | |
47 | 47 | $quoted[] = $n; |
48 | - while ($nn = $src->next()) { |
|
48 | + while ($nn = $src->next()){ |
|
49 | 49 | $quoted[] = $nn; |
50 | - if ($nn instanceof Byte && $nn->char === $n->char) { |
|
50 | + if ($nn instanceof Byte && $nn->char === $n->char){ |
|
51 | 51 | break; |
52 | 52 | } |
53 | 53 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | break; |
59 | 59 | case '=': |
60 | - if ($this->keyword !== []) { |
|
60 | + if ($this->keyword !== []){ |
|
61 | 61 | yield $this->packToken($this->keyword, self::TYPE_KEYWORD); |
62 | 62 | $this->keyword = []; |
63 | 63 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | yield new Token(self::TYPE_EQUAL, $n->offset, '='); |
66 | 66 | break; |
67 | 67 | case ',': |
68 | - if ($this->keyword !== []) { |
|
68 | + if ($this->keyword !== []){ |
|
69 | 69 | yield $this->packToken($this->keyword, self::TYPE_KEYWORD); |
70 | 70 | $this->keyword = []; |
71 | 71 | } |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | yield new Token(self::TYPE_COMMA, $n->offset, ','); |
74 | 74 | break; |
75 | 75 | default: |
76 | - if (\preg_match(self::REGEXP_WHITESPACE, $n->char)) { |
|
77 | - if ($this->keyword !== []) { |
|
76 | + if (\preg_match(self::REGEXP_WHITESPACE, $n->char)){ |
|
77 | + if ($this->keyword !== []){ |
|
78 | 78 | yield $this->packToken($this->keyword, self::TYPE_KEYWORD); |
79 | 79 | $this->keyword = []; |
80 | 80 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | - if ($this->keyword !== []) { |
|
89 | + if ($this->keyword !== []){ |
|
90 | 90 | yield $this->packToken($this->keyword, self::TYPE_KEYWORD); |
91 | 91 | } |
92 | 92 | } |
@@ -35,19 +35,24 @@ discard block |
||
35 | 35 | public function parse(Buffer $src): \Generator |
36 | 36 | { |
37 | 37 | $quoted = []; |
38 | - while ($n = $src->next()) { |
|
39 | - switch ($n->char) { |
|
38 | + while ($n = $src->next()) |
|
39 | + { |
|
40 | + switch ($n->char) |
|
41 | + { |
|
40 | 42 | case '"': |
41 | 43 | case "'": |
42 | - if ($this->keyword !== []) { |
|
44 | + if ($this->keyword !== []) |
|
45 | + { |
|
43 | 46 | yield $this->packToken($this->keyword, self::TYPE_KEYWORD); |
44 | 47 | $this->keyword = []; |
45 | 48 | } |
46 | 49 | |
47 | 50 | $quoted[] = $n; |
48 | - while ($nn = $src->next()) { |
|
51 | + while ($nn = $src->next()) |
|
52 | + { |
|
49 | 53 | $quoted[] = $nn; |
50 | - if ($nn instanceof Byte && $nn->char === $n->char) { |
|
54 | + if ($nn instanceof Byte && $nn->char === $n->char) |
|
55 | + { |
|
51 | 56 | break; |
52 | 57 | } |
53 | 58 | } |
@@ -57,7 +62,8 @@ discard block |
||
57 | 62 | |
58 | 63 | break; |
59 | 64 | case '=': |
60 | - if ($this->keyword !== []) { |
|
65 | + if ($this->keyword !== []) |
|
66 | + { |
|
61 | 67 | yield $this->packToken($this->keyword, self::TYPE_KEYWORD); |
62 | 68 | $this->keyword = []; |
63 | 69 | } |
@@ -65,7 +71,8 @@ discard block |
||
65 | 71 | yield new Token(self::TYPE_EQUAL, $n->offset, '='); |
66 | 72 | break; |
67 | 73 | case ',': |
68 | - if ($this->keyword !== []) { |
|
74 | + if ($this->keyword !== []) |
|
75 | + { |
|
69 | 76 | yield $this->packToken($this->keyword, self::TYPE_KEYWORD); |
70 | 77 | $this->keyword = []; |
71 | 78 | } |
@@ -73,8 +80,10 @@ discard block |
||
73 | 80 | yield new Token(self::TYPE_COMMA, $n->offset, ','); |
74 | 81 | break; |
75 | 82 | default: |
76 | - if (\preg_match(self::REGEXP_WHITESPACE, $n->char)) { |
|
77 | - if ($this->keyword !== []) { |
|
83 | + if (\preg_match(self::REGEXP_WHITESPACE, $n->char)) |
|
84 | + { |
|
85 | + if ($this->keyword !== []) |
|
86 | + { |
|
78 | 87 | yield $this->packToken($this->keyword, self::TYPE_KEYWORD); |
79 | 88 | $this->keyword = []; |
80 | 89 | } |
@@ -86,7 +95,8 @@ discard block |
||
86 | 95 | } |
87 | 96 | } |
88 | 97 | |
89 | - if ($this->keyword !== []) { |
|
98 | + if ($this->keyword !== []) |
|
99 | + { |
|
90 | 100 | yield $this->packToken($this->keyword, self::TYPE_KEYWORD); |
91 | 101 | } |
92 | 102 | } |
@@ -76,7 +76,8 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function starts(Buffer $src, Byte $n): bool |
78 | 78 | { |
79 | - if (!$this->active) { |
|
79 | + if (!$this->active) |
|
80 | + { |
|
80 | 81 | return false; |
81 | 82 | } |
82 | 83 | |
@@ -96,26 +97,32 @@ discard block |
||
96 | 97 | ), |
97 | 98 | ]; |
98 | 99 | |
99 | - while ($n = $src->next()) { |
|
100 | - if (!$n instanceof Byte) { |
|
100 | + while ($n = $src->next()) |
|
101 | + { |
|
102 | + if (!$n instanceof Byte) |
|
103 | + { |
|
101 | 104 | // no other grammars are allowed |
102 | 105 | break; |
103 | 106 | } |
104 | 107 | |
105 | - switch ($n->char) { |
|
108 | + switch ($n->char) |
|
109 | + { |
|
106 | 110 | case '"': |
107 | 111 | case "'": |
108 | 112 | $this->body[] = $n; |
109 | - while ($nn = $src->next()) { |
|
113 | + while ($nn = $src->next()) |
|
114 | + { |
|
110 | 115 | $this->body[] = $nn; |
111 | - if ($nn instanceof Byte && $nn->char === $n->char) { |
|
116 | + if ($nn instanceof Byte && $nn->char === $n->char) |
|
117 | + { |
|
112 | 118 | break; |
113 | 119 | } |
114 | 120 | } |
115 | 121 | break; |
116 | 122 | |
117 | 123 | case $this->endSequence[0]: |
118 | - if (!$this->ends($src, $n)) { |
|
124 | + if (!$this->ends($src, $n)) |
|
125 | + { |
|
119 | 126 | // still part of body |
120 | 127 | $this->body[] = $n; |
121 | 128 | break; |
@@ -134,7 +141,8 @@ discard block |
||
134 | 141 | } |
135 | 142 | } |
136 | 143 | |
137 | - if (\count($this->tokens) !== 3) { |
|
144 | + if (\count($this->tokens) !== 3) |
|
145 | + { |
|
138 | 146 | return null; |
139 | 147 | } |
140 | 148 | |
@@ -161,7 +169,8 @@ discard block |
||
161 | 169 | private function nextBytes(Buffer $src, int $size): string |
162 | 170 | { |
163 | 171 | $result = ''; |
164 | - for ($i = 0; $i < $size; $i++) { |
|
172 | + for ($i = 0; $i < $size; $i++) |
|
173 | + { |
|
165 | 174 | $result .= $src->next()->char; |
166 | 175 | } |
167 | 176 | |
@@ -173,7 +182,8 @@ discard block |
||
173 | 182 | */ |
174 | 183 | private function flushBody(): void |
175 | 184 | { |
176 | - if ($this->body === []) { |
|
185 | + if ($this->body === []) |
|
186 | + { |
|
177 | 187 | return; |
178 | 188 | } |
179 | 189 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | string $endSequence, |
28 | 28 | private readonly int $startToken, |
29 | 29 | private readonly int $endToken, |
30 | - ) { |
|
30 | + ){ |
|
31 | 31 | $this->setStartSequence($startSequence); |
32 | 32 | $this->setEndSequence($endSequence); |
33 | 33 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | public function nextToken(Buffer $src): bool |
70 | 70 | { |
71 | - return $this->active && $src->lookaheadByte(\strlen((string) $this->startSequence)) === $this->startSequence; |
|
71 | + return $this->active && $src->lookaheadByte(\strlen((string)$this->startSequence)) === $this->startSequence; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function starts(Buffer $src, Byte $n): bool |
78 | 78 | { |
79 | - if (!$this->active) { |
|
79 | + if (!$this->active){ |
|
80 | 80 | return false; |
81 | 81 | } |
82 | 82 | |
83 | - return $this->startSequence === ($n->char . $src->lookaheadByte(\strlen((string) $this->startSequence) - 1)); |
|
83 | + return $this->startSequence === ($n->char.$src->lookaheadByte(\strlen((string)$this->startSequence) - 1)); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -92,30 +92,30 @@ discard block |
||
92 | 92 | new Token( |
93 | 93 | $this->startToken, |
94 | 94 | $n->offset, |
95 | - $n->char . $this->nextBytes($src, \strlen((string) $this->startSequence) - 1), |
|
95 | + $n->char.$this->nextBytes($src, \strlen((string)$this->startSequence) - 1), |
|
96 | 96 | ), |
97 | 97 | ]; |
98 | 98 | |
99 | - while ($n = $src->next()) { |
|
100 | - if (!$n instanceof Byte) { |
|
99 | + while ($n = $src->next()){ |
|
100 | + if (!$n instanceof Byte){ |
|
101 | 101 | // no other grammars are allowed |
102 | 102 | break; |
103 | 103 | } |
104 | 104 | |
105 | - switch ($n->char) { |
|
105 | + switch ($n->char){ |
|
106 | 106 | case '"': |
107 | 107 | case "'": |
108 | 108 | $this->body[] = $n; |
109 | - while ($nn = $src->next()) { |
|
109 | + while ($nn = $src->next()){ |
|
110 | 110 | $this->body[] = $nn; |
111 | - if ($nn instanceof Byte && $nn->char === $n->char) { |
|
111 | + if ($nn instanceof Byte && $nn->char === $n->char){ |
|
112 | 112 | break; |
113 | 113 | } |
114 | 114 | } |
115 | 115 | break; |
116 | 116 | |
117 | 117 | case $this->endSequence[0]: |
118 | - if (!$this->ends($src, $n)) { |
|
118 | + if (!$this->ends($src, $n)){ |
|
119 | 119 | // still part of body |
120 | 120 | $this->body[] = $n; |
121 | 121 | break; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $this->tokens[] = new Token( |
126 | 126 | $this->endToken, |
127 | 127 | $n->offset, |
128 | - $n->char . $this->nextBytes($src, \strlen((string) $this->endSequence) - 1), |
|
128 | + $n->char.$this->nextBytes($src, \strlen((string)$this->endSequence) - 1), |
|
129 | 129 | ); |
130 | 130 | |
131 | 131 | break 2; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - if (\count($this->tokens) !== 3) { |
|
137 | + if (\count($this->tokens) !== 3){ |
|
138 | 138 | return null; |
139 | 139 | } |
140 | 140 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | private function ends(Buffer $src, Byte $n): bool |
148 | 148 | { |
149 | - return $this->endSequence === ($n->char . $src->lookaheadByte(\strlen((string) $this->endSequence) - 1)); |
|
149 | + return $this->endSequence === ($n->char.$src->lookaheadByte(\strlen((string)$this->endSequence) - 1)); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | private function nextBytes(Buffer $src, int $size): string |
160 | 160 | { |
161 | 161 | $result = ''; |
162 | - for ($i = 0; $i < $size; $i++) { |
|
162 | + for ($i = 0; $i < $size; $i++){ |
|
163 | 163 | $result .= $src->next()->char; |
164 | 164 | } |
165 | 165 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | private function flushBody(): void |
173 | 173 | { |
174 | - if ($this->body === []) { |
|
174 | + if ($this->body === []){ |
|
175 | 175 | return; |
176 | 176 | } |
177 | 177 |