@@ -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'); |
@@ -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 | } |
@@ -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 | // @codeCoverageIgnoreStart |
60 | 60 | $output->writeln(sprintf( |
61 | 61 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>", |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | // @codeCoverageIgnoreEnd |
67 | 67 | } |
68 | 68 | |
69 | - if ($output->isVerbose()) { |
|
69 | + if ($output->isVerbose()){ |
|
70 | 70 | $output->writeln(sprintf( |
71 | 71 | "<fg=green>[updated]</fg=green> `%s`", |
72 | 72 | $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 | // @codeCoverageIgnoreStart |
60 | 67 | $output->writeln(sprintf( |
61 | 68 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>", |
@@ -66,7 +73,8 @@ discard block |
||
66 | 73 | // @codeCoverageIgnoreEnd |
67 | 74 | } |
68 | 75 | |
69 | - if ($output->isVerbose()) { |
|
76 | + if ($output->isVerbose()) |
|
77 | + { |
|
70 | 78 | $output->writeln(sprintf( |
71 | 79 | "<fg=green>[updated]</fg=green> `%s`", |
72 | 80 | $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|RouterException $e) { |
|
63 | - if ($e instanceof ClientException) { |
|
62 | + }catch (ClientException | RouterException $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|RouterException $e) { |
|
63 | - if ($e instanceof ClientException) { |
|
63 | + } |
|
64 | + catch (ClientException|RouterException $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 |
@@ -35,11 +35,11 @@ |
||
35 | 35 | */ |
36 | 36 | public function createInjection(\ReflectionClass $class, string $context = null) |
37 | 37 | { |
38 | - if (!$this->orm->getSchema()->defines($context)) { |
|
38 | + if (!$this->orm->getSchema()->defines($context)){ |
|
39 | 39 | $context = Inflector::singularize($context); |
40 | 40 | } |
41 | 41 | |
42 | - if (!$this->orm->getSchema()->defines($context)) { |
|
42 | + if (!$this->orm->getSchema()->defines($context)){ |
|
43 | 43 | throw new ORMException("Cycle schema is not initiated or role missing, run `cycle`"); |
44 | 44 | } |
45 | 45 |
@@ -35,11 +35,13 @@ |
||
35 | 35 | */ |
36 | 36 | public function createInjection(\ReflectionClass $class, string $context = null) |
37 | 37 | { |
38 | - if (!$this->orm->getSchema()->defines($context)) { |
|
38 | + if (!$this->orm->getSchema()->defines($context)) |
|
39 | + { |
|
39 | 40 | $context = Inflector::singularize($context); |
40 | 41 | } |
41 | 42 | |
42 | - if (!$this->orm->getSchema()->defines($context)) { |
|
43 | + if (!$this->orm->getSchema()->defines($context)) |
|
44 | + { |
|
43 | 45 | throw new ORMException("Cycle schema is not initiated or role missing, run `cycle`"); |
44 | 46 | } |
45 | 47 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | $services = $locator->getServices(); |
26 | 26 | |
27 | - if ($services === []) { |
|
27 | + if ($services === []){ |
|
28 | 28 | $this->writeln("<comment>No GRPC services were found.</comment>"); |
29 | 29 | return; |
30 | 30 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | 'File:', |
36 | 36 | ]); |
37 | 37 | |
38 | - foreach ($services as $interface => $instance) { |
|
38 | + foreach ($services as $interface => $instance){ |
|
39 | 39 | $grid->addRow([ |
40 | 40 | $interface::NAME, |
41 | 41 | get_class($instance), |
@@ -24,7 +24,8 @@ discard block |
||
24 | 24 | { |
25 | 25 | $services = $locator->getServices(); |
26 | 26 | |
27 | - if ($services === []) { |
|
27 | + if ($services === []) |
|
28 | + { |
|
28 | 29 | $this->writeln("<comment>No GRPC services were found.</comment>"); |
29 | 30 | return; |
30 | 31 | } |
@@ -35,7 +36,8 @@ discard block |
||
35 | 36 | 'File:', |
36 | 37 | ]); |
37 | 38 | |
38 | - foreach ($services as $interface => $instance) { |
|
39 | + foreach ($services as $interface => $instance) |
|
40 | + { |
|
39 | 41 | $grid->addRow([ |
40 | 42 | $interface::NAME, |
41 | 43 | get_class($instance), |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | public function perform(KernelInterface $kernel, FilesInterface $files, DirectoriesInterface $dirs) |
40 | 40 | { |
41 | 41 | $protoFile = $this->argument('proto'); |
42 | - if (!file_exists($protoFile)) { |
|
42 | + if (!file_exists($protoFile)){ |
|
43 | 43 | $this->sprintf("<error>File `%s` not found.</error>", $protoFile); |
44 | 44 | return; |
45 | 45 | } |
@@ -52,19 +52,19 @@ discard block |
||
52 | 52 | |
53 | 53 | $this->sprintf("<info>Compiling <fg=cyan>`%s`</fg=cyan>:</info>\n", $protoFile); |
54 | 54 | |
55 | - try { |
|
55 | + try{ |
|
56 | 56 | $result = $compiler->compile($protoFile); |
57 | - } catch (\Throwable $e) { |
|
57 | + }catch (\Throwable $e){ |
|
58 | 58 | $this->sprintf("<error>Error:</error> <fg=red>%s</fg=red>\n", $e->getMessage()); |
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | - if ($result === []) { |
|
62 | + if ($result === []){ |
|
63 | 63 | $this->sprintf("<info>No files were generated.</info>\n", $protoFile); |
64 | 64 | return; |
65 | 65 | } |
66 | 66 | |
67 | - foreach ($result as $file) { |
|
67 | + foreach ($result as $file){ |
|
68 | 68 | $this->sprintf( |
69 | 69 | "<fg=green>•</fg=green> %s%s%s\n", |
70 | 70 | Color::LIGHT_WHITE, |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | protected function getPath(KernelInterface $kernel): string |
84 | 84 | { |
85 | 85 | $path = $this->argument('namespace'); |
86 | - if ($path !== 'auto') { |
|
86 | + if ($path !== 'auto'){ |
|
87 | 87 | return $path; |
88 | 88 | } |
89 | 89 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | protected function getNamespace(KernelInterface $kernel): string |
102 | 102 | { |
103 | 103 | $namespace = $this->argument('namespace'); |
104 | - if ($namespace !== 'auto') { |
|
104 | + if ($namespace !== 'auto'){ |
|
105 | 105 | return $namespace; |
106 | 106 | } |
107 | 107 |
@@ -39,7 +39,8 @@ discard block |
||
39 | 39 | public function perform(KernelInterface $kernel, FilesInterface $files, DirectoriesInterface $dirs) |
40 | 40 | { |
41 | 41 | $protoFile = $this->argument('proto'); |
42 | - if (!file_exists($protoFile)) { |
|
42 | + if (!file_exists($protoFile)) |
|
43 | + { |
|
43 | 44 | $this->sprintf("<error>File `%s` not found.</error>", $protoFile); |
44 | 45 | return; |
45 | 46 | } |
@@ -52,19 +53,24 @@ discard block |
||
52 | 53 | |
53 | 54 | $this->sprintf("<info>Compiling <fg=cyan>`%s`</fg=cyan>:</info>\n", $protoFile); |
54 | 55 | |
55 | - try { |
|
56 | + try |
|
57 | + { |
|
56 | 58 | $result = $compiler->compile($protoFile); |
57 | - } catch (\Throwable $e) { |
|
59 | + } |
|
60 | + catch (\Throwable $e) |
|
61 | + { |
|
58 | 62 | $this->sprintf("<error>Error:</error> <fg=red>%s</fg=red>\n", $e->getMessage()); |
59 | 63 | return; |
60 | 64 | } |
61 | 65 | |
62 | - if ($result === []) { |
|
66 | + if ($result === []) |
|
67 | + { |
|
63 | 68 | $this->sprintf("<info>No files were generated.</info>\n", $protoFile); |
64 | 69 | return; |
65 | 70 | } |
66 | 71 | |
67 | - foreach ($result as $file) { |
|
72 | + foreach ($result as $file) |
|
73 | + { |
|
68 | 74 | $this->sprintf( |
69 | 75 | "<fg=green>•</fg=green> %s%s%s\n", |
70 | 76 | Color::LIGHT_WHITE, |
@@ -83,7 +89,8 @@ discard block |
||
83 | 89 | protected function getPath(KernelInterface $kernel): string |
84 | 90 | { |
85 | 91 | $path = $this->argument('namespace'); |
86 | - if ($path !== 'auto') { |
|
92 | + if ($path !== 'auto') |
|
93 | + { |
|
87 | 94 | return $path; |
88 | 95 | } |
89 | 96 | |
@@ -101,7 +108,8 @@ discard block |
||
101 | 108 | protected function getNamespace(KernelInterface $kernel): string |
102 | 109 | { |
103 | 110 | $namespace = $this->argument('namespace'); |
104 | - if ($namespace !== 'auto') { |
|
111 | + if ($namespace !== 'auto') |
|
112 | + { |
|
105 | 113 | return $namespace; |
106 | 114 | } |
107 | 115 |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | GenerateMigrations $migrations, |
49 | 49 | Migrator $migrator, |
50 | 50 | Console $console |
51 | - ) { |
|
52 | - if (!$this->verifyConfigured()) { |
|
51 | + ){ |
|
52 | + if (!$this->verifyConfigured()){ |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | - foreach ($migrator->getMigrations() as $migration) { |
|
57 | - if ($migration->getState()->getStatus() !== State::STATUS_EXECUTED) { |
|
56 | + foreach ($migrator->getMigrations() as $migration){ |
|
57 | + if ($migration->getState()->getStatus() !== State::STATUS_EXECUTED){ |
|
58 | 58 | $this->writeln("<fg=red>Outstanding migrations found, run `migrate` first.</fg=red>"); |
59 | 59 | return; |
60 | 60 | } |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | |
70 | 70 | $memory->saveData('cycle', $schema); |
71 | 71 | |
72 | - if ($show->hasChanges()) { |
|
72 | + if ($show->hasChanges()){ |
|
73 | 73 | (new Compiler())->compile($registry, [$migrations]); |
74 | 74 | |
75 | - if ($this->option('run')) { |
|
75 | + if ($this->option('run')){ |
|
76 | 76 | $console->run('migrate', [], $this->output); |
77 | 77 | } |
78 | 78 | } |
@@ -49,12 +49,15 @@ discard block |
||
49 | 49 | Migrator $migrator, |
50 | 50 | Console $console |
51 | 51 | ) { |
52 | - if (!$this->verifyConfigured()) { |
|
52 | + if (!$this->verifyConfigured()) |
|
53 | + { |
|
53 | 54 | return; |
54 | 55 | } |
55 | 56 | |
56 | - foreach ($migrator->getMigrations() as $migration) { |
|
57 | - if ($migration->getState()->getStatus() !== State::STATUS_EXECUTED) { |
|
57 | + foreach ($migrator->getMigrations() as $migration) |
|
58 | + { |
|
59 | + if ($migration->getState()->getStatus() !== State::STATUS_EXECUTED) |
|
60 | + { |
|
58 | 61 | $this->writeln("<fg=red>Outstanding migrations found, run `migrate` first.</fg=red>"); |
59 | 62 | return; |
60 | 63 | } |
@@ -69,10 +72,12 @@ discard block |
||
69 | 72 | |
70 | 73 | $memory->saveData('cycle', $schema); |
71 | 74 | |
72 | - if ($show->hasChanges()) { |
|
75 | + if ($show->hasChanges()) |
|
76 | + { |
|
73 | 77 | (new Compiler())->compile($registry, [$migrations]); |
74 | 78 | |
75 | - if ($this->option('run')) { |
|
79 | + if ($this->option('run')) |
|
80 | + { |
|
76 | 81 | $console->run('migrate', [], $this->output); |
77 | 82 | } |
78 | 83 | } |