Passed
Pull Request — master (#592)
by Aleksei
06:09
created
src/Stempler/src/Compiler/Renderer/HTMLRenderer.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public function render(Compiler $compiler, Compiler\Result $result, NodeInterface $node): bool
29 29
     {
30
-        switch (true) {
30
+        switch (true){
31 31
             case $node instanceof Tag:
32 32
                 $this->tag($compiler, $result, $node);
33 33
                 return true;
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $result->push(sprintf('<%s', $node->name), $node->getContext());
51 51
 
52
-        foreach ($node->attrs as $attr) {
53
-            if (!$attr instanceof Attribute) {
52
+        foreach ($node->attrs as $attr){
53
+            if (!$attr instanceof Attribute){
54 54
                 $compiler->compile($attr, $result);
55 55
                 continue;
56 56
             }
@@ -60,30 +60,30 @@  discard block
 block discarded – undo
60 60
 
61 61
         $result->push(sprintf('%s>', $node->void ? '/' : ''), null);
62 62
 
63
-        foreach ($node->nodes as $child) {
63
+        foreach ($node->nodes as $child){
64 64
             $compiler->compile($child, $result);
65 65
         }
66 66
 
67
-        if (!$node->void) {
67
+        if (!$node->void){
68 68
             $result->push(sprintf('</%s>', $node->name), null);
69 69
         }
70 70
     }
71 71
 
72 72
     private function attribute(Compiler $compiler, Compiler\Result $result, Attr $node): void
73 73
     {
74
-        if ($node->name instanceof NodeInterface) {
74
+        if ($node->name instanceof NodeInterface){
75 75
             $result->push(' ', null);
76 76
             $compiler->compile($node->name, $result);
77
-        } else {
77
+        }else{
78 78
             $result->push(sprintf(' %s', $node->name), $node->getContext());
79 79
         }
80 80
 
81 81
         $value = $node->value;
82
-        if ($value instanceof Nil) {
82
+        if ($value instanceof Nil){
83 83
             return;
84 84
         }
85 85
 
86
-        if ($value instanceof NodeInterface) {
86
+        if ($value instanceof NodeInterface){
87 87
             $result->push('=', null);
88 88
             $compiler->compile($value, $result);
89 89
             return;
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 
95 95
     private function verbatim(Compiler $compiler, Compiler\Result $result, Verbatim $node): void
96 96
     {
97
-        foreach ($node->nodes as $child) {
98
-            if (is_string($child)) {
97
+        foreach ($node->nodes as $child){
98
+            if (is_string($child)){
99 99
                 $result->push($child, null);
100 100
                 continue;
101 101
             }
Please login to merge, or discard this patch.
Braces   +23 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,7 +27,8 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public function render(Compiler $compiler, Compiler\Result $result, NodeInterface $node): bool
29 29
     {
30
-        switch (true) {
30
+        switch (true)
31
+        {
31 32
             case $node instanceof Tag:
32 33
                 $this->tag($compiler, $result, $node);
33 34
                 return true;
@@ -49,8 +50,10 @@  discard block
 block discarded – undo
49 50
     {
50 51
         $result->push(sprintf('<%s', $node->name), $node->getContext());
51 52
 
52
-        foreach ($node->attrs as $attr) {
53
-            if (!$attr instanceof Attribute) {
53
+        foreach ($node->attrs as $attr)
54
+        {
55
+            if (!$attr instanceof Attribute)
56
+            {
54 57
                 $compiler->compile($attr, $result);
55 58
                 continue;
56 59
             }
@@ -60,30 +63,37 @@  discard block
 block discarded – undo
60 63
 
61 64
         $result->push(sprintf('%s>', $node->void ? '/' : ''), null);
62 65
 
63
-        foreach ($node->nodes as $child) {
66
+        foreach ($node->nodes as $child)
67
+        {
64 68
             $compiler->compile($child, $result);
65 69
         }
66 70
 
67
-        if (!$node->void) {
71
+        if (!$node->void)
72
+        {
68 73
             $result->push(sprintf('</%s>', $node->name), null);
69 74
         }
70 75
     }
71 76
 
72 77
     private function attribute(Compiler $compiler, Compiler\Result $result, Attr $node): void
73 78
     {
74
-        if ($node->name instanceof NodeInterface) {
79
+        if ($node->name instanceof NodeInterface)
80
+        {
75 81
             $result->push(' ', null);
76 82
             $compiler->compile($node->name, $result);
77
-        } else {
83
+        }
84
+        else
85
+        {
78 86
             $result->push(sprintf(' %s', $node->name), $node->getContext());
79 87
         }
80 88
 
81 89
         $value = $node->value;
82
-        if ($value instanceof Nil) {
90
+        if ($value instanceof Nil)
91
+        {
83 92
             return;
84 93
         }
85 94
 
86
-        if ($value instanceof NodeInterface) {
95
+        if ($value instanceof NodeInterface)
96
+        {
87 97
             $result->push('=', null);
88 98
             $compiler->compile($value, $result);
89 99
             return;
@@ -94,8 +104,10 @@  discard block
 block discarded – undo
94 104
 
95 105
     private function verbatim(Compiler $compiler, Compiler\Result $result, Verbatim $node): void
96 106
     {
97
-        foreach ($node->nodes as $child) {
98
-            if (is_string($child)) {
107
+        foreach ($node->nodes as $child)
108
+        {
109
+            if (is_string($child))
110
+            {
99 111
                 $result->push($child, null);
100 112
                 continue;
101 113
             }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Finalizer/StackCollector.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function leaveNode($node, VisitorContext $ctx)
42 42
     {
43
-        if ($node instanceof Tag && strpos($node->name, $this->pushKeyword) === 0) {
43
+        if ($node instanceof Tag && strpos($node->name, $this->pushKeyword) === 0){
44 44
             return $this->registerPush(StackContext::on($ctx), $node);
45 45
         }
46 46
 
47
-        if ($node instanceof Tag && strpos($node->name, $this->prependKeyword) === 0) {
47
+        if ($node instanceof Tag && strpos($node->name, $this->prependKeyword) === 0){
48 48
             return $this->registerPrepend(StackContext::on($ctx), $node);
49 49
         }
50 50
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     {
59 59
         $name = $this->stackName($node);
60 60
 
61
-        if ($name === null || !$ctx->push($name, $node, $this->uniqueID($node))) {
61
+        if ($name === null || !$ctx->push($name, $node, $this->uniqueID($node))){
62 62
             return null;
63 63
         }
64 64
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     {
73 73
         $name = $this->stackName($node);
74 74
 
75
-        if ($name === null || !$ctx->prepend($name, $node, $this->uniqueID($node))) {
75
+        if ($name === null || !$ctx->prepend($name, $node, $this->uniqueID($node))){
76 76
             return null;
77 77
         }
78 78
 
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 
82 82
     private function stackName(Tag $tag): ?string
83 83
     {
84
-        foreach ($tag->attrs as $attr) {
85
-            if (is_string($attr->value) && $attr->name === 'name') {
84
+        foreach ($tag->attrs as $attr){
85
+            if (is_string($attr->value) && $attr->name === 'name'){
86 86
                 return trim($attr->value, '\'"');
87 87
             }
88 88
         }
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 
93 93
     private function uniqueID(Tag $tag): ?string
94 94
     {
95
-        foreach ($tag->attrs as $attr) {
96
-            if (is_string($attr->value) && $attr->name === 'unique-id') {
95
+        foreach ($tag->attrs as $attr){
96
+            if (is_string($attr->value) && $attr->name === 'unique-id'){
97 97
                 return trim($attr->value, '\'"');
98 98
             }
99 99
         }
Please login to merge, or discard this patch.
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,11 +40,13 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function leaveNode($node, VisitorContext $ctx)
42 42
     {
43
-        if ($node instanceof Tag && strpos($node->name, $this->pushKeyword) === 0) {
43
+        if ($node instanceof Tag && strpos($node->name, $this->pushKeyword) === 0)
44
+        {
44 45
             return $this->registerPush(StackContext::on($ctx), $node);
45 46
         }
46 47
 
47
-        if ($node instanceof Tag && strpos($node->name, $this->prependKeyword) === 0) {
48
+        if ($node instanceof Tag && strpos($node->name, $this->prependKeyword) === 0)
49
+        {
48 50
             return $this->registerPrepend(StackContext::on($ctx), $node);
49 51
         }
50 52
 
@@ -58,7 +60,8 @@  discard block
 block discarded – undo
58 60
     {
59 61
         $name = $this->stackName($node);
60 62
 
61
-        if ($name === null || !$ctx->push($name, $node, $this->uniqueID($node))) {
63
+        if ($name === null || !$ctx->push($name, $node, $this->uniqueID($node)))
64
+        {
62 65
             return null;
63 66
         }
64 67
 
@@ -72,7 +75,8 @@  discard block
 block discarded – undo
72 75
     {
73 76
         $name = $this->stackName($node);
74 77
 
75
-        if ($name === null || !$ctx->prepend($name, $node, $this->uniqueID($node))) {
78
+        if ($name === null || !$ctx->prepend($name, $node, $this->uniqueID($node)))
79
+        {
76 80
             return null;
77 81
         }
78 82
 
@@ -81,8 +85,10 @@  discard block
 block discarded – undo
81 85
 
82 86
     private function stackName(Tag $tag): ?string
83 87
     {
84
-        foreach ($tag->attrs as $attr) {
85
-            if (is_string($attr->value) && $attr->name === 'name') {
88
+        foreach ($tag->attrs as $attr)
89
+        {
90
+            if (is_string($attr->value) && $attr->name === 'name')
91
+            {
86 92
                 return trim($attr->value, '\'"');
87 93
             }
88 94
         }
@@ -92,8 +98,10 @@  discard block
 block discarded – undo
92 98
 
93 99
     private function uniqueID(Tag $tag): ?string
94 100
     {
95
-        foreach ($tag->attrs as $attr) {
96
-            if (is_string($attr->value) && $attr->name === 'unique-id') {
101
+        foreach ($tag->attrs as $attr)
102
+        {
103
+            if (is_string($attr->value) && $attr->name === 'unique-id')
104
+            {
97 105
                 return trim($attr->value, '\'"');
98 106
             }
99 107
         }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Finalizer/DynamicToPHP.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function leaveNode($node, VisitorContext $ctx)
74 74
     {
75
-        if ($node instanceof Output) {
75
+        if ($node instanceof Output){
76 76
             return $this->output($node, $ctx);
77 77
         }
78 78
 
79
-        if ($node instanceof Directive) {
79
+        if ($node instanceof Directive){
80 80
             return $this->directive($node);
81 81
         }
82 82
 
83
-        if ($node instanceof Template) {
83
+        if ($node instanceof Template){
84 84
             $extendsTag = $node->getAttribute(ExtendsParent::class);
85
-            if ($extendsTag instanceof Tag) {
85
+            if ($extendsTag instanceof Tag){
86 86
                 $extendsTag->attrs = $this->traverser->traverse($extendsTag->attrs);
87 87
             }
88 88
         }
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
 
93 93
     private function directive(Directive $node): PHP
94 94
     {
95
-        foreach ($this->directives as $renderer) {
95
+        foreach ($this->directives as $renderer){
96 96
             $result = $renderer->render($node);
97
-            if ($result !== null) {
97
+            if ($result !== null){
98 98
                 return new PHP($result, token_get_all($result), $node->getContext());
99 99
             }
100 100
         }
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
          * In future this method can support context aware escaping based on tag location.
112 112
          */
113 113
 
114
-        if ($node->rawOutput) {
114
+        if ($node->rawOutput){
115 115
             $result = sprintf('<?php echo %s; ?>', trim($node->body));
116
-        } else {
116
+        }else{
117 117
             $filter = $node->filter ?? $this->getFilterContext($ctx);
118 118
 
119 119
             $result = sprintf("<?php echo {$filter}; ?>", trim($node->body));
@@ -131,22 +131,22 @@  discard block
 block discarded – undo
131 131
         // only "interesting" nodes
132 132
         $context = [];
133 133
 
134
-        foreach (array_reverse($ctx->getScope()) as $node) {
135
-            if ($node instanceof Attr || $node instanceof Tag || $node instanceof Verbatim) {
134
+        foreach (array_reverse($ctx->getScope()) as $node){
135
+            if ($node instanceof Attr || $node instanceof Tag || $node instanceof Verbatim){
136 136
                 $context[] = $node;
137 137
             }
138 138
 
139
-            if (count($context) === 2) {
139
+            if (count($context) === 2){
140 140
                 break;
141 141
             }
142 142
         }
143 143
 
144
-        if (count($context) !== 2) {
144
+        if (count($context) !== 2){
145 145
             return $this->defaultFilter;
146 146
         }
147 147
 
148 148
         // php {{ }} in javascript code (variable passing), use {! !} to bypass the filter
149
-        if ($context[0] instanceof Verbatim && $context[1] instanceof Tag && $context[1]->name === 'script') {
149
+        if ($context[0] instanceof Verbatim && $context[1] instanceof Tag && $context[1]->name === 'script'){
150 150
             return sprintf(
151 151
                 'json_encode(%s, %s, %s)',
152 152
                 '%s',
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         }
157 157
 
158 158
         // in on* and other attributes
159
-        if ($context[0] instanceof Verbatim && $context[1] instanceof Attr && $context[1]->name !== 'style') {
159
+        if ($context[0] instanceof Verbatim && $context[1] instanceof Attr && $context[1]->name !== 'style'){
160 160
             return sprintf("'%s', %s, '%s'", '&quot;', $this->defaultFilter, '&quot;');
161 161
         }
162 162
 
Please login to merge, or discard this patch.
Braces   +29 added lines, -14 removed lines patch added patch discarded remove patch
@@ -72,17 +72,21 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function leaveNode($node, VisitorContext $ctx)
74 74
     {
75
-        if ($node instanceof Output) {
75
+        if ($node instanceof Output)
76
+        {
76 77
             return $this->output($node, $ctx);
77 78
         }
78 79
 
79
-        if ($node instanceof Directive) {
80
+        if ($node instanceof Directive)
81
+        {
80 82
             return $this->directive($node);
81 83
         }
82 84
 
83
-        if ($node instanceof Template) {
85
+        if ($node instanceof Template)
86
+        {
84 87
             $extendsTag = $node->getAttribute(ExtendsParent::class);
85
-            if ($extendsTag instanceof Tag) {
88
+            if ($extendsTag instanceof Tag)
89
+            {
86 90
                 $extendsTag->attrs = $this->traverser->traverse($extendsTag->attrs);
87 91
             }
88 92
         }
@@ -92,9 +96,11 @@  discard block
 block discarded – undo
92 96
 
93 97
     private function directive(Directive $node): PHP
94 98
     {
95
-        foreach ($this->directives as $renderer) {
99
+        foreach ($this->directives as $renderer)
100
+        {
96 101
             $result = $renderer->render($node);
97
-            if ($result !== null) {
102
+            if ($result !== null)
103
+            {
98 104
                 return new PHP($result, token_get_all($result), $node->getContext());
99 105
             }
100 106
         }
@@ -111,9 +117,12 @@  discard block
 block discarded – undo
111 117
          * In future this method can support context aware escaping based on tag location.
112 118
          */
113 119
 
114
-        if ($node->rawOutput) {
120
+        if ($node->rawOutput)
121
+        {
115 122
             $result = sprintf('<?php echo %s; ?>', trim($node->body));
116
-        } else {
123
+        }
124
+        else
125
+        {
117 126
             $filter = $node->filter ?? $this->getFilterContext($ctx);
118 127
 
119 128
             $result = sprintf("<?php echo {$filter}; ?>", trim($node->body));
@@ -131,22 +140,27 @@  discard block
 block discarded – undo
131 140
         // only "interesting" nodes
132 141
         $context = [];
133 142
 
134
-        foreach (array_reverse($ctx->getScope()) as $node) {
135
-            if ($node instanceof Attr || $node instanceof Tag || $node instanceof Verbatim) {
143
+        foreach (array_reverse($ctx->getScope()) as $node)
144
+        {
145
+            if ($node instanceof Attr || $node instanceof Tag || $node instanceof Verbatim)
146
+            {
136 147
                 $context[] = $node;
137 148
             }
138 149
 
139
-            if (count($context) === 2) {
150
+            if (count($context) === 2)
151
+            {
140 152
                 break;
141 153
             }
142 154
         }
143 155
 
144
-        if (count($context) !== 2) {
156
+        if (count($context) !== 2)
157
+        {
145 158
             return $this->defaultFilter;
146 159
         }
147 160
 
148 161
         // php {{ }} in javascript code (variable passing), use {! !} to bypass the filter
149
-        if ($context[0] instanceof Verbatim && $context[1] instanceof Tag && $context[1]->name === 'script') {
162
+        if ($context[0] instanceof Verbatim && $context[1] instanceof Tag && $context[1]->name === 'script')
163
+        {
150 164
             return sprintf(
151 165
                 'json_encode(%s, %s, %s)',
152 166
                 '%s',
@@ -156,7 +170,8 @@  discard block
 block discarded – undo
156 170
         }
157 171
 
158 172
         // in on* and other attributes
159
-        if ($context[0] instanceof Verbatim && $context[1] instanceof Attr && $context[1]->name !== 'style') {
173
+        if ($context[0] instanceof Verbatim && $context[1] instanceof Attr && $context[1]->name !== 'style')
174
+        {
160 175
             return sprintf("'%s', %s, '%s'", '&quot;', $this->defaultFilter, '&quot;');
161 176
         }
162 177
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Context/ImportContext.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     public function add(ImportInterface $import): void
35 35
     {
36 36
         $node = $this->ctx->getParentNode();
37
-        if (!$node instanceof AttributedInterface) {
37
+        if (!$node instanceof AttributedInterface){
38 38
             throw new LogicException(\sprintf(
39 39
                 'Unable to create import on node without attribute storage (%s)',
40 40
                 \is_object($node) ? \get_class($node) : \gettype($node)
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function resolve(Builder $builder, string $name): ?Template
53 53
     {
54
-        foreach ($this->getImports() as $import) {
54
+        foreach ($this->getImports() as $import){
55 55
             $tpl = $import->resolve($builder, $name);
56
-            if ($tpl !== null) {
56
+            if ($tpl !== null){
57 57
                 return $tpl;
58 58
             }
59 59
         }
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
     public function getImports(): array
70 70
     {
71 71
         $imports = [];
72
-        foreach (array_reverse($this->ctx->getScope()) as $node) {
73
-            if ($node instanceof AttributedInterface) {
74
-                foreach ($node->getAttribute(self::class, []) as $import) {
72
+        foreach (array_reverse($this->ctx->getScope()) as $node){
73
+            if ($node instanceof AttributedInterface){
74
+                foreach ($node->getAttribute(self::class, []) as $import){
75 75
                     $imports[] = $import;
76 76
                 }
77 77
             }
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,7 +34,8 @@  discard block
 block discarded – undo
34 34
     public function add(ImportInterface $import): void
35 35
     {
36 36
         $node = $this->ctx->getParentNode();
37
-        if (!$node instanceof AttributedInterface) {
37
+        if (!$node instanceof AttributedInterface)
38
+        {
38 39
             throw new LogicException(\sprintf(
39 40
                 'Unable to create import on node without attribute storage (%s)',
40 41
                 \is_object($node) ? \get_class($node) : \gettype($node)
@@ -51,9 +52,11 @@  discard block
 block discarded – undo
51 52
      */
52 53
     public function resolve(Builder $builder, string $name): ?Template
53 54
     {
54
-        foreach ($this->getImports() as $import) {
55
+        foreach ($this->getImports() as $import)
56
+        {
55 57
             $tpl = $import->resolve($builder, $name);
56
-            if ($tpl !== null) {
58
+            if ($tpl !== null)
59
+            {
57 60
                 return $tpl;
58 61
             }
59 62
         }
@@ -69,9 +72,12 @@  discard block
 block discarded – undo
69 72
     public function getImports(): array
70 73
     {
71 74
         $imports = [];
72
-        foreach (array_reverse($this->ctx->getScope()) as $node) {
73
-            if ($node instanceof AttributedInterface) {
74
-                foreach ($node->getAttribute(self::class, []) as $import) {
75
+        foreach (array_reverse($this->ctx->getScope()) as $node)
76
+        {
77
+            if ($node instanceof AttributedInterface)
78
+            {
79
+                foreach ($node->getAttribute(self::class, []) as $import)
80
+                {
75 81
                     $imports[] = $import;
76 82
                 }
77 83
             }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Context/StackContext.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -41,17 +41,17 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function push(string $name, Tag $child, string $uniqueID = null): bool
43 43
     {
44
-        foreach ($this->getStacks() as $stack) {
45
-            if ($stack->accepts($name) !== $name) {
44
+        foreach ($this->getStacks() as $stack){
45
+            if ($stack->accepts($name) !== $name){
46 46
                 continue;
47 47
             }
48 48
 
49
-            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID])) {
49
+            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID])){
50 50
                 return true;
51 51
             }
52 52
             $stack->uniqueIDs[$uniqueID] = true;
53 53
 
54
-            foreach ($child->nodes as $child) {
54
+            foreach ($child->nodes as $child){
55 55
                 $stack->nodes[] = $child;
56 56
             }
57 57
 
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function prepend(string $name, Tag $child, string $uniqueID = null): bool
68 68
     {
69
-        foreach ($this->getStacks() as $stack) {
70
-            if ($stack->accepts($name) !== $name) {
69
+        foreach ($this->getStacks() as $stack){
70
+            if ($stack->accepts($name) !== $name){
71 71
                 continue;
72 72
             }
73 73
 
74
-            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID])) {
74
+            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID])){
75 75
                 return true;
76 76
             }
77 77
             $stack->uniqueIDs[$uniqueID] = true;
78 78
 
79
-            foreach ($child->nodes as $child) {
79
+            foreach ($child->nodes as $child){
80 80
                 array_unshift($stack->nodes, $child);
81 81
             }
82 82
 
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
     public function getStacks(): array
95 95
     {
96 96
         $stacks = [];
97
-        foreach (array_reverse($this->ctx->getScope()) as $node) {
98
-            if ($node instanceof AttributedInterface) {
99
-                foreach ($node->getAttribute(self::class, []) as $stack) {
97
+        foreach (array_reverse($this->ctx->getScope()) as $node){
98
+            if ($node instanceof AttributedInterface){
99
+                foreach ($node->getAttribute(self::class, []) as $stack){
100 100
                     $stacks[] = $stack;
101 101
                 }
102 102
             }
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
 
113 113
     private function getStackRootNode(int $level): AttributedInterface
114 114
     {
115
-        if ($level === 0) {
115
+        if ($level === 0){
116 116
             $node = $this->ctx->getParentNode();
117
-        } else {
117
+        }else{
118 118
             $scope = $this->ctx->getScope();
119 119
 
120 120
             // looking for the parent node via given nesting level
121 121
             $node = $scope[count($scope) - 2 - $level] ?? $this->ctx->getFirstNode();
122 122
         }
123 123
 
124
-        if (!$node instanceof AttributedInterface) {
124
+        if (!$node instanceof AttributedInterface){
125 125
             throw new \LogicException(
126 126
                 sprintf(
127 127
                     'Unable to create import on node without attribute storage (%s)',
Please login to merge, or discard this patch.
Braces   +29 added lines, -14 removed lines patch added patch discarded remove patch
@@ -41,17 +41,21 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function push(string $name, Tag $child, string $uniqueID = null): bool
43 43
     {
44
-        foreach ($this->getStacks() as $stack) {
45
-            if ($stack->accepts($name) !== $name) {
44
+        foreach ($this->getStacks() as $stack)
45
+        {
46
+            if ($stack->accepts($name) !== $name)
47
+            {
46 48
                 continue;
47 49
             }
48 50
 
49
-            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID])) {
51
+            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID]))
52
+            {
50 53
                 return true;
51 54
             }
52 55
             $stack->uniqueIDs[$uniqueID] = true;
53 56
 
54
-            foreach ($child->nodes as $child) {
57
+            foreach ($child->nodes as $child)
58
+            {
55 59
                 $stack->nodes[] = $child;
56 60
             }
57 61
 
@@ -66,17 +70,21 @@  discard block
 block discarded – undo
66 70
      */
67 71
     public function prepend(string $name, Tag $child, string $uniqueID = null): bool
68 72
     {
69
-        foreach ($this->getStacks() as $stack) {
70
-            if ($stack->accepts($name) !== $name) {
73
+        foreach ($this->getStacks() as $stack)
74
+        {
75
+            if ($stack->accepts($name) !== $name)
76
+            {
71 77
                 continue;
72 78
             }
73 79
 
74
-            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID])) {
80
+            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID]))
81
+            {
75 82
                 return true;
76 83
             }
77 84
             $stack->uniqueIDs[$uniqueID] = true;
78 85
 
79
-            foreach ($child->nodes as $child) {
86
+            foreach ($child->nodes as $child)
87
+            {
80 88
                 array_unshift($stack->nodes, $child);
81 89
             }
82 90
 
@@ -94,9 +102,12 @@  discard block
 block discarded – undo
94 102
     public function getStacks(): array
95 103
     {
96 104
         $stacks = [];
97
-        foreach (array_reverse($this->ctx->getScope()) as $node) {
98
-            if ($node instanceof AttributedInterface) {
99
-                foreach ($node->getAttribute(self::class, []) as $stack) {
105
+        foreach (array_reverse($this->ctx->getScope()) as $node)
106
+        {
107
+            if ($node instanceof AttributedInterface)
108
+            {
109
+                foreach ($node->getAttribute(self::class, []) as $stack)
110
+                {
100 111
                     $stacks[] = $stack;
101 112
                 }
102 113
             }
@@ -112,16 +123,20 @@  discard block
 block discarded – undo
112 123
 
113 124
     private function getStackRootNode(int $level): AttributedInterface
114 125
     {
115
-        if ($level === 0) {
126
+        if ($level === 0)
127
+        {
116 128
             $node = $this->ctx->getParentNode();
117
-        } else {
129
+        }
130
+        else
131
+        {
118 132
             $scope = $this->ctx->getScope();
119 133
 
120 134
             // looking for the parent node via given nesting level
121 135
             $node = $scope[count($scope) - 2 - $level] ?? $this->ctx->getFirstNode();
122 136
         }
123 137
 
124
-        if (!$node instanceof AttributedInterface) {
138
+        if (!$node instanceof AttributedInterface)
139
+        {
125 140
             throw new \LogicException(
126 141
                 sprintf(
127 142
                     'Unable to create import on node without attribute storage (%s)',
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Merge/Inject/PHPMixin.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
     {
33 33
         $replace = [];
34 34
 
35
-        foreach ($this->blocks as $block) {
36
-            for ($i = $block['start']; $i <= $block['end']; $i++) {
35
+        foreach ($this->blocks as $block){
36
+            for ($i = $block['start']; $i <= $block['end']; $i++){
37 37
                 $replace[$i] = '';
38 38
             }
39 39
 
@@ -41,13 +41,13 @@  discard block
 block discarded – undo
41 41
         }
42 42
 
43 43
         $result = '';
44
-        foreach ($this->tokens as $position => $token) {
45
-            if (array_key_exists($position, $replace)) {
44
+        foreach ($this->tokens as $position => $token){
45
+            if (array_key_exists($position, $replace)){
46 46
                 $result .= $replace[$position];
47 47
                 continue;
48 48
             }
49 49
 
50
-            if (is_string($token)) {
50
+            if (is_string($token)){
51 51
                 $result .= $token;
52 52
                 continue;
53 53
             }
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
     {
66 66
         $replace = [];
67 67
 
68
-        foreach ($this->blocks as $block) {
69
-            for ($i = $block['start']; $i <= $block['end']; $i++) {
68
+        foreach ($this->blocks as $block){
69
+            for ($i = $block['start']; $i <= $block['end']; $i++){
70 70
                 $replace[$i] = '';
71 71
             }
72 72
 
@@ -74,18 +74,18 @@  discard block
 block discarded – undo
74 74
         }
75 75
 
76 76
         $result = '';
77
-        foreach ($this->tokens as $position => $token) {
78
-            if (array_key_exists($position, $replace)) {
77
+        foreach ($this->tokens as $position => $token){
78
+            if (array_key_exists($position, $replace)){
79 79
                 $result .= $replace[$position];
80 80
                 continue;
81 81
             }
82 82
 
83
-            if (is_string($token)) {
83
+            if (is_string($token)){
84 84
                 $result .= $token;
85 85
                 continue;
86 86
             }
87 87
 
88
-            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 89
                 continue;
90 90
             }
91 91
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     public function getBlocks(): array
102 102
     {
103 103
         $result = [];
104
-        foreach ($this->blocks as $name => $macro) {
104
+        foreach ($this->blocks as $name => $macro){
105 105
             $result[$name] = $macro['value'];
106 106
         }
107 107
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
     public function set(string $block, string $value): void
117 117
     {
118
-        if (!isset($this->blocks[$block])) {
118
+        if (!isset($this->blocks[$block])){
119 119
             return;
120 120
         }
121 121
 
@@ -126,26 +126,26 @@  discard block
 block discarded – undo
126 126
     {
127 127
         $level = 0;
128 128
         $start = $name = $value = null;
129
-        foreach ($this->tokens as $position => $token) {
130
-            if (!is_array($token)) {
129
+        foreach ($this->tokens as $position => $token){
130
+            if (!is_array($token)){
131 131
                 $token = [$token, $token, 0];
132 132
             }
133 133
 
134
-            switch ($token[0]) {
134
+            switch ($token[0]){
135 135
                 case '(':
136
-                    if ($start !== null) {
136
+                    if ($start !== null){
137 137
                         $level++;
138 138
                         $value .= $token[1];
139 139
                     }
140 140
                     break;
141 141
                 case ')':
142
-                    if ($start === null) {
142
+                    if ($start === null){
143 143
                         break;
144 144
                     }
145 145
 
146 146
                     $level--;
147 147
                     $value .= $token[1];
148
-                    if ($level === 0) {
148
+                    if ($level === 0){
149 149
                         $this->blocks[$name] = [
150 150
                             'start' => $start,
151 151
                             'value' => trim($value),
@@ -157,22 +157,22 @@  discard block
 block discarded – undo
157 157
                     }
158 158
                     break;
159 159
                 case T_STRING:
160
-                    if ($token[1] === $func) {
160
+                    if ($token[1] === $func){
161 161
                         $start = $position;
162 162
                         $value = $token[1];
163 163
                         break;
164 164
                     }
165 165
 
166
-                    if ($start !== null) {
166
+                    if ($start !== null){
167 167
                         $value .= $token[1];
168 168
                     }
169 169
                     break;
170 170
                 case T_CONSTANT_ENCAPSED_STRING:
171
-                    if ($start === null) {
171
+                    if ($start === null){
172 172
                         break;
173 173
                     }
174 174
 
175
-                    if ($name === null) {
175
+                    if ($name === null){
176 176
                         $name = stripcslashes(substr($token[1], 1, -1));
177 177
                     }
178 178
                     $value .= $token[1];
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
                     $value .= $token[1];
182 182
                     break;
183 183
                 default:
184
-                    if ($start !== null) {
184
+                    if ($start !== null){
185 185
                         $value .= $token[1];
186 186
                     }
187 187
             }
Please login to merge, or discard this patch.
Braces   +48 added lines, -24 removed lines patch added patch discarded remove patch
@@ -32,8 +32,10 @@  discard block
 block discarded – undo
32 32
     {
33 33
         $replace = [];
34 34
 
35
-        foreach ($this->blocks as $block) {
36
-            for ($i = $block['start']; $i <= $block['end']; $i++) {
35
+        foreach ($this->blocks as $block)
36
+        {
37
+            for ($i = $block['start']; $i <= $block['end']; $i++)
38
+            {
37 39
                 $replace[$i] = '';
38 40
             }
39 41
 
@@ -41,13 +43,16 @@  discard block
 block discarded – undo
41 43
         }
42 44
 
43 45
         $result = '';
44
-        foreach ($this->tokens as $position => $token) {
45
-            if (array_key_exists($position, $replace)) {
46
+        foreach ($this->tokens as $position => $token)
47
+        {
48
+            if (array_key_exists($position, $replace))
49
+            {
46 50
                 $result .= $replace[$position];
47 51
                 continue;
48 52
             }
49 53
 
50
-            if (is_string($token)) {
54
+            if (is_string($token))
55
+            {
51 56
                 $result .= $token;
52 57
                 continue;
53 58
             }
@@ -65,8 +70,10 @@  discard block
 block discarded – undo
65 70
     {
66 71
         $replace = [];
67 72
 
68
-        foreach ($this->blocks as $block) {
69
-            for ($i = $block['start']; $i <= $block['end']; $i++) {
73
+        foreach ($this->blocks as $block)
74
+        {
75
+            for ($i = $block['start']; $i <= $block['end']; $i++)
76
+            {
70 77
                 $replace[$i] = '';
71 78
             }
72 79
 
@@ -74,18 +81,22 @@  discard block
 block discarded – undo
74 81
         }
75 82
 
76 83
         $result = '';
77
-        foreach ($this->tokens as $position => $token) {
78
-            if (array_key_exists($position, $replace)) {
84
+        foreach ($this->tokens as $position => $token)
85
+        {
86
+            if (array_key_exists($position, $replace))
87
+            {
79 88
                 $result .= $replace[$position];
80 89
                 continue;
81 90
             }
82 91
 
83
-            if (is_string($token)) {
92
+            if (is_string($token))
93
+            {
84 94
                 $result .= $token;
85 95
                 continue;
86 96
             }
87 97
 
88
-            if (in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO])) {
98
+            if (in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO]))
99
+            {
89 100
                 continue;
90 101
             }
91 102
 
@@ -101,7 +112,8 @@  discard block
 block discarded – undo
101 112
     public function getBlocks(): array
102 113
     {
103 114
         $result = [];
104
-        foreach ($this->blocks as $name => $macro) {
115
+        foreach ($this->blocks as $name => $macro)
116
+        {
105 117
             $result[$name] = $macro['value'];
106 118
         }
107 119
 
@@ -115,7 +127,8 @@  discard block
 block discarded – undo
115 127
 
116 128
     public function set(string $block, string $value): void
117 129
     {
118
-        if (!isset($this->blocks[$block])) {
130
+        if (!isset($this->blocks[$block]))
131
+        {
119 132
             return;
120 133
         }
121 134
 
@@ -126,26 +139,32 @@  discard block
 block discarded – undo
126 139
     {
127 140
         $level = 0;
128 141
         $start = $name = $value = null;
129
-        foreach ($this->tokens as $position => $token) {
130
-            if (!is_array($token)) {
142
+        foreach ($this->tokens as $position => $token)
143
+        {
144
+            if (!is_array($token))
145
+            {
131 146
                 $token = [$token, $token, 0];
132 147
             }
133 148
 
134
-            switch ($token[0]) {
149
+            switch ($token[0])
150
+            {
135 151
                 case '(':
136
-                    if ($start !== null) {
152
+                    if ($start !== null)
153
+                    {
137 154
                         $level++;
138 155
                         $value .= $token[1];
139 156
                     }
140 157
                     break;
141 158
                 case ')':
142
-                    if ($start === null) {
159
+                    if ($start === null)
160
+                    {
143 161
                         break;
144 162
                     }
145 163
 
146 164
                     $level--;
147 165
                     $value .= $token[1];
148
-                    if ($level === 0) {
166
+                    if ($level === 0)
167
+                    {
149 168
                         $this->blocks[$name] = [
150 169
                             'start' => $start,
151 170
                             'value' => trim($value),
@@ -157,22 +176,26 @@  discard block
 block discarded – undo
157 176
                     }
158 177
                     break;
159 178
                 case T_STRING:
160
-                    if ($token[1] === $func) {
179
+                    if ($token[1] === $func)
180
+                    {
161 181
                         $start = $position;
162 182
                         $value = $token[1];
163 183
                         break;
164 184
                     }
165 185
 
166
-                    if ($start !== null) {
186
+                    if ($start !== null)
187
+                    {
167 188
                         $value .= $token[1];
168 189
                     }
169 190
                     break;
170 191
                 case T_CONSTANT_ENCAPSED_STRING:
171
-                    if ($start === null) {
192
+                    if ($start === null)
193
+                    {
172 194
                         break;
173 195
                     }
174 196
 
175
-                    if ($name === null) {
197
+                    if ($name === null)
198
+                    {
176 199
                         $name = stripcslashes(substr($token[1], 1, -1));
177 200
                     }
178 201
                     $value .= $token[1];
@@ -181,7 +204,8 @@  discard block
 block discarded – undo
181 204
                     $value .= $token[1];
182 205
                     break;
183 206
                 default:
184
-                    if ($start !== null) {
207
+                    if ($start !== null)
208
+                    {
185 209
                         $value .= $token[1];
186 210
                     }
187 211
             }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Merge/ExtendsParent.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function enterNode($node, VisitorContext $ctx)
49 49
     {
50
-        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0) {
50
+        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0){
51 51
             return self::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
52 52
         }
53 53
 
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function leaveNode($node, VisitorContext $ctx)
61 61
     {
62
-        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0) {
62
+        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0){
63 63
             $parent = $ctx->getParentNode();
64
-            if (!$parent instanceof AttributedInterface) {
64
+            if (!$parent instanceof AttributedInterface){
65 65
                 throw new LogicException(sprintf(
66 66
                     'Unable to extend non attributable node (%s)',
67 67
                     is_object($node) ? get_class($node) : gettype($node)
@@ -74,20 +74,20 @@  discard block
 block discarded – undo
74 74
         }
75 75
 
76 76
         // extend current node
77
-        if ($node instanceof AttributedInterface && $node->getAttribute(self::class) !== null) {
77
+        if ($node instanceof AttributedInterface && $node->getAttribute(self::class) !== null){
78 78
             /** @var Tag $extends */
79 79
             $extends = $node->getAttribute(self::class);
80 80
 
81
-            foreach ($node->nodes as $child) {
81
+            foreach ($node->nodes as $child){
82 82
                 $extends->nodes[] = $child;
83 83
             }
84 84
 
85 85
             $path = 'undefined';
86
-            try {
86
+            try{
87 87
                 $path = $this->getPath($extends);
88 88
 
89 89
                 return $this->merger->merge($this->builder->load($path), $extends);
90
-            } catch (\Throwable $e) {
90
+            }catch (\Throwable $e){
91 91
                 throw new ExtendsException(
92 92
                     "Unable to extend parent `{$path}`",
93 93
                     $extends->getContext(),
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 
102 102
     private function getPath(Tag $tag): string
103 103
     {
104
-        if (strpos($tag->name, $this->extendsKeyword . ':') === 0) {
104
+        if (strpos($tag->name, $this->extendsKeyword.':') === 0){
105 105
             $name = substr($tag->name, strlen($this->extendsKeyword) + 1);
106 106
 
107 107
             return str_replace(['.'], DIRECTORY_SEPARATOR, $name);
108 108
         }
109 109
 
110
-        foreach ($tag->attrs as $attr) {
111
-            if ($attr->name === 'path' && is_string($attr->value)) {
110
+        foreach ($tag->attrs as $attr){
111
+            if ($attr->name === 'path' && is_string($attr->value)){
112 112
                 return trim($attr->value, '\'"');
113 113
             }
114 114
         }
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -47,7 +47,8 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function enterNode($node, VisitorContext $ctx)
49 49
     {
50
-        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0) {
50
+        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0)
51
+        {
51 52
             return self::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
52 53
         }
53 54
 
@@ -59,9 +60,11 @@  discard block
 block discarded – undo
59 60
      */
60 61
     public function leaveNode($node, VisitorContext $ctx)
61 62
     {
62
-        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0) {
63
+        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0)
64
+        {
63 65
             $parent = $ctx->getParentNode();
64
-            if (!$parent instanceof AttributedInterface) {
66
+            if (!$parent instanceof AttributedInterface)
67
+            {
65 68
                 throw new LogicException(sprintf(
66 69
                     'Unable to extend non attributable node (%s)',
67 70
                     is_object($node) ? get_class($node) : gettype($node)
@@ -74,20 +77,25 @@  discard block
 block discarded – undo
74 77
         }
75 78
 
76 79
         // extend current node
77
-        if ($node instanceof AttributedInterface && $node->getAttribute(self::class) !== null) {
80
+        if ($node instanceof AttributedInterface && $node->getAttribute(self::class) !== null)
81
+        {
78 82
             /** @var Tag $extends */
79 83
             $extends = $node->getAttribute(self::class);
80 84
 
81
-            foreach ($node->nodes as $child) {
85
+            foreach ($node->nodes as $child)
86
+            {
82 87
                 $extends->nodes[] = $child;
83 88
             }
84 89
 
85 90
             $path = 'undefined';
86
-            try {
91
+            try
92
+            {
87 93
                 $path = $this->getPath($extends);
88 94
 
89 95
                 return $this->merger->merge($this->builder->load($path), $extends);
90
-            } catch (\Throwable $e) {
96
+            }
97
+            catch (\Throwable $e)
98
+            {
91 99
                 throw new ExtendsException(
92 100
                     "Unable to extend parent `{$path}`",
93 101
                     $extends->getContext(),
@@ -101,14 +109,17 @@  discard block
 block discarded – undo
101 109
 
102 110
     private function getPath(Tag $tag): string
103 111
     {
104
-        if (strpos($tag->name, $this->extendsKeyword . ':') === 0) {
112
+        if (strpos($tag->name, $this->extendsKeyword . ':') === 0)
113
+        {
105 114
             $name = substr($tag->name, strlen($this->extendsKeyword) + 1);
106 115
 
107 116
             return str_replace(['.'], DIRECTORY_SEPARATOR, $name);
108 117
         }
109 118
 
110
-        foreach ($tag->attrs as $attr) {
111
-            if ($attr->name === 'path' && is_string($attr->value)) {
119
+        foreach ($tag->attrs as $attr)
120
+        {
121
+            if ($attr->name === 'path' && is_string($attr->value))
122
+            {
112 123
                 return trim($attr->value, '\'"');
113 124
             }
114 125
         }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Merge/ResolveImports.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function enterNode($node, VisitorContext $ctx)
51 51
     {
52
-        if ($node instanceof Tag && strpos($node->name, $this->useKeyword) === 0) {
52
+        if ($node instanceof Tag && strpos($node->name, $this->useKeyword) === 0){
53 53
             return self::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
54 54
         }
55 55
 
@@ -61,23 +61,23 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function leaveNode($node, VisitorContext $ctx)
63 63
     {
64
-        if (!$node instanceof Tag) {
64
+        if (!$node instanceof Tag){
65 65
             return null;
66 66
         }
67 67
 
68 68
         $importCtx = ImportContext::on($ctx);
69 69
 
70 70
         // import definition
71
-        if (\strpos($node->name, $this->useKeyword) === 0) {
71
+        if (\strpos($node->name, $this->useKeyword) === 0){
72 72
             $importCtx->add($this->makeImport($node));
73 73
 
74 74
             return self::REMOVE_NODE;
75 75
         }
76 76
 
77 77
         // imported tag
78
-        try {
78
+        try{
79 79
             $import = $importCtx->resolve($this->builder, $node->name);
80
-        } catch (\Throwable $e) {
80
+        }catch (\Throwable $e){
81 81
             throw new ImportException(
82 82
                 "Unable to resolve import `{$node->name}`",
83 83
                 $node->getContext(),
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
             );
86 86
         }
87 87
 
88
-        if ($import !== null) {
88
+        if ($import !== null){
89 89
             $node = $this->merger->merge($import, $node);
90 90
 
91 91
             return $this->merger->isolateNodes($node, $import->getContext()->getPath());
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
     private function makeImport(Tag $tag): ImportInterface
103 103
     {
104 104
         $options = [];
105
-        foreach ($tag->attrs as $attr) {
106
-            if (!\is_string($attr->value) || !\is_string($attr->name)) {
105
+        foreach ($tag->attrs as $attr){
106
+            if (!\is_string($attr->value) || !\is_string($attr->name)){
107 107
                 continue;
108 108
             }
109 109
             $options[$attr->name] = trim($attr->value, '\'"');
110 110
         }
111 111
 
112
-        switch (\strtolower($tag->name)) {
112
+        switch (\strtolower($tag->name)){
113 113
             case 'use':
114 114
             case 'use:element':
115 115
                 $this->assertHasOption('path', $options, $tag);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 
156 156
     private function assertHasOption(string $option, array $options, Tag $tag): void
157 157
     {
158
-        if (!isset($options[$option])) {
158
+        if (!isset($options[$option])){
159 159
             throw new ImportException("Missing `{$option}` option", $tag->getContext());
160 160
         }
161 161
     }
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -49,7 +49,8 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function enterNode($node, VisitorContext $ctx)
51 51
     {
52
-        if ($node instanceof Tag && strpos($node->name, $this->useKeyword) === 0) {
52
+        if ($node instanceof Tag && strpos($node->name, $this->useKeyword) === 0)
53
+        {
53 54
             return self::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
54 55
         }
55 56
 
@@ -61,23 +62,28 @@  discard block
 block discarded – undo
61 62
      */
62 63
     public function leaveNode($node, VisitorContext $ctx)
63 64
     {
64
-        if (!$node instanceof Tag) {
65
+        if (!$node instanceof Tag)
66
+        {
65 67
             return null;
66 68
         }
67 69
 
68 70
         $importCtx = ImportContext::on($ctx);
69 71
 
70 72
         // import definition
71
-        if (\strpos($node->name, $this->useKeyword) === 0) {
73
+        if (\strpos($node->name, $this->useKeyword) === 0)
74
+        {
72 75
             $importCtx->add($this->makeImport($node));
73 76
 
74 77
             return self::REMOVE_NODE;
75 78
         }
76 79
 
77 80
         // imported tag
78
-        try {
81
+        try
82
+        {
79 83
             $import = $importCtx->resolve($this->builder, $node->name);
80
-        } catch (\Throwable $e) {
84
+        }
85
+        catch (\Throwable $e)
86
+        {
81 87
             throw new ImportException(
82 88
                 "Unable to resolve import `{$node->name}`",
83 89
                 $node->getContext(),
@@ -85,7 +91,8 @@  discard block
 block discarded – undo
85 91
             );
86 92
         }
87 93
 
88
-        if ($import !== null) {
94
+        if ($import !== null)
95
+        {
89 96
             $node = $this->merger->merge($import, $node);
90 97
 
91 98
             return $this->merger->isolateNodes($node, $import->getContext()->getPath());
@@ -102,14 +109,17 @@  discard block
 block discarded – undo
102 109
     private function makeImport(Tag $tag): ImportInterface
103 110
     {
104 111
         $options = [];
105
-        foreach ($tag->attrs as $attr) {
106
-            if (!\is_string($attr->value) || !\is_string($attr->name)) {
112
+        foreach ($tag->attrs as $attr)
113
+        {
114
+            if (!\is_string($attr->value) || !\is_string($attr->name))
115
+            {
107 116
                 continue;
108 117
             }
109 118
             $options[$attr->name] = trim($attr->value, '\'"');
110 119
         }
111 120
 
112
-        switch (\strtolower($tag->name)) {
121
+        switch (\strtolower($tag->name))
122
+        {
113 123
             case 'use':
114 124
             case 'use:element':
115 125
                 $this->assertHasOption('path', $options, $tag);
@@ -155,7 +165,8 @@  discard block
 block discarded – undo
155 165
 
156 166
     private function assertHasOption(string $option, array $options, Tag $tag): void
157 167
     {
158
-        if (!isset($options[$option])) {
168
+        if (!isset($options[$option]))
169
+        {
159 170
             throw new ImportException("Missing `{$option}` option", $tag->getContext());
160 171
         }
161 172
     }
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/Lexer.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,20 +38,20 @@  discard block
 block discarded – undo
38 38
     public function parse(StreamInterface $src): \Generator
39 39
     {
40 40
         $stream = new Buffer($this->generate($src));
41
-        foreach ($this->grammars as $grammar) {
41
+        foreach ($this->grammars as $grammar){
42 42
             $stream = new Buffer($this->wrap(clone $grammar, $stream));
43 43
         }
44 44
 
45 45
         // always group raw bytes into raw tokens
46
-        foreach ($this->wrap(new RawGrammar(), $stream) as $n) {
46
+        foreach ($this->wrap(new RawGrammar(), $stream) as $n){
47 47
             yield $n;
48 48
         }
49 49
     }
50 50
 
51 51
     private function wrap(GrammarInterface $grammar, Buffer $stream): \Generator
52 52
     {
53
-        foreach ($grammar->parse($stream) as $n) {
54
-            if ($n instanceof Token && $n->grammar === null) {
53
+        foreach ($grammar->parse($stream) as $n){
54
+            if ($n instanceof Token && $n->grammar === null){
55 55
                 $n->grammar = get_class($grammar);
56 56
             }
57 57
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     private function generate(StreamInterface $src)
68 68
     {
69
-        while (!$src->isEOI()) {
69
+        while (!$src->isEOI()){
70 70
             yield new Byte($src->getOffset(), $src->peak());
71 71
         }
72 72
     }
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,20 +38,24 @@  discard block
 block discarded – undo
38 38
     public function parse(StreamInterface $src): \Generator
39 39
     {
40 40
         $stream = new Buffer($this->generate($src));
41
-        foreach ($this->grammars as $grammar) {
41
+        foreach ($this->grammars as $grammar)
42
+        {
42 43
             $stream = new Buffer($this->wrap(clone $grammar, $stream));
43 44
         }
44 45
 
45 46
         // always group raw bytes into raw tokens
46
-        foreach ($this->wrap(new RawGrammar(), $stream) as $n) {
47
+        foreach ($this->wrap(new RawGrammar(), $stream) as $n)
48
+        {
47 49
             yield $n;
48 50
         }
49 51
     }
50 52
 
51 53
     private function wrap(GrammarInterface $grammar, Buffer $stream): \Generator
52 54
     {
53
-        foreach ($grammar->parse($stream) as $n) {
54
-            if ($n instanceof Token && $n->grammar === null) {
55
+        foreach ($grammar->parse($stream) as $n)
56
+        {
57
+            if ($n instanceof Token && $n->grammar === null)
58
+            {
55 59
                 $n->grammar = get_class($grammar);
56 60
             }
57 61
 
@@ -66,7 +70,8 @@  discard block
 block discarded – undo
66 70
      */
67 71
     private function generate(StreamInterface $src)
68 72
     {
69
-        while (!$src->isEOI()) {
73
+        while (!$src->isEOI())
74
+        {
70 75
             yield new Byte($src->getOffset(), $src->peak());
71 76
         }
72 77
     }
Please login to merge, or discard this patch.