@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | |
44 | 44 | $runtimeDirectory = $this->dirs->get('runtime'); |
45 | 45 | |
46 | - if (!$this->files->exists($runtimeDirectory)) { |
|
46 | + if (!$this->files->exists($runtimeDirectory)){ |
|
47 | 47 | $this->files->ensureDirectory($runtimeDirectory); |
48 | 48 | $output->writeln("<comment>created</comment>"); |
49 | 49 | return; |
50 | - } else { |
|
50 | + }else{ |
|
51 | 51 | $output->writeln("<info>exists</info>"); |
52 | 52 | } |
53 | 53 | |
54 | - foreach ($this->files->getFiles($runtimeDirectory) as $filename) { |
|
55 | - try { |
|
54 | + foreach ($this->files->getFiles($runtimeDirectory) as $filename){ |
|
55 | + try{ |
|
56 | 56 | $this->files->setPermissions($filename, FilesInterface::RUNTIME); |
57 | 57 | $this->files->setPermissions(dirname($filename), FilesInterface::RUNTIME); |
58 | - } catch (\Throwable $e) { |
|
58 | + }catch (\Throwable $e){ |
|
59 | 59 | $output->writeln(sprintf( |
60 | 60 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>", |
61 | 61 | $this->files->relativePath($filename, $runtimeDirectory), |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | continue; |
65 | 65 | } |
66 | 66 | |
67 | - if ($output->isVerbose()) { |
|
67 | + if ($output->isVerbose()){ |
|
68 | 68 | $output->writeln(sprintf( |
69 | 69 | "<fg=green>[updated]</fg=green> `%s`", |
70 | 70 | $this->files->relativePath($filename, $runtimeDirectory) |
@@ -43,19 +43,26 @@ discard block |
||
43 | 43 | |
44 | 44 | $runtimeDirectory = $this->dirs->get('runtime'); |
45 | 45 | |
46 | - if (!$this->files->exists($runtimeDirectory)) { |
|
46 | + if (!$this->files->exists($runtimeDirectory)) |
|
47 | + { |
|
47 | 48 | $this->files->ensureDirectory($runtimeDirectory); |
48 | 49 | $output->writeln("<comment>created</comment>"); |
49 | 50 | return; |
50 | - } else { |
|
51 | + } |
|
52 | + else |
|
53 | + { |
|
51 | 54 | $output->writeln("<info>exists</info>"); |
52 | 55 | } |
53 | 56 | |
54 | - foreach ($this->files->getFiles($runtimeDirectory) as $filename) { |
|
55 | - try { |
|
57 | + foreach ($this->files->getFiles($runtimeDirectory) as $filename) |
|
58 | + { |
|
59 | + try |
|
60 | + { |
|
56 | 61 | $this->files->setPermissions($filename, FilesInterface::RUNTIME); |
57 | 62 | $this->files->setPermissions(dirname($filename), FilesInterface::RUNTIME); |
58 | - } catch (\Throwable $e) { |
|
63 | + } |
|
64 | + catch (\Throwable $e) |
|
65 | + { |
|
59 | 66 | $output->writeln(sprintf( |
60 | 67 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>", |
61 | 68 | $this->files->relativePath($filename, $runtimeDirectory), |
@@ -64,7 +71,8 @@ discard block |
||
64 | 71 | continue; |
65 | 72 | } |
66 | 73 | |
67 | - if ($output->isVerbose()) { |
|
74 | + if ($output->isVerbose()) |
|
75 | + { |
|
68 | 76 | $output->writeln(sprintf( |
69 | 77 | "<fg=green>[updated]</fg=green> `%s`", |
70 | 78 | $this->files->relativePath($filename, $runtimeDirectory) |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | bool $suppressErrors, |
45 | 45 | RendererInterface $renderer, |
46 | 46 | SnapshotterInterface $snapshots = null |
47 | - ) { |
|
47 | + ){ |
|
48 | 48 | $this->suppressErrors = $suppressErrors; |
49 | 49 | $this->renderer = $renderer; |
50 | 50 | $this->snapshotter = $snapshots; |
@@ -57,20 +57,20 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function process(Request $request, Handler $handler): Response |
59 | 59 | { |
60 | - try { |
|
60 | + try{ |
|
61 | 61 | return $handler->handle($request); |
62 | - } catch (ClientException|RouteNotFoundException $e) { |
|
63 | - if ($e instanceof ClientException) { |
|
62 | + }catch (ClientException | RouteNotFoundException $e){ |
|
63 | + if ($e instanceof ClientException){ |
|
64 | 64 | $code = $e->getCode(); |
65 | - } else { |
|
65 | + }else{ |
|
66 | 66 | $code = 404; |
67 | 67 | } |
68 | - } catch (\Throwable $e) { |
|
69 | - if (!$this->suppressErrors) { |
|
68 | + }catch (\Throwable $e){ |
|
69 | + if (!$this->suppressErrors){ |
|
70 | 70 | throw $e; |
71 | 71 | } |
72 | 72 | |
73 | - if ($this->snapshotter !== null) { |
|
73 | + if ($this->snapshotter !== null){ |
|
74 | 74 | $this->snapshotter->register($e); |
75 | 75 | } |
76 | 76 |
@@ -57,20 +57,30 @@ |
||
57 | 57 | */ |
58 | 58 | public function process(Request $request, Handler $handler): Response |
59 | 59 | { |
60 | - try { |
|
60 | + try |
|
61 | + { |
|
61 | 62 | return $handler->handle($request); |
62 | - } catch (ClientException|RouteNotFoundException $e) { |
|
63 | - if ($e instanceof ClientException) { |
|
63 | + } |
|
64 | + catch (ClientException|RouteNotFoundException $e) |
|
65 | + { |
|
66 | + if ($e instanceof ClientException) |
|
67 | + { |
|
64 | 68 | $code = $e->getCode(); |
65 | - } else { |
|
69 | + } |
|
70 | + else |
|
71 | + { |
|
66 | 72 | $code = 404; |
67 | 73 | } |
68 | - } catch (\Throwable $e) { |
|
69 | - if (!$this->suppressErrors) { |
|
74 | + } |
|
75 | + catch (\Throwable $e) |
|
76 | + { |
|
77 | + if (!$this->suppressErrors) |
|
78 | + { |
|
70 | 79 | throw $e; |
71 | 80 | } |
72 | 81 | |
73 | - if ($this->snapshotter !== null) { |
|
82 | + if ($this->snapshotter !== null) |
|
83 | + { |
|
74 | 84 | $this->snapshotter->register($e); |
75 | 85 | } |
76 | 86 |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | FinalizerInterface $finalizer, |
48 | 48 | ContainerInterface $container, |
49 | 49 | FactoryInterface $factory |
50 | - ) { |
|
50 | + ){ |
|
51 | 51 | $this->env = $env; |
52 | 52 | $this->finalizer = $finalizer; |
53 | 53 | $this->container = $container; |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | |
74 | 74 | /** @var HttpCore $http */ |
75 | 75 | $http = $this->container->get(HttpCore::class); |
76 | - while ($request = $client->acceptRequest()) { |
|
77 | - try { |
|
76 | + while ($request = $client->acceptRequest()){ |
|
77 | + try{ |
|
78 | 78 | $client->respond($http->handle($request)); |
79 | - } catch (\Throwable $e) { |
|
79 | + }catch (\Throwable $e){ |
|
80 | 80 | $this->handleException($client, $e); |
81 | - } finally { |
|
81 | + }finally{ |
|
82 | 82 | $this->finalizer->finalize(false); |
83 | 83 | } |
84 | 84 | } |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | { |
93 | 93 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
94 | 94 | |
95 | - try { |
|
95 | + try{ |
|
96 | 96 | /** @var SnapshotInterface $snapshot */ |
97 | 97 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
98 | 98 | error_log($snapshot->getMessage()); |
99 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
99 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
100 | 100 | error_log($handler->getMessage($e)); |
101 | 101 | } |
102 | 102 |
@@ -73,12 +73,18 @@ discard block |
||
73 | 73 | |
74 | 74 | /** @var HttpCore $http */ |
75 | 75 | $http = $this->container->get(HttpCore::class); |
76 | - while ($request = $client->acceptRequest()) { |
|
77 | - try { |
|
76 | + while ($request = $client->acceptRequest()) |
|
77 | + { |
|
78 | + try |
|
79 | + { |
|
78 | 80 | $client->respond($http->handle($request)); |
79 | - } catch (\Throwable $e) { |
|
81 | + } |
|
82 | + catch (\Throwable $e) |
|
83 | + { |
|
80 | 84 | $this->handleException($client, $e); |
81 | - } finally { |
|
85 | + } |
|
86 | + finally |
|
87 | + { |
|
82 | 88 | $this->finalizer->finalize(false); |
83 | 89 | } |
84 | 90 | } |
@@ -92,11 +98,14 @@ discard block |
||
92 | 98 | { |
93 | 99 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
94 | 100 | |
95 | - try { |
|
101 | + try |
|
102 | + { |
|
96 | 103 | /** @var SnapshotInterface $snapshot */ |
97 | 104 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
98 | 105 | error_log($snapshot->getMessage()); |
99 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
106 | + } |
|
107 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
108 | + { |
|
100 | 109 | error_log($handler->getMessage($e)); |
101 | 110 | } |
102 | 111 |
@@ -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 | [], |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | EnvironmentInterface $env, |
37 | 37 | FinalizerInterface $finalizer, |
38 | 38 | ContainerInterface $container |
39 | - ) { |
|
39 | + ){ |
|
40 | 40 | $this->environment = $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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $app = $this->makeApp(); |
37 | 37 | |
38 | 38 | $files = $this->app->get(FilesInterface::class)->getFiles( |
39 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
39 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
40 | 40 | ); |
41 | 41 | |
42 | 42 | $this->assertCount(0, $files); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $app->get(SapiDispatcher::class)->serve($e); |
46 | 46 | |
47 | 47 | $files = $this->app->get(FilesInterface::class)->getFiles( |
48 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
48 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
49 | 49 | ); |
50 | 50 | |
51 | 51 | $this->assertCount(1, $files); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | ]); |
63 | 63 | |
64 | 64 | $files = $this->app->get(FilesInterface::class)->getFiles( |
65 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
65 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
66 | 66 | ); |
67 | 67 | |
68 | 68 | $this->assertCount(0, $files); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $app->get(SapiDispatcher::class)->serve($e); |
72 | 72 | |
73 | 73 | $files = $this->app->get(FilesInterface::class)->getFiles( |
74 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
74 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
75 | 75 | ); |
76 | 76 | |
77 | 77 | $this->assertCount(1, $files); |
@@ -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'); |