@@ -36,8 +36,8 @@ |
||
36 | 36 | public function locateCommands(): array |
37 | 37 | { |
38 | 38 | $commands = []; |
39 | - foreach ($this->classes->getClasses(\Symfony\Component\Console\Command\Command::class) as $class) { |
|
40 | - if ($class->isAbstract()) { |
|
39 | + foreach ($this->classes->getClasses(\Symfony\Component\Console\Command\Command::class) as $class){ |
|
40 | + if ($class->isAbstract()){ |
|
41 | 41 | continue; |
42 | 42 | } |
43 | 43 |
@@ -36,8 +36,10 @@ |
||
36 | 36 | public function locateCommands(): array |
37 | 37 | { |
38 | 38 | $commands = []; |
39 | - foreach ($this->classes->getClasses(\Symfony\Component\Console\Command\Command::class) as $class) { |
|
40 | - if ($class->isAbstract()) { |
|
39 | + foreach ($this->classes->getClasses(\Symfony\Component\Console\Command\Command::class) as $class) |
|
40 | + { |
|
41 | + if ($class->isAbstract()) |
|
42 | + { |
|
41 | 43 | continue; |
42 | 44 | } |
43 | 45 |
@@ -46,7 +46,8 @@ |
||
46 | 46 | //We are not forcing locale for now |
47 | 47 | return $source->withCode(preg_replace_callback( |
48 | 48 | self::REGEXP, |
49 | - function ($matches) use ($domain, $context) { |
|
49 | + function ($matches) use ($domain, $context) |
|
50 | + { |
|
50 | 51 | return $this->translator->trans( |
51 | 52 | $matches[1], |
52 | 53 | [], |
@@ -57,8 +57,10 @@ discard block |
||
57 | 57 | { |
58 | 58 | $consumer = $this->container->get(Consumer::class); |
59 | 59 | |
60 | - $consumer->serve(function (\Throwable $e = null) { |
|
61 | - if ($e !== null) { |
|
60 | + $consumer->serve(function (\Throwable $e = null) |
|
61 | + { |
|
62 | + if ($e !== null) |
|
63 | + { |
|
62 | 64 | $this->handleException($e); |
63 | 65 | } |
64 | 66 | |
@@ -71,9 +73,12 @@ discard block |
||
71 | 73 | */ |
72 | 74 | protected function handleException(\Throwable $e) |
73 | 75 | { |
74 | - try { |
|
76 | + try |
|
77 | + { |
|
75 | 78 | $this->container->get(SnapshotterInterface::class)->register($e); |
76 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
79 | + } |
|
80 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
81 | + { |
|
77 | 82 | // no need to notify when unable to register an exception |
78 | 83 | } |
79 | 84 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | EnvironmentInterface $env, |
37 | 37 | FinalizerInterface $finalizer, |
38 | 38 | ContainerInterface $container |
39 | - ) { |
|
39 | + ){ |
|
40 | 40 | $this->env = $env; |
41 | 41 | $this->finalizer = $finalizer; |
42 | 42 | $this->container = $container; |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | { |
58 | 58 | $consumer = $this->container->get(Consumer::class); |
59 | 59 | |
60 | - $consumer->serve(function (\Throwable $e = null) { |
|
61 | - if ($e !== null) { |
|
60 | + $consumer->serve(function (\Throwable $e = null){ |
|
61 | + if ($e !== null){ |
|
62 | 62 | $this->handleException($e); |
63 | 63 | } |
64 | 64 | |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | */ |
72 | 72 | protected function handleException(\Throwable $e) |
73 | 73 | { |
74 | - try { |
|
74 | + try{ |
|
75 | 75 | $this->container->get(SnapshotterInterface::class)->register($e); |
76 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
76 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
77 | 77 | // no need to notify when unable to register an exception |
78 | 78 | } |
79 | 79 | } |
@@ -37,13 +37,13 @@ |
||
37 | 37 | $output = $this->runCommandDebug('cycle:migrate', ['-r' => true]); |
38 | 38 | $this->assertContains('default.users', $output); |
39 | 39 | |
40 | - $user = file_get_contents(__DIR__ . '/../../app/src/User/User.php'); |
|
41 | - unlink(__DIR__ . '/../../app/src/User/User.php'); |
|
42 | - try { |
|
40 | + $user = file_get_contents(__DIR__.'/../../app/src/User/User.php'); |
|
41 | + unlink(__DIR__.'/../../app/src/User/User.php'); |
|
42 | + try{ |
|
43 | 43 | $output = $this->runCommandDebug('cycle:migrate', ['-r' => true]); |
44 | 44 | $this->assertContains('drop foreign key', $output); |
45 | - } finally { |
|
46 | - file_put_contents(__DIR__ . '/../../app/src/User/User.php', $user); |
|
45 | + }finally{ |
|
46 | + file_put_contents(__DIR__.'/../../app/src/User/User.php', $user); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | } |
50 | 50 | \ No newline at end of file |
@@ -39,10 +39,13 @@ |
||
39 | 39 | |
40 | 40 | $user = file_get_contents(__DIR__ . '/../../app/src/User/User.php'); |
41 | 41 | unlink(__DIR__ . '/../../app/src/User/User.php'); |
42 | - try { |
|
42 | + try |
|
43 | + { |
|
43 | 44 | $output = $this->runCommandDebug('cycle:migrate', ['-r' => true]); |
44 | 45 | $this->assertContains('drop foreign key', $output); |
45 | - } finally { |
|
46 | + } |
|
47 | + finally |
|
48 | + { |
|
46 | 49 | file_put_contents(__DIR__ . '/../../app/src/User/User.php', $user); |
47 | 50 | } |
48 | 51 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $this->assertNull($this->app->getEnvironment()->get('FIRED')); |
39 | 39 | |
40 | 40 | $w->shouldReceive('receive')->once()->with( |
41 | - \Mockery::on(function (&$context) { |
|
41 | + \Mockery::on(function (&$context){ |
|
42 | 42 | $context = '{ |
43 | 43 | "id": "1", |
44 | 44 | "job": "spiral.app.job.TestJob" |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $this->app->getContainer()->bind(Worker::class, $w); |
67 | 67 | |
68 | 68 | $w->shouldReceive('receive')->once()->with( |
69 | - \Mockery::on(function (&$context) { |
|
69 | + \Mockery::on(function (&$context){ |
|
70 | 70 | $context = '{ |
71 | 71 | "id": "1", |
72 | 72 | "job": "spiral.app.job.ErrorJob" |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $w->shouldReceive('receive')->once()->andReturn(null); |
83 | 83 | |
84 | 84 | $files = $this->app->get(FilesInterface::class)->getFiles( |
85 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
85 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
86 | 86 | ); |
87 | 87 | |
88 | 88 | $this->assertCount(0, $files); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $this->app->get(JobDispatcher::class)->serve(); |
91 | 91 | |
92 | 92 | $files = $this->app->get(FilesInterface::class)->getFiles( |
93 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
93 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
94 | 94 | ); |
95 | 95 | |
96 | 96 | $this->assertCount(1, $files); |
@@ -38,7 +38,8 @@ discard block |
||
38 | 38 | $this->assertNull($this->app->getEnvironment()->get('FIRED')); |
39 | 39 | |
40 | 40 | $w->shouldReceive('receive')->once()->with( |
41 | - \Mockery::on(function (&$context) { |
|
41 | + \Mockery::on(function (&$context) |
|
42 | + { |
|
42 | 43 | $context = '{ |
43 | 44 | "id": "1", |
44 | 45 | "job": "spiral.app.job.TestJob" |
@@ -66,7 +67,8 @@ discard block |
||
66 | 67 | $this->app->getContainer()->bind(Worker::class, $w); |
67 | 68 | |
68 | 69 | $w->shouldReceive('receive')->once()->with( |
69 | - \Mockery::on(function (&$context) { |
|
70 | + \Mockery::on(function (&$context) |
|
71 | + { |
|
70 | 72 | $context = '{ |
71 | 73 | "id": "1", |
72 | 74 | "job": "spiral.app.job.ErrorJob" |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | PermissionsInterface $rbac, |
30 | 30 | ViewsBootloader $views, |
31 | 31 | ValidationBootloader $validation |
32 | - ) { |
|
32 | + ){ |
|
33 | 33 | $rbac->addRole('user'); |
34 | 34 | $rbac->associate('user', '*'); |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | $router->setDefault($route->withDefaults(['name' => 'Dave'])); |
42 | 42 | |
43 | - $views->addDirectory('custom', __DIR__ . '/../../views/custom/'); |
|
43 | + $views->addDirectory('custom', __DIR__.'/../../views/custom/'); |
|
44 | 44 | $views->addEngine(TestEngine::class); |
45 | 45 | |
46 | 46 | $validation->addAlias('aliased', 'notEmpty'); |
@@ -12,8 +12,10 @@ |
||
12 | 12 | |
13 | 13 | class ErrorJob extends AbstractJob |
14 | 14 | { |
15 | - public function do() |
|
15 | + public function do{ |
|
16 | + () |
|
16 | 17 | { |
17 | 18 | throw new \ErrorException("bad job"); |
18 | 19 | } |
20 | + } |
|
19 | 21 | } |
20 | 22 | \ No newline at end of file |
@@ -13,8 +13,10 @@ |
||
13 | 13 | |
14 | 14 | class TestJob extends AbstractJob |
15 | 15 | { |
16 | - public function do(EnvironmentInterface $env) |
|
16 | + public function do{ |
|
17 | + (EnvironmentInterface $env) |
|
17 | 18 | { |
18 | 19 | $env->set('FIRED', true); |
19 | 20 | } |
21 | + } |
|
20 | 22 | } |
21 | 23 | \ No newline at end of file |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | $this->output->writeln("<info>Detecting schema changes:</info>"); |
41 | 41 | |
42 | 42 | $this->changes = []; |
43 | - foreach ($registry->getIterator() as $e) { |
|
44 | - if ($registry->hasTable($e)) { |
|
43 | + foreach ($registry->getIterator() as $e){ |
|
44 | + if ($registry->hasTable($e)){ |
|
45 | 45 | $table = $registry->getTableSchema($e); |
46 | 46 | |
47 | - if ($table->getComparator()->hasChanges()) { |
|
47 | + if ($table->getComparator()->hasChanges()){ |
|
48 | 48 | $this->changes[] = [ |
49 | 49 | 'database' => $registry->getDatabase($e), |
50 | 50 | 'table' => $registry->getTable($e), |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | - if ($this->changes === []) { |
|
57 | + if ($this->changes === []){ |
|
58 | 58 | $this->output->writeln("<fg=yellow>no database changes has been detected</fg=yellow>"); |
59 | 59 | |
60 | 60 | return $registry; |
61 | 61 | } |
62 | 62 | |
63 | - foreach ($this->changes as $change) { |
|
63 | + foreach ($this->changes as $change){ |
|
64 | 64 | $this->output->write(sprintf("• <fg=cyan>%s.%s</fg=cyan>", $change['database'], $change['table'])); |
65 | 65 | $this->describeChanges($change['schema']); |
66 | 66 | } |
@@ -73,22 +73,22 @@ discard block |
||
73 | 73 | */ |
74 | 74 | protected function describeChanges(AbstractTable $table) |
75 | 75 | { |
76 | - if (!$this->output->isVerbose()) { |
|
76 | + if (!$this->output->isVerbose()){ |
|
77 | 77 | $this->output->writeln(sprintf( |
78 | 78 | ": <fg=green>%s</fg=green> change(s) detected", |
79 | 79 | $this->numChanges($table) |
80 | 80 | )); |
81 | 81 | |
82 | 82 | return; |
83 | - } else { |
|
83 | + }else{ |
|
84 | 84 | $this->output->write("\n"); |
85 | 85 | } |
86 | 86 | |
87 | - if (!$table->exists()) { |
|
87 | + if (!$table->exists()){ |
|
88 | 88 | $this->output->writeln(" - create table"); |
89 | 89 | } |
90 | 90 | |
91 | - if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) { |
|
91 | + if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED){ |
|
92 | 92 | $this->output->writeln(" - drop table"); |
93 | 93 | return; |
94 | 94 | } |
@@ -105,15 +105,15 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function describeColumns(Comparator $cmp) |
107 | 107 | { |
108 | - foreach ($cmp->addedColumns() as $column) { |
|
108 | + foreach ($cmp->addedColumns() as $column){ |
|
109 | 109 | $this->output->writeln(" - add column <fg=yellow>{$column->getName()}</fg=yellow>"); |
110 | 110 | } |
111 | 111 | |
112 | - foreach ($cmp->droppedColumns() as $column) { |
|
112 | + foreach ($cmp->droppedColumns() as $column){ |
|
113 | 113 | $this->output->writeln(" - drop column <fg=yellow>{$column->getName()}</fg=yellow>"); |
114 | 114 | } |
115 | 115 | |
116 | - foreach ($cmp->alteredColumns() as $column) { |
|
116 | + foreach ($cmp->alteredColumns() as $column){ |
|
117 | 117 | $column = $column[0]; |
118 | 118 | $this->output->writeln(" - alter column <fg=yellow>{$column->getName()}</fg=yellow>"); |
119 | 119 | } |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | */ |
125 | 125 | protected function describeIndexes(Comparator $cmp) |
126 | 126 | { |
127 | - foreach ($cmp->addedIndexes() as $index) { |
|
127 | + foreach ($cmp->addedIndexes() as $index){ |
|
128 | 128 | $index = join(', ', $index->getColumns()); |
129 | 129 | $this->output->writeln(" - add index on <fg=yellow>[{$index}]</fg=yellow>"); |
130 | 130 | } |
131 | 131 | |
132 | - foreach ($cmp->droppedIndexes() as $index) { |
|
132 | + foreach ($cmp->droppedIndexes() as $index){ |
|
133 | 133 | $index = join(', ', $index->getColumns()); |
134 | 134 | $this->output->writeln(" - drop index on <fg=yellow>[{$index}]</fg=yellow>"); |
135 | 135 | } |
136 | 136 | |
137 | - foreach ($cmp->alteredIndexes() as $index) { |
|
137 | + foreach ($cmp->alteredIndexes() as $index){ |
|
138 | 138 | $index = $index[0]; |
139 | 139 | $index = join(', ', $index->getColumns()); |
140 | 140 | $this->output->writeln(" - alter index on <fg=yellow>[{$index}]</fg=yellow>"); |
@@ -146,15 +146,15 @@ discard block |
||
146 | 146 | */ |
147 | 147 | protected function describeFKs(Comparator $cmp) |
148 | 148 | { |
149 | - foreach ($cmp->addedForeignKeys() as $fk) { |
|
149 | + foreach ($cmp->addedForeignKeys() as $fk){ |
|
150 | 150 | $this->output->writeln(" - add foreign key on <fg=yellow>{$fk->getColumn()}</fg=yellow>"); |
151 | 151 | } |
152 | 152 | |
153 | - foreach ($cmp->droppedForeignKeys() as $fk) { |
|
153 | + foreach ($cmp->droppedForeignKeys() as $fk){ |
|
154 | 154 | $this->output->writeln(" - drop foreign key <fg=yellow>{$fk->getColumn()}</fg=yellow>"); |
155 | 155 | } |
156 | 156 | |
157 | - foreach ($cmp->alteredForeignKeys() as $fk) { |
|
157 | + foreach ($cmp->alteredForeignKeys() as $fk){ |
|
158 | 158 | $fk = $fk[0]; |
159 | 159 | $this->output->writeln(" - alter foreign key <fg=yellow>{$fk->getColumn()}</fg=yellow>"); |
160 | 160 | } |
@@ -40,11 +40,14 @@ discard block |
||
40 | 40 | $this->output->writeln("<info>Detecting schema changes:</info>"); |
41 | 41 | |
42 | 42 | $this->changes = []; |
43 | - foreach ($registry->getIterator() as $e) { |
|
44 | - if ($registry->hasTable($e)) { |
|
43 | + foreach ($registry->getIterator() as $e) |
|
44 | + { |
|
45 | + if ($registry->hasTable($e)) |
|
46 | + { |
|
45 | 47 | $table = $registry->getTableSchema($e); |
46 | 48 | |
47 | - if ($table->getComparator()->hasChanges()) { |
|
49 | + if ($table->getComparator()->hasChanges()) |
|
50 | + { |
|
48 | 51 | $this->changes[] = [ |
49 | 52 | 'database' => $registry->getDatabase($e), |
50 | 53 | 'table' => $registry->getTable($e), |
@@ -54,13 +57,15 @@ discard block |
||
54 | 57 | } |
55 | 58 | } |
56 | 59 | |
57 | - if ($this->changes === []) { |
|
60 | + if ($this->changes === []) |
|
61 | + { |
|
58 | 62 | $this->output->writeln("<fg=yellow>no database changes has been detected</fg=yellow>"); |
59 | 63 | |
60 | 64 | return $registry; |
61 | 65 | } |
62 | 66 | |
63 | - foreach ($this->changes as $change) { |
|
67 | + foreach ($this->changes as $change) |
|
68 | + { |
|
64 | 69 | $this->output->write(sprintf("• <fg=cyan>%s.%s</fg=cyan>", $change['database'], $change['table'])); |
65 | 70 | $this->describeChanges($change['schema']); |
66 | 71 | } |
@@ -73,22 +78,27 @@ discard block |
||
73 | 78 | */ |
74 | 79 | protected function describeChanges(AbstractTable $table) |
75 | 80 | { |
76 | - if (!$this->output->isVerbose()) { |
|
81 | + if (!$this->output->isVerbose()) |
|
82 | + { |
|
77 | 83 | $this->output->writeln(sprintf( |
78 | 84 | ": <fg=green>%s</fg=green> change(s) detected", |
79 | 85 | $this->numChanges($table) |
80 | 86 | )); |
81 | 87 | |
82 | 88 | return; |
83 | - } else { |
|
89 | + } |
|
90 | + else |
|
91 | + { |
|
84 | 92 | $this->output->write("\n"); |
85 | 93 | } |
86 | 94 | |
87 | - if (!$table->exists()) { |
|
95 | + if (!$table->exists()) |
|
96 | + { |
|
88 | 97 | $this->output->writeln(" - create table"); |
89 | 98 | } |
90 | 99 | |
91 | - if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) { |
|
100 | + if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) |
|
101 | + { |
|
92 | 102 | $this->output->writeln(" - drop table"); |
93 | 103 | return; |
94 | 104 | } |
@@ -105,15 +115,18 @@ discard block |
||
105 | 115 | */ |
106 | 116 | protected function describeColumns(Comparator $cmp) |
107 | 117 | { |
108 | - foreach ($cmp->addedColumns() as $column) { |
|
118 | + foreach ($cmp->addedColumns() as $column) |
|
119 | + { |
|
109 | 120 | $this->output->writeln(" - add column <fg=yellow>{$column->getName()}</fg=yellow>"); |
110 | 121 | } |
111 | 122 | |
112 | - foreach ($cmp->droppedColumns() as $column) { |
|
123 | + foreach ($cmp->droppedColumns() as $column) |
|
124 | + { |
|
113 | 125 | $this->output->writeln(" - drop column <fg=yellow>{$column->getName()}</fg=yellow>"); |
114 | 126 | } |
115 | 127 | |
116 | - foreach ($cmp->alteredColumns() as $column) { |
|
128 | + foreach ($cmp->alteredColumns() as $column) |
|
129 | + { |
|
117 | 130 | $column = $column[0]; |
118 | 131 | $this->output->writeln(" - alter column <fg=yellow>{$column->getName()}</fg=yellow>"); |
119 | 132 | } |
@@ -124,17 +137,20 @@ discard block |
||
124 | 137 | */ |
125 | 138 | protected function describeIndexes(Comparator $cmp) |
126 | 139 | { |
127 | - foreach ($cmp->addedIndexes() as $index) { |
|
140 | + foreach ($cmp->addedIndexes() as $index) |
|
141 | + { |
|
128 | 142 | $index = join(', ', $index->getColumns()); |
129 | 143 | $this->output->writeln(" - add index on <fg=yellow>[{$index}]</fg=yellow>"); |
130 | 144 | } |
131 | 145 | |
132 | - foreach ($cmp->droppedIndexes() as $index) { |
|
146 | + foreach ($cmp->droppedIndexes() as $index) |
|
147 | + { |
|
133 | 148 | $index = join(', ', $index->getColumns()); |
134 | 149 | $this->output->writeln(" - drop index on <fg=yellow>[{$index}]</fg=yellow>"); |
135 | 150 | } |
136 | 151 | |
137 | - foreach ($cmp->alteredIndexes() as $index) { |
|
152 | + foreach ($cmp->alteredIndexes() as $index) |
|
153 | + { |
|
138 | 154 | $index = $index[0]; |
139 | 155 | $index = join(', ', $index->getColumns()); |
140 | 156 | $this->output->writeln(" - alter index on <fg=yellow>[{$index}]</fg=yellow>"); |
@@ -146,15 +162,18 @@ discard block |
||
146 | 162 | */ |
147 | 163 | protected function describeFKs(Comparator $cmp) |
148 | 164 | { |
149 | - foreach ($cmp->addedForeignKeys() as $fk) { |
|
165 | + foreach ($cmp->addedForeignKeys() as $fk) |
|
166 | + { |
|
150 | 167 | $this->output->writeln(" - add foreign key on <fg=yellow>{$fk->getColumn()}</fg=yellow>"); |
151 | 168 | } |
152 | 169 | |
153 | - foreach ($cmp->droppedForeignKeys() as $fk) { |
|
170 | + foreach ($cmp->droppedForeignKeys() as $fk) |
|
171 | + { |
|
154 | 172 | $this->output->writeln(" - drop foreign key <fg=yellow>{$fk->getColumn()}</fg=yellow>"); |
155 | 173 | } |
156 | 174 | |
157 | - foreach ($cmp->alteredForeignKeys() as $fk) { |
|
175 | + foreach ($cmp->alteredForeignKeys() as $fk) |
|
176 | + { |
|
158 | 177 | $fk = $fk[0]; |
159 | 178 | $this->output->writeln(" - alter foreign key <fg=yellow>{$fk->getColumn()}</fg=yellow>"); |
160 | 179 | } |