Passed
Pull Request — master (#370)
by Valentin
04:51
created
src/Stempler/src/Transform/Merge/ExtendsParent.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function enterNode($node, VisitorContext $ctx)
53 53
     {
54
-        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0) {
54
+        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0){
55 55
             return self::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
56 56
         }
57 57
 
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public function leaveNode($node, VisitorContext $ctx)
65 65
     {
66
-        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0) {
66
+        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0){
67 67
             $parent = $ctx->getParentNode();
68
-            if (!$parent instanceof AttributedInterface) {
68
+            if (!$parent instanceof AttributedInterface){
69 69
                 throw new LogicException(sprintf(
70 70
                     'Unable to extend non attributable node (%s)',
71 71
                     is_object($node) ? get_class($node) : gettype($node)
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
         }
79 79
 
80 80
         // extend current node
81
-        if ($node instanceof AttributedInterface && $node->getAttribute(self::class) !== null) {
81
+        if ($node instanceof AttributedInterface && $node->getAttribute(self::class) !== null){
82 82
             /** @var Tag $extends */
83 83
             $extends = $node->getAttribute(self::class);
84 84
 
85
-            foreach ($node->nodes as $child) {
85
+            foreach ($node->nodes as $child){
86 86
                 $extends->nodes[] = $child;
87 87
             }
88 88
 
89 89
             $path = 'undefined';
90
-            try {
90
+            try{
91 91
                 $path = $this->getPath($extends);
92 92
 
93 93
                 return $this->merger->merge($this->builder->load($path), $extends);
94
-            } catch (\Throwable $e) {
94
+            }catch (\Throwable $e){
95 95
                 throw new ExtendsException(
96 96
                     "Unable to extend parent `{$path}`",
97 97
                     $extends->getContext(),
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
      */
110 110
     private function getPath(Tag $tag): string
111 111
     {
112
-        if (strpos($tag->name, $this->extendsKeyword . ':') === 0) {
112
+        if (strpos($tag->name, $this->extendsKeyword.':') === 0){
113 113
             $name = substr($tag->name, strlen($this->extendsKeyword) + 1);
114 114
 
115 115
             return str_replace(['.'], DIRECTORY_SEPARATOR, $name);
116 116
         }
117 117
 
118
-        foreach ($tag->attrs as $attr) {
119
-            if ($attr->name === 'path' && is_string($attr->value)) {
118
+        foreach ($tag->attrs as $attr){
119
+            if ($attr->name === 'path' && is_string($attr->value)){
120 120
                 return trim($attr->value, '\'"');
121 121
             }
122 122
         }
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -51,7 +51,8 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function enterNode($node, VisitorContext $ctx)
53 53
     {
54
-        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0) {
54
+        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0)
55
+        {
55 56
             return self::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
56 57
         }
57 58
 
@@ -63,9 +64,11 @@  discard block
 block discarded – undo
63 64
      */
64 65
     public function leaveNode($node, VisitorContext $ctx)
65 66
     {
66
-        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0) {
67
+        if ($node instanceof Tag && strpos($node->name, $this->extendsKeyword) === 0)
68
+        {
67 69
             $parent = $ctx->getParentNode();
68
-            if (!$parent instanceof AttributedInterface) {
70
+            if (!$parent instanceof AttributedInterface)
71
+            {
69 72
                 throw new LogicException(sprintf(
70 73
                     'Unable to extend non attributable node (%s)',
71 74
                     is_object($node) ? get_class($node) : gettype($node)
@@ -78,20 +81,25 @@  discard block
 block discarded – undo
78 81
         }
79 82
 
80 83
         // extend current node
81
-        if ($node instanceof AttributedInterface && $node->getAttribute(self::class) !== null) {
84
+        if ($node instanceof AttributedInterface && $node->getAttribute(self::class) !== null)
85
+        {
82 86
             /** @var Tag $extends */
83 87
             $extends = $node->getAttribute(self::class);
84 88
 
85
-            foreach ($node->nodes as $child) {
89
+            foreach ($node->nodes as $child)
90
+            {
86 91
                 $extends->nodes[] = $child;
87 92
             }
88 93
 
89 94
             $path = 'undefined';
90
-            try {
95
+            try
96
+            {
91 97
                 $path = $this->getPath($extends);
92 98
 
93 99
                 return $this->merger->merge($this->builder->load($path), $extends);
94
-            } catch (\Throwable $e) {
100
+            }
101
+            catch (\Throwable $e)
102
+            {
95 103
                 throw new ExtendsException(
96 104
                     "Unable to extend parent `{$path}`",
97 105
                     $extends->getContext(),
@@ -109,14 +117,17 @@  discard block
 block discarded – undo
109 117
      */
110 118
     private function getPath(Tag $tag): string
111 119
     {
112
-        if (strpos($tag->name, $this->extendsKeyword . ':') === 0) {
120
+        if (strpos($tag->name, $this->extendsKeyword . ':') === 0)
121
+        {
113 122
             $name = substr($tag->name, strlen($this->extendsKeyword) + 1);
114 123
 
115 124
             return str_replace(['.'], DIRECTORY_SEPARATOR, $name);
116 125
         }
117 126
 
118
-        foreach ($tag->attrs as $attr) {
119
-            if ($attr->name === 'path' && is_string($attr->value)) {
127
+        foreach ($tag->attrs as $attr)
128
+        {
129
+            if ($attr->name === 'path' && is_string($attr->value))
130
+            {
120 131
                 return trim($attr->value, '\'"');
121 132
             }
122 133
         }
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
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function enterNode($node, VisitorContext $ctx)
55 55
     {
56
-        if ($node instanceof Tag && strpos($node->name, $this->useKeyword) === 0) {
56
+        if ($node instanceof Tag && strpos($node->name, $this->useKeyword) === 0){
57 57
             return self::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
58 58
         }
59 59
 
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function leaveNode($node, VisitorContext $ctx)
67 67
     {
68
-        if (!$node instanceof Tag) {
68
+        if (!$node instanceof Tag){
69 69
             return null;
70 70
         }
71 71
 
72 72
         $importCtx = ImportContext::on($ctx);
73 73
 
74 74
         // import definition
75
-        if (strpos($node->name, $this->useKeyword) === 0) {
75
+        if (strpos($node->name, $this->useKeyword) === 0){
76 76
             $importCtx->add($this->makeImport($node));
77 77
 
78 78
             return self::REMOVE_NODE;
79 79
         }
80 80
 
81 81
         // imported tag
82
-        try {
82
+        try{
83 83
             $import = $importCtx->resolve($this->builder, $node->name);
84
-        } catch (\Throwable $e) {
84
+        }catch (\Throwable $e){
85 85
             throw new ImportException(
86 86
                 "Unable to resolve import `{$node->name}`",
87 87
                 $node->getContext(),
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
             );
90 90
         }
91 91
 
92
-        if ($import !== null) {
92
+        if ($import !== null){
93 93
             $node = $this->merger->merge($import, $node);
94 94
 
95 95
             return $this->merger->isolateNodes($node, $import->getContext()->getPath());
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
     private function makeImport(Tag $tag): ImportInterface
108 108
     {
109 109
         $options = [];
110
-        foreach ($tag->attrs as $attr) {
111
-            if (is_string($attr->value)) {
110
+        foreach ($tag->attrs as $attr){
111
+            if (is_string($attr->value)){
112 112
                 $options[$attr->name] = trim($attr->value, '\'"');
113 113
             }
114 114
         }
115 115
 
116
-        switch (strtolower($tag->name)) {
116
+        switch (strtolower($tag->name)){
117 117
             case 'use':
118 118
             case 'use:element':
119 119
                 $this->assertHasOption('path', $options, $tag);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      */
165 165
     private function assertHasOption(string $option, array $options, Tag $tag): void
166 166
     {
167
-        if (!isset($options[$option])) {
167
+        if (!isset($options[$option])){
168 168
             throw new ImportException("Missing `{$option}` option", $tag->getContext());
169 169
         }
170 170
     }
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -53,7 +53,8 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function enterNode($node, VisitorContext $ctx)
55 55
     {
56
-        if ($node instanceof Tag && strpos($node->name, $this->useKeyword) === 0) {
56
+        if ($node instanceof Tag && strpos($node->name, $this->useKeyword) === 0)
57
+        {
57 58
             return self::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
58 59
         }
59 60
 
@@ -65,23 +66,28 @@  discard block
 block discarded – undo
65 66
      */
66 67
     public function leaveNode($node, VisitorContext $ctx)
67 68
     {
68
-        if (!$node instanceof Tag) {
69
+        if (!$node instanceof Tag)
70
+        {
69 71
             return null;
70 72
         }
71 73
 
72 74
         $importCtx = ImportContext::on($ctx);
73 75
 
74 76
         // import definition
75
-        if (strpos($node->name, $this->useKeyword) === 0) {
77
+        if (strpos($node->name, $this->useKeyword) === 0)
78
+        {
76 79
             $importCtx->add($this->makeImport($node));
77 80
 
78 81
             return self::REMOVE_NODE;
79 82
         }
80 83
 
81 84
         // imported tag
82
-        try {
85
+        try
86
+        {
83 87
             $import = $importCtx->resolve($this->builder, $node->name);
84
-        } catch (\Throwable $e) {
88
+        }
89
+        catch (\Throwable $e)
90
+        {
85 91
             throw new ImportException(
86 92
                 "Unable to resolve import `{$node->name}`",
87 93
                 $node->getContext(),
@@ -89,7 +95,8 @@  discard block
 block discarded – undo
89 95
             );
90 96
         }
91 97
 
92
-        if ($import !== null) {
98
+        if ($import !== null)
99
+        {
93 100
             $node = $this->merger->merge($import, $node);
94 101
 
95 102
             return $this->merger->isolateNodes($node, $import->getContext()->getPath());
@@ -107,13 +114,16 @@  discard block
 block discarded – undo
107 114
     private function makeImport(Tag $tag): ImportInterface
108 115
     {
109 116
         $options = [];
110
-        foreach ($tag->attrs as $attr) {
111
-            if (is_string($attr->value)) {
117
+        foreach ($tag->attrs as $attr)
118
+        {
119
+            if (is_string($attr->value))
120
+            {
112 121
                 $options[$attr->name] = trim($attr->value, '\'"');
113 122
             }
114 123
         }
115 124
 
116
-        switch (strtolower($tag->name)) {
125
+        switch (strtolower($tag->name))
126
+        {
117 127
             case 'use':
118 128
             case 'use:element':
119 129
                 $this->assertHasOption('path', $options, $tag);
@@ -164,7 +174,8 @@  discard block
 block discarded – undo
164 174
      */
165 175
     private function assertHasOption(string $option, array $options, Tag $tag): void
166 176
     {
167
-        if (!isset($options[$option])) {
177
+        if (!isset($options[$option]))
178
+        {
168 179
             throw new ImportException("Missing `{$option}` option", $tag->getContext());
169 180
         }
170 181
     }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Merge/Inject/InjectAttributes.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -43,25 +43,25 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function enterNode($node, VisitorContext $ctx)
45 45
     {
46
-        if (!$node instanceof Aggregate) {
46
+        if (!$node instanceof Aggregate){
47 47
             return null;
48 48
         }
49 49
 
50
-        foreach ($this->blocks->getUnclaimed() as $name) {
50
+        foreach ($this->blocks->getUnclaimed() as $name){
51 51
             $alias = $node->accepts($name);
52
-            if ($alias === null) {
52
+            if ($alias === null){
53 53
                 continue;
54 54
             }
55 55
 
56 56
             $value = $this->blocks->claim($name);
57 57
 
58
-            if ($value instanceof QuotedValue) {
58
+            if ($value instanceof QuotedValue){
59 59
                 $node->nodes[] = new Attr($alias, $value->getValue());
60 60
                 continue;
61 61
             }
62 62
 
63 63
             // simple copy attribute copy
64
-            if ($value instanceof Attr) {
64
+            if ($value instanceof Attr){
65 65
                 $node->nodes[] = clone $value;
66 66
                 continue;
67 67
             }
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
      */
84 84
     private function wrapValue($value)
85 85
     {
86
-        if ($value === [] || $value === null || $value instanceof Nil) {
86
+        if ($value === [] || $value === null || $value instanceof Nil){
87 87
             return new Nil();
88 88
         }
89 89
 
90
-        if ($value instanceof Verbatim || is_scalar($value)) {
90
+        if ($value instanceof Verbatim || is_scalar($value)){
91 91
             return $value;
92 92
         }
93 93
 
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -43,25 +43,30 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function enterNode($node, VisitorContext $ctx)
45 45
     {
46
-        if (!$node instanceof Aggregate) {
46
+        if (!$node instanceof Aggregate)
47
+        {
47 48
             return null;
48 49
         }
49 50
 
50
-        foreach ($this->blocks->getUnclaimed() as $name) {
51
+        foreach ($this->blocks->getUnclaimed() as $name)
52
+        {
51 53
             $alias = $node->accepts($name);
52
-            if ($alias === null) {
54
+            if ($alias === null)
55
+            {
53 56
                 continue;
54 57
             }
55 58
 
56 59
             $value = $this->blocks->claim($name);
57 60
 
58
-            if ($value instanceof QuotedValue) {
61
+            if ($value instanceof QuotedValue)
62
+            {
59 63
                 $node->nodes[] = new Attr($alias, $value->getValue());
60 64
                 continue;
61 65
             }
62 66
 
63 67
             // simple copy attribute copy
64
-            if ($value instanceof Attr) {
68
+            if ($value instanceof Attr)
69
+            {
65 70
                 $node->nodes[] = clone $value;
66 71
                 continue;
67 72
             }
@@ -83,11 +88,13 @@  discard block
 block discarded – undo
83 88
      */
84 89
     private function wrapValue($value)
85 90
     {
86
-        if ($value === [] || $value === null || $value instanceof Nil) {
91
+        if ($value === [] || $value === null || $value instanceof Nil)
92
+        {
87 93
             return new Nil();
88 94
         }
89 95
 
90
-        if ($value instanceof Verbatim || is_scalar($value)) {
96
+        if ($value instanceof Verbatim || is_scalar($value))
97
+        {
91 98
             return $value;
92 99
         }
93 100
 
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
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
     {
40 40
         $replace = [];
41 41
 
42
-        foreach ($this->blocks as $block) {
43
-            for ($i = $block['start']; $i <= $block['end']; $i++) {
42
+        foreach ($this->blocks as $block){
43
+            for ($i = $block['start']; $i <= $block['end']; $i++){
44 44
                 $replace[$i] = '';
45 45
             }
46 46
 
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
         }
49 49
 
50 50
         $result = '';
51
-        foreach ($this->tokens as $position => $token) {
52
-            if (array_key_exists($position, $replace)) {
51
+        foreach ($this->tokens as $position => $token){
52
+            if (array_key_exists($position, $replace)){
53 53
                 $result .= $replace[$position];
54 54
                 continue;
55 55
             }
56 56
 
57
-            if (is_string($token)) {
57
+            if (is_string($token)){
58 58
                 $result .= $token;
59 59
                 continue;
60 60
             }
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
     {
75 75
         $replace = [];
76 76
 
77
-        foreach ($this->blocks as $block) {
78
-            for ($i = $block['start']; $i <= $block['end']; $i++) {
77
+        foreach ($this->blocks as $block){
78
+            for ($i = $block['start']; $i <= $block['end']; $i++){
79 79
                 $replace[$i] = '';
80 80
             }
81 81
 
@@ -83,18 +83,18 @@  discard block
 block discarded – undo
83 83
         }
84 84
 
85 85
         $result = '';
86
-        foreach ($this->tokens as $position => $token) {
87
-            if (array_key_exists($position, $replace)) {
86
+        foreach ($this->tokens as $position => $token){
87
+            if (array_key_exists($position, $replace)){
88 88
                 $result .= $replace[$position];
89 89
                 continue;
90 90
             }
91 91
 
92
-            if (is_string($token)) {
92
+            if (is_string($token)){
93 93
                 $result .= $token;
94 94
                 continue;
95 95
             }
96 96
 
97
-            if (in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO])) {
97
+            if (in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO])){
98 98
                 continue;
99 99
             }
100 100
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     public function getBlocks(): array
113 113
     {
114 114
         $result = [];
115
-        foreach ($this->blocks as $name => $macro) {
115
+        foreach ($this->blocks as $name => $macro){
116 116
             $result[$name] = $macro['value'];
117 117
         }
118 118
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      */
135 135
     public function set(string $block, string $value): void
136 136
     {
137
-        if (!isset($this->blocks[$block])) {
137
+        if (!isset($this->blocks[$block])){
138 138
             return;
139 139
         }
140 140
 
@@ -148,26 +148,26 @@  discard block
 block discarded – undo
148 148
     {
149 149
         $level = 0;
150 150
         $start = $name = $value = null;
151
-        foreach ($this->tokens as $position => $token) {
152
-            if (!is_array($token)) {
151
+        foreach ($this->tokens as $position => $token){
152
+            if (!is_array($token)){
153 153
                 $token = [$token, $token, 0];
154 154
             }
155 155
 
156
-            switch ($token[0]) {
156
+            switch ($token[0]){
157 157
                 case '(':
158
-                    if ($start !== null) {
158
+                    if ($start !== null){
159 159
                         $level++;
160 160
                         $value .= $token[1];
161 161
                     }
162 162
                     break;
163 163
                 case ')':
164
-                    if ($start === null) {
164
+                    if ($start === null){
165 165
                         break;
166 166
                     }
167 167
 
168 168
                     $level--;
169 169
                     $value .= $token[1];
170
-                    if ($level === 0) {
170
+                    if ($level === 0){
171 171
                         $this->blocks[$name] = [
172 172
                             'start' => $start,
173 173
                             'value' => trim($value),
@@ -179,22 +179,22 @@  discard block
 block discarded – undo
179 179
                     }
180 180
                     break;
181 181
                 case T_STRING:
182
-                    if ($token[1] === $func) {
182
+                    if ($token[1] === $func){
183 183
                         $start = $position;
184 184
                         $value = $token[1];
185 185
                         break;
186 186
                     }
187 187
 
188
-                    if ($start !== null) {
188
+                    if ($start !== null){
189 189
                         $value .= $token[1];
190 190
                     }
191 191
                     break;
192 192
                 case T_CONSTANT_ENCAPSED_STRING:
193
-                    if ($start === null) {
193
+                    if ($start === null){
194 194
                         break;
195 195
                     }
196 196
 
197
-                    if ($name === null) {
197
+                    if ($name === null){
198 198
                         $name = stripcslashes(substr($token[1], 1, -1));
199 199
                     }
200 200
                     $value .= $token[1];
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
                     $value .= $token[1];
204 204
                     break;
205 205
                 default:
206
-                    if ($start !== null) {
206
+                    if ($start !== null){
207 207
                         $value .= $token[1];
208 208
                     }
209 209
             }
Please login to merge, or discard this patch.
Braces   +48 added lines, -24 removed lines patch added patch discarded remove patch
@@ -39,8 +39,10 @@  discard block
 block discarded – undo
39 39
     {
40 40
         $replace = [];
41 41
 
42
-        foreach ($this->blocks as $block) {
43
-            for ($i = $block['start']; $i <= $block['end']; $i++) {
42
+        foreach ($this->blocks as $block)
43
+        {
44
+            for ($i = $block['start']; $i <= $block['end']; $i++)
45
+            {
44 46
                 $replace[$i] = '';
45 47
             }
46 48
 
@@ -48,13 +50,16 @@  discard block
 block discarded – undo
48 50
         }
49 51
 
50 52
         $result = '';
51
-        foreach ($this->tokens as $position => $token) {
52
-            if (array_key_exists($position, $replace)) {
53
+        foreach ($this->tokens as $position => $token)
54
+        {
55
+            if (array_key_exists($position, $replace))
56
+            {
53 57
                 $result .= $replace[$position];
54 58
                 continue;
55 59
             }
56 60
 
57
-            if (is_string($token)) {
61
+            if (is_string($token))
62
+            {
58 63
                 $result .= $token;
59 64
                 continue;
60 65
             }
@@ -74,8 +79,10 @@  discard block
 block discarded – undo
74 79
     {
75 80
         $replace = [];
76 81
 
77
-        foreach ($this->blocks as $block) {
78
-            for ($i = $block['start']; $i <= $block['end']; $i++) {
82
+        foreach ($this->blocks as $block)
83
+        {
84
+            for ($i = $block['start']; $i <= $block['end']; $i++)
85
+            {
79 86
                 $replace[$i] = '';
80 87
             }
81 88
 
@@ -83,18 +90,22 @@  discard block
 block discarded – undo
83 90
         }
84 91
 
85 92
         $result = '';
86
-        foreach ($this->tokens as $position => $token) {
87
-            if (array_key_exists($position, $replace)) {
93
+        foreach ($this->tokens as $position => $token)
94
+        {
95
+            if (array_key_exists($position, $replace))
96
+            {
88 97
                 $result .= $replace[$position];
89 98
                 continue;
90 99
             }
91 100
 
92
-            if (is_string($token)) {
101
+            if (is_string($token))
102
+            {
93 103
                 $result .= $token;
94 104
                 continue;
95 105
             }
96 106
 
97
-            if (in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO])) {
107
+            if (in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO]))
108
+            {
98 109
                 continue;
99 110
             }
100 111
 
@@ -112,7 +123,8 @@  discard block
 block discarded – undo
112 123
     public function getBlocks(): array
113 124
     {
114 125
         $result = [];
115
-        foreach ($this->blocks as $name => $macro) {
126
+        foreach ($this->blocks as $name => $macro)
127
+        {
116 128
             $result[$name] = $macro['value'];
117 129
         }
118 130
 
@@ -134,7 +146,8 @@  discard block
 block discarded – undo
134 146
      */
135 147
     public function set(string $block, string $value): void
136 148
     {
137
-        if (!isset($this->blocks[$block])) {
149
+        if (!isset($this->blocks[$block]))
150
+        {
138 151
             return;
139 152
         }
140 153
 
@@ -148,26 +161,32 @@  discard block
 block discarded – undo
148 161
     {
149 162
         $level = 0;
150 163
         $start = $name = $value = null;
151
-        foreach ($this->tokens as $position => $token) {
152
-            if (!is_array($token)) {
164
+        foreach ($this->tokens as $position => $token)
165
+        {
166
+            if (!is_array($token))
167
+            {
153 168
                 $token = [$token, $token, 0];
154 169
             }
155 170
 
156
-            switch ($token[0]) {
171
+            switch ($token[0])
172
+            {
157 173
                 case '(':
158
-                    if ($start !== null) {
174
+                    if ($start !== null)
175
+                    {
159 176
                         $level++;
160 177
                         $value .= $token[1];
161 178
                     }
162 179
                     break;
163 180
                 case ')':
164
-                    if ($start === null) {
181
+                    if ($start === null)
182
+                    {
165 183
                         break;
166 184
                     }
167 185
 
168 186
                     $level--;
169 187
                     $value .= $token[1];
170
-                    if ($level === 0) {
188
+                    if ($level === 0)
189
+                    {
171 190
                         $this->blocks[$name] = [
172 191
                             'start' => $start,
173 192
                             'value' => trim($value),
@@ -179,22 +198,26 @@  discard block
 block discarded – undo
179 198
                     }
180 199
                     break;
181 200
                 case T_STRING:
182
-                    if ($token[1] === $func) {
201
+                    if ($token[1] === $func)
202
+                    {
183 203
                         $start = $position;
184 204
                         $value = $token[1];
185 205
                         break;
186 206
                     }
187 207
 
188
-                    if ($start !== null) {
208
+                    if ($start !== null)
209
+                    {
189 210
                         $value .= $token[1];
190 211
                     }
191 212
                     break;
192 213
                 case T_CONSTANT_ENCAPSED_STRING:
193
-                    if ($start === null) {
214
+                    if ($start === null)
215
+                    {
194 216
                         break;
195 217
                     }
196 218
 
197
-                    if ($name === null) {
219
+                    if ($name === null)
220
+                    {
198 221
                         $name = stripcslashes(substr($token[1], 1, -1));
199 222
                     }
200 223
                     $value .= $token[1];
@@ -203,7 +226,8 @@  discard block
 block discarded – undo
203 226
                     $value .= $token[1];
204 227
                     break;
205 228
                 default:
206
-                    if ($start !== null) {
229
+                    if ($start !== null)
230
+                    {
207 231
                         $value .= $token[1];
208 232
                     }
209 233
             }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Merge/Inject/InjectPHP.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
                 strpos($node->content, self::PHP_MACRO_FUNCTION) === false
60 60
                 && strpos($node->content, self::PHP_MARCO_EXISTS_FUNCTION) === false
61 61
             )
62
-        ) {
62
+        ){
63 63
             return null;
64 64
         }
65 65
 
66 66
         $php = new PHPMixin($node->tokens, self::PHP_MACRO_FUNCTION);
67
-        foreach ($this->blocks->getNames() as $name) {
67
+        foreach ($this->blocks->getNames() as $name){
68 68
             $block = $this->blocks->get($name);
69 69
 
70
-            if ($this->isReference($block)) {
70
+            if ($this->isReference($block)){
71 71
                 // resolved on later stage
72 72
                 continue;
73 73
             }
74 74
 
75
-            if ($php->has($name)) {
75
+            if ($php->has($name)){
76 76
                 $php->set($name, $this->trimPHP($this->blocks->claim($name)));
77 77
             }
78 78
         }
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
         $node->tokens = token_get_all($node->content);
82 82
 
83 83
         $exists = new PHPMixin($node->tokens, self::PHP_MARCO_EXISTS_FUNCTION);
84
-        foreach ($this->blocks->getNames() as $name) {
84
+        foreach ($this->blocks->getNames() as $name){
85 85
             $block = $this->blocks->get($name);
86 86
 
87
-            if ($this->isReference($block)) {
87
+            if ($this->isReference($block)){
88 88
                 // resolved on later stage
89 89
                 continue;
90 90
             }
91 91
 
92
-            if ($exists->has($name)) {
92
+            if ($exists->has($name)){
93 93
                 $exists->set($name, 'true');
94 94
             }
95 95
         }
@@ -111,10 +111,10 @@  discard block
 block discarded – undo
111 111
      */
112 112
     private function isReference($node): bool
113 113
     {
114
-        switch (true) {
114
+        switch (true){
115 115
             case is_array($node):
116
-                foreach ($node as $child) {
117
-                    if ($this->isReference($child)) {
116
+                foreach ($node as $child){
117
+                    if ($this->isReference($child)){
118 118
                         return true;
119 119
                     }
120 120
                 }
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
                 return $this->isReference($node->getValue());
126 126
 
127 127
             case $node instanceof Mixin:
128
-                foreach ($node->nodes as $child) {
129
-                    if ($this->isReference($child)) {
128
+                foreach ($node->nodes as $child){
129
+                    if ($this->isReference($child)){
130 130
                         return true;
131 131
                     }
132 132
                 }
@@ -146,10 +146,10 @@  discard block
 block discarded – undo
146 146
      */
147 147
     private function trimPHP($node): string
148 148
     {
149
-        switch (true) {
149
+        switch (true){
150 150
             case is_array($node):
151 151
                 $result = [];
152
-                foreach ($node as $child) {
152
+                foreach ($node as $child){
153 153
                     $result[] = $this->trimPHP($child);
154 154
                 }
155 155
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
             case $node instanceof Mixin:
159 159
                 $result = [];
160
-                foreach ($node->nodes as $child) {
160
+                foreach ($node->nodes as $child){
161 161
                     $result[] = $this->trimPHP($child);
162 162
                 }
163 163
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
                 return trim($node->body);
171 171
 
172 172
             case $node instanceof PHP:
173
-                if ($node->getContext()->getValue(PHP::ORIGINAL_BODY) !== null) {
173
+                if ($node->getContext()->getValue(PHP::ORIGINAL_BODY) !== null){
174 174
                     return $node->getContext()->getValue(PHP::ORIGINAL_BODY);
175 175
                 }
176 176
 
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
     private function exportValue(Raw $node): string
191 191
     {
192 192
         $value = $node->content;
193
-        switch (true) {
193
+        switch (true){
194 194
             case strtolower($value) === 'true':
195 195
                 return 'true';
196 196
             case strtolower($value) === 'false':
197 197
                 return 'false';
198 198
             case is_float($value) || is_numeric($value):
199
-                return (string) $value;
199
+                return (string)$value;
200 200
         }
201 201
 
202 202
         return var_export($node->content, true);
Please login to merge, or discard this patch.
Braces   +32 added lines, -16 removed lines patch added patch discarded remove patch
@@ -64,15 +64,18 @@  discard block
 block discarded – undo
64 64
         }
65 65
 
66 66
         $php = new PHPMixin($node->tokens, self::PHP_MACRO_FUNCTION);
67
-        foreach ($this->blocks->getNames() as $name) {
67
+        foreach ($this->blocks->getNames() as $name)
68
+        {
68 69
             $block = $this->blocks->get($name);
69 70
 
70
-            if ($this->isReference($block)) {
71
+            if ($this->isReference($block))
72
+            {
71 73
                 // resolved on later stage
72 74
                 continue;
73 75
             }
74 76
 
75
-            if ($php->has($name)) {
77
+            if ($php->has($name))
78
+            {
76 79
                 $php->set($name, $this->trimPHP($this->blocks->claim($name)));
77 80
             }
78 81
         }
@@ -81,15 +84,18 @@  discard block
 block discarded – undo
81 84
         $node->tokens = token_get_all($node->content);
82 85
 
83 86
         $exists = new PHPMixin($node->tokens, self::PHP_MARCO_EXISTS_FUNCTION);
84
-        foreach ($this->blocks->getNames() as $name) {
87
+        foreach ($this->blocks->getNames() as $name)
88
+        {
85 89
             $block = $this->blocks->get($name);
86 90
 
87
-            if ($this->isReference($block)) {
91
+            if ($this->isReference($block))
92
+            {
88 93
                 // resolved on later stage
89 94
                 continue;
90 95
             }
91 96
 
92
-            if ($exists->has($name)) {
97
+            if ($exists->has($name))
98
+            {
93 99
                 $exists->set($name, 'true');
94 100
             }
95 101
         }
@@ -111,10 +117,13 @@  discard block
 block discarded – undo
111 117
      */
112 118
     private function isReference($node): bool
113 119
     {
114
-        switch (true) {
120
+        switch (true)
121
+        {
115 122
             case is_array($node):
116
-                foreach ($node as $child) {
117
-                    if ($this->isReference($child)) {
123
+                foreach ($node as $child)
124
+                {
125
+                    if ($this->isReference($child))
126
+                    {
118 127
                         return true;
119 128
                     }
120 129
                 }
@@ -125,8 +134,10 @@  discard block
 block discarded – undo
125 134
                 return $this->isReference($node->getValue());
126 135
 
127 136
             case $node instanceof Mixin:
128
-                foreach ($node->nodes as $child) {
129
-                    if ($this->isReference($child)) {
137
+                foreach ($node->nodes as $child)
138
+                {
139
+                    if ($this->isReference($child))
140
+                    {
130 141
                         return true;
131 142
                     }
132 143
                 }
@@ -146,10 +157,12 @@  discard block
 block discarded – undo
146 157
      */
147 158
     private function trimPHP($node): string
148 159
     {
149
-        switch (true) {
160
+        switch (true)
161
+        {
150 162
             case is_array($node):
151 163
                 $result = [];
152
-                foreach ($node as $child) {
164
+                foreach ($node as $child)
165
+                {
153 166
                     $result[] = $this->trimPHP($child);
154 167
                 }
155 168
 
@@ -157,7 +170,8 @@  discard block
 block discarded – undo
157 170
 
158 171
             case $node instanceof Mixin:
159 172
                 $result = [];
160
-                foreach ($node->nodes as $child) {
173
+                foreach ($node->nodes as $child)
174
+                {
161 175
                     $result[] = $this->trimPHP($child);
162 176
                 }
163 177
 
@@ -170,7 +184,8 @@  discard block
 block discarded – undo
170 184
                 return trim($node->body);
171 185
 
172 186
             case $node instanceof PHP:
173
-                if ($node->getContext()->getValue(PHP::ORIGINAL_BODY) !== null) {
187
+                if ($node->getContext()->getValue(PHP::ORIGINAL_BODY) !== null)
188
+                {
174 189
                     return $node->getContext()->getValue(PHP::ORIGINAL_BODY);
175 190
                 }
176 191
 
@@ -190,7 +205,8 @@  discard block
 block discarded – undo
190 205
     private function exportValue(Raw $node): string
191 206
     {
192 207
         $value = $node->content;
193
-        switch (true) {
208
+        switch (true)
209
+        {
194 210
             case strtolower($value) === 'true':
195 211
                 return 'true';
196 212
             case strtolower($value) === 'false':
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Visitor/DefineAttributes.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,15 +30,15 @@
 block discarded – undo
30 30
      */
31 31
     public function enterNode($node, VisitorContext $ctx)
32 32
     {
33
-        if (!$node instanceof Attr || $node->name !== self::AGGREGATE_ATTRIBUTE) {
33
+        if (!$node instanceof Attr || $node->name !== self::AGGREGATE_ATTRIBUTE){
34 34
             return null;
35 35
         }
36 36
 
37
-        if ($node->value instanceof Nil) {
37
+        if ($node->value instanceof Nil){
38 38
             return new Aggregate($node->getContext());
39 39
         }
40 40
 
41
-        if (!is_string($node->value)) {
41
+        if (!is_string($node->value)){
42 42
             return null;
43 43
         }
44 44
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,15 +30,18 @@
 block discarded – undo
30 30
      */
31 31
     public function enterNode($node, VisitorContext $ctx)
32 32
     {
33
-        if (!$node instanceof Attr || $node->name !== self::AGGREGATE_ATTRIBUTE) {
33
+        if (!$node instanceof Attr || $node->name !== self::AGGREGATE_ATTRIBUTE)
34
+        {
34 35
             return null;
35 36
         }
36 37
 
37
-        if ($node->value instanceof Nil) {
38
+        if ($node->value instanceof Nil)
39
+        {
38 40
             return new Aggregate($node->getContext());
39 41
         }
40 42
 
41
-        if (!is_string($node->value)) {
43
+        if (!is_string($node->value))
44
+        {
42 45
             return null;
43 46
         }
44 47
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Visitor/DefineStacks.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function enterNode($node, VisitorContext $ctx)
32 32
     {
33
-        if ($node instanceof Tag && strpos($node->name, $this->stackKeyword) === 0) {
33
+        if ($node instanceof Tag && strpos($node->name, $this->stackKeyword) === 0){
34 34
             return $this->registerAggregate(StackContext::on($ctx), $node);
35 35
         }
36 36
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     private function registerAggregate(StackContext $ctx, Tag $node)
53 53
     {
54 54
         $name = $this->stackName($node);
55
-        if ($name === null) {
55
+        if ($name === null){
56 56
             return $node;
57 57
         }
58 58
 
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
     private function stackName(Tag $tag): ?string
73 73
     {
74 74
         $options = [];
75
-        foreach ($tag->attrs as $attr) {
76
-            if (is_string($attr->value)) {
75
+        foreach ($tag->attrs as $attr){
76
+            if (is_string($attr->value)){
77 77
                 $options[$attr->name] = trim($attr->value, '\'"');
78 78
             }
79 79
         }
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
     private function stackLevel(Tag $tag): int
89 89
     {
90 90
         $options = [];
91
-        foreach ($tag->attrs as $attr) {
92
-            if (is_string($attr->value)) {
91
+        foreach ($tag->attrs as $attr){
92
+            if (is_string($attr->value)){
93 93
                 $options[$attr->name] = trim($attr->value, '\'"');
94 94
             }
95 95
         }
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,7 +30,8 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function enterNode($node, VisitorContext $ctx)
32 32
     {
33
-        if ($node instanceof Tag && strpos($node->name, $this->stackKeyword) === 0) {
33
+        if ($node instanceof Tag && strpos($node->name, $this->stackKeyword) === 0)
34
+        {
34 35
             return $this->registerAggregate(StackContext::on($ctx), $node);
35 36
         }
36 37
 
@@ -52,7 +53,8 @@  discard block
 block discarded – undo
52 53
     private function registerAggregate(StackContext $ctx, Tag $node)
53 54
     {
54 55
         $name = $this->stackName($node);
55
-        if ($name === null) {
56
+        if ($name === null)
57
+        {
56 58
             return $node;
57 59
         }
58 60
 
@@ -72,8 +74,10 @@  discard block
 block discarded – undo
72 74
     private function stackName(Tag $tag): ?string
73 75
     {
74 76
         $options = [];
75
-        foreach ($tag->attrs as $attr) {
76
-            if (is_string($attr->value)) {
77
+        foreach ($tag->attrs as $attr)
78
+        {
79
+            if (is_string($attr->value))
80
+            {
77 81
                 $options[$attr->name] = trim($attr->value, '\'"');
78 82
             }
79 83
         }
@@ -88,8 +92,10 @@  discard block
 block discarded – undo
88 92
     private function stackLevel(Tag $tag): int
89 93
     {
90 94
         $options = [];
91
-        foreach ($tag->attrs as $attr) {
92
-            if (is_string($attr->value)) {
95
+        foreach ($tag->attrs as $attr)
96
+        {
97
+            if (is_string($attr->value))
98
+            {
93 99
                 $options[$attr->name] = trim($attr->value, '\'"');
94 100
             }
95 101
         }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Visitor/DefineBlocks.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public function enterNode($node, VisitorContext $ctx)
35 35
     {
36
-        if ($node instanceof Tag) {
36
+        if ($node instanceof Tag){
37 37
             return $this->makeBlock($node);
38 38
         }
39 39
 
40
-        if ($node instanceof Inline) {
40
+        if ($node instanceof Inline){
41 41
             $block = new Block($node->name, $node->getContext());
42
-            if ($node->value !== null) {
42
+            if ($node->value !== null){
43 43
                 $block->nodes[] = new Raw($node->value);
44 44
             }
45 45
 
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
     private function makeBlock(Tag $node): ?NodeInterface
66 66
     {
67 67
         $name = null;
68
-        foreach ($this->prefix as $prefix) {
69
-            if (strpos($node->name, $prefix) === 0) {
68
+        foreach ($this->prefix as $prefix){
69
+            if (strpos($node->name, $prefix) === 0){
70 70
                 $name = substr($node->name, strlen($prefix));
71 71
                 break;
72 72
             }
73 73
         }
74 74
 
75
-        if ($name === null) {
75
+        if ($name === null){
76 76
             return null;
77 77
         }
78 78
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -33,13 +33,16 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public function enterNode($node, VisitorContext $ctx)
35 35
     {
36
-        if ($node instanceof Tag) {
36
+        if ($node instanceof Tag)
37
+        {
37 38
             return $this->makeBlock($node);
38 39
         }
39 40
 
40
-        if ($node instanceof Inline) {
41
+        if ($node instanceof Inline)
42
+        {
41 43
             $block = new Block($node->name, $node->getContext());
42
-            if ($node->value !== null) {
44
+            if ($node->value !== null)
45
+            {
43 46
                 $block->nodes[] = new Raw($node->value);
44 47
             }
45 48
 
@@ -65,14 +68,17 @@  discard block
 block discarded – undo
65 68
     private function makeBlock(Tag $node): ?NodeInterface
66 69
     {
67 70
         $name = null;
68
-        foreach ($this->prefix as $prefix) {
69
-            if (strpos($node->name, $prefix) === 0) {
71
+        foreach ($this->prefix as $prefix)
72
+        {
73
+            if (strpos($node->name, $prefix) === 0)
74
+            {
70 75
                 $name = substr($node->name, strlen($prefix));
71 76
                 break;
72 77
             }
73 78
         }
74 79
 
75
-        if ($name === null) {
80
+        if ($name === null)
81
+        {
76 82
             return null;
77 83
         }
78 84
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Visitor/DefineHidden.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
      */
34 34
     public function leaveNode($node, VisitorContext $ctx)
35 35
     {
36
-        if ($node instanceof Tag && strpos($node->name, $this->hiddenKeyword) === 0) {
36
+        if ($node instanceof Tag && strpos($node->name, $this->hiddenKeyword) === 0){
37 37
             return new Hidden([$node]);
38 38
         }
39 39
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,8 @@
 block discarded – undo
33 33
      */
34 34
     public function leaveNode($node, VisitorContext $ctx)
35 35
     {
36
-        if ($node instanceof Tag && strpos($node->name, $this->hiddenKeyword) === 0) {
36
+        if ($node instanceof Tag && strpos($node->name, $this->hiddenKeyword) === 0)
37
+        {
37 38
             return new Hidden([$node]);
38 39
         }
39 40
 
Please login to merge, or discard this patch.