@@ -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 | } |
@@ -69,14 +69,18 @@ discard block |
||
| 69 | 69 | $this->fetchID($request) |
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | - try { |
|
| 72 | + try |
|
| 73 | + { |
|
| 73 | 74 | $response = $this->scope->runScope( |
| 74 | 75 | [SessionInterface::class => $session], |
| 75 | - function () use ($session, $request, $handler) { |
|
| 76 | + function () use ($session, $request, $handler) |
|
| 77 | + { |
|
| 76 | 78 | return $handler->handle($request->withAttribute(static::ATTRIBUTE, $session)); |
| 77 | 79 | } |
| 78 | 80 | ); |
| 79 | - } catch (\Throwable $e) { |
|
| 81 | + } |
|
| 82 | + catch (\Throwable $e) |
|
| 83 | + { |
|
| 80 | 84 | $session->abort(); |
| 81 | 85 | throw $e; |
| 82 | 86 | } |
@@ -95,14 +99,16 @@ discard block |
||
| 95 | 99 | Request $request, |
| 96 | 100 | Response $response |
| 97 | 101 | ): Response { |
| 98 | - if (!$session->isStarted()) { |
|
| 102 | + if (!$session->isStarted()) |
|
| 103 | + { |
|
| 99 | 104 | return $response; |
| 100 | 105 | } |
| 101 | 106 | |
| 102 | 107 | $session->commit(); |
| 103 | 108 | |
| 104 | 109 | //SID changed |
| 105 | - if ($this->fetchID($request) != $session->getID()) { |
|
| 110 | + if ($this->fetchID($request) != $session->getID()) |
|
| 111 | + { |
|
| 106 | 112 | return $this->withCookie($request, $response, $session->getID()); |
| 107 | 113 | } |
| 108 | 114 | |
@@ -119,7 +125,8 @@ discard block |
||
| 119 | 125 | protected function fetchID(Request $request): ?string |
| 120 | 126 | { |
| 121 | 127 | $cookies = $request->getCookieParams(); |
| 122 | - if (empty($cookies[$this->config->getCookie()])) { |
|
| 128 | + if (empty($cookies[$this->config->getCookie()])) |
|
| 129 | + { |
|
| 123 | 130 | return null; |
| 124 | 131 | } |
| 125 | 132 | |
@@ -152,7 +159,8 @@ discard block |
||
| 152 | 159 | protected function clientSignature(Request $request): string |
| 153 | 160 | { |
| 154 | 161 | $signature = ''; |
| 155 | - foreach (static::SIGNATURE_HEADERS as $header) { |
|
| 162 | + foreach (static::SIGNATURE_HEADERS as $header) |
|
| 163 | + { |
|
| 156 | 164 | $signature .= $request->getHeaderLine($header) . ';'; |
| 157 | 165 | } |
| 158 | 166 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | CookiesConfig $cookiesConfig, |
| 58 | 58 | SessionFactory $factory, |
| 59 | 59 | ScopeInterface $scope |
| 60 | - ) { |
|
| 60 | + ){ |
|
| 61 | 61 | $this->config = $config; |
| 62 | 62 | $this->httpConfig = $httpConfig; |
| 63 | 63 | $this->cookiesConfig = $cookiesConfig; |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | $this->fetchID($request) |
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | - try { |
|
| 79 | + try{ |
|
| 80 | 80 | $response = $this->scope->runScope( |
| 81 | 81 | [SessionInterface::class => $session], |
| 82 | 82 | function () use ($session, $request, $handler) { |
| 83 | 83 | return $handler->handle($request->withAttribute(static::ATTRIBUTE, $session)); |
| 84 | 84 | } |
| 85 | 85 | ); |
| 86 | - } catch (\Throwable $e) { |
|
| 86 | + }catch (\Throwable $e){ |
|
| 87 | 87 | $session->abort(); |
| 88 | 88 | throw $e; |
| 89 | 89 | } |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | Request $request, |
| 103 | 103 | Response $response |
| 104 | 104 | ): Response { |
| 105 | - if (!$session->isStarted()) { |
|
| 105 | + if (!$session->isStarted()){ |
|
| 106 | 106 | return $response; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $session->commit(); |
| 110 | 110 | |
| 111 | 111 | //SID changed |
| 112 | - if ($this->fetchID($request) != $session->getID()) { |
|
| 112 | + if ($this->fetchID($request) != $session->getID()){ |
|
| 113 | 113 | return $this->withCookie($request, $response, $session->getID()); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | protected function fetchID(Request $request): ?string |
| 127 | 127 | { |
| 128 | 128 | $cookies = $request->getCookieParams(); |
| 129 | - if (empty($cookies[$this->config->getCookie()])) { |
|
| 129 | + if (empty($cookies[$this->config->getCookie()])){ |
|
| 130 | 130 | return null; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | protected function clientSignature(Request $request): string |
| 160 | 160 | { |
| 161 | 161 | $signature = ''; |
| 162 | - foreach (static::SIGNATURE_HEADERS as $header) { |
|
| 163 | - $signature .= $request->getHeaderLine($header) . ';'; |
|
| 162 | + foreach (static::SIGNATURE_HEADERS as $header){ |
|
| 163 | + $signature .= $request->getHeaderLine($header).';'; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | return hash('sha256', $signature); |
@@ -38,15 +38,15 @@ |
||
| 38 | 38 | public function getServices(): array |
| 39 | 39 | { |
| 40 | 40 | $result = []; |
| 41 | - foreach ($this->classes->getClasses(ServiceInterface::class) as $service) { |
|
| 42 | - if (!$service->isInstantiable()) { |
|
| 41 | + foreach ($this->classes->getClasses(ServiceInterface::class) as $service){ |
|
| 42 | + if (!$service->isInstantiable()){ |
|
| 43 | 43 | continue; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $instance = $this->container->get($service->getName()); |
| 47 | 47 | |
| 48 | - foreach ($service->getInterfaces() as $interface) { |
|
| 49 | - if ($interface->isSubclassOf(ServiceInterface::class)) { |
|
| 48 | + foreach ($service->getInterfaces() as $interface){ |
|
| 49 | + if ($interface->isSubclassOf(ServiceInterface::class)){ |
|
| 50 | 50 | $result[$interface->getName()] = $instance; |
| 51 | 51 | } |
| 52 | 52 | } |
@@ -38,15 +38,19 @@ |
||
| 38 | 38 | public function getServices(): array |
| 39 | 39 | { |
| 40 | 40 | $result = []; |
| 41 | - foreach ($this->classes->getClasses(ServiceInterface::class) as $service) { |
|
| 42 | - if (!$service->isInstantiable()) { |
|
| 41 | + foreach ($this->classes->getClasses(ServiceInterface::class) as $service) |
|
| 42 | + { |
|
| 43 | + if (!$service->isInstantiable()) |
|
| 44 | + { |
|
| 43 | 45 | continue; |
| 44 | 46 | } |
| 45 | 47 | |
| 46 | 48 | $instance = $this->container->get($service->getName()); |
| 47 | 49 | |
| 48 | - foreach ($service->getInterfaces() as $interface) { |
|
| 49 | - if ($interface->isSubclassOf(ServiceInterface::class)) { |
|
| 50 | + foreach ($service->getInterfaces() as $interface) |
|
| 51 | + { |
|
| 52 | + if ($interface->isSubclassOf(ServiceInterface::class)) |
|
| 53 | + { |
|
| 50 | 54 | $result[$interface->getName()] = $instance; |
| 51 | 55 | } |
| 52 | 56 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | EnvironmentInterface $env, |
| 38 | 38 | FinalizerInterface $finalizer, |
| 39 | 39 | ContainerInterface $container |
| 40 | - ) { |
|
| 40 | + ){ |
|
| 41 | 41 | $this->env = $env; |
| 42 | 42 | $this->finalizer = $finalizer; |
| 43 | 43 | $this->container = $container; |
@@ -65,12 +65,12 @@ discard block |
||
| 65 | 65 | $worker = $this->container->get(Worker::class); |
| 66 | 66 | $locator = $this->container->get(LocatorInterface::class); |
| 67 | 67 | |
| 68 | - foreach ($locator->getServices() as $interface => $service) { |
|
| 68 | + foreach ($locator->getServices() as $interface => $service){ |
|
| 69 | 69 | $server->registerService($interface, $service); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $server->serve($worker, function (\Throwable $e = null) { |
|
| 73 | - if ($e !== null) { |
|
| 72 | + $server->serve($worker, function (\Throwable $e = null){ |
|
| 73 | + if ($e !== null){ |
|
| 74 | 74 | $this->handleException($e); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | protected function handleException(\Throwable $e) |
| 85 | 85 | { |
| 86 | - try { |
|
| 86 | + try{ |
|
| 87 | 87 | $this->container->get(SnapshotterInterface::class)->register($e); |
| 88 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 88 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
| 89 | 89 | // no need to notify when unable to register an exception |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -65,12 +65,15 @@ discard block |
||
| 65 | 65 | $worker = $this->container->get(Worker::class); |
| 66 | 66 | $locator = $this->container->get(LocatorInterface::class); |
| 67 | 67 | |
| 68 | - foreach ($locator->getServices() as $interface => $service) { |
|
| 68 | + foreach ($locator->getServices() as $interface => $service) |
|
| 69 | + { |
|
| 69 | 70 | $server->registerService($interface, $service); |
| 70 | 71 | } |
| 71 | 72 | |
| 72 | - $server->serve($worker, function (\Throwable $e = null) { |
|
| 73 | - if ($e !== null) { |
|
| 73 | + $server->serve($worker, function (\Throwable $e = null) |
|
| 74 | + { |
|
| 75 | + if ($e !== null) |
|
| 76 | + { |
|
| 74 | 77 | $this->handleException($e); |
| 75 | 78 | } |
| 76 | 79 | |
@@ -83,9 +86,12 @@ discard block |
||
| 83 | 86 | */ |
| 84 | 87 | protected function handleException(\Throwable $e) |
| 85 | 88 | { |
| 86 | - try { |
|
| 89 | + try |
|
| 90 | + { |
|
| 87 | 91 | $this->container->get(SnapshotterInterface::class)->register($e); |
| 88 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 92 | + } |
|
| 93 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
| 94 | + { |
|
| 89 | 95 | // no need to notify when unable to register an exception |
| 90 | 96 | } |
| 91 | 97 | } |