@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | { |
31 | 31 | $this->migrator->configure(); |
32 | 32 | |
33 | - if (empty($this->migrator->getMigrations())) { |
|
33 | + if (empty($this->migrator->getMigrations())){ |
|
34 | 34 | $this->writeln('<comment>No migrations were found.</comment>'); |
35 | 35 | |
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
39 | 39 | $table = $this->table(['Migration', 'Created at', 'Executed at']); |
40 | - foreach ($this->migrator->getMigrations() as $migration) { |
|
40 | + foreach ($this->migrator->getMigrations() as $migration){ |
|
41 | 41 | $state = $migration->getState(); |
42 | 42 | |
43 | 43 | $table->addRow( |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $state->getTimeCreated()->format('Y-m-d H:i:s'), |
47 | 47 | $state->getStatus() == State::STATUS_PENDING |
48 | 48 | ? self::PENDING |
49 | - : '<info>' . $state->getTimeExecuted()->format('Y-m-d H:i:s') . '</info>', |
|
49 | + : '<info>'.$state->getTimeExecuted()->format('Y-m-d H:i:s').'</info>', |
|
50 | 50 | ] |
51 | 51 | ); |
52 | 52 | } |
@@ -30,14 +30,16 @@ |
||
30 | 30 | { |
31 | 31 | $this->migrator->configure(); |
32 | 32 | |
33 | - if (empty($this->migrator->getMigrations())) { |
|
33 | + if (empty($this->migrator->getMigrations())) |
|
34 | + { |
|
34 | 35 | $this->writeln('<comment>No migrations were found.</comment>'); |
35 | 36 | |
36 | 37 | return; |
37 | 38 | } |
38 | 39 | |
39 | 40 | $table = $this->table(['Migration', 'Created at', 'Executed at']); |
40 | - foreach ($this->migrator->getMigrations() as $migration) { |
|
41 | + foreach ($this->migrator->getMigrations() as $migration) |
|
42 | + { |
|
41 | 43 | $state = $migration->getState(); |
42 | 44 | |
43 | 45 | $table->addRow( |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function perform(): void |
28 | 28 | { |
29 | - if (!$this->verifyEnvironment()) { |
|
29 | + if (!$this->verifyEnvironment()){ |
|
30 | 30 | //Making sure we can safely migrate in this environment |
31 | 31 | return; |
32 | 32 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | $found = false; |
37 | 37 | $count = !$this->option('all') ? 1 : PHP_INT_MAX; |
38 | - while ($count > 0 && ($migration = $this->migrator->rollback())) { |
|
38 | + while ($count > 0 && ($migration = $this->migrator->rollback())){ |
|
39 | 39 | $found = true; |
40 | 40 | $count--; |
41 | 41 | $this->sprintf( |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | ); |
45 | 45 | } |
46 | 46 | |
47 | - if (!$found) { |
|
47 | + if (!$found){ |
|
48 | 48 | $this->writeln('<fg=red>No executed migrations were found.</fg=red>'); |
49 | 49 | } |
50 | 50 | } |
@@ -26,7 +26,8 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function perform(): void |
28 | 28 | { |
29 | - if (!$this->verifyEnvironment()) { |
|
29 | + if (!$this->verifyEnvironment()) |
|
30 | + { |
|
30 | 31 | //Making sure we can safely migrate in this environment |
31 | 32 | return; |
32 | 33 | } |
@@ -35,7 +36,8 @@ discard block |
||
35 | 36 | |
36 | 37 | $found = false; |
37 | 38 | $count = !$this->option('all') ? 1 : PHP_INT_MAX; |
38 | - while ($count > 0 && ($migration = $this->migrator->rollback())) { |
|
39 | + while ($count > 0 && ($migration = $this->migrator->rollback())) |
|
40 | + { |
|
39 | 41 | $found = true; |
40 | 42 | $count--; |
41 | 43 | $this->sprintf( |
@@ -44,7 +46,8 @@ discard block |
||
44 | 46 | ); |
45 | 47 | } |
46 | 48 | |
47 | - if (!$found) { |
|
49 | + if (!$found) |
|
50 | + { |
|
48 | 51 | $this->writeln('<fg=red>No executed migrations were found.</fg=red>'); |
49 | 52 | } |
50 | 53 | } |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | ): void { |
53 | 53 | $migrator->configure(); |
54 | 54 | |
55 | - foreach ($migrator->getMigrations() as $migration) { |
|
56 | - if ($migration->getState()->getStatus() !== Status::STATUS_EXECUTED) { |
|
55 | + foreach ($migrator->getMigrations() as $migration){ |
|
56 | + if ($migration->getState()->getStatus() !== Status::STATUS_EXECUTED){ |
|
57 | 57 | $this->writeln('<fg=red>Outstanding migrations found, run `migrate` first.</fg=red>'); |
58 | 58 | return; |
59 | 59 | } |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | ); |
68 | 68 | $schemaCompiler->toMemory($memory); |
69 | 69 | |
70 | - if ($show->hasChanges()) { |
|
70 | + if ($show->hasChanges()){ |
|
71 | 71 | (new Compiler())->compile($registry, [$migrations]); |
72 | 72 | |
73 | - if ($this->option('run')) { |
|
73 | + if ($this->option('run')){ |
|
74 | 74 | $console->run('migrate', [], $this->output); |
75 | 75 | } |
76 | 76 | } |
@@ -52,8 +52,10 @@ discard block |
||
52 | 52 | ): void { |
53 | 53 | $migrator->configure(); |
54 | 54 | |
55 | - foreach ($migrator->getMigrations() as $migration) { |
|
56 | - if ($migration->getState()->getStatus() !== Status::STATUS_EXECUTED) { |
|
55 | + foreach ($migrator->getMigrations() as $migration) |
|
56 | + { |
|
57 | + if ($migration->getState()->getStatus() !== Status::STATUS_EXECUTED) |
|
58 | + { |
|
57 | 59 | $this->writeln('<fg=red>Outstanding migrations found, run `migrate` first.</fg=red>'); |
58 | 60 | return; |
59 | 61 | } |
@@ -67,10 +69,12 @@ discard block |
||
67 | 69 | ); |
68 | 70 | $schemaCompiler->toMemory($memory); |
69 | 71 | |
70 | - if ($show->hasChanges()) { |
|
72 | + if ($show->hasChanges()) |
|
73 | + { |
|
71 | 74 | (new Compiler())->compile($registry, [$migrations]); |
72 | 75 | |
73 | - if ($this->option('run')) { |
|
76 | + if ($this->option('run')) |
|
77 | + { |
|
74 | 78 | $console->run('migrate', [], $this->output); |
75 | 79 | } |
76 | 80 | } |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | { |
31 | 31 | $role = $this->argument('role'); |
32 | 32 | |
33 | - if ($role !== null && !$rbac->hasRole($role)) { |
|
33 | + if ($role !== null && !$rbac->hasRole($role)){ |
|
34 | 34 | throw new CommandException('Unknown role provided'); |
35 | 35 | } |
36 | 36 | |
37 | - if ($role !== null) { |
|
37 | + if ($role !== null){ |
|
38 | 38 | $rows = $this->getRolePermissions($role, $rbac); |
39 | - } else { |
|
39 | + }else{ |
|
40 | 40 | $rows = []; |
41 | 41 | |
42 | - foreach ($rbac->getRoles() as $role) { |
|
42 | + foreach ($rbac->getRoles() as $role){ |
|
43 | 43 | /** @noinspection SlowArrayOperationsInLoopInspection */ |
44 | 44 | $rows = array_merge( |
45 | 45 | $this->getRolePermissions($role, $rbac), |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | $permissions = []; |
69 | 69 | |
70 | - foreach ($rbac->getPermissions($role) as $permission => $rule) { |
|
70 | + foreach ($rbac->getPermissions($role) as $permission => $rule){ |
|
71 | 71 | $permissions[] = [ |
72 | 72 | 'role' => $role, |
73 | 73 | 'permission' => $permission, |
@@ -30,16 +30,21 @@ discard block |
||
30 | 30 | { |
31 | 31 | $role = $this->argument('role'); |
32 | 32 | |
33 | - if ($role !== null && !$rbac->hasRole($role)) { |
|
33 | + if ($role !== null && !$rbac->hasRole($role)) |
|
34 | + { |
|
34 | 35 | throw new CommandException('Unknown role provided'); |
35 | 36 | } |
36 | 37 | |
37 | - if ($role !== null) { |
|
38 | + if ($role !== null) |
|
39 | + { |
|
38 | 40 | $rows = $this->getRolePermissions($role, $rbac); |
39 | - } else { |
|
41 | + } |
|
42 | + else |
|
43 | + { |
|
40 | 44 | $rows = []; |
41 | 45 | |
42 | - foreach ($rbac->getRoles() as $role) { |
|
46 | + foreach ($rbac->getRoles() as $role) |
|
47 | + { |
|
43 | 48 | /** @noinspection SlowArrayOperationsInLoopInspection */ |
44 | 49 | $rows = array_merge( |
45 | 50 | $this->getRolePermissions($role, $rbac), |
@@ -67,7 +72,8 @@ discard block |
||
67 | 72 | { |
68 | 73 | $permissions = []; |
69 | 74 | |
70 | - foreach ($rbac->getPermissions($role) as $permission => $rule) { |
|
75 | + foreach ($rbac->getPermissions($role) as $permission => $rule) |
|
76 | + { |
|
71 | 77 | $permissions[] = [ |
72 | 78 | 'role' => $role, |
73 | 79 | 'permission' => $permission, |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | public function renderBreak(Directive $directive): string |
42 | 42 | { |
43 | - if (isset($directive->values[0])) { |
|
43 | + if (isset($directive->values[0])){ |
|
44 | 44 | return sprintf('<?php break %s; ?>', $directive->values[0]); |
45 | 45 | } |
46 | 46 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | public function renderContinue(Directive $directive): string |
51 | 51 | { |
52 | - if (isset($directive->values[0])) { |
|
52 | + if (isset($directive->values[0])){ |
|
53 | 53 | return sprintf('<?php continue %s; ?>', $directive->values[0]); |
54 | 54 | } |
55 | 55 |
@@ -40,7 +40,8 @@ discard block |
||
40 | 40 | |
41 | 41 | public function renderBreak(Directive $directive): string |
42 | 42 | { |
43 | - if (isset($directive->values[0])) { |
|
43 | + if (isset($directive->values[0])) |
|
44 | + { |
|
44 | 45 | return sprintf('<?php break %s; ?>', $directive->values[0]); |
45 | 46 | } |
46 | 47 | |
@@ -49,7 +50,8 @@ discard block |
||
49 | 50 | |
50 | 51 | public function renderContinue(Directive $directive): string |
51 | 52 | { |
52 | - if (isset($directive->values[0])) { |
|
53 | + if (isset($directive->values[0])) |
|
54 | + { |
|
53 | 55 | return sprintf('<?php continue %s; ?>', $directive->values[0]); |
54 | 56 | } |
55 | 57 |
@@ -32,15 +32,15 @@ |
||
32 | 32 | |
33 | 33 | public function hasDirective(string $name): bool |
34 | 34 | { |
35 | - return $this->r->hasMethod('render' . ucfirst($name)); |
|
35 | + return $this->r->hasMethod('render'.ucfirst($name)); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function render(Directive $directive): ?string |
39 | 39 | { |
40 | - if (!$this->hasDirective($directive->name)) { |
|
40 | + if (!$this->hasDirective($directive->name)){ |
|
41 | 41 | return null; |
42 | 42 | } |
43 | 43 | |
44 | - return call_user_func([$this, 'render' . ucfirst($directive->name)], $directive); |
|
44 | + return call_user_func([$this, 'render'.ucfirst($directive->name)], $directive); |
|
45 | 45 | } |
46 | 46 | } |
@@ -37,7 +37,8 @@ |
||
37 | 37 | |
38 | 38 | public function render(Directive $directive): ?string |
39 | 39 | { |
40 | - if (!$this->hasDirective($directive->name)) { |
|
40 | + if (!$this->hasDirective($directive->name)) |
|
41 | + { |
|
41 | 42 | return null; |
42 | 43 | } |
43 | 44 |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | public function renderCase(Directive $directive): string |
82 | 82 | { |
83 | - if ($this->firstSwitchCase) { |
|
83 | + if ($this->firstSwitchCase){ |
|
84 | 84 | $this->firstSwitchCase = false; |
85 | 85 | |
86 | 86 | return sprintf('case (%s): ?>', $directive->body); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | public function renderDefault(Directive $directive): string |
93 | 93 | { |
94 | - if ($this->firstSwitchCase) { |
|
94 | + if ($this->firstSwitchCase){ |
|
95 | 95 | $this->firstSwitchCase = false; |
96 | 96 | |
97 | 97 | return 'default: ?>'; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | public function renderBreak(Directive $directive): string |
109 | 109 | { |
110 | - if (isset($directive->values[0])) { |
|
110 | + if (isset($directive->values[0])){ |
|
111 | 111 | return sprintf('<?php break %s; ?>', $directive->values[0]); |
112 | 112 | } |
113 | 113 |
@@ -80,7 +80,8 @@ discard block |
||
80 | 80 | |
81 | 81 | public function renderCase(Directive $directive): string |
82 | 82 | { |
83 | - if ($this->firstSwitchCase) { |
|
83 | + if ($this->firstSwitchCase) |
|
84 | + { |
|
84 | 85 | $this->firstSwitchCase = false; |
85 | 86 | |
86 | 87 | return sprintf('case (%s): ?>', $directive->body); |
@@ -91,7 +92,8 @@ discard block |
||
91 | 92 | |
92 | 93 | public function renderDefault(Directive $directive): string |
93 | 94 | { |
94 | - if ($this->firstSwitchCase) { |
|
95 | + if ($this->firstSwitchCase) |
|
96 | + { |
|
95 | 97 | $this->firstSwitchCase = false; |
96 | 98 | |
97 | 99 | return 'default: ?>'; |
@@ -107,7 +109,8 @@ discard block |
||
107 | 109 | |
108 | 110 | public function renderBreak(Directive $directive): string |
109 | 111 | { |
110 | - if (isset($directive->values[0])) { |
|
112 | + if (isset($directive->values[0])) |
|
113 | + { |
|
111 | 114 | return sprintf('<?php break %s; ?>', $directive->values[0]); |
112 | 115 | } |
113 | 116 |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | |
34 | 34 | public function hasDirective(string $name): bool |
35 | 35 | { |
36 | - foreach ($this->directives as $directiveRenderer) { |
|
37 | - if ($directiveRenderer->hasDirective($name)) { |
|
36 | + foreach ($this->directives as $directiveRenderer){ |
|
37 | + if ($directiveRenderer->hasDirective($name)){ |
|
38 | 38 | return true; |
39 | 39 | } |
40 | 40 | } |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | |
45 | 45 | public function render(Directive $directive): ?string |
46 | 46 | { |
47 | - foreach ($this->directives as $directiveRenderer) { |
|
48 | - if ($directiveRenderer->hasDirective($directive->name)) { |
|
47 | + foreach ($this->directives as $directiveRenderer){ |
|
48 | + if ($directiveRenderer->hasDirective($directive->name)){ |
|
49 | 49 | return $directiveRenderer->render($directive); |
50 | 50 | } |
51 | 51 | } |
@@ -33,8 +33,10 @@ discard block |
||
33 | 33 | |
34 | 34 | public function hasDirective(string $name): bool |
35 | 35 | { |
36 | - foreach ($this->directives as $directiveRenderer) { |
|
37 | - if ($directiveRenderer->hasDirective($name)) { |
|
36 | + foreach ($this->directives as $directiveRenderer) |
|
37 | + { |
|
38 | + if ($directiveRenderer->hasDirective($name)) |
|
39 | + { |
|
38 | 40 | return true; |
39 | 41 | } |
40 | 42 | } |
@@ -44,8 +46,10 @@ discard block |
||
44 | 46 | |
45 | 47 | public function render(Directive $directive): ?string |
46 | 48 | { |
47 | - foreach ($this->directives as $directiveRenderer) { |
|
48 | - if ($directiveRenderer->hasDirective($directive->name)) { |
|
49 | + foreach ($this->directives as $directiveRenderer) |
|
50 | + { |
|
51 | + if ($directiveRenderer->hasDirective($directive->name)) |
|
52 | + { |
|
49 | 53 | return $directiveRenderer->render($directive); |
50 | 54 | } |
51 | 55 | } |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | |
34 | 34 | public function withinContext(?Context $ctx, callable $body): void |
35 | 35 | { |
36 | - if ($ctx === null || $ctx->getPath() === null) { |
|
36 | + if ($ctx === null || $ctx->getPath() === null){ |
|
37 | 37 | $body($this); |
38 | 38 | return; |
39 | 39 | } |
40 | 40 | |
41 | - try { |
|
41 | + try{ |
|
42 | 42 | $this->parent = Location::fromContext($ctx, $this->parent); |
43 | 43 | $body($this); |
44 | - } finally { |
|
44 | + }finally{ |
|
45 | 45 | $this->parent = $this->parent->parent; |
46 | 46 | } |
47 | 47 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function push(string $content, Context $ctx = null): void |
53 | 53 | { |
54 | - if ($ctx !== null && $ctx->getPath() !== null) { |
|
54 | + if ($ctx !== null && $ctx->getPath() !== null){ |
|
55 | 55 | $this->locations[strlen($this->content)] = Location::fromContext($ctx, $this->parent); |
56 | 56 | } |
57 | 57 | |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | $paths = []; |
72 | 72 | |
73 | 73 | // We can scan top level only |
74 | - foreach ($this->locations as $loc) { |
|
75 | - if (!in_array($loc->path, $paths, true)) { |
|
74 | + foreach ($this->locations as $loc){ |
|
75 | + if (!in_array($loc->path, $paths, true)){ |
|
76 | 76 | $paths[] = $loc->path; |
77 | 77 | } |
78 | 78 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | { |
88 | 88 | $locations = []; |
89 | 89 | |
90 | - foreach ($this->locations as $offset => $location) { |
|
90 | + foreach ($this->locations as $offset => $location){ |
|
91 | 91 | $locations[$offset] = $location; |
92 | 92 | } |
93 | 93 |
@@ -33,15 +33,19 @@ discard block |
||
33 | 33 | |
34 | 34 | public function withinContext(?Context $ctx, callable $body): void |
35 | 35 | { |
36 | - if ($ctx === null || $ctx->getPath() === null) { |
|
36 | + if ($ctx === null || $ctx->getPath() === null) |
|
37 | + { |
|
37 | 38 | $body($this); |
38 | 39 | return; |
39 | 40 | } |
40 | 41 | |
41 | - try { |
|
42 | + try |
|
43 | + { |
|
42 | 44 | $this->parent = Location::fromContext($ctx, $this->parent); |
43 | 45 | $body($this); |
44 | - } finally { |
|
46 | + } |
|
47 | + finally |
|
48 | + { |
|
45 | 49 | $this->parent = $this->parent->parent; |
46 | 50 | } |
47 | 51 | } |
@@ -51,7 +55,8 @@ discard block |
||
51 | 55 | */ |
52 | 56 | public function push(string $content, Context $ctx = null): void |
53 | 57 | { |
54 | - if ($ctx !== null && $ctx->getPath() !== null) { |
|
58 | + if ($ctx !== null && $ctx->getPath() !== null) |
|
59 | + { |
|
55 | 60 | $this->locations[strlen($this->content)] = Location::fromContext($ctx, $this->parent); |
56 | 61 | } |
57 | 62 | |
@@ -71,8 +76,10 @@ discard block |
||
71 | 76 | $paths = []; |
72 | 77 | |
73 | 78 | // We can scan top level only |
74 | - foreach ($this->locations as $loc) { |
|
75 | - if (!in_array($loc->path, $paths, true)) { |
|
79 | + foreach ($this->locations as $loc) |
|
80 | + { |
|
81 | + if (!in_array($loc->path, $paths, true)) |
|
82 | + { |
|
76 | 83 | $paths[] = $loc->path; |
77 | 84 | } |
78 | 85 | } |
@@ -87,7 +94,8 @@ discard block |
||
87 | 94 | { |
88 | 95 | $locations = []; |
89 | 96 | |
90 | - foreach ($this->locations as $offset => $location) { |
|
97 | + foreach ($this->locations as $offset => $location) |
|
98 | + { |
|
91 | 99 | $locations[$offset] = $location; |
92 | 100 | } |
93 | 101 |