Passed
Pull Request — master (#1205)
by Aleksei
20:40
created
src/Prototype/tests/Traverse/ConstructorParamsVisitor.php 1 patch
Braces   +17 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,19 +16,29 @@
 block discarded – undo
16 16
      */
17 17
     public function leaveNode(Node $node): void
18 18
     {
19
-        if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct') {
20
-            foreach ($node->params as $param) {
21
-                if ($param->type instanceof Node\NullableType) {
22
-                    if ($param->type->type instanceof Node\Identifier) {
19
+        if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct')
20
+        {
21
+            foreach ($node->params as $param)
22
+            {
23
+                if ($param->type instanceof Node\NullableType)
24
+                {
25
+                    if ($param->type->type instanceof Node\Identifier)
26
+                    {
23 27
                         $type = $param->type->type->name;
24
-                    } else {
28
+                    }
29
+                    else
30
+                    {
25 31
                         $type = implode('\\', $param->type->type->getParts());
26 32
                     }
27 33
 
28 34
                     $type = "?$type";
29
-                } elseif ($param->type instanceof Node\Name) {
35
+                }
36
+                elseif ($param->type instanceof Node\Name)
37
+                {
30 38
                     $type = implode('\\', $param->type->getParts());
31
-                } else {
39
+                }
40
+                else
41
+                {
32 42
                     $type = $param->type->name ?? null;
33 43
                 }
34 44
 
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/ClassNode/LocateStatements.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,10 @@
 block discarded – undo
16 16
 
17 17
     public function enterNode(Node $node): void
18 18
     {
19
-        if ($node instanceof Node\Stmt\Use_) {
20
-            foreach ($node->uses as $use) {
19
+        if ($node instanceof Node\Stmt\Use_)
20
+        {
21
+            foreach ($node->uses as $use)
22
+            {
21 23
                 $this->imports[] = [
22 24
                     'name'  => \implode('\\', $use->name->getParts()),
23 25
                     'alias' => $use->alias->name ?? null,
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/ClassNode/DeclareClass.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,11 +15,13 @@
 block discarded – undo
15 15
 
16 16
     public function enterNode(Node $node): ?int
17 17
     {
18
-        if ($node instanceof Node\Stmt\Namespace_) {
18
+        if ($node instanceof Node\Stmt\Namespace_)
19
+        {
19 20
             $this->namespace = \implode('\\', $node->name->getParts());
20 21
         }
21 22
 
22
-        if ($node instanceof Node\Stmt\Class_) {
23
+        if ($node instanceof Node\Stmt\Class_)
24
+        {
23 25
             $this->class = $node->name->name;
24 26
 
25 27
             return NodeTraverser::STOP_TRAVERSAL;
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/RemoveTrait.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,12 +17,15 @@  discard block
 block discarded – undo
17 17
 {
18 18
     public function leaveNode(Node $node): int|Node|null
19 19
     {
20
-        if (!$node instanceof Node\Stmt\TraitUse) {
20
+        if (!$node instanceof Node\Stmt\TraitUse)
21
+        {
21 22
             return null;
22 23
         }
23 24
 
24
-        foreach ($node->traits as $index => $use) {
25
-            if ($use instanceof Node\Name) {
25
+        foreach ($node->traits as $index => $use)
26
+        {
27
+            if ($use instanceof Node\Name)
28
+            {
26 29
                 $name = $this->trimSlashes(\implode('\\', $use->getParts()));
27 30
                 if (
28 31
                     \in_array($name, [
@@ -36,7 +39,8 @@  discard block
 block discarded – undo
36 39
         }
37 40
 
38 41
         $node->traits = \array_values($node->traits);
39
-        if (empty($node->traits)) {
42
+        if (empty($node->traits))
43
+        {
40 44
             return NodeTraverser::REMOVE_NODE;
41 45
         }
42 46
 
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/AddUse.php 1 patch
Braces   +36 added lines, -18 removed lines patch added patch discarded remove patch
@@ -20,20 +20,26 @@  discard block
 block discarded – undo
20 20
 
21 21
     public function __construct(
22 22
         private readonly ClassNode $node,
23
-    ) {}
23
+    ) {
24
+}
24 25
 
25 26
     public function leaveNode(Node $node): ?Node
26 27
     {
27
-        if (!$node instanceof Node\Stmt\Namespace_) {
28
+        if (!$node instanceof Node\Stmt\Namespace_)
29
+        {
28 30
             return null;
29 31
         }
30 32
 
31 33
         $imported = [];
32
-        if (!$this->node->hasConstructor && $this->node->constructorParams) {
33
-            foreach ($this->node->constructorParams as $param) {
34
-                if (!empty($param->type) && $param->type->fullName) {
34
+        if (!$this->node->hasConstructor && $this->node->constructorParams)
35
+        {
36
+            foreach ($this->node->constructorParams as $param)
37
+            {
38
+                if (!empty($param->type) && $param->type->fullName)
39
+                {
35 40
                     $import = [$param->type->fullName, $param->type->alias];
36
-                    if (\in_array($import, $imported, true)) {
41
+                    if (\in_array($import, $imported, true))
42
+                    {
37 43
                         continue;
38 44
                     }
39 45
 
@@ -43,9 +49,11 @@  discard block
 block discarded – undo
43 49
             }
44 50
         }
45 51
 
46
-        foreach ($this->node->dependencies as $dependency) {
52
+        foreach ($this->node->dependencies as $dependency)
53
+        {
47 54
             $import = [$dependency->type->fullName, $dependency->type->alias];
48
-            if (\in_array($import, $imported, true)) {
55
+            if (\in_array($import, $imported, true))
56
+            {
49 57
                 continue;
50 58
             }
51 59
 
@@ -68,8 +76,10 @@  discard block
 block discarded – undo
68 76
 
69 77
     private function definePlacementID(Node\Stmt\Namespace_ $node): int
70 78
     {
71
-        foreach ($node->stmts as $index => $child) {
72
-            if ($child instanceof Node\Stmt\Class_) {
79
+        foreach ($node->stmts as $index => $child)
80
+        {
81
+            if ($child instanceof Node\Stmt\Class_)
82
+            {
73 83
                 return $index;
74 84
             }
75 85
         }
@@ -86,13 +96,17 @@  discard block
 block discarded – undo
86 96
     {
87 97
         $uses = $this->getExistingUseParts($stmts);
88 98
 
89
-        foreach ($nodes as $i => $node) {
90
-            if (!$node instanceof Node\Stmt\Use_) {
99
+        foreach ($nodes as $i => $node)
100
+        {
101
+            if (!$node instanceof Node\Stmt\Use_)
102
+            {
91 103
                 continue;
92 104
             }
93 105
 
94
-            foreach ($node->uses as $use) {
95
-                if (\in_array($use->name->getParts(), $uses, true)) {
106
+            foreach ($node->uses as $use)
107
+            {
108
+                if (\in_array($use->name->getParts(), $uses, true))
109
+                {
96 110
                     unset($nodes[$i]);
97 111
                 }
98 112
             }
@@ -111,12 +125,15 @@  discard block
 block discarded – undo
111 125
     private function getExistingUseParts(array $stmts): array
112 126
     {
113 127
         $uses = [];
114
-        foreach ($stmts as $stmt) {
115
-            if (!$stmt instanceof Node\Stmt\Use_) {
128
+        foreach ($stmts as $stmt)
129
+        {
130
+            if (!$stmt instanceof Node\Stmt\Use_)
131
+            {
116 132
                 continue;
117 133
             }
118 134
 
119
-            foreach ($stmt->uses as $use) {
135
+            foreach ($stmt->uses as $use)
136
+            {
120 137
                 $uses[] = $use->name->getParts();
121 138
             }
122 139
         }
@@ -127,7 +144,8 @@  discard block
 block discarded – undo
127 144
     private function buildUse(string $type, ?string $alias = null): Node\Stmt\Use_
128 145
     {
129 146
         $b = new Use_(new Node\Name($type), Node\Stmt\Use_::TYPE_NORMAL);
130
-        if (!empty($alias)) {
147
+        if (!empty($alias))
148
+        {
131 149
             $b->as($alias);
132 150
         }
133 151
 
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/UpdateConstructor.php 1 patch
Braces   +36 added lines, -18 removed lines patch added patch discarded remove patch
@@ -17,17 +17,21 @@  discard block
 block discarded – undo
17 17
 {
18 18
     public function __construct(
19 19
         private readonly ClassNode $definition,
20
-    ) {}
20
+    ) {
21
+}
21 22
 
22 23
     public function leaveNode(Node $node): int|Node|null
23 24
     {
24
-        if (!$node instanceof Node\Stmt\Class_) {
25
+        if (!$node instanceof Node\Stmt\Class_)
26
+        {
25 27
             return null;
26 28
         }
27 29
 
28 30
         $constructor = $this->getConstructor($node);
29
-        if ($constructor === null) {
30
-            if ($this->definition->dependencies === []) {
31
+        if ($constructor === null)
32
+        {
33
+            if ($this->definition->dependencies === [])
34
+            {
31 35
                 return $node;
32 36
             }
33 37
 
@@ -38,7 +42,8 @@  discard block
 block discarded – undo
38 42
 
39 43
         $this->addDependencies($constructor);
40 44
 
41
-        if (!$this->definition->hasConstructor && $this->definition->constructorParams) {
45
+        if (!$this->definition->hasConstructor && $this->definition->constructorParams)
46
+        {
42 47
             $this->addParentConstructorCall($constructor);
43 48
         }
44 49
 
@@ -50,7 +55,8 @@  discard block
 block discarded – undo
50 55
      */
51 56
     private function addDependencies(Node\Stmt\ClassMethod $constructor): void
52 57
     {
53
-        foreach ($this->definition->dependencies as $dependency) {
58
+        foreach ($this->definition->dependencies as $dependency)
59
+        {
54 60
             \array_unshift($constructor->params, $this->buildConstructorParam($dependency));
55 61
         }
56 62
     }
@@ -67,34 +73,41 @@  discard block
 block discarded – undo
67 73
     private function addParentConstructorCall(Node\Stmt\ClassMethod $constructor): void
68 74
     {
69 75
         $parentConstructorDependencies = [];
70
-        foreach ($this->definition->constructorParams as $param) {
76
+        foreach ($this->definition->constructorParams as $param)
77
+        {
71 78
             $parentConstructorDependencies[] = new Node\Arg(new Node\Expr\Variable($param->name));
72 79
 
73 80
             $cp = new Param($param->name);
74
-            if (!empty($param->type)) {
81
+            if (!empty($param->type))
82
+            {
75 83
                 $type = $this->getParamType($param);
76
-                if ($param->nullable) {
84
+                if ($param->nullable)
85
+                {
77 86
                     $type = \sprintf('?%s', $type);
78 87
                 }
79 88
 
80 89
                 $cp->setType(new Node\Name($type));
81 90
             }
82 91
 
83
-            if ($param->byRef) {
92
+            if ($param->byRef)
93
+            {
84 94
                 $cp->makeByRef();
85 95
             }
86 96
 
87
-            if ($param->isVariadic) {
97
+            if ($param->isVariadic)
98
+            {
88 99
                 $cp->makeVariadic();
89 100
             }
90 101
 
91
-            if ($param->hasDefault) {
102
+            if ($param->hasDefault)
103
+            {
92 104
                 $cp->setDefault($param->default);
93 105
             }
94 106
             $constructor->params[] = $cp->getNode();
95 107
         }
96 108
 
97
-        if ($parentConstructorDependencies !== []) {
109
+        if ($parentConstructorDependencies !== [])
110
+        {
98 111
             \array_unshift(
99 112
                 $constructor->stmts,
100 113
                 new Node\Stmt\Expression(
@@ -115,8 +128,10 @@  discard block
 block discarded – undo
115 128
 
116 129
     private function getPropertyType(Dependency $dependency): string
117 130
     {
118
-        foreach ($this->definition->getStmts() as $stmt) {
119
-            if ($stmt->name === $dependency->type->fullName && $stmt->alias) {
131
+        foreach ($this->definition->getStmts() as $stmt)
132
+        {
133
+            if ($stmt->name === $dependency->type->fullName && $stmt->alias)
134
+            {
120 135
                 return $stmt->alias;
121 136
             }
122 137
         }
@@ -126,13 +141,16 @@  discard block
 block discarded – undo
126 141
 
127 142
     private function getParamType(ClassNode\ConstructorParam $param): string
128 143
     {
129
-        foreach ($this->definition->getStmts() as $stmt) {
130
-            if ($stmt->name === $param->type->fullName && $stmt->alias) {
144
+        foreach ($this->definition->getStmts() as $stmt)
145
+        {
146
+            if ($stmt->name === $param->type->fullName && $stmt->alias)
147
+            {
131 148
                 return $stmt->alias;
132 149
             }
133 150
         }
134 151
 
135
-        if ($param->type->alias) {
152
+        if ($param->type->alias)
153
+        {
136 154
             return $param->type->alias;
137 155
         }
138 156
 
Please login to merge, or discard this patch.
src/Http/src/Request/InputManager.php 1 patch
Braces   +38 added lines, -18 removed lines patch added patch discarded remove patch
@@ -134,10 +134,13 @@  discard block
 block discarded – undo
134 134
     {
135 135
         $input = clone $this;
136 136
 
137
-        if ($add) {
137
+        if ($add)
138
+        {
138 139
             $input->prefix .= '.' . $prefix;
139 140
             $input->prefix = \trim($input->prefix, '.');
140
-        } else {
141
+        }
142
+        else
143
+        {
141 144
             $input->prefix = $prefix;
142 145
         }
143 146
 
@@ -173,9 +176,12 @@  discard block
 block discarded – undo
173 176
      */
174 177
     public function request(): Request
175 178
     {
176
-        try {
179
+        try
180
+        {
177 181
             $request = $this->container->get(Request::class);
178
-        } catch (ContainerExceptionInterface $e) {
182
+        }
183
+        catch (ContainerExceptionInterface $e)
184
+        {
179 185
             $scope = \implode('.', \array_reverse(Introspector::scopeNames($this->container)));
180 186
             throw new ScopeException(
181 187
                 "Unable to get `ServerRequestInterface` in the `$scope` container scope",
@@ -185,7 +191,8 @@  discard block
 block discarded – undo
185 191
         }
186 192
 
187 193
         // Flushing input state
188
-        if ($this->request !== $request) {
194
+        if ($this->request !== $request)
195
+        {
189 196
             $this->bags = [];
190 197
             $this->request = $request;
191 198
         }
@@ -202,7 +209,8 @@  discard block
 block discarded – undo
202 209
 
203 210
         $position = \strrpos($header, 'Bearer ');
204 211
 
205
-        if ($position !== false) {
212
+        if ($position !== false)
213
+        {
206 214
             $header = \substr($header, $position + 7);
207 215
 
208 216
             /** @psalm-suppress FalsableReturnStatement */
@@ -257,16 +265,21 @@  discard block
 block discarded – undo
257 265
     public function isJsonExpected(bool $softMatch = false): bool
258 266
     {
259 267
         $acceptHeader = AcceptHeader::fromString($this->request()->getHeaderLine('Accept'));
260
-        foreach ($this->jsonTypes as $jsonType) {
261
-            if ($acceptHeader->has($jsonType)) {
268
+        foreach ($this->jsonTypes as $jsonType)
269
+        {
270
+            if ($acceptHeader->has($jsonType))
271
+            {
262 272
                 return true;
263 273
             }
264 274
         }
265 275
 
266
-        if ($softMatch) {
267
-            foreach ($acceptHeader->getAll() as $item) {
276
+        if ($softMatch)
277
+        {
278
+            foreach ($acceptHeader->getAll() as $item)
279
+            {
268 280
                 $itemValue = \strtolower((string) $item->getValue());
269
-                if (\str_ends_with($itemValue, '/json') || \str_ends_with($itemValue, '+json')) {
281
+                if (\str_ends_with($itemValue, '/json') || \str_ends_with($itemValue, '+json'))
282
+                {
270 283
                     return true;
271 284
                 }
272 285
             }
@@ -305,19 +318,22 @@  discard block
 block discarded – undo
305 318
         // ensure proper request association
306 319
         $this->request();
307 320
 
308
-        if (isset($this->bags[$name])) {
321
+        if (isset($this->bags[$name]))
322
+        {
309 323
             return $this->bags[$name];
310 324
         }
311 325
 
312 326
         $definition = $this->findBagDefinition($name);
313
-        if (!$definition) {
327
+        if (!$definition)
328
+        {
314 329
             throw new InputException(\sprintf("Undefined input bag '%s'", $name));
315 330
         }
316 331
 
317 332
         $class = $definition['class'];
318 333
         $data = \call_user_func([$this->request(), $definition['source']]);
319 334
 
320
-        if (!\is_array($data)) {
335
+        if (!\is_array($data))
336
+        {
321 337
             $data = (array) $data;
322 338
         }
323 339
 
@@ -326,7 +342,8 @@  discard block
 block discarded – undo
326 342
 
327 343
     public function hasBag(string $name): bool
328 344
     {
329
-        if (isset($this->bags[$name])) {
345
+        if (isset($this->bags[$name]))
346
+        {
330 347
             return true;
331 348
         }
332 349
 
@@ -364,12 +381,15 @@  discard block
 block discarded – undo
364 381
      */
365 382
     private function findBagDefinition(string $name): ?array
366 383
     {
367
-        if (isset($this->bagAssociations[$name])) {
384
+        if (isset($this->bagAssociations[$name]))
385
+        {
368 386
             return $this->bagAssociations[$name];
369 387
         }
370 388
 
371
-        foreach ($this->bagAssociations as $bag) {
372
-            if (isset($bag['alias']) && $bag['alias'] === $name) {
389
+        foreach ($this->bagAssociations as $bag)
390
+        {
391
+            if (isset($bag['alias']) && $bag['alias'] === $name)
392
+            {
373 393
                 return $bag;
374 394
             }
375 395
         }
Please login to merge, or discard this patch.
src/Files/src/Files.php 1 patch
Braces   +71 added lines, -34 removed lines patch added patch discarded remove patch
@@ -39,30 +39,36 @@  discard block
 block discarded – undo
39 39
         ?int $mode = null,
40 40
         bool $recursivePermissions = true,
41 41
     ): bool {
42
-        if (empty($mode)) {
42
+        if (empty($mode))
43
+        {
43 44
             $mode = self::DEFAULT_FILE_MODE;
44 45
         }
45 46
 
46 47
         //Directories always executable
47 48
         $mode |= 0o111;
48
-        if (\is_dir($directory)) {
49
+        if (\is_dir($directory))
50
+        {
49 51
             //Exists :(
50 52
             return $this->setPermissions($directory, $mode);
51 53
         }
52 54
 
53
-        if (!$recursivePermissions) {
55
+        if (!$recursivePermissions)
56
+        {
54 57
             return \mkdir($directory, $mode, true);
55 58
         }
56 59
 
57 60
         $directoryChain = [\basename($directory)];
58 61
 
59 62
         $baseDirectory = $directory;
60
-        while (!\is_dir($baseDirectory = \dirname($baseDirectory))) {
63
+        while (!\is_dir($baseDirectory = \dirname($baseDirectory)))
64
+        {
61 65
             $directoryChain[] = \basename($baseDirectory);
62 66
         }
63 67
 
64
-        foreach (\array_reverse($directoryChain) as $dir) {
65
-            if (!\mkdir($baseDirectory = \sprintf('%s/%s', $baseDirectory, $dir))) {
68
+        foreach (\array_reverse($directoryChain) as $dir)
69
+        {
70
+            if (!\mkdir($baseDirectory = \sprintf('%s/%s', $baseDirectory, $dir)))
71
+            {
66 72
                 return false;
67 73
             }
68 74
 
@@ -74,7 +80,8 @@  discard block
 block discarded – undo
74 80
 
75 81
     public function read(string $filename): string
76 82
     {
77
-        if (!$this->exists($filename)) {
83
+        if (!$this->exists($filename))
84
+        {
78 85
             throw new FileNotFoundException($filename);
79 86
         }
80 87
 
@@ -96,12 +103,15 @@  discard block
 block discarded – undo
96 103
     ): bool {
97 104
         $mode ??= self::DEFAULT_FILE_MODE;
98 105
 
99
-        try {
100
-            if ($ensureDirectory) {
106
+        try
107
+        {
108
+            if ($ensureDirectory)
109
+            {
101 110
                 $this->ensureDirectory(\dirname($filename), $mode);
102 111
             }
103 112
 
104
-            if ($this->exists($filename)) {
113
+            if ($this->exists($filename))
114
+            {
105 115
                 //Forcing mode for existed file
106 116
                 $this->setPermissions($filename, $mode);
107 117
             }
@@ -112,11 +122,14 @@  discard block
 block discarded – undo
112 122
                 $append ? FILE_APPEND | LOCK_EX : LOCK_EX,
113 123
             );
114 124
 
115
-            if ($result !== false) {
125
+            if ($result !== false)
126
+            {
116 127
                 //Forcing mode after file creation
117 128
                 $this->setPermissions($filename, $mode);
118 129
             }
119
-        } catch (\Exception $e) {
130
+        }
131
+        catch (\Exception $e)
132
+        {
120 133
             throw new WriteErrorException($e->getMessage(), (int) $e->getCode(), $e);
121 134
         }
122 135
 
@@ -134,7 +147,8 @@  discard block
 block discarded – undo
134 147
 
135 148
     public function delete(string $filename): bool
136 149
     {
137
-        if ($this->exists($filename)) {
150
+        if ($this->exists($filename))
151
+        {
138 152
             $result = \unlink($filename);
139 153
 
140 154
             //Wiping out changes in local file cache
@@ -153,7 +167,8 @@  discard block
 block discarded – undo
153 167
      */
154 168
     public function deleteDirectory(string $directory, bool $contentOnly = false): bool
155 169
     {
156
-        if (!$this->isDirectory($directory)) {
170
+        if (!$this->isDirectory($directory))
171
+        {
157 172
             throw new FilesException(\sprintf('Undefined or invalid directory %s', $directory));
158 173
         }
159 174
 
@@ -162,15 +177,20 @@  discard block
 block discarded – undo
162 177
             \RecursiveIteratorIterator::CHILD_FIRST,
163 178
         );
164 179
 
165
-        foreach ($files as $file) {
166
-            if ($file->isDir()) {
180
+        foreach ($files as $file)
181
+        {
182
+            if ($file->isDir())
183
+            {
167 184
                 \rmdir($file->getRealPath());
168
-            } else {
185
+            }
186
+            else
187
+            {
169 188
                 $this->delete($file->getRealPath());
170 189
             }
171 190
         }
172 191
 
173
-        if (!$contentOnly) {
192
+        if (!$contentOnly)
193
+        {
174 194
             return \rmdir($directory);
175 195
         }
176 196
 
@@ -179,7 +199,8 @@  discard block
 block discarded – undo
179 199
 
180 200
     public function move(string $filename, string $destination): bool
181 201
     {
182
-        if (!$this->exists($filename)) {
202
+        if (!$this->exists($filename))
203
+        {
183 204
             throw new FileNotFoundException($filename);
184 205
         }
185 206
 
@@ -188,7 +209,8 @@  discard block
 block discarded – undo
188 209
 
189 210
     public function copy(string $filename, string $destination): bool
190 211
     {
191
-        if (!$this->exists($filename)) {
212
+        if (!$this->exists($filename))
213
+        {
192 214
             throw new FileNotFoundException($filename);
193 215
         }
194 216
 
@@ -197,7 +219,8 @@  discard block
 block discarded – undo
197 219
 
198 220
     public function touch(string $filename, ?int $mode = null): bool
199 221
     {
200
-        if (!\touch($filename)) {
222
+        if (!\touch($filename))
223
+        {
201 224
             return false;
202 225
         }
203 226
 
@@ -223,7 +246,8 @@  discard block
 block discarded – undo
223 246
 
224 247
     public function md5(string $filename): string
225 248
     {
226
-        if (!$this->exists($filename)) {
249
+        if (!$this->exists($filename))
250
+        {
227 251
             throw new FileNotFoundException($filename);
228 252
         }
229 253
 
@@ -237,7 +261,8 @@  discard block
 block discarded – undo
237 261
 
238 262
     public function time(string $filename): int
239 263
     {
240
-        if (!$this->exists($filename)) {
264
+        if (!$this->exists($filename))
265
+        {
241 266
             throw new FileNotFoundException($filename);
242 267
         }
243 268
 
@@ -268,7 +293,8 @@  discard block
 block discarded – undo
268 293
 
269 294
     public function setPermissions(string $filename, int $mode): bool
270 295
     {
271
-        if (\is_dir($filename)) {
296
+        if (\is_dir($filename))
297
+        {
272 298
             //Directories must always be executable (i.e. 664 for dir => 775)
273 299
             $mode |= 0111;
274 300
         }
@@ -279,8 +305,10 @@  discard block
 block discarded – undo
279 305
     public function getFiles(string $location, ?string $pattern = null): array
280 306
     {
281 307
         $result = [];
282
-        foreach ($this->filesIterator($location, $pattern) as $filename) {
283
-            if ($this->isDirectory($filename->getPathname())) {
308
+        foreach ($this->filesIterator($location, $pattern) as $filename)
309
+        {
310
+            if ($this->isDirectory($filename->getPathname()))
311
+            {
284 312
                 $result = \array_merge($result, $this->getFiles($filename . DIRECTORY_SEPARATOR));
285 313
 
286 314
                 continue;
@@ -294,14 +322,16 @@  discard block
 block discarded – undo
294 322
 
295 323
     public function tempFilename(string $extension = '', ?string $location = null): string
296 324
     {
297
-        if (empty($location)) {
325
+        if (empty($location))
326
+        {
298 327
             $location = \sys_get_temp_dir();
299 328
         }
300 329
 
301 330
         $filename = \tempnam($location, 'spiral');
302 331
         $filename === false and throw new FilesException('Unable to create temporary file.');
303 332
 
304
-        if (!empty($extension)) {
333
+        if (!empty($extension))
334
+        {
305 335
             $old = $filename;
306 336
             $filename = \sprintf('%s.%s', $filename, $extension);
307 337
             \rename($old, $filename);
@@ -314,7 +344,8 @@  discard block
 block discarded – undo
314 344
     public function normalizePath(string $path, bool $asDirectory = false): string
315 345
     {
316 346
         $isUnc = \str_starts_with($path, '\\\\') || \str_starts_with($path, '//');
317
-        if ($isUnc) {
347
+        if ($isUnc)
348
+        {
318 349
             $leadingSlashes = \substr($path, 0, 2);
319 350
             $path = \substr($path, 2);
320 351
         }
@@ -337,15 +368,20 @@  discard block
 block discarded – undo
337 368
         $path = \explode('/', $path);
338 369
         $relative = $path;
339 370
 
340
-        foreach ($from as $depth => $dir) {
371
+        foreach ($from as $depth => $dir)
372
+        {
341 373
             //Find first non-matching dir
342
-            if ($dir === $path[$depth]) {
374
+            if ($dir === $path[$depth])
375
+            {
343 376
                 //Ignore this directory
344 377
                 \array_shift($relative);
345
-            } else {
378
+            }
379
+            else
380
+            {
346 381
                 //Get number of remaining dirs to $from
347 382
                 $remaining = \count($from) - $depth;
348
-                if ($remaining > 1) {
383
+                if ($remaining > 1)
384
+                {
349 385
                     //Add traversals up to first matching directory
350 386
                     $padLength = (\count($relative) + $remaining - 1) * -1;
351 387
                     $relative = \array_pad($relative, $padLength, '..');
@@ -363,7 +399,8 @@  discard block
 block discarded – undo
363 399
      */
364 400
     public function __destruct()
365 401
     {
366
-        foreach ($this->destructFiles as $filename) {
402
+        foreach ($this->destructFiles as $filename)
403
+        {
367 404
             $this->delete($filename);
368 405
         }
369 406
     }
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/ClassNode/LocateVariables.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,9 +15,12 @@  discard block
 block discarded – undo
15 15
 
16 16
     public function enterNode(Node $node): int|Node\Stmt\ClassMethod|null
17 17
     {
18
-        if ($node instanceof Node\Stmt\Class_) {
19
-            foreach ($node->stmts as $stmt) {
20
-                if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name->toLowerString() === '__construct') {
18
+        if ($node instanceof Node\Stmt\Class_)
19
+        {
20
+            foreach ($node->stmts as $stmt)
21
+            {
22
+                if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name->toLowerString() === '__construct')
23
+                {
21 24
                     return $stmt;
22 25
                 }
23 26
             }
@@ -25,7 +28,8 @@  discard block
 block discarded – undo
25 28
             return NodeVisitor::DONT_TRAVERSE_CHILDREN;
26 29
         }
27 30
 
28
-        if ($node instanceof Node\Expr\Variable) {
31
+        if ($node instanceof Node\Expr\Variable)
32
+        {
29 33
             $this->vars[] = $node->name;
30 34
         }
31 35
 
Please login to merge, or discard this patch.