Passed
Push — master ( 1d6cd7...f498cd )
by Aleksei
06:14
created
src/Attributes/src/Composite/SelectiveReader.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@
 block discarded – undo
18 18
      */
19 19
     protected function each(callable $resolver): iterable
20 20
     {
21
-        foreach ($this->readers as $reader) {
21
+        foreach ($this->readers as $reader){
22 22
             $result = $this->iterableToArray($resolver($reader));
23 23
 
24
-            if (\count($result) > 0) {
24
+            if (\count($result) > 0){
25 25
                 return $result;
26 26
             }
27 27
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,10 +18,12 @@
 block discarded – undo
18 18
      */
19 19
     protected function each(callable $resolver): iterable
20 20
     {
21
-        foreach ($this->readers as $reader) {
21
+        foreach ($this->readers as $reader)
22
+        {
22 23
             $result = $this->iterableToArray($resolver($reader));
23 24
 
24
-            if (\count($result) > 0) {
25
+            if (\count($result) > 0)
26
+            {
25 27
                 return $result;
26 28
             }
27 29
         }
Please login to merge, or discard this patch.
src/Framework/Bootloader/Cycle/SchemaBootloader.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
     public function getGenerators(): array
86 86
     {
87 87
         $result = [];
88
-        foreach ($this->generators as $group) {
89
-            foreach ($group as $generator) {
90
-                if (is_object($generator) && !$generator instanceof Container\Autowire) {
88
+        foreach ($this->generators as $group){
89
+            foreach ($group as $generator){
90
+                if (is_object($generator) && !$generator instanceof Container\Autowire){
91 91
                     $result[] = $generator;
92
-                } else {
92
+                }else{
93 93
                     $result[] = $this->container->get($generator);
94 94
                 }
95 95
             }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     protected function schema(MemoryInterface $memory): SchemaInterface
108 108
     {
109 109
         $schemaCompiler = SchemaCompiler::fromMemory($memory);
110
-        if ($schemaCompiler->isEmpty()) {
110
+        if ($schemaCompiler->isEmpty()){
111 111
             $schemaCompiler = SchemaCompiler::compile(
112 112
                 $this->container->get(Registry::class),
113 113
                 $this->getGenerators()
Please login to merge, or discard this patch.
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -85,11 +85,16 @@  discard block
 block discarded – undo
85 85
     public function getGenerators(): array
86 86
     {
87 87
         $result = [];
88
-        foreach ($this->generators as $group) {
89
-            foreach ($group as $generator) {
90
-                if (is_object($generator) && !$generator instanceof Container\Autowire) {
88
+        foreach ($this->generators as $group)
89
+        {
90
+            foreach ($group as $generator)
91
+            {
92
+                if (is_object($generator) && !$generator instanceof Container\Autowire)
93
+                {
91 94
                     $result[] = $generator;
92
-                } else {
95
+                }
96
+                else
97
+                {
93 98
                     $result[] = $this->container->get($generator);
94 99
                 }
95 100
             }
@@ -107,7 +112,8 @@  discard block
 block discarded – undo
107 112
     protected function schema(MemoryInterface $memory): SchemaInterface
108 113
     {
109 114
         $schemaCompiler = SchemaCompiler::fromMemory($memory);
110
-        if ($schemaCompiler->isEmpty()) {
115
+        if ($schemaCompiler->isEmpty())
116
+        {
111 117
             $schemaCompiler = SchemaCompiler::compile(
112 118
                 $this->container->get(Registry::class),
113 119
                 $this->getGenerators()
Please login to merge, or discard this patch.
src/Framework/Command/Cycle/SyncCommand.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
         );
45 45
         $schemaCompiler->toMemory($memory);
46 46
 
47
-        if ($show->hasChanges()) {
47
+        if ($show->hasChanges()){
48 48
             $this->writeln("\n<info>ORM Schema has been synchronized</info>");
49 49
         }
50 50
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,8 @@
 block discarded – undo
44 44
         );
45 45
         $schemaCompiler->toMemory($memory);
46 46
 
47
-        if ($show->hasChanges()) {
47
+        if ($show->hasChanges())
48
+        {
48 49
             $this->writeln("\n<info>ORM Schema has been synchronized</info>");
49 50
         }
50 51
     }
Please login to merge, or discard this patch.
src/Prototype/tests/Commands/AbstractCommandsTest.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 
40 40
     public function __construct($name = null, array $data = [], $dataName = '')
41 41
     {
42
-        $this->storage = new Storage($this->dir() . '/Fixtures/');
42
+        $this->storage = new Storage($this->dir().'/Fixtures/');
43 43
         parent::__construct($name, $data, $dataName);
44 44
     }
45 45
 
46 46
     public function setUp(): void
47 47
     {
48
-        if (!\class_exists(Kernel::class)) {
48
+        if (!\class_exists(Kernel::class)){
49 49
             $this->markTestSkipped('A "spiral/framework" dependency is required to run these tests');
50 50
         }
51 51
 
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
             'cache'  => sys_get_temp_dir()
57 57
         ], null, false);
58 58
 
59
-        foreach (static::STORE as $name) {
59
+        foreach (static::STORE as $name){
60 60
             $this->storage->store($name);
61 61
         }
62 62
     }
63 63
 
64 64
     public function tearDown(): void
65 65
     {
66
-        foreach (static::STORE as $name) {
66
+        foreach (static::STORE as $name){
67 67
             $this->storage->restore($name);
68 68
         }
69 69
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,7 +45,8 @@  discard block
 block discarded – undo
45 45
 
46 46
     public function setUp(): void
47 47
     {
48
-        if (!\class_exists(Kernel::class)) {
48
+        if (!\class_exists(Kernel::class))
49
+        {
49 50
             $this->markTestSkipped('A "spiral/framework" dependency is required to run these tests');
50 51
         }
51 52
 
@@ -56,14 +57,16 @@  discard block
 block discarded – undo
56 57
             'cache'  => sys_get_temp_dir()
57 58
         ], null, false);
58 59
 
59
-        foreach (static::STORE as $name) {
60
+        foreach (static::STORE as $name)
61
+        {
60 62
             $this->storage->store($name);
61 63
         }
62 64
     }
63 65
 
64 66
     public function tearDown(): void
65 67
     {
66
-        foreach (static::STORE as $name) {
68
+        foreach (static::STORE as $name)
69
+        {
67 70
             $this->storage->restore($name);
68 71
         }
69 72
     }
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/ClassNode/LocateStatements.php 2 patches
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 Node\Stmt\Use_) {
31
-            foreach ($node->uses as $use) {
30
+        if ($node instanceof Node\Stmt\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.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,10 @@
 block discarded – undo
27 27
      */
28 28
     public function enterNode(Node $node)
29 29
     {
30
-        if ($node instanceof Node\Stmt\Use_) {
31
-            foreach ($node->uses as $use) {
30
+        if ($node instanceof Node\Stmt\Use_)
31
+        {
32
+            foreach ($node->uses as $use)
33
+            {
32 34
                 $this->imports[] = [
33 35
                     'name'  => implode('\\', $use->name->parts),
34 36
                     'alias' => $use->alias->name ?? null,
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/ClassNode/LocateVariables.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@
 block discarded – undo
25 25
      */
26 26
     public function enterNode(Node $node)
27 27
     {
28
-        if ($node instanceof Node\Stmt\Class_) {
29
-            foreach ($node->stmts as $stmt) {
30
-                if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct') {
28
+        if ($node instanceof Node\Stmt\Class_){
29
+            foreach ($node->stmts as $stmt){
30
+                if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct'){
31 31
                     return $stmt;
32 32
                 }
33 33
             }
34 34
             return NodeTraverser::DONT_TRAVERSE_CHILDREN;
35 35
         }
36 36
 
37
-        if ($node instanceof Node\Expr\Variable) {
37
+        if ($node instanceof Node\Expr\Variable){
38 38
             $this->vars[] = $node->name;
39 39
         }
40 40
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,16 +25,20 @@
 block discarded – undo
25 25
      */
26 26
     public function enterNode(Node $node)
27 27
     {
28
-        if ($node instanceof Node\Stmt\Class_) {
29
-            foreach ($node->stmts as $stmt) {
30
-                if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct') {
28
+        if ($node instanceof Node\Stmt\Class_)
29
+        {
30
+            foreach ($node->stmts as $stmt)
31
+            {
32
+                if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct')
33
+                {
31 34
                     return $stmt;
32 35
                 }
33 36
             }
34 37
             return NodeTraverser::DONT_TRAVERSE_CHILDREN;
35 38
         }
36 39
 
37
-        if ($node instanceof Node\Expr\Variable) {
40
+        if ($node instanceof Node\Expr\Variable)
41
+        {
38 42
             $this->vars[] = $node->name;
39 43
         }
40 44
 
Please login to merge, or discard this patch.
src/Prototype/tests/Commands/InjectCommandTest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         $source = file_get_contents($filename);
30 30
         $this->assertStringContainsString('use PrototypeTrait;', $source);
31 31
 
32
-        try {
32
+        try{
33 33
             $this->app->bindApp();
34 34
 
35 35
             $inp = new ArrayInput(['--remove' => true]);
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
             $this->app->get(Console::class)->run('prototype:inject', $inp, $out);
38 38
 
39 39
             $this->assertStringNotContainsString('use PrototypeTrait;', file_get_contents($filename));
40
-        } finally {
40
+        }finally{
41 41
             file_put_contents($filename, $source);
42 42
         }
43 43
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,8 @@  discard block
 block discarded – undo
29 29
         $source = file_get_contents($filename);
30 30
         $this->assertStringContainsString('use PrototypeTrait;', $source);
31 31
 
32
-        try {
32
+        try
33
+        {
33 34
             $this->app->bindApp();
34 35
 
35 36
             $inp = new ArrayInput(['--remove' => true]);
@@ -37,7 +38,9 @@  discard block
 block discarded – undo
37 38
             $this->app->get(Console::class)->run('prototype:inject', $inp, $out);
38 39
 
39 40
             $this->assertStringNotContainsString('use PrototypeTrait;', file_get_contents($filename));
40
-        } finally {
41
+        }
42
+        finally
43
+        {
41 44
             file_put_contents($filename, $source);
42 45
         }
43 46
     }
Please login to merge, or discard this patch.
src/Views/src/Processor/ContextProcessor.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,8 @@
 block discarded – undo
39 39
      */
40 40
     public function process(ViewSource $source, ContextInterface $context): ViewSource
41 41
     {
42
-        return $source->withCode(preg_replace_callback($this->pattern, static function ($matches) use ($context) {
42
+        return $source->withCode(preg_replace_callback($this->pattern, static function ($matches) use ($context)
43
+        {
43 44
             return $context->resolveValue($matches[1]);
44 45
         }, $source->getCode()));
45 46
     }
Please login to merge, or discard this patch.
src/Files/src/Files.php 3 patches
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function __destruct()
47 47
     {
48
-        foreach ($this->destructFiles as $filename) {
48
+        foreach ($this->destructFiles as $filename){
49 49
             $this->delete($filename);
50 50
         }
51 51
     }
@@ -60,30 +60,30 @@  discard block
 block discarded – undo
60 60
         int $mode = null,
61 61
         bool $recursivePermissions = true
62 62
     ): bool {
63
-        if (empty($mode)) {
63
+        if (empty($mode)){
64 64
             $mode = self::DEFAULT_FILE_MODE;
65 65
         }
66 66
 
67 67
         //Directories always executable
68 68
         $mode = $mode | 0111;
69
-        if (is_dir($directory)) {
69
+        if (is_dir($directory)){
70 70
             //Exists :(
71 71
             return $this->setPermissions($directory, $mode);
72 72
         }
73 73
 
74
-        if (!$recursivePermissions) {
74
+        if (!$recursivePermissions){
75 75
             return mkdir($directory, $mode, true);
76 76
         }
77 77
 
78 78
         $directoryChain = [basename($directory)];
79 79
 
80 80
         $baseDirectory = $directory;
81
-        while (!is_dir($baseDirectory = dirname($baseDirectory))) {
81
+        while (!is_dir($baseDirectory = dirname($baseDirectory))){
82 82
             $directoryChain[] = basename($baseDirectory);
83 83
         }
84 84
 
85
-        foreach (array_reverse($directoryChain) as $directory) {
86
-            if (!mkdir($baseDirectory = "{$baseDirectory}/{$directory}")) {
85
+        foreach (array_reverse($directoryChain) as $directory){
86
+            if (!mkdir($baseDirectory = "{$baseDirectory}/{$directory}")){
87 87
                 return false;
88 88
             }
89 89
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function read(string $filename): string
100 100
     {
101
-        if (!$this->exists($filename)) {
101
+        if (!$this->exists($filename)){
102 102
             throw new FileNotFoundException($filename);
103 103
         }
104 104
 
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
     ): bool {
120 120
         $mode = $mode ?? self::DEFAULT_FILE_MODE;
121 121
 
122
-        try {
123
-            if ($ensureDirectory) {
122
+        try{
123
+            if ($ensureDirectory){
124 124
                 $this->ensureDirectory(dirname($filename), $mode);
125 125
             }
126 126
 
127
-            if ($this->exists($filename)) {
127
+            if ($this->exists($filename)){
128 128
                 //Forcing mode for existed file
129 129
                 $this->setPermissions($filename, $mode);
130 130
             }
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
                 $append ? FILE_APPEND | LOCK_EX : LOCK_EX
136 136
             );
137 137
 
138
-            if ($result !== false) {
138
+            if ($result !== false){
139 139
                 //Forcing mode after file creation
140 140
                 $this->setPermissions($filename, $mode);
141 141
             }
142
-        } catch (\Exception $e) {
142
+        }catch (\Exception $e){
143 143
             throw new WriteErrorException($e->getMessage(), $e->getCode(), $e);
144 144
         }
145 145
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      */
164 164
     public function delete(string $filename)
165 165
     {
166
-        if ($this->exists($filename)) {
166
+        if ($this->exists($filename)){
167 167
             $result = unlink($filename);
168 168
 
169 169
             //Wiping out changes in local file cache
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
      */
188 188
     public function deleteDirectory(string $directory, bool $contentOnly = false): void
189 189
     {
190
-        if (!$this->isDirectory($directory)) {
190
+        if (!$this->isDirectory($directory)){
191 191
             throw new FilesException("Undefined or invalid directory {$directory}");
192 192
         }
193 193
 
@@ -196,15 +196,15 @@  discard block
 block discarded – undo
196 196
             \RecursiveIteratorIterator::CHILD_FIRST
197 197
         );
198 198
 
199
-        foreach ($files as $file) {
200
-            if ($file->isDir()) {
199
+        foreach ($files as $file){
200
+            if ($file->isDir()){
201 201
                 rmdir($file->getRealPath());
202
-            } else {
202
+            }else{
203 203
                 $this->delete($file->getRealPath());
204 204
             }
205 205
         }
206 206
 
207
-        if (!$contentOnly) {
207
+        if (!$contentOnly){
208 208
             rmdir($directory);
209 209
         }
210 210
     }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
      */
215 215
     public function move(string $filename, string $destination): bool
216 216
     {
217
-        if (!$this->exists($filename)) {
217
+        if (!$this->exists($filename)){
218 218
             throw new FileNotFoundException($filename);
219 219
         }
220 220
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      */
227 227
     public function copy(string $filename, string $destination): bool
228 228
     {
229
-        if (!$this->exists($filename)) {
229
+        if (!$this->exists($filename)){
230 230
             throw new FileNotFoundException($filename);
231 231
         }
232 232
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
      */
239 239
     public function touch(string $filename, int $mode = null): bool
240 240
     {
241
-        if (!touch($filename)) {
241
+        if (!touch($filename)){
242 242
             return false;
243 243
         }
244 244
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      */
259 259
     public function size(string $filename): int
260 260
     {
261
-        if (!$this->exists($filename)) {
261
+        if (!$this->exists($filename)){
262 262
             throw new FileNotFoundException($filename);
263 263
         }
264 264
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
      */
279 279
     public function md5(string $filename): string
280 280
     {
281
-        if (!$this->exists($filename)) {
281
+        if (!$this->exists($filename)){
282 282
             throw new FileNotFoundException($filename);
283 283
         }
284 284
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
      */
291 291
     public function time(string $filename): int
292 292
     {
293
-        if (!$this->exists($filename)) {
293
+        if (!$this->exists($filename)){
294 294
             throw new FileNotFoundException($filename);
295 295
         }
296 296
 
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
      */
319 319
     public function getPermissions(string $filename): int
320 320
     {
321
-        if (!$this->exists($filename)) {
321
+        if (!$this->exists($filename)){
322 322
             throw new FileNotFoundException($filename);
323 323
         }
324 324
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
      */
331 331
     public function setPermissions(string $filename, int $mode)
332 332
     {
333
-        if (is_dir($filename)) {
333
+        if (is_dir($filename)){
334 334
             //Directories must always be executable (i.e. 664 for dir => 775)
335 335
             $mode |= 0111;
336 336
         }
@@ -344,9 +344,9 @@  discard block
 block discarded – undo
344 344
     public function getFiles(string $location, string $pattern = null): array
345 345
     {
346 346
         $result = [];
347
-        foreach ($this->filesIterator($location, $pattern) as $filename) {
348
-            if ($this->isDirectory($filename->getPathname())) {
349
-                $result = array_merge($result, $this->getFiles($filename . DIRECTORY_SEPARATOR));
347
+        foreach ($this->filesIterator($location, $pattern) as $filename){
348
+            if ($this->isDirectory($filename->getPathname())){
349
+                $result = array_merge($result, $this->getFiles($filename.DIRECTORY_SEPARATOR));
350 350
 
351 351
                 continue;
352 352
             }
@@ -362,13 +362,13 @@  discard block
 block discarded – undo
362 362
      */
363 363
     public function tempFilename(string $extension = '', string $location = null): string
364 364
     {
365
-        if (empty($location)) {
365
+        if (empty($location)){
366 366
             $location = sys_get_temp_dir();
367 367
         }
368 368
 
369 369
         $filename = tempnam($location, 'spiral');
370 370
 
371
-        if (!empty($extension)) {
371
+        if (!empty($extension)){
372 372
             [$old, $filename] = [$filename, "{$filename}.{$extension}"];
373 373
             rename($old, $filename);
374 374
             $this->destructFiles[] = $filename;
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
         $path = str_replace(['//', '\\'], '/', $path);
386 386
 
387 387
         //Potentially open links and ../ type directories?
388
-        return rtrim($path, '/') . ($asDirectory ? '/' : '');
388
+        return rtrim($path, '/').($asDirectory ? '/' : '');
389 389
     }
390 390
 
391 391
     /**
@@ -402,21 +402,21 @@  discard block
 block discarded – undo
402 402
         $path = explode('/', $path);
403 403
         $relative = $path;
404 404
 
405
-        foreach ($from as $depth => $dir) {
405
+        foreach ($from as $depth => $dir){
406 406
             //Find first non-matching dir
407
-            if ($dir === $path[$depth]) {
407
+            if ($dir === $path[$depth]){
408 408
                 //Ignore this directory
409 409
                 array_shift($relative);
410
-            } else {
410
+            }else{
411 411
                 //Get number of remaining dirs to $from
412 412
                 $remaining = count($from) - $depth;
413
-                if ($remaining > 1) {
413
+                if ($remaining > 1){
414 414
                     //Add traversals up to first matching directory
415 415
                     $padLength = (count($relative) + $remaining - 1) * -1;
416 416
                     $relative = array_pad($relative, $padLength, '..');
417 417
                     break;
418 418
                 }
419
-                $relative[0] = './' . $relative[0];
419
+                $relative[0] = './'.$relative[0];
420 420
             }
421 421
         }
422 422
 
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
     private function filesIterator(string $location, string $pattern = null): \GlobIterator
433 433
     {
434 434
         $pattern = $pattern ?? '*';
435
-        $regexp = rtrim($location, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($pattern, DIRECTORY_SEPARATOR);
435
+        $regexp = rtrim($location, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.ltrim($pattern, DIRECTORY_SEPARATOR);
436 436
 
437 437
         return new \GlobIterator($regexp);
438 438
     }
Please login to merge, or discard this patch.
Braces   +73 added lines, -35 removed lines patch added patch discarded remove patch
@@ -45,7 +45,8 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function __destruct()
47 47
     {
48
-        foreach ($this->destructFiles as $filename) {
48
+        foreach ($this->destructFiles as $filename)
49
+        {
49 50
             $this->delete($filename);
50 51
         }
51 52
     }
@@ -60,30 +61,36 @@  discard block
 block discarded – undo
60 61
         int $mode = null,
61 62
         bool $recursivePermissions = true
62 63
     ): bool {
63
-        if (empty($mode)) {
64
+        if (empty($mode))
65
+        {
64 66
             $mode = self::DEFAULT_FILE_MODE;
65 67
         }
66 68
 
67 69
         //Directories always executable
68 70
         $mode = $mode | 0111;
69
-        if (is_dir($directory)) {
71
+        if (is_dir($directory))
72
+        {
70 73
             //Exists :(
71 74
             return $this->setPermissions($directory, $mode);
72 75
         }
73 76
 
74
-        if (!$recursivePermissions) {
77
+        if (!$recursivePermissions)
78
+        {
75 79
             return mkdir($directory, $mode, true);
76 80
         }
77 81
 
78 82
         $directoryChain = [basename($directory)];
79 83
 
80 84
         $baseDirectory = $directory;
81
-        while (!is_dir($baseDirectory = dirname($baseDirectory))) {
85
+        while (!is_dir($baseDirectory = dirname($baseDirectory)))
86
+        {
82 87
             $directoryChain[] = basename($baseDirectory);
83 88
         }
84 89
 
85
-        foreach (array_reverse($directoryChain) as $directory) {
86
-            if (!mkdir($baseDirectory = "{$baseDirectory}/{$directory}")) {
90
+        foreach (array_reverse($directoryChain) as $directory)
91
+        {
92
+            if (!mkdir($baseDirectory = "{$baseDirectory}/{$directory}"))
93
+            {
87 94
                 return false;
88 95
             }
89 96
 
@@ -98,7 +105,8 @@  discard block
 block discarded – undo
98 105
      */
99 106
     public function read(string $filename): string
100 107
     {
101
-        if (!$this->exists($filename)) {
108
+        if (!$this->exists($filename))
109
+        {
102 110
             throw new FileNotFoundException($filename);
103 111
         }
104 112
 
@@ -119,12 +127,15 @@  discard block
 block discarded – undo
119 127
     ): bool {
120 128
         $mode = $mode ?? self::DEFAULT_FILE_MODE;
121 129
 
122
-        try {
123
-            if ($ensureDirectory) {
130
+        try
131
+        {
132
+            if ($ensureDirectory)
133
+            {
124 134
                 $this->ensureDirectory(dirname($filename), $mode);
125 135
             }
126 136
 
127
-            if ($this->exists($filename)) {
137
+            if ($this->exists($filename))
138
+            {
128 139
                 //Forcing mode for existed file
129 140
                 $this->setPermissions($filename, $mode);
130 141
             }
@@ -135,11 +146,14 @@  discard block
 block discarded – undo
135 146
                 $append ? FILE_APPEND | LOCK_EX : LOCK_EX
136 147
             );
137 148
 
138
-            if ($result !== false) {
149
+            if ($result !== false)
150
+            {
139 151
                 //Forcing mode after file creation
140 152
                 $this->setPermissions($filename, $mode);
141 153
             }
142
-        } catch (\Exception $e) {
154
+        }
155
+        catch (\Exception $e)
156
+        {
143 157
             throw new WriteErrorException($e->getMessage(), $e->getCode(), $e);
144 158
         }
145 159
 
@@ -163,7 +177,8 @@  discard block
 block discarded – undo
163 177
      */
164 178
     public function delete(string $filename)
165 179
     {
166
-        if ($this->exists($filename)) {
180
+        if ($this->exists($filename))
181
+        {
167 182
             $result = unlink($filename);
168 183
 
169 184
             //Wiping out changes in local file cache
@@ -187,7 +202,8 @@  discard block
 block discarded – undo
187 202
      */
188 203
     public function deleteDirectory(string $directory, bool $contentOnly = false): void
189 204
     {
190
-        if (!$this->isDirectory($directory)) {
205
+        if (!$this->isDirectory($directory))
206
+        {
191 207
             throw new FilesException("Undefined or invalid directory {$directory}");
192 208
         }
193 209
 
@@ -196,15 +212,20 @@  discard block
 block discarded – undo
196 212
             \RecursiveIteratorIterator::CHILD_FIRST
197 213
         );
198 214
 
199
-        foreach ($files as $file) {
200
-            if ($file->isDir()) {
215
+        foreach ($files as $file)
216
+        {
217
+            if ($file->isDir())
218
+            {
201 219
                 rmdir($file->getRealPath());
202
-            } else {
220
+            }
221
+            else
222
+            {
203 223
                 $this->delete($file->getRealPath());
204 224
             }
205 225
         }
206 226
 
207
-        if (!$contentOnly) {
227
+        if (!$contentOnly)
228
+        {
208 229
             rmdir($directory);
209 230
         }
210 231
     }
@@ -214,7 +235,8 @@  discard block
 block discarded – undo
214 235
      */
215 236
     public function move(string $filename, string $destination): bool
216 237
     {
217
-        if (!$this->exists($filename)) {
238
+        if (!$this->exists($filename))
239
+        {
218 240
             throw new FileNotFoundException($filename);
219 241
         }
220 242
 
@@ -226,7 +248,8 @@  discard block
 block discarded – undo
226 248
      */
227 249
     public function copy(string $filename, string $destination): bool
228 250
     {
229
-        if (!$this->exists($filename)) {
251
+        if (!$this->exists($filename))
252
+        {
230 253
             throw new FileNotFoundException($filename);
231 254
         }
232 255
 
@@ -238,7 +261,8 @@  discard block
 block discarded – undo
238 261
      */
239 262
     public function touch(string $filename, int $mode = null): bool
240 263
     {
241
-        if (!touch($filename)) {
264
+        if (!touch($filename))
265
+        {
242 266
             return false;
243 267
         }
244 268
 
@@ -258,7 +282,8 @@  discard block
 block discarded – undo
258 282
      */
259 283
     public function size(string $filename): int
260 284
     {
261
-        if (!$this->exists($filename)) {
285
+        if (!$this->exists($filename))
286
+        {
262 287
             throw new FileNotFoundException($filename);
263 288
         }
264 289
 
@@ -278,7 +303,8 @@  discard block
 block discarded – undo
278 303
      */
279 304
     public function md5(string $filename): string
280 305
     {
281
-        if (!$this->exists($filename)) {
306
+        if (!$this->exists($filename))
307
+        {
282 308
             throw new FileNotFoundException($filename);
283 309
         }
284 310
 
@@ -290,7 +316,8 @@  discard block
 block discarded – undo
290 316
      */
291 317
     public function time(string $filename): int
292 318
     {
293
-        if (!$this->exists($filename)) {
319
+        if (!$this->exists($filename))
320
+        {
294 321
             throw new FileNotFoundException($filename);
295 322
         }
296 323
 
@@ -318,7 +345,8 @@  discard block
 block discarded – undo
318 345
      */
319 346
     public function getPermissions(string $filename): int
320 347
     {
321
-        if (!$this->exists($filename)) {
348
+        if (!$this->exists($filename))
349
+        {
322 350
             throw new FileNotFoundException($filename);
323 351
         }
324 352
 
@@ -330,7 +358,8 @@  discard block
 block discarded – undo
330 358
      */
331 359
     public function setPermissions(string $filename, int $mode)
332 360
     {
333
-        if (is_dir($filename)) {
361
+        if (is_dir($filename))
362
+        {
334 363
             //Directories must always be executable (i.e. 664 for dir => 775)
335 364
             $mode |= 0111;
336 365
         }
@@ -344,8 +373,10 @@  discard block
 block discarded – undo
344 373
     public function getFiles(string $location, string $pattern = null): array
345 374
     {
346 375
         $result = [];
347
-        foreach ($this->filesIterator($location, $pattern) as $filename) {
348
-            if ($this->isDirectory($filename->getPathname())) {
376
+        foreach ($this->filesIterator($location, $pattern) as $filename)
377
+        {
378
+            if ($this->isDirectory($filename->getPathname()))
379
+            {
349 380
                 $result = array_merge($result, $this->getFiles($filename . DIRECTORY_SEPARATOR));
350 381
 
351 382
                 continue;
@@ -362,13 +393,15 @@  discard block
 block discarded – undo
362 393
      */
363 394
     public function tempFilename(string $extension = '', string $location = null): string
364 395
     {
365
-        if (empty($location)) {
396
+        if (empty($location))
397
+        {
366 398
             $location = sys_get_temp_dir();
367 399
         }
368 400
 
369 401
         $filename = tempnam($location, 'spiral');
370 402
 
371
-        if (!empty($extension)) {
403
+        if (!empty($extension))
404
+        {
372 405
             [$old, $filename] = [$filename, "{$filename}.{$extension}"];
373 406
             rename($old, $filename);
374 407
             $this->destructFiles[] = $filename;
@@ -402,15 +435,20 @@  discard block
 block discarded – undo
402 435
         $path = explode('/', $path);
403 436
         $relative = $path;
404 437
 
405
-        foreach ($from as $depth => $dir) {
438
+        foreach ($from as $depth => $dir)
439
+        {
406 440
             //Find first non-matching dir
407
-            if ($dir === $path[$depth]) {
441
+            if ($dir === $path[$depth])
442
+            {
408 443
                 //Ignore this directory
409 444
                 array_shift($relative);
410
-            } else {
445
+            }
446
+            else
447
+            {
411 448
                 //Get number of remaining dirs to $from
412 449
                 $remaining = count($from) - $depth;
413
-                if ($remaining > 1) {
450
+                if ($remaining > 1)
451
+                {
414 452
                     //Add traversals up to first matching directory
415 453
                     $padLength = (count($relative) + $remaining - 1) * -1;
416 454
                     $relative = array_pad($relative, $padLength, '..');
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     /**
24 24
      * Default file mode for this manager.
25 25
      */
26
-    public const DEFAULT_FILE_MODE = self::READONLY;
26
+    public const DEFAULT_FILE_MODE = self::readonly;
27 27
 
28 28
     /**
29 29
      * Files to be removed when component destructed.
Please login to merge, or discard this patch.