Test Failed
Pull Request — master (#1003)
by Maxim
20:36 queued 08:54
created
src/Stempler/src/Transform/Finalizer/IsolateBlocks.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@
 block discarded – undo
15 15
 {
16 16
     public function __construct(
17 17
         private readonly string $path
18
-    ) {
18
+    ){
19 19
     }
20 20
 
21 21
     public function enterNode(mixed $node, VisitorContext $ctx): mixed
22 22
     {
23
-        if ($node instanceof Block && $node->getContext()->getPath() === $this->path) {
23
+        if ($node instanceof Block && $node->getContext()->getPath() === $this->path){
24 24
             $node->name = null;
25 25
         }
26 26
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@
 block discarded – undo
20 20
 
21 21
     public function enterNode(mixed $node, VisitorContext $ctx): mixed
22 22
     {
23
-        if ($node instanceof Block && $node->getContext()->getPath() === $this->path) {
23
+        if ($node instanceof Block && $node->getContext()->getPath() === $this->path)
24
+        {
24 25
             $node->name = null;
25 26
         }
26 27
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Finalizer/IsolatePHPBlocks.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,21 +19,21 @@
 block discarded – undo
19 19
 
20 20
     public function __construct(
21 21
         private readonly string $path
22
-    ) {
22
+    ){
23 23
     }
24 24
 
25 25
     public function enterNode(mixed $node, VisitorContext $ctx): mixed
26 26
     {
27
-        if (!$node instanceof PHP || !\str_contains($node->content, self::PHP_MARCO_EXISTS_FUNCTION)) {
27
+        if (!$node instanceof PHP || !\str_contains($node->content, self::PHP_MARCO_EXISTS_FUNCTION)){
28 28
             return null;
29 29
         }
30 30
 
31
-        if ($node->getContext()->getPath() !== $this->path) {
31
+        if ($node->getContext()->getPath() !== $this->path){
32 32
             return null;
33 33
         }
34 34
 
35 35
         $exists = new PHPMixin($node->tokens, self::PHP_MARCO_EXISTS_FUNCTION);
36
-        foreach (\array_keys($exists->getBlocks()) as $name) {
36
+        foreach (\array_keys($exists->getBlocks()) as $name){
37 37
             // do not leak to parent template
38 38
             $exists->set($name, 'false');
39 39
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,16 +24,19 @@
 block discarded – undo
24 24
 
25 25
     public function enterNode(mixed $node, VisitorContext $ctx): mixed
26 26
     {
27
-        if (!$node instanceof PHP || !\str_contains($node->content, self::PHP_MARCO_EXISTS_FUNCTION)) {
27
+        if (!$node instanceof PHP || !\str_contains($node->content, self::PHP_MARCO_EXISTS_FUNCTION))
28
+        {
28 29
             return null;
29 30
         }
30 31
 
31
-        if ($node->getContext()->getPath() !== $this->path) {
32
+        if ($node->getContext()->getPath() !== $this->path)
33
+        {
32 34
             return null;
33 35
         }
34 36
 
35 37
         $exists = new PHPMixin($node->tokens, self::PHP_MARCO_EXISTS_FUNCTION);
36
-        foreach (\array_keys($exists->getBlocks()) as $name) {
38
+        foreach (\array_keys($exists->getBlocks()) as $name)
39
+        {
37 40
             // do not leak to parent template
38 41
             $exists->set($name, 'false');
39 42
         }
Please login to merge, or discard this patch.
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/Finalizer/DynamicToPHP.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     public function __construct(
36 36
         private readonly string $defaultFilter = self::DEFAULT_FILTER,
37 37
         private array $directives = []
38
-    ) {
38
+    ){
39 39
         $this->traverser = new Traverser();
40 40
         $this->traverser->addVisitor($this);
41 41
     }
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
 
56 56
     public function leaveNode(mixed $node, VisitorContext $ctx): mixed
57 57
     {
58
-        if ($node instanceof Output) {
58
+        if ($node instanceof Output){
59 59
             return $this->output($node, $ctx);
60 60
         }
61 61
 
62
-        if ($node instanceof Directive) {
62
+        if ($node instanceof Directive){
63 63
             return $this->directive($node);
64 64
         }
65 65
 
66
-        if ($node instanceof Template) {
66
+        if ($node instanceof Template){
67 67
             $extendsTag = $node->getAttribute(ExtendsParent::class);
68
-            if ($extendsTag instanceof Tag) {
68
+            if ($extendsTag instanceof Tag){
69 69
                 $extendsTag->attrs = $this->traverser->traverse($extendsTag->attrs);
70 70
             }
71 71
         }
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 
76 76
     private function directive(Directive $node): PHP
77 77
     {
78
-        foreach ($this->directives as $renderer) {
78
+        foreach ($this->directives as $renderer){
79 79
             $result = $renderer->render($node);
80
-            if ($result !== null) {
80
+            if ($result !== null){
81 81
                 return new PHP($result, \token_get_all($result), $node->getContext());
82 82
             }
83 83
         }
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
          * In future this method can support context aware escaping based on tag location.
95 95
          */
96 96
 
97
-        if ($node->rawOutput) {
97
+        if ($node->rawOutput){
98 98
             $result = \sprintf('<?php echo %s; ?>', \trim($node->body));
99
-        } else {
99
+        }else{
100 100
             $filter = $node->filter ?? $this->getFilterContext($ctx);
101 101
 
102 102
             $result = \sprintf(\sprintf('<?php echo %s; ?>', $filter), \trim($node->body));
@@ -114,22 +114,22 @@  discard block
 block discarded – undo
114 114
         // only "interesting" nodes
115 115
         $context = [];
116 116
 
117
-        foreach (\array_reverse($ctx->getScope()) as $node) {
118
-            if ($node instanceof Attr || $node instanceof Tag || $node instanceof Verbatim) {
117
+        foreach (\array_reverse($ctx->getScope()) as $node){
118
+            if ($node instanceof Attr || $node instanceof Tag || $node instanceof Verbatim){
119 119
                 $context[] = $node;
120 120
             }
121 121
 
122
-            if (\count($context) === 2) {
122
+            if (\count($context) === 2){
123 123
                 break;
124 124
             }
125 125
         }
126 126
 
127
-        if (\count($context) !== 2) {
127
+        if (\count($context) !== 2){
128 128
             return $this->defaultFilter;
129 129
         }
130 130
 
131 131
         // php {{ }} in javascript code (variable passing), use {! !} to bypass the filter
132
-        if ($context[0] instanceof Verbatim && $context[1] instanceof Tag && $context[1]->name === 'script') {
132
+        if ($context[0] instanceof Verbatim && $context[1] instanceof Tag && $context[1]->name === 'script'){
133 133
             return \sprintf(
134 134
                 'json_encode(%s, %s, %s)',
135 135
                 '%s',
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         }
140 140
 
141 141
         // in on* and other attributes
142
-        if ($context[0] instanceof Verbatim && $context[1] instanceof Attr && $context[1]->name !== 'style') {
142
+        if ($context[0] instanceof Verbatim && $context[1] instanceof Attr && $context[1]->name !== 'style'){
143 143
             return \sprintf("'%s', %s, '%s'", '&quot;', $this->defaultFilter, '&quot;');
144 144
         }
145 145
 
Please login to merge, or discard this patch.
Braces   +29 added lines, -14 removed lines patch added patch discarded remove patch
@@ -55,17 +55,21 @@  discard block
 block discarded – undo
55 55
 
56 56
     public function leaveNode(mixed $node, VisitorContext $ctx): mixed
57 57
     {
58
-        if ($node instanceof Output) {
58
+        if ($node instanceof Output)
59
+        {
59 60
             return $this->output($node, $ctx);
60 61
         }
61 62
 
62
-        if ($node instanceof Directive) {
63
+        if ($node instanceof Directive)
64
+        {
63 65
             return $this->directive($node);
64 66
         }
65 67
 
66
-        if ($node instanceof Template) {
68
+        if ($node instanceof Template)
69
+        {
67 70
             $extendsTag = $node->getAttribute(ExtendsParent::class);
68
-            if ($extendsTag instanceof Tag) {
71
+            if ($extendsTag instanceof Tag)
72
+            {
69 73
                 $extendsTag->attrs = $this->traverser->traverse($extendsTag->attrs);
70 74
             }
71 75
         }
@@ -75,9 +79,11 @@  discard block
 block discarded – undo
75 79
 
76 80
     private function directive(Directive $node): PHP
77 81
     {
78
-        foreach ($this->directives as $renderer) {
82
+        foreach ($this->directives as $renderer)
83
+        {
79 84
             $result = $renderer->render($node);
80
-            if ($result !== null) {
85
+            if ($result !== null)
86
+            {
81 87
                 return new PHP($result, \token_get_all($result), $node->getContext());
82 88
             }
83 89
         }
@@ -94,9 +100,12 @@  discard block
 block discarded – undo
94 100
          * In future this method can support context aware escaping based on tag location.
95 101
          */
96 102
 
97
-        if ($node->rawOutput) {
103
+        if ($node->rawOutput)
104
+        {
98 105
             $result = \sprintf('<?php echo %s; ?>', \trim($node->body));
99
-        } else {
106
+        }
107
+        else
108
+        {
100 109
             $filter = $node->filter ?? $this->getFilterContext($ctx);
101 110
 
102 111
             $result = \sprintf(\sprintf('<?php echo %s; ?>', $filter), \trim($node->body));
@@ -114,22 +123,27 @@  discard block
 block discarded – undo
114 123
         // only "interesting" nodes
115 124
         $context = [];
116 125
 
117
-        foreach (\array_reverse($ctx->getScope()) as $node) {
118
-            if ($node instanceof Attr || $node instanceof Tag || $node instanceof Verbatim) {
126
+        foreach (\array_reverse($ctx->getScope()) as $node)
127
+        {
128
+            if ($node instanceof Attr || $node instanceof Tag || $node instanceof Verbatim)
129
+            {
119 130
                 $context[] = $node;
120 131
             }
121 132
 
122
-            if (\count($context) === 2) {
133
+            if (\count($context) === 2)
134
+            {
123 135
                 break;
124 136
             }
125 137
         }
126 138
 
127
-        if (\count($context) !== 2) {
139
+        if (\count($context) !== 2)
140
+        {
128 141
             return $this->defaultFilter;
129 142
         }
130 143
 
131 144
         // php {{ }} in javascript code (variable passing), use {! !} to bypass the filter
132
-        if ($context[0] instanceof Verbatim && $context[1] instanceof Tag && $context[1]->name === 'script') {
145
+        if ($context[0] instanceof Verbatim && $context[1] instanceof Tag && $context[1]->name === 'script')
146
+        {
133 147
             return \sprintf(
134 148
                 'json_encode(%s, %s, %s)',
135 149
                 '%s',
@@ -139,7 +153,8 @@  discard block
 block discarded – undo
139 153
         }
140 154
 
141 155
         // in on* and other attributes
142
-        if ($context[0] instanceof Verbatim && $context[1] instanceof Attr && $context[1]->name !== 'style') {
156
+        if ($context[0] instanceof Verbatim && $context[1] instanceof Attr && $context[1]->name !== 'style')
157
+        {
143 158
             return \sprintf("'%s', %s, '%s'", '&quot;', $this->defaultFilter, '&quot;');
144 159
         }
145 160
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Finalizer/TrimRaw.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 {
17 17
     public function __construct(
18 18
         private readonly string $characters = " \n\t\r"
19
-    ) {
19
+    ){
20 20
     }
21 21
 
22 22
     public function enterNode(mixed $node, VisitorContext $ctx): mixed
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 
27 27
     public function leaveNode(mixed $node, VisitorContext $ctx): mixed
28 28
     {
29
-        if ($node instanceof Raw && \trim($node->content, $this->characters) === '') {
30
-            foreach ($ctx->getScope() as $scope) {
31
-                if ($scope instanceof Attr) {
29
+        if ($node instanceof Raw && \trim($node->content, $this->characters) === ''){
30
+            foreach ($ctx->getScope() as $scope){
31
+                if ($scope instanceof Attr){
32 32
                     // do not trim attribute values
33 33
                     return null;
34 34
                 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,9 +26,12 @@
 block discarded – undo
26 26
 
27 27
     public function leaveNode(mixed $node, VisitorContext $ctx): mixed
28 28
     {
29
-        if ($node instanceof Raw && \trim($node->content, $this->characters) === '') {
30
-            foreach ($ctx->getScope() as $scope) {
31
-                if ($scope instanceof Attr) {
29
+        if ($node instanceof Raw && \trim($node->content, $this->characters) === '')
30
+        {
31
+            foreach ($ctx->getScope() as $scope)
32
+            {
33
+                if ($scope instanceof Attr)
34
+                {
32 35
                     // do not trim attribute values
33 36
                     return null;
34 37
                 }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/QuotedValue.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 final class QuotedValue
16 16
 {
17 17
     public function __construct(
18
-        private readonly NodeInterface|string $value
19
-    ) {
18
+        private readonly NodeInterface | string $value
19
+    ){
20 20
     }
21 21
 
22 22
     public function getValue(): mixed
@@ -30,29 +30,29 @@  discard block
 block discarded – undo
30 30
     public function trimValue(): array
31 31
     {
32 32
         $value = $this->value;
33
-        if ($value instanceof Nil) {
33
+        if ($value instanceof Nil){
34 34
             return [];
35 35
         }
36 36
 
37
-        if (\is_string($value)) {
37
+        if (\is_string($value)){
38 38
             return [new Raw(\trim($value, '\'"'))];
39 39
         }
40 40
 
41
-        if (!$value instanceof Mixin) {
41
+        if (!$value instanceof Mixin){
42 42
             return [$value];
43 43
         }
44 44
 
45 45
         // trim mixin quotes
46 46
         $nodes = $value->nodes;
47 47
 
48
-        if (\count($nodes) >= 3 && $nodes[0] instanceof Raw && $nodes[\count($nodes) - 1] instanceof Raw) {
48
+        if (\count($nodes) >= 3 && $nodes[0] instanceof Raw && $nodes[\count($nodes) - 1] instanceof Raw){
49 49
             /**
50 50
              * TODO issue #767
51 51
              * @link https://github.com/spiral/framework/issues/767
52 52
              * @psalm-suppress InvalidArrayAccess
53 53
              */
54 54
             $quote = $nodes[0]->content[0];
55
-            if (!\in_array($quote, ['"', "'"])) {
55
+            if (!\in_array($quote, ['"', "'"])){
56 56
                 return $nodes;
57 57
             }
58 58
 
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
             );
69 69
         }
70 70
 
71
-        foreach ($nodes as $index => $node) {
72
-            if ($node instanceof Raw && $node->content === '') {
71
+        foreach ($nodes as $index => $node){
72
+            if ($node instanceof Raw && $node->content === ''){
73 73
                 unset($nodes[$index]);
74 74
             }
75 75
         }
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,29 +30,34 @@  discard block
 block discarded – undo
30 30
     public function trimValue(): array
31 31
     {
32 32
         $value = $this->value;
33
-        if ($value instanceof Nil) {
33
+        if ($value instanceof Nil)
34
+        {
34 35
             return [];
35 36
         }
36 37
 
37
-        if (\is_string($value)) {
38
+        if (\is_string($value))
39
+        {
38 40
             return [new Raw(\trim($value, '\'"'))];
39 41
         }
40 42
 
41
-        if (!$value instanceof Mixin) {
43
+        if (!$value instanceof Mixin)
44
+        {
42 45
             return [$value];
43 46
         }
44 47
 
45 48
         // trim mixin quotes
46 49
         $nodes = $value->nodes;
47 50
 
48
-        if (\count($nodes) >= 3 && $nodes[0] instanceof Raw && $nodes[\count($nodes) - 1] instanceof Raw) {
51
+        if (\count($nodes) >= 3 && $nodes[0] instanceof Raw && $nodes[\count($nodes) - 1] instanceof Raw)
52
+        {
49 53
             /**
50 54
              * TODO issue #767
51 55
              * @link https://github.com/spiral/framework/issues/767
52 56
              * @psalm-suppress InvalidArrayAccess
53 57
              */
54 58
             $quote = $nodes[0]->content[0];
55
-            if (!\in_array($quote, ['"', "'"])) {
59
+            if (!\in_array($quote, ['"', "'"]))
60
+            {
56 61
                 return $nodes;
57 62
             }
58 63
 
@@ -68,8 +73,10 @@  discard block
 block discarded – undo
68 73
             );
69 74
         }
70 75
 
71
-        foreach ($nodes as $index => $node) {
72
-            if ($node instanceof Raw && $node->content === '') {
76
+        foreach ($nodes as $index => $node)
77
+        {
78
+            if ($node instanceof Raw && $node->content === '')
79
+            {
73 80
                 unset($nodes[$index]);
74 81
             }
75 82
         }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Merge/ExtendsParent.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
     public function __construct(
29 29
         private readonly Builder $builder,
30 30
         private readonly Merger $merger = new Merger()
31
-    ) {
31
+    ){
32 32
     }
33 33
 
34 34
     public function enterNode(mixed $node, VisitorContext $ctx): mixed
35 35
     {
36
-        if ($node instanceof Tag && \str_starts_with($node->name, $this->extendsKeyword)) {
36
+        if ($node instanceof Tag && \str_starts_with($node->name, $this->extendsKeyword)){
37 37
             return self::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
38 38
         }
39 39
 
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function leaveNode(mixed $node, VisitorContext $ctx): mixed
44 44
     {
45
-        if ($node instanceof Tag && \str_starts_with($node->name, $this->extendsKeyword)) {
45
+        if ($node instanceof Tag && \str_starts_with($node->name, $this->extendsKeyword)){
46 46
             $parent = $ctx->getParentNode();
47
-            if (!$parent instanceof AttributedInterface) {
47
+            if (!$parent instanceof AttributedInterface){
48 48
                 throw new LogicException(\sprintf(
49 49
                     'Unable to extend non attributable node (%s)',
50 50
                     \get_debug_type($node)
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
 
59 59
         // extend current node
60 60
         /** @psalm-var Template|Block|Verbatim|Tag $node */
61
-        if ($node instanceof AttributedInterface && $node->getAttribute(self::class) !== null) {
61
+        if ($node instanceof AttributedInterface && $node->getAttribute(self::class) !== null){
62 62
             /** @var Tag $extends */
63 63
             $extends = $node->getAttribute(self::class);
64 64
 
65
-            foreach ($node->nodes as $child) {
65
+            foreach ($node->nodes as $child){
66 66
                 /**
67 67
                  * TODO issue #767
68 68
                  * @link https://github.com/spiral/framework/issues/767
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
             }
73 73
 
74 74
             $path = 'undefined';
75
-            try {
75
+            try{
76 76
                 $path = $this->getPath($extends);
77 77
 
78 78
                 return $this->merger->merge($this->builder->load($path), $extends);
79
-            } catch (\Throwable $e) {
79
+            }catch (\Throwable $e){
80 80
                 throw new ExtendsException(
81 81
                     \sprintf('Unable to extend parent `%s`', $path),
82 82
                     $extends->getContext(),
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
 
91 91
     private function getPath(Tag $tag): string
92 92
     {
93
-        if (\str_starts_with($tag->name, $this->extendsKeyword . ':')) {
93
+        if (\str_starts_with($tag->name, $this->extendsKeyword.':')){
94 94
             $name = \substr($tag->name, \strlen($this->extendsKeyword) + 1);
95 95
 
96 96
             return \str_replace(['.'], DIRECTORY_SEPARATOR, $name);
97 97
         }
98 98
 
99
-        foreach ($tag->attrs as $attr) {
100
-            if ($attr->name === 'path' && \is_string($attr->value)) {
99
+        foreach ($tag->attrs as $attr){
100
+            if ($attr->name === 'path' && \is_string($attr->value)){
101 101
                 return \trim($attr->value, '\'"');
102 102
             }
103 103
         }
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -33,7 +33,8 @@  discard block
 block discarded – undo
33 33
 
34 34
     public function enterNode(mixed $node, VisitorContext $ctx): mixed
35 35
     {
36
-        if ($node instanceof Tag && \str_starts_with($node->name, $this->extendsKeyword)) {
36
+        if ($node instanceof Tag && \str_starts_with($node->name, $this->extendsKeyword))
37
+        {
37 38
             return self::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
38 39
         }
39 40
 
@@ -42,9 +43,11 @@  discard block
 block discarded – undo
42 43
 
43 44
     public function leaveNode(mixed $node, VisitorContext $ctx): mixed
44 45
     {
45
-        if ($node instanceof Tag && \str_starts_with($node->name, $this->extendsKeyword)) {
46
+        if ($node instanceof Tag && \str_starts_with($node->name, $this->extendsKeyword))
47
+        {
46 48
             $parent = $ctx->getParentNode();
47
-            if (!$parent instanceof AttributedInterface) {
49
+            if (!$parent instanceof AttributedInterface)
50
+            {
48 51
                 throw new LogicException(\sprintf(
49 52
                     'Unable to extend non attributable node (%s)',
50 53
                     \get_debug_type($node)
@@ -58,11 +61,13 @@  discard block
 block discarded – undo
58 61
 
59 62
         // extend current node
60 63
         /** @psalm-var Template|Block|Verbatim|Tag $node */
61
-        if ($node instanceof AttributedInterface && $node->getAttribute(self::class) !== null) {
64
+        if ($node instanceof AttributedInterface && $node->getAttribute(self::class) !== null)
65
+        {
62 66
             /** @var Tag $extends */
63 67
             $extends = $node->getAttribute(self::class);
64 68
 
65
-            foreach ($node->nodes as $child) {
69
+            foreach ($node->nodes as $child)
70
+            {
66 71
                 /**
67 72
                  * TODO issue #767
68 73
                  * @link https://github.com/spiral/framework/issues/767
@@ -72,11 +77,14 @@  discard block
 block discarded – undo
72 77
             }
73 78
 
74 79
             $path = 'undefined';
75
-            try {
80
+            try
81
+            {
76 82
                 $path = $this->getPath($extends);
77 83
 
78 84
                 return $this->merger->merge($this->builder->load($path), $extends);
79
-            } catch (\Throwable $e) {
85
+            }
86
+            catch (\Throwable $e)
87
+            {
80 88
                 throw new ExtendsException(
81 89
                     \sprintf('Unable to extend parent `%s`', $path),
82 90
                     $extends->getContext(),
@@ -90,14 +98,17 @@  discard block
 block discarded – undo
90 98
 
91 99
     private function getPath(Tag $tag): string
92 100
     {
93
-        if (\str_starts_with($tag->name, $this->extendsKeyword . ':')) {
101
+        if (\str_starts_with($tag->name, $this->extendsKeyword . ':'))
102
+        {
94 103
             $name = \substr($tag->name, \strlen($this->extendsKeyword) + 1);
95 104
 
96 105
             return \str_replace(['.'], DIRECTORY_SEPARATOR, $name);
97 106
         }
98 107
 
99
-        foreach ($tag->attrs as $attr) {
100
-            if ($attr->name === 'path' && \is_string($attr->value)) {
108
+        foreach ($tag->attrs as $attr)
109
+        {
110
+            if ($attr->name === 'path' && \is_string($attr->value))
111
+            {
101 112
                 return \trim($attr->value, '\'"');
102 113
             }
103 114
         }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Merge/Inject/PHPMixin.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     public function __construct(
15 15
         private readonly array $tokens,
16 16
         string $func
17
-    ) {
17
+    ){
18 18
         $this->parse($func);
19 19
     }
20 20
 
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
     {
23 23
         $replace = [];
24 24
 
25
-        foreach ($this->blocks as $block) {
26
-            for ($i = $block['start']; $i <= $block['end']; $i++) {
25
+        foreach ($this->blocks as $block){
26
+            for ($i = $block['start']; $i <= $block['end']; $i++){
27 27
                 $replace[$i] = '';
28 28
             }
29 29
 
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
         }
32 32
 
33 33
         $result = '';
34
-        foreach ($this->tokens as $position => $token) {
35
-            if (\array_key_exists($position, $replace)) {
34
+        foreach ($this->tokens as $position => $token){
35
+            if (\array_key_exists($position, $replace)){
36 36
                 $result .= $replace[$position];
37 37
                 continue;
38 38
             }
39 39
 
40
-            if (\is_string($token)) {
40
+            if (\is_string($token)){
41 41
                 $result .= $token;
42 42
                 continue;
43 43
             }
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
     {
56 56
         $replace = [];
57 57
 
58
-        foreach ($this->blocks as $block) {
59
-            for ($i = $block['start']; $i <= $block['end']; ++$i) {
58
+        foreach ($this->blocks as $block){
59
+            for ($i = $block['start']; $i <= $block['end']; ++$i){
60 60
                 $replace[$i] = '';
61 61
             }
62 62
 
@@ -64,18 +64,18 @@  discard block
 block discarded – undo
64 64
         }
65 65
 
66 66
         $result = '';
67
-        foreach ($this->tokens as $position => $token) {
68
-            if (\array_key_exists($position, $replace)) {
67
+        foreach ($this->tokens as $position => $token){
68
+            if (\array_key_exists($position, $replace)){
69 69
                 $result .= $replace[$position];
70 70
                 continue;
71 71
             }
72 72
 
73
-            if (\is_string($token)) {
73
+            if (\is_string($token)){
74 74
                 $result .= $token;
75 75
                 continue;
76 76
             }
77 77
 
78
-            if (\in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO])) {
78
+            if (\in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO])){
79 79
                 continue;
80 80
             }
81 81
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     public function getBlocks(): array
92 92
     {
93 93
         $result = [];
94
-        foreach ($this->blocks as $name => $macro) {
94
+        foreach ($this->blocks as $name => $macro){
95 95
             $result[$name] = $macro['value'];
96 96
         }
97 97
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
     public function set(string $block, string $value): void
107 107
     {
108
-        if (!isset($this->blocks[$block])) {
108
+        if (!isset($this->blocks[$block])){
109 109
             return;
110 110
         }
111 111
 
@@ -116,26 +116,26 @@  discard block
 block discarded – undo
116 116
     {
117 117
         $level = 0;
118 118
         $start = $name = $value = null;
119
-        foreach ($this->tokens as $position => $token) {
120
-            if (!\is_array($token)) {
119
+        foreach ($this->tokens as $position => $token){
120
+            if (!\is_array($token)){
121 121
                 $token = [$token, $token, 0];
122 122
             }
123 123
 
124
-            switch ($token[0]) {
124
+            switch ($token[0]){
125 125
                 case '(':
126
-                    if ($start !== null) {
126
+                    if ($start !== null){
127 127
                         $level++;
128 128
                         $value .= $token[1];
129 129
                     }
130 130
                     break;
131 131
                 case ')':
132
-                    if ($start === null) {
132
+                    if ($start === null){
133 133
                         break;
134 134
                     }
135 135
 
136 136
                     $level--;
137 137
                     $value .= $token[1];
138
-                    if ($level === 0) {
138
+                    if ($level === 0){
139 139
                         $this->blocks[$name] = [
140 140
                             'start' => $start,
141 141
                             'value' => trim($value),
@@ -147,22 +147,22 @@  discard block
 block discarded – undo
147 147
                     }
148 148
                     break;
149 149
                 case T_STRING:
150
-                    if ($token[1] === $func) {
150
+                    if ($token[1] === $func){
151 151
                         $start = $position;
152 152
                         $value = $token[1];
153 153
                         break;
154 154
                     }
155 155
 
156
-                    if ($start !== null) {
156
+                    if ($start !== null){
157 157
                         $value .= $token[1];
158 158
                     }
159 159
                     break;
160 160
                 case T_CONSTANT_ENCAPSED_STRING:
161
-                    if ($start === null) {
161
+                    if ($start === null){
162 162
                         break;
163 163
                     }
164 164
 
165
-                    if ($name === null) {
165
+                    if ($name === null){
166 166
                         $name = \stripcslashes(\substr($token[1], 1, -1));
167 167
                     }
168 168
                     $value .= $token[1];
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
                     $value .= $token[1];
172 172
                     break;
173 173
                 default:
174
-                    if ($start !== null) {
174
+                    if ($start !== null){
175 175
                         $value .= $token[1];
176 176
                     }
177 177
             }
Please login to merge, or discard this patch.
Braces   +48 added lines, -24 removed lines patch added patch discarded remove patch
@@ -22,8 +22,10 @@  discard block
 block discarded – undo
22 22
     {
23 23
         $replace = [];
24 24
 
25
-        foreach ($this->blocks as $block) {
26
-            for ($i = $block['start']; $i <= $block['end']; $i++) {
25
+        foreach ($this->blocks as $block)
26
+        {
27
+            for ($i = $block['start']; $i <= $block['end']; $i++)
28
+            {
27 29
                 $replace[$i] = '';
28 30
             }
29 31
 
@@ -31,13 +33,16 @@  discard block
 block discarded – undo
31 33
         }
32 34
 
33 35
         $result = '';
34
-        foreach ($this->tokens as $position => $token) {
35
-            if (\array_key_exists($position, $replace)) {
36
+        foreach ($this->tokens as $position => $token)
37
+        {
38
+            if (\array_key_exists($position, $replace))
39
+            {
36 40
                 $result .= $replace[$position];
37 41
                 continue;
38 42
             }
39 43
 
40
-            if (\is_string($token)) {
44
+            if (\is_string($token))
45
+            {
41 46
                 $result .= $token;
42 47
                 continue;
43 48
             }
@@ -55,8 +60,10 @@  discard block
 block discarded – undo
55 60
     {
56 61
         $replace = [];
57 62
 
58
-        foreach ($this->blocks as $block) {
59
-            for ($i = $block['start']; $i <= $block['end']; ++$i) {
63
+        foreach ($this->blocks as $block)
64
+        {
65
+            for ($i = $block['start']; $i <= $block['end']; ++$i)
66
+            {
60 67
                 $replace[$i] = '';
61 68
             }
62 69
 
@@ -64,18 +71,22 @@  discard block
 block discarded – undo
64 71
         }
65 72
 
66 73
         $result = '';
67
-        foreach ($this->tokens as $position => $token) {
68
-            if (\array_key_exists($position, $replace)) {
74
+        foreach ($this->tokens as $position => $token)
75
+        {
76
+            if (\array_key_exists($position, $replace))
77
+            {
69 78
                 $result .= $replace[$position];
70 79
                 continue;
71 80
             }
72 81
 
73
-            if (\is_string($token)) {
82
+            if (\is_string($token))
83
+            {
74 84
                 $result .= $token;
75 85
                 continue;
76 86
             }
77 87
 
78
-            if (\in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO])) {
88
+            if (\in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO]))
89
+            {
79 90
                 continue;
80 91
             }
81 92
 
@@ -91,7 +102,8 @@  discard block
 block discarded – undo
91 102
     public function getBlocks(): array
92 103
     {
93 104
         $result = [];
94
-        foreach ($this->blocks as $name => $macro) {
105
+        foreach ($this->blocks as $name => $macro)
106
+        {
95 107
             $result[$name] = $macro['value'];
96 108
         }
97 109
 
@@ -105,7 +117,8 @@  discard block
 block discarded – undo
105 117
 
106 118
     public function set(string $block, string $value): void
107 119
     {
108
-        if (!isset($this->blocks[$block])) {
120
+        if (!isset($this->blocks[$block]))
121
+        {
109 122
             return;
110 123
         }
111 124
 
@@ -116,26 +129,32 @@  discard block
 block discarded – undo
116 129
     {
117 130
         $level = 0;
118 131
         $start = $name = $value = null;
119
-        foreach ($this->tokens as $position => $token) {
120
-            if (!\is_array($token)) {
132
+        foreach ($this->tokens as $position => $token)
133
+        {
134
+            if (!\is_array($token))
135
+            {
121 136
                 $token = [$token, $token, 0];
122 137
             }
123 138
 
124
-            switch ($token[0]) {
139
+            switch ($token[0])
140
+            {
125 141
                 case '(':
126
-                    if ($start !== null) {
142
+                    if ($start !== null)
143
+                    {
127 144
                         $level++;
128 145
                         $value .= $token[1];
129 146
                     }
130 147
                     break;
131 148
                 case ')':
132
-                    if ($start === null) {
149
+                    if ($start === null)
150
+                    {
133 151
                         break;
134 152
                     }
135 153
 
136 154
                     $level--;
137 155
                     $value .= $token[1];
138
-                    if ($level === 0) {
156
+                    if ($level === 0)
157
+                    {
139 158
                         $this->blocks[$name] = [
140 159
                             'start' => $start,
141 160
                             'value' => trim($value),
@@ -147,22 +166,26 @@  discard block
 block discarded – undo
147 166
                     }
148 167
                     break;
149 168
                 case T_STRING:
150
-                    if ($token[1] === $func) {
169
+                    if ($token[1] === $func)
170
+                    {
151 171
                         $start = $position;
152 172
                         $value = $token[1];
153 173
                         break;
154 174
                     }
155 175
 
156
-                    if ($start !== null) {
176
+                    if ($start !== null)
177
+                    {
157 178
                         $value .= $token[1];
158 179
                     }
159 180
                     break;
160 181
                 case T_CONSTANT_ENCAPSED_STRING:
161
-                    if ($start === null) {
182
+                    if ($start === null)
183
+                    {
162 184
                         break;
163 185
                     }
164 186
 
165
-                    if ($name === null) {
187
+                    if ($name === null)
188
+                    {
166 189
                         $name = \stripcslashes(\substr($token[1], 1, -1));
167 190
                     }
168 191
                     $value .= $token[1];
@@ -171,7 +194,8 @@  discard block
 block discarded – undo
171 194
                     $value .= $token[1];
172 195
                     break;
173 196
                 default:
174
-                    if ($start !== null) {
197
+                    if ($start !== null)
198
+                    {
175 199
                         $value .= $token[1];
176 200
                     }
177 201
             }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Merge/Inject/InjectAttributes.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,24 +22,24 @@  discard block
 block discarded – undo
22 22
 {
23 23
     public function __construct(
24 24
         private readonly BlockClaims $blocks
25
-    ) {
25
+    ){
26 26
     }
27 27
 
28 28
     public function enterNode(mixed $node, VisitorContext $ctx): mixed
29 29
     {
30
-        if (!$node instanceof Aggregate) {
30
+        if (!$node instanceof Aggregate){
31 31
             return null;
32 32
         }
33 33
 
34
-        foreach ($this->blocks->getUnclaimed() as $name) {
34
+        foreach ($this->blocks->getUnclaimed() as $name){
35 35
             $alias = $node->accepts($name);
36
-            if ($alias === null) {
36
+            if ($alias === null){
37 37
                 continue;
38 38
             }
39 39
 
40 40
             $value = $this->blocks->claim($name);
41 41
 
42
-            if ($value instanceof QuotedValue) {
42
+            if ($value instanceof QuotedValue){
43 43
                 /**
44 44
                  * TODO issue #767
45 45
                  * @link https://github.com/spiral/framework/issues/767
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
             }
51 51
 
52 52
             // simple copy attribute copy
53
-            if ($value instanceof Attr) {
53
+            if ($value instanceof Attr){
54 54
                 /**
55 55
                  * TODO issue #767
56 56
                  * @link https://github.com/spiral/framework/issues/767
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,19 +27,23 @@  discard block
 block discarded – undo
27 27
 
28 28
     public function enterNode(mixed $node, VisitorContext $ctx): mixed
29 29
     {
30
-        if (!$node instanceof Aggregate) {
30
+        if (!$node instanceof Aggregate)
31
+        {
31 32
             return null;
32 33
         }
33 34
 
34
-        foreach ($this->blocks->getUnclaimed() as $name) {
35
+        foreach ($this->blocks->getUnclaimed() as $name)
36
+        {
35 37
             $alias = $node->accepts($name);
36
-            if ($alias === null) {
38
+            if ($alias === null)
39
+            {
37 40
                 continue;
38 41
             }
39 42
 
40 43
             $value = $this->blocks->claim($name);
41 44
 
42
-            if ($value instanceof QuotedValue) {
45
+            if ($value instanceof QuotedValue)
46
+            {
43 47
                 /**
44 48
                  * TODO issue #767
45 49
                  * @link https://github.com/spiral/framework/issues/767
@@ -50,7 +54,8 @@  discard block
 block discarded – undo
50 54
             }
51 55
 
52 56
             // simple copy attribute copy
53
-            if ($value instanceof Attr) {
57
+            if ($value instanceof Attr)
58
+            {
54 59
                 /**
55 60
                  * TODO issue #767
56 61
                  * @link https://github.com/spiral/framework/issues/767
Please login to merge, or discard this patch.