Passed
Pull Request — master (#370)
by Valentin
04:51
created
src/Stempler/src/Transform/Context/StackContext.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -51,17 +51,17 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function push(string $name, Tag $child, string $uniqueID = null): bool
53 53
     {
54
-        foreach ($this->getStacks() as $stack) {
55
-            if ($stack->accepts($name) !== $name) {
54
+        foreach ($this->getStacks() as $stack){
55
+            if ($stack->accepts($name) !== $name){
56 56
                 continue;
57 57
             }
58 58
 
59
-            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID])) {
59
+            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID])){
60 60
                 return true;
61 61
             }
62 62
             $stack->uniqueIDs[$uniqueID] = true;
63 63
 
64
-            foreach ($child->nodes as $child) {
64
+            foreach ($child->nodes as $child){
65 65
                 $stack->nodes[] = $child;
66 66
             }
67 67
 
@@ -79,17 +79,17 @@  discard block
 block discarded – undo
79 79
      */
80 80
     public function prepend(string $name, Tag $child, string $uniqueID = null): bool
81 81
     {
82
-        foreach ($this->getStacks() as $stack) {
83
-            if ($stack->accepts($name) !== $name) {
82
+        foreach ($this->getStacks() as $stack){
83
+            if ($stack->accepts($name) !== $name){
84 84
                 continue;
85 85
             }
86 86
 
87
-            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID])) {
87
+            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID])){
88 88
                 return true;
89 89
             }
90 90
             $stack->uniqueIDs[$uniqueID] = true;
91 91
 
