Passed
Pull Request — master (#736)
by Abdul Malik
07:17 queued 45s
created
src/Prototype/src/NodeVisitors/LocateProperties.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,13 +49,13 @@
 block discarded – undo
49 49
             $node instanceof PropertyFetch &&
50 50
             $node->var instanceof Variable &&
51 51
             $node->var->name === 'this'
52
-        ) {
52
+        ){
53 53
             $this->requested[$node->name->name] = $node->name->name;
54 54
         }
55 55
 
56
-        if ($node instanceof Property) {
57
-            foreach ($node->props as $prop) {
58
-                if ($prop instanceof PropertyProperty) {
56
+        if ($node instanceof Property){
57
+            foreach ($node->props as $prop){
58
+                if ($prop instanceof PropertyProperty){
59 59
                     $this->properties[$prop->name->name] = $prop->name->name;
60 60
                 }
61 61
             }
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/DefineConstructor.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,15 +28,15 @@
 block discarded – undo
28 28
      */
29 29
     public function leaveNode(Node $node)
30 30
     {
31
-        if (!$node instanceof Class_) {
31
+        if (!$node instanceof Class_){
32 32
             return null;
33 33
         }
34 34
 
35 35
         $placementID = 0;
36
-        foreach ($node->stmts as $index => $child) {
36
+        foreach ($node->stmts as $index => $child){
37 37
             $placementID = $index;
38
-            if ($child instanceof ClassMethod) {
39
-                if ($child->name->name === '__construct') {
38
+            if ($child instanceof ClassMethod){
39
+                if ($child->name->name === '__construct'){
40 40
                     $node->setAttribute('constructor', $child);
41 41
 
42 42
                     return null;
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/RemoveTrait.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,26 +29,26 @@
 block discarded – undo
29 29
      */
30 30
     public function leaveNode(Node $node)
31 31
     {
32
-        if (!$node instanceof TraitUse) {
32
+        if (!$node instanceof TraitUse){
33 33
             return null;
34 34
         }
35 35
 
36
-        foreach ($node->traits as $index => $use) {
37
-            if ($use instanceof Name) {
36
+        foreach ($node->traits as $index => $use){
37
+            if ($use instanceof Name){
38 38
                 $name = $this->trimSlashes(implode('\\', $use->parts));
39 39
                 if (
40 40
                     in_array($name, [
41 41
                         $this->trimSlashes(PrototypeTrait::class),
42 42
                         Utils::shortName(PrototypeTrait::class),
43 43
                     ], true)
44
-                ) {
44
+                ){
45 45
                     unset($node->traits[$index]);
46 46
                 }
47 47
             }
48 48
         }
49 49
 
50 50
         $node->traits = array_values($node->traits);
51
-        if (empty($node->traits)) {
51
+        if (empty($node->traits)){
52 52
             return NodeTraverser::REMOVE_NODE;
53 53
         }
54 54
 
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/AddProperty.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function leaveNode(Node $node)
41 41
     {
42
-        if (!$node instanceof Class_) {
42
+        if (!$node instanceof Class_){
43 43
             return null;
44 44
         }
45 45
 
46 46
         $nodes = [];
47
-        foreach ($this->definition->dependencies as $dependency) {
47
+        foreach ($this->definition->dependencies as $dependency){
48 48
             $nodes[] = $this->buildProperty($dependency);
49 49
         }
50 50
 
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 
57 57
     private function definePlacementID(Class_ $node): int
58 58
     {
59
-        foreach ($node->stmts as $index => $child) {
60
-            if ($child instanceof ClassMethod || $child instanceof Node\Stmt\Property) {
59
+        foreach ($node->stmts as $index => $child){
60
+            if ($child instanceof ClassMethod || $child instanceof Node\Stmt\Property){
61 61
                 return $index;
62 62
             }
63 63
         }
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
         $b = new Property($dependency->property);
71 71
         $b->makePrivate();
72 72
 
73
-        if ($this->useTypedProperty()) {
73
+        if ($this->useTypedProperty()){
74 74
             $b->setType($this->getPropertyType($dependency));
75 75
         }
76 76
 
77
-        if ($this->renderDoc()) {
77
+        if ($this->renderDoc()){
78 78
             $b->setDocComment(new Doc(sprintf('/** @var %s */', $this->getPropertyType($dependency))));
79 79
         }
80 80
 
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 
94 94
     private function getPropertyType(Dependency $dependency): string
95 95
     {
96
-        foreach ($this->definition->getStmts() as $stmt) {
97
-            if (($stmt->name === $dependency->type->fullName) && $stmt->alias) {
96
+        foreach ($this->definition->getStmts() as $stmt){
97
+            if (($stmt->name === $dependency->type->fullName) && $stmt->alias){
98 98
                 return $stmt->alias;
99 99
             }
100 100
         }
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/AddUse.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function leaveNode(Node $node)
42 42
     {
43
-        if (!$node instanceof Namespace_) {
43
+        if (!$node instanceof Namespace_){
44 44
             return null;
45 45
         }
46 46
 
47 47
         $imported = [];
48
-        if (!$this->node->hasConstructor && $this->node->constructorParams) {
49
-            foreach ($this->node->constructorParams as $param) {
50
-                if (!empty($param->type) && $param->type->fullName) {
48
+        if (!$this->node->hasConstructor && $this->node->constructorParams){
49
+            foreach ($this->node->constructorParams as $param){
50
+                if (!empty($param->type) && $param->type->fullName){
51 51
                     $import = [$param->type->fullName, $param->type->alias];
52
-                    if (in_array($import, $imported, true)) {
52
+                    if (in_array($import, $imported, true)){
53 53
                         continue;
54 54
                     }
55 55
 
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
             }
60 60
         }
61 61
 
62
-        foreach ($this->node->dependencies as $dependency) {
62
+        foreach ($this->node->dependencies as $dependency){
63 63
             $import = [$dependency->type->fullName, $dependency->type->alias];
64
-            if (in_array($import, $imported, true)) {
64
+            if (in_array($import, $imported, true)){
65 65
                 continue;
66 66
             }
67 67
 
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 
85 85
     private function definePlacementID(Namespace_ $node): int
86 86
     {
87
-        foreach ($node->stmts as $index => $child) {
88
-            if ($child instanceof Class_) {
87
+        foreach ($node->stmts as $index => $child){
88
+            if ($child instanceof Class_){
89 89
                 return $index;
90 90
             }
91 91
         }
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
     {
103 103
         $uses = $this->getExistingUseParts($stmts);
104 104
 
105
-        foreach ($nodes as $i => $node) {
106
-            if (!$node instanceof Node\Stmt\Use_) {
105
+        foreach ($nodes as $i => $node){
106
+            if (!$node instanceof Node\Stmt\Use_){
107 107
                 continue;
108 108
             }
109 109
 
110
-            foreach ($node->uses as $use) {
111
-                if (in_array($use->name->parts, $uses, true)) {
110
+            foreach ($node->uses as $use){
111
+                if (in_array($use->name->parts, $uses, true)){
112 112
                     unset($nodes[$i]);
113 113
                 }
114 114
             }
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
     private function getExistingUseParts(array $stmts): array
128 128
     {
129 129
         $uses = [];
130
-        foreach ($stmts as $stmt) {
131
-            if (!$stmt instanceof Node\Stmt\Use_) {
130
+        foreach ($stmts as $stmt){
131
+            if (!$stmt instanceof Node\Stmt\Use_){
132 132
                 continue;
133 133
             }
134 134
 
135
-            foreach ($stmt->uses as $use) {
135
+            foreach ($stmt->uses as $use){
136 136
                 $uses[] = $use->name->parts;
137 137
             }
138 138
         }
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
     private function buildUse(string $type, ?string $alias = null): Node\Stmt\Use_
144 144
     {
145 145
         $b = new Use_(new Name($type), Node\Stmt\Use_::TYPE_NORMAL);
146
-        if (!empty($alias)) {
146
+        if (!empty($alias)){
147 147
             $b->as($alias);
148 148
         }
149 149
 
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/ClassNode/LocateVariables.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,16 +27,16 @@
 block discarded – undo
27 27
      */
28 28
     public function enterNode(Node $node)
29 29
     {
30
-        if ($node instanceof Class_) {
31
-            foreach ($node->stmts as $stmt) {
32
-                if ($stmt instanceof ClassMethod && $stmt->name === '__construct') {
30
+        if ($node instanceof Class_){
31
+            foreach ($node->stmts as $stmt){
32
+                if ($stmt instanceof ClassMethod && $stmt->name === '__construct'){
33 33
                     return $stmt;
34 34
                 }
35 35
             }
36 36
             return NodeTraverser::DONT_TRAVERSE_CHILDREN;
37 37
         }
38 38
 
39
-        if ($node instanceof Variable) {
39
+        if ($node instanceof Variable){
40 40
             $this->vars[] = $node->name;
41 41
         }
42 42
 
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/ClassNode/DeclareClass.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@
 block discarded – undo
27 27
      */
28 28
     public function enterNode(Node $node)
29 29
     {
30
-        if ($node instanceof Namespace_) {
30
+        if ($node instanceof Namespace_){
31 31
             $this->namespace = implode('\\', $node->name->parts);
32 32
         }
33 33
 
34
-        if ($node instanceof Class_) {
34
+        if ($node instanceof Class_){
35 35
             $this->class = $node->name->name;
36 36
 
37 37
             return NodeTraverser::STOP_TRAVERSAL;
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/ClassNode/LocateStatements.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@
 block discarded – undo
27 27
      */
28 28
     public function enterNode(Node $node)
29 29
     {
30
-        if ($node instanceof Use_) {
31
-            foreach ($node->uses as $use) {
30
+        if ($node instanceof Use_){
31
+            foreach ($node->uses as $use){
32 32
                 $this->imports[] = [
33 33
                     'name'  => implode('\\', $use->name->parts),
34 34
                     'alias' => $use->alias->name ?? null,
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/UpdateConstructor.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function leaveNode(Node $node)
51 51
     {
52
-        if (!$node instanceof Class_) {
52
+        if (!$node instanceof Class_){
53 53
             return null;
54 54
         }
55 55
 
56 56
         $constructor = $this->getConstructorAttribute($node);
57 57
         $this->addDependencies($constructor);
58
-        if (!$this->definition->hasConstructor && $this->definition->constructorParams) {
58
+        if (!$this->definition->hasConstructor && $this->definition->constructorParams){
59 59
             $this->addParentConstructorCall($constructor);
60 60
         }
61 61
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      */
72 72
     private function addDependencies(ClassMethod $constructor): void
73 73
     {
74
-        foreach ($this->definition->dependencies as $dependency) {
74
+        foreach ($this->definition->dependencies as $dependency){
75 75
             array_unshift($constructor->params, $this->buildConstructorParam($dependency));
76 76
             array_unshift(
77 77
                 $constructor->stmts,
@@ -94,34 +94,34 @@  discard block
 block discarded – undo
94 94
     private function addParentConstructorCall(ClassMethod $constructor): void
95 95
     {
96 96
         $parentConstructorDependencies = [];
97
-        foreach ($this->definition->constructorParams as $param) {
97
+        foreach ($this->definition->constructorParams as $param){
98 98
             $parentConstructorDependencies[] = new Arg(new Variable($param->name));
99 99
 
100 100
             $cp = new Param($param->name);
101
-            if (!empty($param->type)) {
101
+            if (!empty($param->type)){
102 102
                 $type = $this->getParamType($param);
103
-                if ($param->nullable) {
103
+                if ($param->nullable){
104 104
                     $type = "?$type";
105 105
                 }
106 106
 
107 107
                 $cp->setType(new Name($type));
108 108
             }
109 109
 
110
-            if ($param->byRef) {
110
+            if ($param->byRef){
111 111
                 $cp->makeByRef();
112 112
             }
113 113
 
114
-            if ($param->isVariadic) {
114
+            if ($param->isVariadic){
115 115
                 $cp->makeVariadic();
116 116
             }
117 117
 
118
-            if ($param->hasDefault) {
118
+            if ($param->hasDefault){
119 119
                 $cp->setDefault($param->default);
120 120
             }
121 121
             $constructor->params[] = $cp->getNode();
122 122
         }
123 123
 
124
-        if ($parentConstructorDependencies) {
124
+        if ($parentConstructorDependencies){
125 125
             array_unshift(
126 126
                 $constructor->stmts,
127 127
                 new Expression(
@@ -151,18 +151,18 @@  discard block
 block discarded – undo
151 151
 
152 152
         $params = [];
153 153
 
154
-        foreach ($this->definition->dependencies as $dependency) {
154
+        foreach ($this->definition->dependencies as $dependency){
155 155
             $params[] = new Line(
156 156
                 sprintf('%s $%s', $this->getPropertyType($dependency), $dependency->var),
157 157
                 'param'
158 158
             );
159 159
         }
160 160
 
161
-        if (!$this->definition->hasConstructor) {
162
-            foreach ($this->definition->constructorParams as $param) {
163
-                if (!empty($param->type)) {
161
+        if (!$this->definition->hasConstructor){
162
+            foreach ($this->definition->constructorParams as $param){
163
+                if (!empty($param->type)){
164 164
                     $type = $this->getParamType($param);
165
-                    if ($param->nullable) {
165
+                    if ($param->nullable){
166 166
                         $type = "$type|null";
167 167
                     }
168 168
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
                         sprintf($param->isVariadic ? '%s ...$%s' : '%s $%s', $type, $param->name),
171 171
                         'param'
172 172
                     );
173
-                } else {
173
+                }else{
174 174
                     $params[] = new Line(
175 175
                         sprintf('$%s', $param->name),
176 176
                         'param'
@@ -181,12 +181,12 @@  discard block
 block discarded – undo
181 181
 
182 182
         $placementID = 0;
183 183
         $previous = null;
184
-        foreach ($an->lines as $index => $line) {
184
+        foreach ($an->lines as $index => $line){
185 185
             // always next node
186 186
             $placementID = $index + 1;
187 187
 
188 188
             // inject before this parameters
189
-            if ($line->is(['throws', 'return'])) {
189
+            if ($line->is(['throws', 'return'])){
190 190
                 // insert before given node
191 191
                 $placementID--;
192 192
                 break;
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
             $previous = $line;
196 196
         }
197 197
 
198
-        if ($previous !== null && !$previous->isEmpty()) {
198
+        if ($previous !== null && !$previous->isEmpty()){
199 199
             $placementID++;
200 200
         }
201 201
 
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 
207 207
     private function getPropertyType(Dependency $dependency): string
208 208
     {
209
-        foreach ($this->definition->getStmts() as $stmt) {
210
-            if ($stmt->name === $dependency->type->fullName) {
211
-                if ($stmt->alias) {
209
+        foreach ($this->definition->getStmts() as $stmt){
210
+            if ($stmt->name === $dependency->type->fullName){
211
+                if ($stmt->alias){
212 212
                     return $stmt->alias;
213 213
                 }
214 214
             }
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
 
220 220
     private function getParamType(ConstructorParam $param): string
221 221
     {
222
-        foreach ($this->definition->getStmts() as $stmt) {
223
-            if ($stmt->name === $param->type->fullName) {
224
-                if ($stmt->alias) {
222
+        foreach ($this->definition->getStmts() as $stmt){
223
+            if ($stmt->name === $param->type->fullName){
224
+                if ($stmt->alias){
225 225
                     return $stmt->alias;
226 226
                 }
227 227
             }
228 228
         }
229 229
 
230
-        if ($param->type->alias) {
230
+        if ($param->type->alias){
231 231
             return $param->type->alias;
232 232
         }
233 233
 
Please login to merge, or discard this patch.