@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | EnvironmentInterface $env, |
40 | 40 | FinalizerInterface $finalizer, |
41 | 41 | ContainerInterface $container |
42 | - ) { |
|
42 | + ){ |
|
43 | 43 | $this->env = $env; |
44 | 44 | $this->finalizer = $finalizer; |
45 | 45 | $this->container = $container; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $consumer->serve( |
71 | 71 | $worker, |
72 | 72 | function (\Throwable $e = null): void { |
73 | - if ($e !== null) { |
|
73 | + if ($e !== null){ |
|
74 | 74 | $this->handleException($e); |
75 | 75 | } |
76 | 76 | |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function handleException(\Throwable $e): void |
86 | 86 | { |
87 | - try { |
|
87 | + try{ |
|
88 | 88 | $this->container->get(SnapshotterInterface::class)->register($e); |
89 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
89 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
90 | 90 | // no need to notify when unable to register an exception |
91 | 91 | } |
92 | 92 | } |
@@ -70,7 +70,8 @@ discard block |
||
70 | 70 | $consumer->serve( |
71 | 71 | $worker, |
72 | 72 | function (\Throwable $e = null): void { |
73 | - if ($e !== null) { |
|
73 | + if ($e !== null) |
|
74 | + { |
|
74 | 75 | $this->handleException($e); |
75 | 76 | } |
76 | 77 | |
@@ -84,9 +85,12 @@ discard block |
||
84 | 85 | */ |
85 | 86 | protected function handleException(\Throwable $e): void |
86 | 87 | { |
87 | - try { |
|
88 | + try |
|
89 | + { |
|
88 | 90 | $this->container->get(SnapshotterInterface::class)->register($e); |
89 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
91 | + } |
|
92 | + catch (\Throwable | ContainerExceptionInterface $se) |
|
93 | + { |
|
90 | 94 | // no need to notify when unable to register an exception |
91 | 95 | } |
92 | 96 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $runtimeDirectory = $this->dirs->get('runtime'); |
47 | 47 | |
48 | - if (!$this->files->exists($runtimeDirectory)) { |
|
48 | + if (!$this->files->exists($runtimeDirectory)){ |
|
49 | 49 | $this->files->ensureDirectory($runtimeDirectory); |
50 | 50 | $output->writeln('<comment>created</comment>'); |
51 | 51 | return; |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | $output->writeln('<info>exists</info>'); |
54 | 54 | |
55 | 55 | |
56 | - foreach ($this->files->getFiles($runtimeDirectory) as $filename) { |
|
57 | - try { |
|
56 | + foreach ($this->files->getFiles($runtimeDirectory) as $filename){ |
|
57 | + try{ |
|
58 | 58 | $this->files->setPermissions($filename, FilesInterface::RUNTIME); |
59 | 59 | $this->files->setPermissions(dirname($filename), FilesInterface::RUNTIME); |
60 | - } catch (\Throwable $e) { |
|
60 | + }catch (\Throwable $e){ |
|
61 | 61 | // @codeCoverageIgnoreStart |
62 | 62 | $output->writeln( |
63 | 63 | sprintf( |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | // @codeCoverageIgnoreEnd |
71 | 71 | } |
72 | 72 | |
73 | - if ($output->isVerbose()) { |
|
73 | + if ($output->isVerbose()){ |
|
74 | 74 | $output->writeln( |
75 | 75 | sprintf( |
76 | 76 | '<fg=green>[updated]</fg=green> `%s`', |
@@ -45,7 +45,8 @@ discard block |
||
45 | 45 | |
46 | 46 | $runtimeDirectory = $this->dirs->get('runtime'); |
47 | 47 | |
48 | - if (!$this->files->exists($runtimeDirectory)) { |
|
48 | + if (!$this->files->exists($runtimeDirectory)) |
|
49 | + { |
|
49 | 50 | $this->files->ensureDirectory($runtimeDirectory); |
50 | 51 | $output->writeln('<comment>created</comment>'); |
51 | 52 | return; |
@@ -53,11 +54,15 @@ discard block |
||
53 | 54 | $output->writeln('<info>exists</info>'); |
54 | 55 | |
55 | 56 | |
56 | - foreach ($this->files->getFiles($runtimeDirectory) as $filename) { |
|
57 | - try { |
|
57 | + foreach ($this->files->getFiles($runtimeDirectory) as $filename) |
|
58 | + { |
|
59 | + try |
|
60 | + { |
|
58 | 61 | $this->files->setPermissions($filename, FilesInterface::RUNTIME); |
59 | 62 | $this->files->setPermissions(dirname($filename), FilesInterface::RUNTIME); |
60 | - } catch (\Throwable $e) { |
|
63 | + } |
|
64 | + catch (\Throwable $e) |
|
65 | + { |
|
61 | 66 | // @codeCoverageIgnoreStart |
62 | 67 | $output->writeln( |
63 | 68 | sprintf( |
@@ -70,7 +75,8 @@ discard block |
||
70 | 75 | // @codeCoverageIgnoreEnd |
71 | 76 | } |
72 | 77 | |
73 | - if ($output->isVerbose()) { |
|
78 | + if ($output->isVerbose()) |
|
79 | + { |
|
74 | 80 | $output->writeln( |
75 | 81 | sprintf( |
76 | 82 | '<fg=green>[updated]</fg=green> `%s`', |
@@ -112,7 +112,7 @@ |
||
112 | 112 | ] |
113 | 113 | ); |
114 | 114 | |
115 | - $tokenizer->addDirectory(directory('vendor') . 'spiral/validation/src/'); |
|
115 | + $tokenizer->addDirectory(directory('vendor').'spiral/validation/src/'); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -31,7 +31,7 @@ |
||
31 | 31 | function () use ($container): void { |
32 | 32 | /** @var DatabaseManager $dbal */ |
33 | 33 | $dbal = $container->get(DatabaseManager::class); |
34 | - foreach ($dbal->getDrivers() as $driver) { |
|
34 | + foreach ($dbal->getDrivers() as $driver){ |
|
35 | 35 | $driver->disconnect(); |
36 | 36 | } |
37 | 37 | } |
@@ -31,7 +31,8 @@ |
||
31 | 31 | function () use ($container): void { |
32 | 32 | /** @var DatabaseManager $dbal */ |
33 | 33 | $dbal = $container->get(DatabaseManager::class); |
34 | - foreach ($dbal->getDrivers() as $driver) { |
|
34 | + foreach ($dbal->getDrivers() as $driver) |
|
35 | + { |
|
35 | 36 | $driver->disconnect(); |
36 | 37 | } |
37 | 38 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $finalizer->addFinalizer( |
55 | 55 | function () use ($container): void { |
56 | - if ($container->hasInstance(ORMInterface::class)) { |
|
56 | + if ($container->hasInstance(ORMInterface::class)){ |
|
57 | 57 | $container->get(ORMInterface::class)->getHeap()->clean(); |
58 | 58 | } |
59 | 59 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | ): ORMInterface { |
76 | 76 | $orm = new ORM($factory, $schema); |
77 | 77 | |
78 | - if ($promiseFactory !== null) { |
|
78 | + if ($promiseFactory !== null){ |
|
79 | 79 | return $orm->withPromiseFactory($promiseFactory); |
80 | 80 | } |
81 | 81 |
@@ -53,7 +53,8 @@ discard block |
||
53 | 53 | { |
54 | 54 | $finalizer->addFinalizer( |
55 | 55 | function () use ($container): void { |
56 | - if ($container->hasInstance(ORMInterface::class)) { |
|
56 | + if ($container->hasInstance(ORMInterface::class)) |
|
57 | + { |
|
57 | 58 | $container->get(ORMInterface::class)->getHeap()->clean(); |
58 | 59 | } |
59 | 60 | } |
@@ -75,7 +76,8 @@ discard block |
||
75 | 76 | ): ORMInterface { |
76 | 77 | $orm = new ORM($factory, $schema); |
77 | 78 | |
78 | - if ($promiseFactory !== null) { |
|
79 | + if ($promiseFactory !== null) |
|
80 | + { |
|
79 | 81 | return $orm->withPromiseFactory($promiseFactory); |
80 | 82 | } |
81 | 83 |
@@ -56,7 +56,7 @@ |
||
56 | 56 | ] |
57 | 57 | ); |
58 | 58 | |
59 | - if ($env->get('RR_BROADCAST_PATH', null) !== null) { |
|
59 | + if ($env->get('RR_BROADCAST_PATH', null) !== null){ |
|
60 | 60 | $http->addMiddleware(WebsocketsMiddleware::class); |
61 | 61 | } |
62 | 62 | } |
@@ -56,7 +56,8 @@ |
||
56 | 56 | ] |
57 | 57 | ); |
58 | 58 | |
59 | - if ($env->get('RR_BROADCAST_PATH', null) !== null) { |
|
59 | + if ($env->get('RR_BROADCAST_PATH', null) !== null) |
|
60 | + { |
|
60 | 61 | $http->addMiddleware(WebsocketsMiddleware::class); |
61 | 62 | } |
62 | 63 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | 'handler' => new Autowire( |
63 | 63 | FileHandler::class, |
64 | 64 | [ |
65 | - 'directory' => $directories->get('runtime') . 'session', |
|
65 | + 'directory' => $directories->get('runtime').'session', |
|
66 | 66 | 'lifetime' => 86400 |
67 | 67 | ] |
68 | 68 | ) |
@@ -70,16 +70,16 @@ |
||
70 | 70 | { |
71 | 71 | $state = new State(); |
72 | 72 | |
73 | - foreach ($this->collectors as $collector) { |
|
74 | - if (is_string($collector)) { |
|
73 | + foreach ($this->collectors as $collector){ |
|
74 | + if (is_string($collector)){ |
|
75 | 75 | $collector = $this->factory->make($collector); |
76 | 76 | } |
77 | 77 | |
78 | - if ($collector instanceof Autowire) { |
|
78 | + if ($collector instanceof Autowire){ |
|
79 | 79 | $collector = $collector->resolve($this->factory); |
80 | 80 | } |
81 | 81 | |
82 | - if (!$collector instanceof StateCollectorInterface) { |
|
82 | + if (!$collector instanceof StateCollectorInterface){ |
|
83 | 83 | throw new StateException( |
84 | 84 | sprintf( |
85 | 85 | 'Unable to populate state, invalid state collector %s', |
@@ -70,16 +70,20 @@ |
||
70 | 70 | { |
71 | 71 | $state = new State(); |
72 | 72 | |
73 | - foreach ($this->collectors as $collector) { |
|
74 | - if (is_string($collector)) { |
|
73 | + foreach ($this->collectors as $collector) |
|
74 | + { |
|
75 | + if (is_string($collector)) |
|
76 | + { |
|
75 | 77 | $collector = $this->factory->make($collector); |
76 | 78 | } |
77 | 79 | |
78 | - if ($collector instanceof Autowire) { |
|
80 | + if ($collector instanceof Autowire) |
|
81 | + { |
|
79 | 82 | $collector = $collector->resolve($this->factory); |
80 | 83 | } |
81 | 84 | |
82 | - if (!$collector instanceof StateCollectorInterface) { |
|
85 | + if (!$collector instanceof StateCollectorInterface) |
|
86 | + { |
|
83 | 87 | throw new StateException( |
84 | 88 | sprintf( |
85 | 89 | 'Unable to populate state, invalid state collector %s', |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function perform(DatabaseConfig $config, DatabaseManager $dbal): void |
36 | 36 | { |
37 | - if ($this->argument('db')) { |
|
37 | + if ($this->argument('db')){ |
|
38 | 38 | $databases = [$this->argument('db')]; |
39 | - } else { |
|
39 | + }else{ |
|
40 | 40 | $databases = array_keys($config->getDatabases()); |
41 | 41 | } |
42 | 42 | |
43 | - if (empty($databases)) { |
|
43 | + if (empty($databases)){ |
|
44 | 44 | $this->writeln('<fg=red>No databases found.</fg=red>'); |
45 | 45 | |
46 | 46 | return; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | ] |
59 | 59 | ); |
60 | 60 | |
61 | - foreach ($databases as $database) { |
|
61 | + foreach ($databases as $database){ |
|
62 | 62 | $database = $dbal->database($database); |
63 | 63 | |
64 | 64 | /** @var Driver $driver */ |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | $database->getPrefix() ?: '<comment>---</comment>' |
72 | 72 | ]; |
73 | 73 | |
74 | - try { |
|
74 | + try{ |
|
75 | 75 | $driver->connect(); |
76 | - } catch (\Exception $exception) { |
|
76 | + }catch (\Exception $exception){ |
|
77 | 77 | $this->renderException($grid, $header, $exception); |
78 | 78 | |
79 | - if ($database->getName() != end($databases)) { |
|
79 | + if ($database->getName() != end($databases)){ |
|
80 | 80 | $grid->addRow(new TableSeparator()); |
81 | 81 | } |
82 | 82 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | $header[] = '<info>connected</info>'; |
87 | 87 | $this->renderTables($grid, $header, $database); |
88 | - if ($database->getName() != end($databases)) { |
|
88 | + if ($database->getName() != end($databases)){ |
|
89 | 89 | $grid->addRow(new TableSeparator()); |
90 | 90 | } |
91 | 91 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | private function renderTables(Table $grid, array $header, Database $database): void |
121 | 121 | { |
122 | - foreach ($database->getTables() as $table) { |
|
122 | + foreach ($database->getTables() as $table){ |
|
123 | 123 | $grid->addRow( |
124 | 124 | array_merge( |
125 | 125 | $header, |
@@ -34,13 +34,17 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function perform(DatabaseConfig $config, DatabaseManager $dbal): void |
36 | 36 | { |
37 | - if ($this->argument('db')) { |
|
37 | + if ($this->argument('db')) |
|
38 | + { |
|
38 | 39 | $databases = [$this->argument('db')]; |
39 | - } else { |
|
40 | + } |
|
41 | + else |
|
42 | + { |
|
40 | 43 | $databases = array_keys($config->getDatabases()); |
41 | 44 | } |
42 | 45 | |
43 | - if (empty($databases)) { |
|
46 | + if (empty($databases)) |
|
47 | + { |
|
44 | 48 | $this->writeln('<fg=red>No databases found.</fg=red>'); |
45 | 49 | |
46 | 50 | return; |
@@ -58,7 +62,8 @@ discard block |
||
58 | 62 | ] |
59 | 63 | ); |
60 | 64 | |
61 | - foreach ($databases as $database) { |
|
65 | + foreach ($databases as $database) |
|
66 | + { |
|
62 | 67 | $database = $dbal->database($database); |
63 | 68 | |
64 | 69 | /** @var Driver $driver */ |
@@ -71,12 +76,16 @@ discard block |
||
71 | 76 | $database->getPrefix() ?: '<comment>---</comment>' |
72 | 77 | ]; |
73 | 78 | |
74 | - try { |
|
79 | + try |
|
80 | + { |
|
75 | 81 | $driver->connect(); |
76 | - } catch (\Exception $exception) { |
|
82 | + } |
|
83 | + catch (\Exception $exception) |
|
84 | + { |
|
77 | 85 | $this->renderException($grid, $header, $exception); |
78 | 86 | |
79 | - if ($database->getName() != end($databases)) { |
|
87 | + if ($database->getName() != end($databases)) |
|
88 | + { |
|
80 | 89 | $grid->addRow(new TableSeparator()); |
81 | 90 | } |
82 | 91 | |
@@ -85,7 +94,8 @@ discard block |
||
85 | 94 | |
86 | 95 | $header[] = '<info>connected</info>'; |
87 | 96 | $this->renderTables($grid, $header, $database); |
88 | - if ($database->getName() != end($databases)) { |
|
97 | + if ($database->getName() != end($databases)) |
|
98 | + { |
|
89 | 99 | $grid->addRow(new TableSeparator()); |
90 | 100 | } |
91 | 101 | } |
@@ -119,7 +129,8 @@ discard block |
||
119 | 129 | */ |
120 | 130 | private function renderTables(Table $grid, array $header, Database $database): void |
121 | 131 | { |
122 | - foreach ($database->getTables() as $table) { |
|
132 | + foreach ($database->getTables() as $table) |
|
133 | + { |
|
123 | 134 | $grid->addRow( |
124 | 135 | array_merge( |
125 | 136 | $header, |