Passed
Pull Request — master (#361)
by Valentin
05:14
created
src/Prototype/src/Command/ListCommand.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     public function perform(): void
23 23
     {
24 24
         $prototyped = $this->locator->getTargetClasses();
25
-        if ($prototyped === []) {
25
+        if ($prototyped === []){
26 26
             $this->writeln('<comment>No prototyped classes found.</comment>');
27 27
 
28 28
             return;
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
         $grid = $this->table(['Class:', 'Property:', 'Target:']);
32 32
 
33
-        foreach ($prototyped as $class) {
33
+        foreach ($prototyped as $class){
34 34
             $proto = $this->getPrototypeProperties($class, $prototyped);
35 35
 
36 36
             $grid->addRow([$class->getName(), $this->mergeNames($proto), $this->mergeTargets($proto)]);
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,8 @@  discard block
 block discarded – undo
22 22
     public function perform(): void
23 23
     {
24 24
         $prototyped = $this->locator->getTargetClasses();
25
-        if ($prototyped === []) {
25
+        if ($prototyped === [])
26
+        {
26 27
             $this->writeln('<comment>No prototyped classes found.</comment>');
27 28
 
28 29
             return;
@@ -30,7 +31,8 @@  discard block
 block discarded – undo
30 31
 
31 32
         $grid = $this->table(['Class:', 'Property:', 'Target:']);
32 33
 
33
-        foreach ($prototyped as $class) {
34
+        foreach ($prototyped as $class)
35
+        {
34 36
             $proto = $this->getPrototypeProperties($class, $prototyped);
35 37
 
36 38
             $grid->addRow([$class->getName(), $this->mergeNames($proto), $this->mergeTargets($proto)]);
Please login to merge, or discard this patch.
src/Prototype/src/Command/AbstractCommand.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         $results = [$this->readProperties($class)];
59 59
 
60 60
         $parent = $class->getParentClass();
61
-        while ($parent instanceof \ReflectionClass && isset($all[$parent->getName()])) {
61
+        while ($parent instanceof \ReflectionClass && isset($all[$parent->getName()])){
62 62
             $results[] = $this->readProperties($parent);
63 63
             $parent = $parent->getParentClass();
64 64
         }
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
     {
92 92
         $result = [];
93 93
 
94
-        foreach ($properties as $target) {
95
-            if ($target instanceof \Throwable) {
94
+        foreach ($properties as $target){
95
+            if ($target instanceof \Throwable){
96 96
                 $result[] = sprintf(
97 97
                     '<fg=red>%s [f: %s, l: %s]</fg=red>',
98 98
                     $target->getMessage(),
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                 continue;
103 103
             }
104 104
 
105
-            if ($target === null) {
105
+            if ($target === null){
106 106
                 $result[] = '<fg=yellow>undefined</fg=yellow>';
107 107
                 continue;
108 108
             }
@@ -115,16 +115,16 @@  discard block
 block discarded – undo
115 115
 
116 116
     private function readProperties(\ReflectionClass $class): array
117 117
     {
118
-        if (isset($this->cache[$class->getFileName()])) {
118
+        if (isset($this->cache[$class->getFileName()])){
119 119
             $proto = $this->cache[$class->getFileName()];
120
-        } else {
120
+        }else{
121 121
             $proto = $this->getExtractor()->getPrototypeProperties(file_get_contents($class->getFilename()));
122 122
             $this->cache[$class->getFileName()] = $proto;
123 123
         }
124 124
 
125 125
         $result = [];
126
-        foreach ($proto as $name) {
127
-            if (!isset($result[$name])) {
126
+        foreach ($proto as $name){
127
+            if (!isset($result[$name])){
128 128
                 $result[$name] = $this->registry->resolveProperty($name);
129 129
             }
130 130
         }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
     private function reverse(array $results): ?\Generator
136 136
     {
137
-        foreach (array_reverse($results) as $result) {
137
+        foreach (array_reverse($results) as $result){
138 138
             yield from $result;
139 139
         }
140 140
     }
Please login to merge, or discard this patch.
Braces   +19 added lines, -9 removed lines patch added patch discarded remove patch
@@ -58,7 +58,8 @@  discard block
 block discarded – undo
58 58
         $results = [$this->readProperties($class)];
59 59
 
60 60
         $parent = $class->getParentClass();
61
-        while ($parent instanceof \ReflectionClass && isset($all[$parent->getName()])) {
61
+        while ($parent instanceof \ReflectionClass && isset($all[$parent->getName()]))
62
+        {
62 63
             $results[] = $this->readProperties($parent);
63 64
             $parent = $parent->getParentClass();
64 65
         }
@@ -91,8 +92,10 @@  discard block
 block discarded – undo
91 92
     {
92 93
         $result = [];
93 94
 
94
-        foreach ($properties as $target) {
95
-            if ($target instanceof \Throwable) {
95
+        foreach ($properties as $target)
96
+        {
97
+            if ($target instanceof \Throwable)
98
+            {
96 99
                 $result[] = sprintf(
97 100
                     '<fg=red>%s [f: %s, l: %s]</fg=red>',
98 101
                     $target->getMessage(),
@@ -102,7 +105,8 @@  discard block
 block discarded – undo
102 105
                 continue;
103 106
             }
104 107
 
105
-            if ($target === null) {
108
+            if ($target === null)
109
+            {
106 110
                 $result[] = '<fg=yellow>undefined</fg=yellow>';
107 111
                 continue;
108 112
             }
@@ -115,16 +119,21 @@  discard block
 block discarded – undo
115 119
 
116 120
     private function readProperties(\ReflectionClass $class): array
117 121
     {
118
-        if (isset($this->cache[$class->getFileName()])) {
122
+        if (isset($this->cache[$class->getFileName()]))
123
+        {
119 124
             $proto = $this->cache[$class->getFileName()];
120
-        } else {
125
+        }
126
+        else
127
+        {
121 128
             $proto = $this->getExtractor()->getPrototypeProperties(file_get_contents($class->getFilename()));
122 129
             $this->cache[$class->getFileName()] = $proto;
123 130
         }
124 131
 
125 132
         $result = [];
126
-        foreach ($proto as $name) {
127
-            if (!isset($result[$name])) {
133
+        foreach ($proto as $name)
134
+        {
135
+            if (!isset($result[$name]))
136
+            {
128 137
                 $result[$name] = $this->registry->resolveProperty($name);
129 138
             }
130 139
         }
@@ -134,7 +143,8 @@  discard block
 block discarded – undo
134 143
 
135 144
     private function reverse(array $results): ?\Generator
136 145
     {
137
-        foreach (array_reverse($results) as $result) {
146
+        foreach (array_reverse($results) as $result)
147
+        {
138 148
             yield from $result;
139 149
         }
140 150
     }
Please login to merge, or discard this patch.
src/Prototype/src/Command/InjectCommand.php 2 patches
Braces   +25 added lines, -12 removed lines patch added patch discarded remove patch
@@ -55,7 +55,8 @@  discard block
 block discarded – undo
55 55
     public function perform(): void
56 56
     {
57 57
         $prototyped = $this->locator->getTargetClasses();
58
-        if ($prototyped === []) {
58
+        if ($prototyped === [])
59
+        {
59 60
             $this->writeln('<comment>No prototyped classes found.</comment>');
60 61
 
61 62
             return;
@@ -63,18 +64,23 @@  discard block
 block discarded – undo
63 64
 
64 65
         $targets = [];
65 66
 
66
-        foreach ($prototyped as $class) {
67
+        foreach ($prototyped as $class)
68
+        {
67 69
             $proto = $this->getPrototypeProperties($class, $prototyped);
68
-            if (empty($proto)) {
70
+            if (empty($proto))
71
+            {
69 72
                 $modified = $this->modify($class, $proto);
70
-                if ($modified !== null) {
73
+                if ($modified !== null)
74
+                {
71 75
                     $targets[] = $modified;
72 76
                 }
73 77
                 continue;
74 78
             }
75 79
 
76
-            foreach ($proto as $target) {
77
-                if ($target instanceof \Throwable) {
80
+            foreach ($proto as $target)
81
+            {
82
+                if ($target instanceof \Throwable)
83
+                {
78 84
                     $targets[] = [
79 85
                         $class->getName(),
80 86
                         $target->getMessage(),
@@ -83,7 +89,8 @@  discard block
 block discarded – undo
83 89
                     continue 2;
84 90
                 }
85 91
 
86
-                if ($target === null) {
92
+                if ($target === null)
93
+                {
87 94
                     continue 2;
88 95
                 }
89 96
             }
@@ -91,14 +98,17 @@  discard block
 block discarded – undo
91 98
             $targets[] = [$class->getName(), $this->mergeNames($proto), $this->mergeTargets($proto)];
92 99
 
93 100
             $modified = $this->modify($class, $proto);
94
-            if ($modified !== null) {
101
+            if ($modified !== null)
102
+            {
95 103
                 $targets[] = $modified;
96 104
             }
97 105
         }
98 106
 
99
-        if (!empty($targets)) {
107
+        if (!empty($targets))
108
+        {
100 109
             $grid = $this->table(['Class:', 'Property:', 'Target:']);
101
-            foreach ($targets as $target) {
110
+            foreach ($targets as $target)
111
+            {
102 112
                 $grid->addRow($target);
103 113
             }
104 114
 
@@ -109,7 +119,8 @@  discard block
 block discarded – undo
109 119
     private function modify(\ReflectionClass $class, array $proto): ?array
110 120
     {
111 121
         $classDefinition = $this->extractor->extract($class->getFilename(), $proto);
112
-        try {
122
+        try
123
+        {
113 124
             $modified = $this->injector->injectDependencies(
114 125
                 file_get_contents($class->getFileName()),
115 126
                 $classDefinition,
@@ -120,7 +131,9 @@  discard block
 block discarded – undo
120 131
 
121 132
             file_put_contents($class->getFileName(), $modified);
122 133
             return null;
123
-        } catch (\Throwable $e) {
134
+        }
135
+        catch (\Throwable $e)
136
+        {
124 137
             return [$class->getName(), $e->getMessage(), "{$e->getFile()}:L{$e->getLine()}"];
125 138
         }
126 139
     }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     public function perform(): void
52 52
     {
53 53
         $prototyped = $this->locator->getTargetClasses();
54
-        if ($prototyped === []) {
54
+        if ($prototyped === []){
55 55
             $this->writeln('<comment>No prototyped classes found.</comment>');
56 56
 
57 57
             return;
@@ -59,18 +59,18 @@  discard block
 block discarded – undo
59 59
 
60 60
         $targets = [];
61 61
 
62
-        foreach ($prototyped as $class) {
62
+        foreach ($prototyped as $class){
63 63
             $proto = $this->getPrototypeProperties($class, $prototyped);
64
-            if (empty($proto)) {
64
+            if (empty($proto)){
65 65
                 $modified = $this->modify($class, $proto);
66
-                if ($modified !== null) {
66
+                if ($modified !== null){
67 67
                     $targets[] = $modified;
68 68
                 }
69 69
                 continue;
70 70
             }
71 71
 
72
-            foreach ($proto as $target) {
73
-                if ($target instanceof \Throwable) {
72
+            foreach ($proto as $target){
73
+                if ($target instanceof \Throwable){
74 74
                     $targets[] = [
75 75
                         $class->getName(),
76 76
                         $target->getMessage(),
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                     continue 2;
80 80
                 }
81 81
 
82
-                if ($target === null) {
82
+                if ($target === null){
83 83
                     continue 2;
84 84
                 }
85 85
             }
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
             $targets[] = [$class->getName(), $this->mergeNames($proto), $this->mergeTargets($proto)];
88 88
 
89 89
             $modified = $this->modify($class, $proto);
90
-            if ($modified !== null) {
90
+            if ($modified !== null){
91 91
                 $targets[] = $modified;
92 92
             }
93 93
         }
94 94
 
95
-        if (!empty($targets)) {
95
+        if (!empty($targets)){
96 96
             $grid = $this->table(['Class:', 'Property:', 'Target:']);
97
-            foreach ($targets as $target) {
97
+            foreach ($targets as $target){
98 98
                 $grid->addRow($target);
99 99
             }
100 100
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     private function modify(\ReflectionClass $class, array $proto): ?array
106 106
     {
107 107
         $classDefinition = $this->extractor->extract($class->getFilename(), $proto);
108
-        try {
108
+        try{
109 109
             $modified = $this->injector->injectDependencies(
110 110
                 file_get_contents($class->getFileName()),
111 111
                 $classDefinition,
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
             file_put_contents($class->getFileName(), $modified);
118 118
             return null;
119
-        } catch (\Throwable $e) {
119
+        }catch (\Throwable $e){
120 120
             return [$class->getName(), $e->getMessage(), "{$e->getFile()}:L{$e->getLine()}"];
121 121
         }
122 122
     }
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/UpdateConstructor.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function leaveNode(Node $node)
44 44
     {
45
-        if (!$node instanceof Node\Stmt\Class_) {
45
+        if (!$node instanceof Node\Stmt\Class_){
46 46
             return null;
47 47
         }
48 48
 
49 49
         $constructor = $this->getConstructorAttribute($node);
50
-        if (!$this->definition->hasConstructor && $this->definition->constructorParams) {
50
+        if (!$this->definition->hasConstructor && $this->definition->constructorParams){
51 51
             $this->addParentConstructorCall($constructor);
52 52
         }
53 53
         $this->addDependencies($constructor);
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     private function addDependencies(Node\Stmt\ClassMethod $constructor): void
68 68
     {
69
-        foreach ($this->definition->dependencies as $dependency) {
69
+        foreach ($this->definition->dependencies as $dependency){
70 70
             $constructor->params[] = (new Param($dependency->var))->setType(
71 71
                 new Node\Name($this->getPropertyType($dependency))
72 72
             )->getNode();
@@ -91,34 +91,34 @@  discard block
 block discarded – undo
91 91
     private function addParentConstructorCall(Node\Stmt\ClassMethod $constructor): void
92 92
     {
93 93
         $parentConstructorDependencies = [];
94
-        foreach ($this->definition->constructorParams as $param) {
94
+        foreach ($this->definition->constructorParams as $param){
95 95
             $parentConstructorDependencies[] = new Node\Arg(new Node\Expr\Variable($param->name));
96 96
 
97 97
             $cp = new Param($param->name);
98
-            if (!empty($param->type)) {
98
+            if (!empty($param->type)){
99 99
                 $type = $this->getParamType($param);
100
-                if ($param->nullable) {
100
+                if ($param->nullable){
101 101
                     $type = "?$type";
102 102
                 }
103 103
 
104 104
                 $cp->setType(new Node\Name($type));
105 105
             }
106 106
 
107
-            if ($param->byRef) {
107
+            if ($param->byRef){
108 108
                 $cp->makeByRef();
109 109
             }
110 110
 
111
-            if ($param->isVariadic) {
111
+            if ($param->isVariadic){
112 112
                 $cp->makeVariadic();
113 113
             }
114 114
 
115
-            if ($param->hasDefault) {
115
+            if ($param->hasDefault){
116 116
                 $cp->setDefault($param->default);
117 117
             }
118 118
             $constructor->params[] = $cp->getNode();
119 119
         }
120 120
 
121
-        if ($parentConstructorDependencies) {
121
+        if ($parentConstructorDependencies){
122 122
             array_unshift(
123 123
                 $constructor->stmts,
124 124
                 new Node\Stmt\Expression(
@@ -153,18 +153,18 @@  discard block
 block discarded – undo
153 153
 
154 154
         $params = [];
155 155
 
156
-        foreach ($this->definition->dependencies as $dependency) {
156
+        foreach ($this->definition->dependencies as $dependency){
157 157
             $params[] = new Annotation\Line(
158 158
                 sprintf('%s $%s', $this->getPropertyType($dependency), $dependency->var),
159 159
                 'param'
160 160
             );
161 161
         }
162 162
 
163
-        if (!$this->definition->hasConstructor) {
164
-            foreach ($this->definition->constructorParams as $param) {
165
-                if (!empty($param->type)) {
163
+        if (!$this->definition->hasConstructor){
164
+            foreach ($this->definition->constructorParams as $param){
165
+                if (!empty($param->type)){
166 166
                     $type = $this->getParamType($param);
167
-                    if ($param->nullable) {
167
+                    if ($param->nullable){
168 168
                         $type = "$type|null";
169 169
                     }
170 170
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
                         sprintf($param->isVariadic ? '%s ...$%s' : '%s $%s', $type, $param->name),
173 173
                         'param'
174 174
                     );
175
-                } else {
175
+                }else{
176 176
                     $params[] = new Annotation\Line(
177 177
                         sprintf('$%s', $param->name),
178 178
                         'param'
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
 
184 184
         $placementID = 0;
185 185
         $previous = null;
186
-        foreach ($an->lines as $index => $line) {
186
+        foreach ($an->lines as $index => $line){
187 187
             // always next node
188 188
             $placementID = $index + 1;
189 189
 
190 190
             // inject before this parameters
191
-            if ($line->is(['throws', 'return'])) {
191
+            if ($line->is(['throws', 'return'])){
192 192
                 // insert before given node
193 193
                 $placementID--;
194 194
                 break;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             $previous = $line;
198 198
         }
199 199
 
200
-        if ($previous !== null && !$previous->isEmpty()) {
200
+        if ($previous !== null && !$previous->isEmpty()){
201 201
             $placementID++;
202 202
         }
203 203
 
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
      */
213 213
     private function getPropertyType(Dependency $dependency): string
214 214
     {
215
-        foreach ($this->definition->getStmts() as $stmt) {
216
-            if ($stmt->name === $dependency->type->fullName) {
217
-                if ($stmt->alias) {
215
+        foreach ($this->definition->getStmts() as $stmt){
216
+            if ($stmt->name === $dependency->type->fullName){
217
+                if ($stmt->alias){
218 218
                     return $stmt->alias;
219 219
                 }
220 220
             }
@@ -229,15 +229,15 @@  discard block
 block discarded – undo
229 229
      */
230 230
     private function getParamType(ClassNode\ConstructorParam $param): string
231 231
     {
232
-        foreach ($this->definition->getStmts() as $stmt) {
233
-            if ($stmt->name === $param->type->fullName) {
234
-                if ($stmt->alias) {
232
+        foreach ($this->definition->getStmts() as $stmt){
233
+            if ($stmt->name === $param->type->fullName){
234
+                if ($stmt->alias){
235 235
                     return $stmt->alias;
236 236
                 }
237 237
             }
238 238
         }
239 239
 
240
-        if ($param->type->alias) {
240
+        if ($param->type->alias){
241 241
             return $param->type->alias;
242 242
         }
243 243
 
Please login to merge, or discard this patch.
Braces   +53 added lines, -26 removed lines patch added patch discarded remove patch
@@ -42,12 +42,14 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function leaveNode(Node $node)
44 44
     {
45
-        if (!$node instanceof Node\Stmt\Class_) {
45
+        if (!$node instanceof Node\Stmt\Class_)
46
+        {
46 47
             return null;
47 48
         }
48 49
 
49 50
         $constructor = $this->getConstructorAttribute($node);
50
-        if (!$this->definition->hasConstructor && $this->definition->constructorParams) {
51
+        if (!$this->definition->hasConstructor && $this->definition->constructorParams)
52
+        {
51 53
             $this->addParentConstructorCall($constructor);
52 54
         }
53 55
         $this->addDependencies($constructor);
@@ -66,7 +68,8 @@  discard block
 block discarded – undo
66 68
      */
67 69
     private function addDependencies(Node\Stmt\ClassMethod $constructor): void
68 70
     {
69
-        foreach ($this->definition->dependencies as $dependency) {
71
+        foreach ($this->definition->dependencies as $dependency)
72
+        {
70 73
             $constructor->params[] = (new Param($dependency->var))->setType(
71 74
                 new Node\Name($this->getPropertyType($dependency))
72 75
             )->getNode();
@@ -91,34 +94,41 @@  discard block
 block discarded – undo
91 94
     private function addParentConstructorCall(Node\Stmt\ClassMethod $constructor): void
92 95
     {
93 96
         $parentConstructorDependencies = [];
94
-        foreach ($this->definition->constructorParams as $param) {
97
+        foreach ($this->definition->constructorParams as $param)
98
+        {
95 99
             $parentConstructorDependencies[] = new Node\Arg(new Node\Expr\Variable($param->name));
96 100
 
97 101
             $cp = new Param($param->name);
98
-            if (!empty($param->type)) {
102
+            if (!empty($param->type))
103
+            {
99 104
                 $type = $this->getParamType($param);
100
-                if ($param->nullable) {
105
+                if ($param->nullable)
106
+                {
101 107
                     $type = "?$type";
102 108
                 }
103 109
 
104 110
                 $cp->setType(new Node\Name($type));
105 111
             }
106 112
 
107
-            if ($param->byRef) {
113
+            if ($param->byRef)
114
+            {
108 115
                 $cp->makeByRef();
109 116
             }
110 117
 
111
-            if ($param->isVariadic) {
118
+            if ($param->isVariadic)
119
+            {
112 120
                 $cp->makeVariadic();
113 121
             }
114 122
 
115
-            if ($param->hasDefault) {
123
+            if ($param->hasDefault)
124
+            {
116 125
                 $cp->setDefault($param->default);
117 126
             }
118 127
             $constructor->params[] = $cp->getNode();
119 128
         }
120 129
 
121
-        if ($parentConstructorDependencies) {
130
+        if ($parentConstructorDependencies)
131
+        {
122 132
             array_unshift(
123 133
                 $constructor->stmts,
124 134
                 new Node\Stmt\Expression(
@@ -153,18 +163,23 @@  discard block
 block discarded – undo
153 163
 
154 164
         $params = [];
155 165
 
156
-        foreach ($this->definition->dependencies as $dependency) {
166
+        foreach ($this->definition->dependencies as $dependency)
167
+        {
157 168
             $params[] = new Annotation\Line(
158 169
                 sprintf('%s $%s', $this->getPropertyType($dependency), $dependency->var),
159 170
                 'param'
160 171
             );
161 172
         }
162 173
 
163
-        if (!$this->definition->hasConstructor) {
164
-            foreach ($this->definition->constructorParams as $param) {
165
-                if (!empty($param->type)) {
174
+        if (!$this->definition->hasConstructor)
175
+        {
176
+            foreach ($this->definition->constructorParams as $param)
177
+            {
178
+                if (!empty($param->type))
179
+                {
166 180
                     $type = $this->getParamType($param);
167
-                    if ($param->nullable) {
181
+                    if ($param->nullable)
182
+                    {
168 183
                         $type = "$type|null";
169 184
                     }
170 185
 
@@ -172,7 +187,9 @@  discard block
 block discarded – undo
172 187
                         sprintf($param->isVariadic ? '%s ...$%s' : '%s $%s', $type, $param->name),
173 188
                         'param'
174 189
                     );
175
-                } else {
190
+                }
191
+                else
192
+                {
176 193
                     $params[] = new Annotation\Line(
177 194
                         sprintf('$%s', $param->name),
178 195
                         'param'
@@ -183,12 +200,14 @@  discard block
 block discarded – undo
183 200
 
184 201
         $placementID = 0;
185 202
         $previous = null;
186
-        foreach ($an->lines as $index => $line) {
203
+        foreach ($an->lines as $index => $line)
204
+        {
187 205
             // always next node
188 206
             $placementID = $index + 1;
189 207
 
190 208
             // inject before this parameters
191
-            if ($line->is(['throws', 'return'])) {
209
+            if ($line->is(['throws', 'return']))
210
+            {
192 211
                 // insert before given node
193 212
                 $placementID--;
194 213
                 break;
@@ -197,7 +216,8 @@  discard block
 block discarded – undo
197 216
             $previous = $line;
198 217
         }
199 218
 
200
-        if ($previous !== null && !$previous->isEmpty()) {
219
+        if ($previous !== null && !$previous->isEmpty())
220
+        {
201 221
             $placementID++;
202 222
         }
203 223
 
@@ -212,9 +232,12 @@  discard block
 block discarded – undo
212 232
      */
213 233
     private function getPropertyType(Dependency $dependency): string
214 234
     {
215
-        foreach ($this->definition->getStmts() as $stmt) {
216
-            if ($stmt->name === $dependency->type->fullName) {
217
-                if ($stmt->alias) {
235
+        foreach ($this->definition->getStmts() as $stmt)
236
+        {
237
+            if ($stmt->name === $dependency->type->fullName)
238
+            {
239
+                if ($stmt->alias)
240
+                {
218 241
                     return $stmt->alias;
219 242
                 }
220 243
             }
@@ -229,15 +252,19 @@  discard block
 block discarded – undo
229 252
      */
230 253
     private function getParamType(ClassNode\ConstructorParam $param): string
231 254
     {
232
-        foreach ($this->definition->getStmts() as $stmt) {
233
-            if ($stmt->name === $param->type->fullName) {
234
-                if ($stmt->alias) {
255
+        foreach ($this->definition->getStmts() as $stmt)
256
+        {
257
+            if ($stmt->name === $param->type->fullName)
258
+            {
259
+                if ($stmt->alias)
260
+                {
235 261
                     return $stmt->alias;
236 262
                 }
237 263
             }
238 264
         }
239 265
 
240
-        if ($param->type->alias) {
266
+        if ($param->type->alias)
267
+        {
241 268
             return $param->type->alias;
242 269
         }
243 270
 
Please login to merge, or discard this patch.
src/Prototype/tests/InjectorTest.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
     public function setUp(): void
29 29
     {
30
-        if ((string)ini_get('zend.assertions') === 1) {
30
+        if ((string)ini_get('zend.assertions') === 1){
31 31
             ini_set('zend.assertions', 0);
32 32
         }
33 33
     }
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     {
41 41
         $i = new Injector();
42 42
 
43
-        $filename = __DIR__ . '/Fixtures/TestClass.php';
43
+        $filename = __DIR__.'/Fixtures/TestClass.php';
44 44
         $printed = $i->injectDependencies(
45 45
             file_get_contents($filename),
46 46
             $this->getDefinition($filename, ['testClass' => TestClass::class])
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     ): void {
67 67
         $i = new Injector();
68 68
 
69
-        $filename = __DIR__ . '/Fixtures/TestClass.php';
69
+        $filename = __DIR__.'/Fixtures/TestClass.php';
70 70
         $printed = $i->injectDependencies(
71 71
             file_get_contents($filename),
72 72
             $this->getDefinition($filename, ['testClass' => TestClass::class]),
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
             $noPhpDoc
76 76
         );
77 77
 
78
-        if ($expectedTypedProperty) {
78
+        if ($expectedTypedProperty){
79 79
             $this->assertStringContainsString('private TestClass $testClass;', $printed);
80
-        } else {
80
+        }else{
81 81
             $this->assertStringNotContainsString('private TestClass $testClass;', $printed);
82 82
         }
83 83
 
84
-        if ($expectedPhpDoc) {
84
+        if ($expectedPhpDoc){
85 85
             $this->assertRegExp('/@var TestClass[\s|\r\n]/', $printed);
86
-        } else {
86
+        }else{
87 87
             $this->assertNotRegExp('/@var TestClass[\s|\r\n]/', $printed);
88 88
         }
89 89
     }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     {
107 107
         $i = new Injector();
108 108
 
109
-        $filename = __DIR__ . '/Fixtures/TestEmptyClass.php';
109
+        $filename = __DIR__.'/Fixtures/TestEmptyClass.php';
110 110
         $content = file_get_contents($filename);
111 111
         $printed = $i->injectDependencies(
112 112
             file_get_contents($filename),
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     {
125 125
         $i = new Injector();
126 126
 
127
-        $filename = __DIR__ . '/Fixtures/TestClass.php';
127
+        $filename = __DIR__.'/Fixtures/TestClass.php';
128 128
         $r = $i->injectDependencies(
129 129
             file_get_contents($filename),
130 130
             $this->getDefinition($filename, ['testClass' => TestClass::class])
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     {
150 150
         $i = new Injector();
151 151
 
152
-        $filename = __DIR__ . '/Fixtures/ChildClass.php';
152
+        $filename = __DIR__.'/Fixtures/ChildClass.php';
153 153
         $r = $i->injectDependencies(
154 154
             file_get_contents($filename),
155 155
             $this->getDefinition($filename, ['testClass' => TestClass::class])
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     {
168 168
         $i = new Injector();
169 169
 
170
-        $filename = __DIR__ . '/Fixtures/ChildWithConstructorClass.php';
170
+        $filename = __DIR__.'/Fixtures/ChildWithConstructorClass.php';
171 171
         $r = $i->injectDependencies(
172 172
             file_get_contents($filename),
173 173
             $this->getDefinition($filename, ['testClass' => TestClass::class])
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
      */
184 184
     public function testModifyConstructor(): void
185 185
     {
186
-        $filename = __DIR__ . '/Fixtures/WithConstructor.php';
186
+        $filename = __DIR__.'/Fixtures/WithConstructor.php';
187 187
         $extractor = new Traverse\Extractor();
188 188
 
189 189
         $parameters = $extractor->extractFromFilename($filename);
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
      */
210 210
     public function testPriorOptionalConstructorParameters(): void
211 211
     {
212
-        $filename = __DIR__ . '/Fixtures/OptionalConstructorArgsClass.php';
212
+        $filename = __DIR__.'/Fixtures/OptionalConstructorArgsClass.php';
213 213
         $extractor = new Traverse\Extractor();
214 214
 
215 215
         $parameters = $extractor->extractFromFilename($filename);
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
     {
241 241
         $i = new Injector();
242 242
 
243
-        $filename = __DIR__ . '/ClassNode/ConflictResolver/Fixtures/ChildClass.php';
243
+        $filename = __DIR__.'/ClassNode/ConflictResolver/Fixtures/ChildClass.php';
244 244
         $printed = $i->injectDependencies(
245 245
             file_get_contents($filename),
246 246
             $this->getDefinition(
Please login to merge, or discard this patch.