@@ -27,20 +27,20 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function perform(ViewsConfig $config, FilesInterface $files): void |
| 29 | 29 | { |
| 30 | - if (!$files->exists($config->getCacheDirectory())) { |
|
| 30 | + if (!$files->exists($config->getCacheDirectory())){ |
|
| 31 | 31 | $this->writeln('Cache directory is missing, no cache to be cleaned.'); |
| 32 | 32 | |
| 33 | 33 | return; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if ($this->isVerbose()) { |
|
| 36 | + if ($this->isVerbose()){ |
|
| 37 | 37 | $this->writeln('<info>Cleaning view cache:</info>'); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - foreach ($files->getFiles($config->getCacheDirectory()) as $filename) { |
|
| 41 | - try { |
|
| 40 | + foreach ($files->getFiles($config->getCacheDirectory()) as $filename){ |
|
| 41 | + try{ |
|
| 42 | 42 | $files->delete($filename); |
| 43 | - } catch (\Throwable $e) { |
|
| 43 | + }catch (\Throwable $e){ |
|
| 44 | 44 | // @codeCoverageIgnoreStart |
| 45 | 45 | $this->sprintf( |
| 46 | 46 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>\n", |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | // @codeCoverageIgnoreEnd |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if ($this->isVerbose()) { |
|
| 56 | + if ($this->isVerbose()){ |
|
| 57 | 57 | $this->sprintf( |
| 58 | 58 | "<fg=green>[deleted]</fg=green> `%s`\n", |
| 59 | 59 | $files->relativePath($filename, $config->getCacheDirectory()) |
@@ -27,20 +27,26 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function perform(ViewsConfig $config, FilesInterface $files): void |
| 29 | 29 | { |
| 30 | - if (!$files->exists($config->getCacheDirectory())) { |
|
| 30 | + if (!$files->exists($config->getCacheDirectory())) |
|
| 31 | + { |
|
| 31 | 32 | $this->writeln('Cache directory is missing, no cache to be cleaned.'); |
| 32 | 33 | |
| 33 | 34 | return; |
| 34 | 35 | } |
| 35 | 36 | |
| 36 | - if ($this->isVerbose()) { |
|
| 37 | + if ($this->isVerbose()) |
|
| 38 | + { |
|
| 37 | 39 | $this->writeln('<info>Cleaning view cache:</info>'); |
| 38 | 40 | } |
| 39 | 41 | |
| 40 | - foreach ($files->getFiles($config->getCacheDirectory()) as $filename) { |
|
| 41 | - try { |
|
| 42 | + foreach ($files->getFiles($config->getCacheDirectory()) as $filename) |
|
| 43 | + { |
|
| 44 | + try |
|
| 45 | + { |
|
| 42 | 46 | $files->delete($filename); |
| 43 | - } catch (\Throwable $e) { |
|
| 47 | + } |
|
| 48 | + catch (\Throwable $e) |
|
| 49 | + { |
|
| 44 | 50 | // @codeCoverageIgnoreStart |
| 45 | 51 | $this->sprintf( |
| 46 | 52 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>\n", |
@@ -53,7 +59,8 @@ discard block |
||
| 53 | 59 | // @codeCoverageIgnoreEnd |
| 54 | 60 | } |
| 55 | 61 | |
| 56 | - if ($this->isVerbose()) { |
|
| 62 | + if ($this->isVerbose()) |
|
| 63 | + { |
|
| 57 | 64 | $this->sprintf( |
| 58 | 65 | "<fg=green>[deleted]</fg=green> `%s`\n", |
| 59 | 66 | $files->relativePath($filename, $config->getCacheDirectory()) |
@@ -42,8 +42,10 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $grid = $this->table(['Name:', 'Verbs:', 'Pattern:', 'Target:']); |
| 44 | 44 | |
| 45 | - foreach ($router->getRoutes() as $name => $route) { |
|
| 46 | - if ($route instanceof Route) { |
|
| 45 | + foreach ($router->getRoutes() as $name => $route) |
|
| 46 | + { |
|
| 47 | + if ($route instanceof Route) |
|
| 48 | + { |
|
| 47 | 49 | $grid->addRow( |
| 48 | 50 | [ |
| 49 | 51 | $name, |
@@ -64,14 +66,17 @@ discard block |
||
| 64 | 66 | */ |
| 65 | 67 | private function getVerbs(Route $route): string |
| 66 | 68 | { |
| 67 | - if ($route->getVerbs() === Route::VERBS) { |
|
| 69 | + if ($route->getVerbs() === Route::VERBS) |
|
| 70 | + { |
|
| 68 | 71 | return '*'; |
| 69 | 72 | } |
| 70 | 73 | |
| 71 | 74 | $result = []; |
| 72 | 75 | |
| 73 | - foreach ($route->getVerbs() as $verb) { |
|
| 74 | - switch (strtolower($verb)) { |
|
| 76 | + foreach ($route->getVerbs() as $verb) |
|
| 77 | + { |
|
| 78 | + switch (strtolower($verb)) |
|
| 79 | + { |
|
| 75 | 80 | case 'get': |
| 76 | 81 | $verb = '<fg=green>GET</>'; |
| 77 | 82 | break; |
@@ -107,7 +112,8 @@ discard block |
||
| 107 | 112 | |
| 108 | 113 | return preg_replace_callback( |
| 109 | 114 | '/<([^>]*)>/', |
| 110 | - static function ($m) { |
|
| 115 | + static function ($m) |
|
| 116 | + { |
|
| 111 | 117 | return sprintf('<fg=magenta>%s</>', $m[0]); |
| 112 | 118 | }, |
| 113 | 119 | $pattern |
@@ -124,7 +130,8 @@ discard block |
||
| 124 | 130 | private function getTarget(Route $route, KernelInterface $kernel): string |
| 125 | 131 | { |
| 126 | 132 | $target = $this->getValue($route, 'target'); |
| 127 | - switch (true) { |
|
| 133 | + switch (true) |
|
| 134 | + { |
|
| 128 | 135 | case $target instanceof Closure: |
| 129 | 136 | $reflection = new ReflectionFunction($target); |
| 130 | 137 | return sprintf( |
@@ -148,7 +155,8 @@ discard block |
||
| 148 | 155 | |
| 149 | 156 | case $target instanceof Group: |
| 150 | 157 | $result = []; |
| 151 | - foreach ($this->getValue($target, 'controllers') as $alias => $class) { |
|
| 158 | + foreach ($this->getValue($target, 'controllers') as $alias => $class) |
|
| 159 | + { |
|
| 152 | 160 | $result[] = sprintf('%s => %s', $alias, $this->relativeClass($class, $kernel)); |
| 153 | 161 | } |
| 154 | 162 | |
@@ -174,11 +182,14 @@ discard block |
||
| 174 | 182 | */ |
| 175 | 183 | private function getValue(object $object, string $property) |
| 176 | 184 | { |
| 177 | - try { |
|
| 185 | + try |
|
| 186 | + { |
|
| 178 | 187 | $r = new ReflectionObject($object); |
| 179 | 188 | $prop = $r->getProperty($property); |
| 180 | 189 | $prop->setAccessible(true); |
| 181 | - } catch (Throwable $e) { |
|
| 190 | + } |
|
| 191 | + catch (Throwable $e) |
|
| 192 | + { |
|
| 182 | 193 | return $e->getMessage(); |
| 183 | 194 | } |
| 184 | 195 | |
@@ -195,7 +206,8 @@ discard block |
||
| 195 | 206 | $r = new ReflectionObject($kernel); |
| 196 | 207 | $r->getNamespaceName(); |
| 197 | 208 | |
| 198 | - if (strpos($class, $r->getNamespaceName()) === 0) { |
|
| 209 | + if (strpos($class, $r->getNamespaceName()) === 0) |
|
| 210 | + { |
|
| 199 | 211 | return substr($class, strlen($r->getNamespaceName()) + 1); |
| 200 | 212 | } |
| 201 | 213 | |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $grid = $this->table(['Name:', 'Verbs:', 'Pattern:', 'Target:']); |
| 44 | 44 | |
| 45 | - foreach ($router->getRoutes() as $name => $route) { |
|
| 46 | - if ($route instanceof Route) { |
|
| 45 | + foreach ($router->getRoutes() as $name => $route){ |
|
| 46 | + if ($route instanceof Route){ |
|
| 47 | 47 | $grid->addRow( |
| 48 | 48 | [ |
| 49 | 49 | $name, |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | private function getVerbs(Route $route): string |
| 66 | 66 | { |
| 67 | - if ($route->getVerbs() === Route::VERBS) { |
|
| 67 | + if ($route->getVerbs() === Route::VERBS){ |
|
| 68 | 68 | return '*'; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $result = []; |
| 72 | 72 | |
| 73 | - foreach ($route->getVerbs() as $verb) { |
|
| 74 | - switch (strtolower($verb)) { |
|
| 73 | + foreach ($route->getVerbs() as $verb){ |
|
| 74 | + switch (strtolower($verb)){ |
|
| 75 | 75 | case 'get': |
| 76 | 76 | $verb = '<fg=green>GET</>'; |
| 77 | 77 | break; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | return preg_replace_callback( |
| 109 | 109 | '/<([^>]*)>/', |
| 110 | - static function ($m) { |
|
| 110 | + static function ($m){ |
|
| 111 | 111 | return sprintf('<fg=magenta>%s</>', $m[0]); |
| 112 | 112 | }, |
| 113 | 113 | $pattern |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | private function getTarget(Route $route, KernelInterface $kernel): string |
| 125 | 125 | { |
| 126 | 126 | $target = $this->getValue($route, 'target'); |
| 127 | - switch (true) { |
|
| 127 | + switch (true){ |
|
| 128 | 128 | case $target instanceof Closure: |
| 129 | 129 | $reflection = new ReflectionFunction($target); |
| 130 | 130 | return sprintf( |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | return sprintf( |
| 138 | 138 | '%s->%s', |
| 139 | 139 | $this->relativeClass($this->getValue($target, 'controller'), $kernel), |
| 140 | - implode('|', (array) $this->getValue($target, 'action')) |
|
| 140 | + implode('|', (array)$this->getValue($target, 'action')) |
|
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | 143 | case $target instanceof Controller: |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | case $target instanceof Group: |
| 150 | 150 | $result = []; |
| 151 | - foreach ($this->getValue($target, 'controllers') as $alias => $class) { |
|
| 151 | + foreach ($this->getValue($target, 'controllers') as $alias => $class){ |
|
| 152 | 152 | $result[] = sprintf('%s => %s', $alias, $this->relativeClass($class, $kernel)); |
| 153 | 153 | } |
| 154 | 154 | |
@@ -172,11 +172,11 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | private function getValue(object $object, string $property) |
| 174 | 174 | { |
| 175 | - try { |
|
| 175 | + try{ |
|
| 176 | 176 | $r = new ReflectionObject($object); |
| 177 | 177 | $prop = $r->getProperty($property); |
| 178 | 178 | $prop->setAccessible(true); |
| 179 | - } catch (Throwable $e) { |
|
| 179 | + }catch (Throwable $e){ |
|
| 180 | 180 | return $e->getMessage(); |
| 181 | 181 | } |
| 182 | 182 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $r = new ReflectionObject($kernel); |
| 194 | 194 | $r->getNamespaceName(); |
| 195 | 195 | |
| 196 | - if (strpos($class, $r->getNamespaceName()) === 0) { |
|
| 196 | + if (strpos($class, $r->getNamespaceName()) === 0){ |
|
| 197 | 197 | return substr($class, strlen($r->getNamespaceName()) + 1); |
| 198 | 198 | } |
| 199 | 199 | |
@@ -55,21 +55,21 @@ |
||
| 55 | 55 | $this->sprintf("<info>New encryption key:</info> <fg=cyan>%s</fg=cyan>\n", $key); |
| 56 | 56 | |
| 57 | 57 | $file = $this->option('mount'); |
| 58 | - if ($file === null) { |
|
| 58 | + if ($file === null){ |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if (!$files->exists($file)) { |
|
| 62 | + if (!$files->exists($file)){ |
|
| 63 | 63 | $this->sprintf('<error>Unable to find `%s`</error>', $file); |
| 64 | 64 | return; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $content = $files->read($file); |
| 68 | 68 | |
| 69 | - try { |
|
| 69 | + try{ |
|
| 70 | 70 | $content = str_replace($this->option('placeholder'), $key, $content); |
| 71 | 71 | $content = str_replace($enc->getKey(), $key, $content); |
| 72 | - } catch (\Throwable $e) { |
|
| 72 | + }catch (\Throwable $e){ |
|
| 73 | 73 | // current keys is not set |
| 74 | 74 | } |
| 75 | 75 | |
@@ -55,21 +55,26 @@ |
||
| 55 | 55 | $this->sprintf("<info>New encryption key:</info> <fg=cyan>%s</fg=cyan>\n", $key); |
| 56 | 56 | |
| 57 | 57 | $file = $this->option('mount'); |
| 58 | - if ($file === null) { |
|
| 58 | + if ($file === null) |
|
| 59 | + { |
|
| 59 | 60 | return; |
| 60 | 61 | } |
| 61 | 62 | |
| 62 | - if (!$files->exists($file)) { |
|
| 63 | + if (!$files->exists($file)) |
|
| 64 | + { |
|
| 63 | 65 | $this->sprintf('<error>Unable to find `%s`</error>', $file); |
| 64 | 66 | return; |
| 65 | 67 | } |
| 66 | 68 | |
| 67 | 69 | $content = $files->read($file); |
| 68 | 70 | |
| 69 | - try { |
|
| 71 | + try |
|
| 72 | + { |
|
| 70 | 73 | $content = str_replace($this->option('placeholder'), $key, $content); |
| 71 | 74 | $content = str_replace($enc->getKey(), $key, $content); |
| 72 | - } catch (\Throwable $e) { |
|
| 75 | + } |
|
| 76 | + catch (\Throwable $e) |
|
| 77 | + { |
|
| 73 | 78 | // current keys is not set |
| 74 | 79 | } |
| 75 | 80 | |
@@ -26,20 +26,20 @@ discard block |
||
| 26 | 26 | public function perform(FilesInterface $files, DirectoriesInterface $directories): void |
| 27 | 27 | { |
| 28 | 28 | $cacheDirectory = $directories->get('cache'); |
| 29 | - if (!$files->exists($cacheDirectory)) { |
|
| 29 | + if (!$files->exists($cacheDirectory)){ |
|
| 30 | 30 | $this->writeln('Cache directory is missing, no cache to be cleaned.'); |
| 31 | 31 | |
| 32 | 32 | return; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if ($this->isVerbose()) { |
|
| 35 | + if ($this->isVerbose()){ |
|
| 36 | 36 | $this->writeln('<info>Cleaning application cache:</info>'); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - foreach ($files->getFiles($cacheDirectory) as $filename) { |
|
| 40 | - try { |
|
| 39 | + foreach ($files->getFiles($cacheDirectory) as $filename){ |
|
| 40 | + try{ |
|
| 41 | 41 | $files->delete($filename); |
| 42 | - } catch (\Throwable $e) { |
|
| 42 | + }catch (\Throwable $e){ |
|
| 43 | 43 | // @codeCoverageIgnoreStart |
| 44 | 44 | $this->sprintf( |
| 45 | 45 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>\n", |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | // @codeCoverageIgnoreEnd |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if ($this->isVerbose()) { |
|
| 54 | + if ($this->isVerbose()){ |
|
| 55 | 55 | $this->sprintf( |
| 56 | 56 | "<fg=green>[deleted]</fg=green> `%s`\n", |
| 57 | 57 | $files->relativePath($filename, $cacheDirectory) |
@@ -26,20 +26,26 @@ discard block |
||
| 26 | 26 | public function perform(FilesInterface $files, DirectoriesInterface $directories): void |
| 27 | 27 | { |
| 28 | 28 | $cacheDirectory = $directories->get('cache'); |
| 29 | - if (!$files->exists($cacheDirectory)) { |
|
| 29 | + if (!$files->exists($cacheDirectory)) |
|
| 30 | + { |
|
| 30 | 31 | $this->writeln('Cache directory is missing, no cache to be cleaned.'); |
| 31 | 32 | |
| 32 | 33 | return; |
| 33 | 34 | } |
| 34 | 35 | |
| 35 | - if ($this->isVerbose()) { |
|
| 36 | + if ($this->isVerbose()) |
|
| 37 | + { |
|
| 36 | 38 | $this->writeln('<info>Cleaning application cache:</info>'); |
| 37 | 39 | } |
| 38 | 40 | |
| 39 | - foreach ($files->getFiles($cacheDirectory) as $filename) { |
|
| 40 | - try { |
|
| 41 | + foreach ($files->getFiles($cacheDirectory) as $filename) |
|
| 42 | + { |
|
| 43 | + try |
|
| 44 | + { |
|
| 41 | 45 | $files->delete($filename); |
| 42 | - } catch (\Throwable $e) { |
|
| 46 | + } |
|
| 47 | + catch (\Throwable $e) |
|
| 48 | + { |
|
| 43 | 49 | // @codeCoverageIgnoreStart |
| 44 | 50 | $this->sprintf( |
| 45 | 51 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>\n", |
@@ -51,7 +57,8 @@ discard block |
||
| 51 | 57 | // @codeCoverageIgnoreEnd |
| 52 | 58 | } |
| 53 | 59 | |
| 54 | - if ($this->isVerbose()) { |
|
| 60 | + if ($this->isVerbose()) |
|
| 61 | + { |
|
| 55 | 62 | $this->sprintf( |
| 56 | 63 | "<fg=green>[deleted]</fg=green> `%s`\n", |
| 57 | 64 | $files->relativePath($filename, $cacheDirectory) |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | $services = $locator->getServices(); |
| 28 | 28 | |
| 29 | - if ($services === []) { |
|
| 29 | + if ($services === []){ |
|
| 30 | 30 | $this->writeln('<comment>No GRPC services were found.</comment>'); |
| 31 | 31 | return; |
| 32 | 32 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | ] |
| 40 | 40 | ); |
| 41 | 41 | |
| 42 | - foreach ($services as $interface => $instance) { |
|
| 42 | + foreach ($services as $interface => $instance){ |
|
| 43 | 43 | $grid->addRow( |
| 44 | 44 | [ |
| 45 | 45 | $interface::NAME, |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | $services = $locator->getServices(); |
| 28 | 28 | |
| 29 | - if ($services === []) { |
|
| 29 | + if ($services === []) |
|
| 30 | + { |
|
| 30 | 31 | $this->writeln('<comment>No GRPC services were found.</comment>'); |
| 31 | 32 | return; |
| 32 | 33 | } |
@@ -39,7 +40,8 @@ discard block |
||
| 39 | 40 | ] |
| 40 | 41 | ); |
| 41 | 42 | |
| 42 | - foreach ($services as $interface => $instance) { |
|
| 43 | + foreach ($services as $interface => $instance) |
|
| 44 | + { |
|
| 43 | 45 | $grid->addRow( |
| 44 | 46 | [ |
| 45 | 47 | $interface::NAME, |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | public function perform(KernelInterface $kernel, FilesInterface $files, DirectoriesInterface $dirs): void |
| 38 | 38 | { |
| 39 | 39 | $protoFile = $this->argument('proto'); |
| 40 | - if (!file_exists($protoFile)) { |
|
| 40 | + if (!file_exists($protoFile)){ |
|
| 41 | 41 | $this->sprintf('<error>File `%s` not found.</error>', $protoFile); |
| 42 | 42 | return; |
| 43 | 43 | } |
@@ -50,19 +50,19 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | $this->sprintf("<info>Compiling <fg=cyan>`%s`</fg=cyan>:</info>\n", $protoFile); |
| 52 | 52 | |
| 53 | - try { |
|
| 53 | + try{ |
|
| 54 | 54 | $result = $compiler->compile($protoFile); |
| 55 | - } catch (\Throwable $e) { |
|
| 55 | + }catch (\Throwable $e){ |
|
| 56 | 56 | $this->sprintf("<error>Error:</error> <fg=red>%s</fg=red>\n", $e->getMessage()); |
| 57 | 57 | return; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if ($result === []) { |
|
| 60 | + if ($result === []){ |
|
| 61 | 61 | $this->sprintf("<info>No files were generated.</info>\n", $protoFile); |
| 62 | 62 | return; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - foreach ($result as $file) { |
|
| 65 | + foreach ($result as $file){ |
|
| 66 | 66 | $this->sprintf( |
| 67 | 67 | "<fg=green>•</fg=green> %s%s%s\n", |
| 68 | 68 | Color::LIGHT_WHITE, |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | protected function getPath(KernelInterface $kernel): string |
| 82 | 82 | { |
| 83 | 83 | $path = $this->argument('path'); |
| 84 | - if ($path !== 'auto') { |
|
| 84 | + if ($path !== 'auto'){ |
|
| 85 | 85 | return $path; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | protected function getNamespace(KernelInterface $kernel): string |
| 100 | 100 | { |
| 101 | 101 | $namespace = $this->argument('namespace'); |
| 102 | - if ($namespace !== 'auto') { |
|
| 102 | + if ($namespace !== 'auto'){ |
|
| 103 | 103 | return $namespace; |
| 104 | 104 | } |
| 105 | 105 | |
@@ -37,7 +37,8 @@ discard block |
||
| 37 | 37 | public function perform(KernelInterface $kernel, FilesInterface $files, DirectoriesInterface $dirs): void |
| 38 | 38 | { |
| 39 | 39 | $protoFile = $this->argument('proto'); |
| 40 | - if (!file_exists($protoFile)) { |
|
| 40 | + if (!file_exists($protoFile)) |
|
| 41 | + { |
|
| 41 | 42 | $this->sprintf('<error>File `%s` not found.</error>', $protoFile); |
| 42 | 43 | return; |
| 43 | 44 | } |
@@ -50,19 +51,24 @@ discard block |
||
| 50 | 51 | |
| 51 | 52 | $this->sprintf("<info>Compiling <fg=cyan>`%s`</fg=cyan>:</info>\n", $protoFile); |
| 52 | 53 | |
| 53 | - try { |
|
| 54 | + try |
|
| 55 | + { |
|
| 54 | 56 | $result = $compiler->compile($protoFile); |
| 55 | - } catch (\Throwable $e) { |
|
| 57 | + } |
|
| 58 | + catch (\Throwable $e) |
|
| 59 | + { |
|
| 56 | 60 | $this->sprintf("<error>Error:</error> <fg=red>%s</fg=red>\n", $e->getMessage()); |
| 57 | 61 | return; |
| 58 | 62 | } |
| 59 | 63 | |
| 60 | - if ($result === []) { |
|
| 64 | + if ($result === []) |
|
| 65 | + { |
|
| 61 | 66 | $this->sprintf("<info>No files were generated.</info>\n", $protoFile); |
| 62 | 67 | return; |
| 63 | 68 | } |
| 64 | 69 | |
| 65 | - foreach ($result as $file) { |
|
| 70 | + foreach ($result as $file) |
|
| 71 | + { |
|
| 66 | 72 | $this->sprintf( |
| 67 | 73 | "<fg=green>•</fg=green> %s%s%s\n", |
| 68 | 74 | Color::LIGHT_WHITE, |
@@ -81,7 +87,8 @@ discard block |
||
| 81 | 87 | protected function getPath(KernelInterface $kernel): string |
| 82 | 88 | { |
| 83 | 89 | $path = $this->argument('path'); |
| 84 | - if ($path !== 'auto') { |
|
| 90 | + if ($path !== 'auto') |
|
| 91 | + { |
|
| 85 | 92 | return $path; |
| 86 | 93 | } |
| 87 | 94 | |
@@ -99,7 +106,8 @@ discard block |
||
| 99 | 106 | protected function getNamespace(KernelInterface $kernel): string |
| 100 | 107 | { |
| 101 | 108 | $namespace = $this->argument('namespace'); |
| 102 | - if ($namespace !== 'auto') { |
|
| 109 | + if ($namespace !== 'auto') |
|
| 110 | + { |
|
| 103 | 111 | return $namespace; |
| 104 | 112 | } |
| 105 | 113 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | use Spiral\Core\Container\Autowire; |
| 13 | 13 | use Spiral\Debug\Dumper; |
| 14 | 14 | |
| 15 | -if (!function_exists('bind')) { |
|
| 15 | +if (!function_exists('bind')){ |
|
| 16 | 16 | /** |
| 17 | 17 | * Shortcut to container Autowire definition. |
| 18 | 18 | * |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | -if (!function_exists('dumprr')) { |
|
| 33 | +if (!function_exists('dumprr')){ |
|
| 34 | 34 | /** |
| 35 | 35 | * Dumprr is similar to Dump function but always redirect output to STDERR. |
| 36 | 36 | * |
@@ -12,7 +12,8 @@ discard block |
||
| 12 | 12 | use Spiral\Core\Container\Autowire; |
| 13 | 13 | use Spiral\Debug\Dumper; |
| 14 | 14 | |
| 15 | -if (!function_exists('bind')) { |
|
| 15 | +if (!function_exists('bind')) |
|
| 16 | +{ |
|
| 16 | 17 | /** |
| 17 | 18 | * Shortcut to container Autowire definition. |
| 18 | 19 | * |
@@ -30,7 +31,8 @@ discard block |
||
| 30 | 31 | } |
| 31 | 32 | } |
| 32 | 33 | |
| 33 | -if (!function_exists('dumprr')) { |
|
| 34 | +if (!function_exists('dumprr')) |
|
| 35 | +{ |
|
| 34 | 36 | /** |
| 35 | 37 | * Dumprr is similar to Dump function but always redirect output to STDERR. |
| 36 | 38 | * |
@@ -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 | } |
@@ -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; |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | $worker = $this->container->get(Worker::class); |
| 70 | 70 | $locator = $this->container->get(LocatorInterface::class); |
| 71 | 71 | |
| 72 | - foreach ($locator->getServices() as $interface => $service) { |
|
| 72 | + foreach ($locator->getServices() as $interface => $service){ |
|
| 73 | 73 | $server->registerService($interface, $service); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $server->serve( |
| 77 | 77 | $worker, |
| 78 | 78 | function (\Throwable $e = null): void { |
| 79 | - if ($e !== null) { |
|
| 79 | + if ($e !== null){ |
|
| 80 | 80 | $this->handleException($e); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | protected function handleException(\Throwable $e): void |
| 92 | 92 | { |
| 93 | - try { |
|
| 93 | + try{ |
|
| 94 | 94 | $this->container->get(SnapshotterInterface::class)->register($e); |
| 95 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
| 95 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
| 96 | 96 | // no need to notify when unable to register an exception |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -69,14 +69,16 @@ discard block |
||
| 69 | 69 | $worker = $this->container->get(Worker::class); |
| 70 | 70 | $locator = $this->container->get(LocatorInterface::class); |
| 71 | 71 | |
| 72 | - foreach ($locator->getServices() as $interface => $service) { |
|
| 72 | + foreach ($locator->getServices() as $interface => $service) |
|
| 73 | + { |
|
| 73 | 74 | $server->registerService($interface, $service); |
| 74 | 75 | } |
| 75 | 76 | |
| 76 | 77 | $server->serve( |
| 77 | 78 | $worker, |
| 78 | 79 | function (\Throwable $e = null): void { |
| 79 | - if ($e !== null) { |
|
| 80 | + if ($e !== null) |
|
| 81 | + { |
|
| 80 | 82 | $this->handleException($e); |
| 81 | 83 | } |
| 82 | 84 | |
@@ -90,9 +92,12 @@ discard block |
||
| 90 | 92 | */ |
| 91 | 93 | protected function handleException(\Throwable $e): void |
| 92 | 94 | { |
| 93 | - try { |
|
| 95 | + try |
|
| 96 | + { |
|
| 94 | 97 | $this->container->get(SnapshotterInterface::class)->register($e); |
| 95 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
| 98 | + } |
|
| 99 | + catch (\Throwable | ContainerExceptionInterface $se) |
|
| 100 | + { |
|
| 96 | 101 | // no need to notify when unable to register an exception |
| 97 | 102 | } |
| 98 | 103 | } |