92
-            foreach ($child->nodes as $child) {
92
+            foreach ($child->nodes as $child){
93 93
                 array_unshift($stack->nodes, $child);
94 94
             }
95 95
 
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
     public function getStacks(): array
108 108
     {
109 109
         $stacks = [];
110
-        foreach (array_reverse($this->ctx->getScope()) as $node) {
111
-            if ($node instanceof AttributedInterface) {
112
-                foreach ($node->getAttribute(self::class, []) as $stack) {
110
+        foreach (array_reverse($this->ctx->getScope()) as $node){
111
+            if ($node instanceof AttributedInterface){
112
+                foreach ($node->getAttribute(self::class, []) as $stack){
113 113
                     $stacks[] = $stack;
114 114
                 }
115 115
             }
@@ -133,16 +133,16 @@  discard block
 block discarded – undo
133 133
      */
134 134
     private function getStackRootNode(int $level): AttributedInterface
135 135
     {
136
-        if ($level === 0) {
136
+        if ($level === 0){
137 137
             $node = $this->ctx->getParentNode();
138
-        } else {
138
+        }else{
139 139
             $scope = $this->ctx->getScope();
140 140
 
141 141
             // looking for the parent node via given nesting level
142 142
             $node = $scope[count($scope) - 2 - $level] ?? $this->ctx->getFirstNode();
143 143
         }
144 144
 
145
-        if (!$node instanceof AttributedInterface) {
145
+        if (!$node instanceof AttributedInterface){
146 146
             throw new \LogicException(
147 147
                 sprintf(
148 148
                     '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
@@ -51,17 +51,21 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function push(string $name, Tag $child, string $uniqueID = null): bool
53 53
     {
54
-        foreach ($this->getStacks() as $stack) {
55
-            if ($stack->accepts($name) !== $name) {
54
+        foreach ($this->getStacks() as $stack)
55
+        {
56
+            if ($stack->accepts($name) !== $name)
57
+            {
56 58
                 continue;
57 59
             }
58 60
 
59
-            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID])) {
61
+            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID]))
62
+            {
60 63
                 return true;
61 64
             }
62 65
             $stack->uniqueIDs[$uniqueID] = true;
63 66
 
64
-            foreach ($child->nodes as $child) {
67
+            foreach ($child->nodes as $child)
68
+            {
65 69
                 $stack->nodes[] = $child;
66 70
             }
67 71
 
@@ -79,17 +83,21 @@  discard block
 block discarded – undo
79 83
      */
80 84
     public function prepend(string $name, Tag $child, string $uniqueID = null): bool
81 85
     {
82
-        foreach ($this->getStacks() as $stack) {
83
-            if ($stack->accepts($name) !== $name) {
86
+        foreach ($this->getStacks() as $stack)
87
+        {
88
+            if ($stack->accepts($name) !== $name)
89
+            {
84 90
                 continue;
85 91
             }
86 92
 
87
-            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID])) {
93
+            if ($uniqueID !== null && isset($stack->uniqueIDs[$uniqueID]))
94
+            {
88 95
                 return true;
89 96
             }
90 97
             $stack->uniqueIDs[$uniqueID] = true;
91 98
 
92
-            foreach ($child->nodes as $child) {
99
+            foreach ($child->nodes as $child)
100
+            {
93 101
                 array_unshift($stack->nodes, $child);
94 102
             }
95 103
 
@@ -107,9 +115,12 @@  discard block
 block discarded – undo
107 115
     public function getStacks(): array
108 116
     {
109 117
         $stacks = [];
110
-        foreach (array_reverse($this->ctx->getScope()) as $node) {
111
-            if ($node instanceof AttributedInterface) {
112
-                foreach ($node->getAttribute(self::class, []) as $stack) {
118
+        foreach (array_reverse($this->ctx->getScope()) as $node)
119
+        {
120
+            if ($node instanceof AttributedInterface)
121
+            {
122
+                foreach ($node->getAttribute(self::class, []) as $stack)
123
+                {
113 124
                     $stacks[] = $stack;
114 125
                 }
115 126
             }
@@ -133,16 +144,20 @@  discard block
 block discarded – undo
133 144
      */
134 145
     private function getStackRootNode(int $level): AttributedInterface
135 146
     {
136
-        if ($level === 0) {
147
+        if ($level === 0)
148
+        {
137 149
             $node = $this->ctx->getParentNode();
138
-        } else {
150
+        }
151
+        else
152
+        {
139 153
             $scope = $this->ctx->getScope();
140 154
 
141 155
             // looking for the parent node via given nesting level
142 156
             $node = $scope[count($scope) - 2 - $level] ?? $this->ctx->getFirstNode();
143 157
         }
144 158
 
145
-        if (!$node instanceof AttributedInterface) {
159
+        if (!$node instanceof AttributedInterface)
160
+        {
146 161
             throw new \LogicException(
147 162
                 sprintf(
148 163
                     'Unable to create import on node without attribute storage (%s)',
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
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     public function add(ImportInterface $import): void
42 42
     {
43 43
         $node = $this->ctx->getParentNode();
44
-        if (!$node instanceof AttributedInterface) {
44
+        if (!$node instanceof AttributedInterface){
45 45
             throw new LogicException(sprintf(
46 46
                 'Unable to create import on node without attribute storage (%s)',
47 47
                 is_object($node) ? get_class($node) : gettype($node)
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public function resolve(Builder $builder, string $name): ?Template
66 66
     {
67
-        foreach ($this->getImports() as $import) {
67
+        foreach ($this->getImports() as $import){
68 68
             $tpl = $import->resolve($builder, $name);
69
-            if ($tpl !== null) {
69
+            if ($tpl !== null){
70 70
                 return $tpl;
71 71
             }
72 72
         }
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
     public function getImports(): array
83 83
     {
84 84
         $imports = [];
85
-        foreach (array_reverse($this->ctx->getScope()) as $node) {
86
-            if ($node instanceof AttributedInterface) {
87
-                foreach ($node->getAttribute(self::class, []) as $import) {
85
+        foreach (array_reverse($this->ctx->getScope()) as $node){
86
+            if ($node instanceof AttributedInterface){
87
+                foreach ($node->getAttribute(self::class, []) as $import){
88 88
                     $imports[] = $import;
89 89
                 }
90 90
             }
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,7 +41,8 @@  discard block
 block discarded – undo
41 41
     public function add(ImportInterface $import): void
42 42
     {
43 43
         $node = $this->ctx->getParentNode();
44
-        if (!$node instanceof AttributedInterface) {
44
+        if (!$node instanceof AttributedInterface)
45
+        {
45 46
             throw new LogicException(sprintf(
46 47
                 'Unable to create import on node without attribute storage (%s)',
47 48
                 is_object($node) ? get_class($node) : gettype($node)
@@ -64,9 +65,11 @@  discard block
 block discarded – undo
64 65
      */
65 66
     public function resolve(Builder $builder, string $name): ?Template
66 67
     {
67
-        foreach ($this->getImports() as $import) {
68
+        foreach ($this->getImports() as $import)
69
+        {
68 70
             $tpl = $import->resolve($builder, $name);
69
-            if ($tpl !== null) {
71
+            if ($tpl !== null)
72
+            {
70 73
                 return $tpl;
71 74
             }
72 75
         }
@@ -82,9 +85,12 @@  discard block
 block discarded – undo
82 85
     public function getImports(): array
83 86
     {
84 87
         $imports = [];
85
-        foreach (array_reverse($this->ctx->getScope()) as $node) {
86
-            if ($node instanceof AttributedInterface) {
87
-                foreach ($node->getAttribute(self::class, []) as $import) {
88
+        foreach (array_reverse($this->ctx->getScope()) as $node)
89
+        {
90
+            if ($node instanceof AttributedInterface)
91
+            {
92
+                foreach ($node->getAttribute(self::class, []) as $import)
93
+                {
88 94
                     $imports[] = $import;
89 95
                 }
90 96
             }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/BlockFetcher.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
     {
32 32
         $blocks = ['context' => []];
33 33
 
34
-        foreach ($caller->attrs as $attr) {
35
-            if (!$attr instanceof Attr || $attr->name instanceof NodeInterface) {
34
+        foreach ($caller->attrs as $attr){
35
+            if (!$attr instanceof Attr || $attr->name instanceof NodeInterface){
36 36
                 // ignore name when attribute is dynamic
37 37
                 $blocks[sprintf('attr-%s', count($blocks))] = $attr;
38 38
                 continue;
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
             $blocks[$attr->name] = new QuotedValue($attr->value);
43 43
         }
44 44
 
45
-        foreach ($caller->nodes as $node) {
46
-            if ($node instanceof Block) {
45
+        foreach ($caller->nodes as $node){
46
+            if ($node instanceof Block){
47 47
                 $blocks[$node->name] = $node->nodes;
48
-            } else {
48
+            }else{
49 49
                 $blocks['context'][] = $node;
50 50
             }
51 51
         }
52 52
 
53
-        if ($blocks['context'] === []) {
53
+        if ($blocks['context'] === []){
54 54
             unset($blocks['context']);
55 55
         }
56 56
 
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,8 +31,10 @@  discard block
 block discarded – undo
31 31
     {
32 32
         $blocks = ['context' => []];
33 33
 
34
-        foreach ($caller->attrs as $attr) {
35
-            if (!$attr instanceof Attr || $attr->name instanceof NodeInterface) {
34
+        foreach ($caller->attrs as $attr)
35
+        {
36
+            if (!$attr instanceof Attr || $attr->name instanceof NodeInterface)
37
+            {
36 38
                 // ignore name when attribute is dynamic
37 39
                 $blocks[sprintf('attr-%s', count($blocks))] = $attr;
38 40
                 continue;
@@ -42,15 +44,20 @@  discard block
 block discarded – undo
42 44
             $blocks[$attr->name] = new QuotedValue($attr->value);
43 45
         }
44 46
 
45
-        foreach ($caller->nodes as $node) {
46
-            if ($node instanceof Block) {
47
+        foreach ($caller->nodes as $node)
48
+        {
49
+            if ($node instanceof Block)
50
+            {
47 51
                 $blocks[$node->name] = $node->nodes;
48
-            } else {
52
+            }
53
+            else
54
+            {
49 55
                 $blocks['context'][] = $node;
50 56
             }
51 57
         }
52 58
 
53
-        if ($blocks['context'] === []) {
59
+        if ($blocks['context'] === [])
60
+        {
54 61
             unset($blocks['context']);
55 62
         }
56 63
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Merger.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@
 block discarded – undo
96 96
     protected function traverse(array $nodes, VisitorInterface ...$visitors)
97 97
     {
98 98
         $traverser = new Traverser();
99
-        foreach ($visitors as $visitor) {
99
+        foreach ($visitors as $visitor){
100 100
             $traverser->addVisitor($visitor);
101 101
         }
102 102
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,8 @@
 block discarded – undo
96 96
     protected function traverse(array $nodes, VisitorInterface ...$visitors)
97 97
     {
98 98
         $traverser = new Traverser();
99
-        foreach ($visitors as $visitor) {
99
+        foreach ($visitors as $visitor)
100
+        {
100 101
             $traverser->addVisitor($visitor);
101 102
         }
102 103
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Finalizer/IsolateBlocks.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
      */
37 37
     public function enterNode($node, VisitorContext $ctx): void
38 38
     {
39
-        if ($node instanceof Block && $node->getContext()->getPath() === $this->path) {
39
+        if ($node instanceof Block && $node->getContext()->getPath() === $this->path){
40 40
             $node->name = null;
41 41
         }
42 42
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,8 @@
 block discarded – undo
36 36
      */
37 37
     public function enterNode($node, VisitorContext $ctx): void
38 38
     {
39
-        if ($node instanceof Block && $node->getContext()->getPath() === $this->path) {
39
+        if ($node instanceof Block && $node->getContext()->getPath() === $this->path)
40
+        {
40 41
             $node->name = null;
41 42
         }
42 43
     }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Finalizer/TrimRaw.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,9 +44,9 @@
 block discarded – undo
44 44
      */
45 45
     public function leaveNode($node, VisitorContext $ctx)
46 46
     {
47
-        if ($node instanceof Raw && trim($node->content, $this->trim) === '') {
48
-            foreach ($ctx->getScope() as $scope) {
49
-                if ($scope instanceof Attr) {
47
+        if ($node instanceof Raw && trim($node->content, $this->trim) === ''){
48
+            foreach ($ctx->getScope() as $scope){
49
+                if ($scope instanceof Attr){
50 50
                     // do not trim attribute values
51 51
                     return null;
52 52
                 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,9 +44,12 @@
 block discarded – undo
44 44
      */
45 45
     public function leaveNode($node, VisitorContext $ctx)
46 46
     {
47
-        if ($node instanceof Raw && trim($node->content, $this->trim) === '') {
48
-            foreach ($ctx->getScope() as $scope) {
49
-                if ($scope instanceof Attr) {
47
+        if ($node instanceof Raw && trim($node->content, $this->trim) === '')
48
+        {
49
+            foreach ($ctx->getScope() as $scope)
50
+            {
51
+                if ($scope instanceof Attr)
52
+                {
50 53
                     // do not trim attribute values
51 54
                     return null;
52 55
                 }
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Import/Element.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         $this->path = $path;
40 40
         $this->alias = $alias ?? $path;
41 41
 
42
-        if ($alias === null && strrpos($this->alias, '/') !== false) {
42
+        if ($alias === null && strrpos($this->alias, '/') !== false){
43 43
             $this->alias = substr($this->alias, strrpos($this->alias, '/') + 1);
44 44
         }
45 45
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function resolve(Builder $builder, string $name): ?Template
69 69
     {
70
-        if ($this->alias !== $name) {
70
+        if ($this->alias !== $name){
71 71
             return null;
72 72
         }
73 73
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,8 @@  discard block
 block discarded – undo
39 39
         $this->path = $path;
40 40
         $this->alias = $alias ?? $path;
41 41
 
42
-        if ($alias === null && strrpos($this->alias, '/') !== false) {
42
+        if ($alias === null && strrpos($this->alias, '/') !== false)
43
+        {
43 44
             $this->alias = substr($this->alias, strrpos($this->alias, '/') + 1);
44 45
         }
45 46
 
@@ -67,7 +68,8 @@  discard block
 block discarded – undo
67 68
      */
68 69
     public function resolve(Builder $builder, string $name): ?Template
69 70
     {
70
-        if ($this->alias !== $name) {
71
+        if ($this->alias !== $name)
72
+        {
71 73
             return null;
72 74
         }
73 75
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Import/Inline.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
      */
47 47
     public function resolve(Builder $builder, string $name): ?Template
48 48
     {
49
-        if ($name !== $this->name) {
49
+        if ($name !== $this->name){
50 50
             return null;
51 51
         }
52 52
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,8 @@
 block discarded – undo
46 46
      */
47 47
     public function resolve(Builder $builder, string $name): ?Template
48 48
     {
49
-        if ($name !== $this->name) {
49
+        if ($name !== $this->name)
50
+        {
50 51
             return null;
51 52
         }
52 53
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Import/Directory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,6 +49,6 @@
 block discarded – undo
49 49
         $path = substr($name, strlen($this->prefix) + 1);
50 50
         $path = str_replace('.', DIRECTORY_SEPARATOR, $path);
51 51
 
52
-        return $builder->load($this->path . DIRECTORY_SEPARATOR . $path);
52
+        return $builder->load($this->path.DIRECTORY_SEPARATOR.$path);
53 53
     }
54 54
 }
Please login to merge, or discard this patch.