Passed
Pull Request — master (#1205)
by Aleksei
18:36 queued 06:28
created
src/Stempler/src/Transform/Finalizer/StackCollector.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,33 +25,33 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,11 +25,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Visitor/DefineAttributes.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,15 +20,15 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,15 +20,18 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Visitor/DefineStacks.php 2 patches
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,7 +19,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Visitor/DefineHidden.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Import/Inline.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,8 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Import/Element.php 2 patches
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Stempler/src/Directive/ConditionalDirective.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,7 +72,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Stempler/src/Directive/LoopDirective.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/Grammar/Traits/TokenTrait.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,11 +20,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.