@@ -17,5 +17,5 @@ |
||
| 17 | 17 | * @param mixed $context Validation context (available for checkers and validation |
| 18 | 18 | * methods but is not validated). |
| 19 | 19 | */ |
| 20 | - public function validate(array|object $data, array $rules, mixed $context = null): ValidatorInterface; |
|
| 20 | + public function validate(array | object $data, array $rules, mixed $context = null): ValidatorInterface; |
|
| 21 | 21 | } |
@@ -24,11 +24,13 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public function confirmToProceed(string $message = 'Application in production.'): bool |
| 26 | 26 | { |
| 27 | - if (!$this->appEnv->isProduction()) { |
|
| 27 | + if (!$this->appEnv->isProduction()) |
|
| 28 | + { |
|
| 28 | 29 | return true; |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | - if ($this->hasOption('force') && $this->option('force')) { |
|
| 32 | + if ($this->hasOption('force') && $this->option('force')) |
|
| 33 | + { |
|
| 32 | 34 | return true; |
| 33 | 35 | } |
| 34 | 36 | |
@@ -36,7 +38,8 @@ discard block |
||
| 36 | 38 | |
| 37 | 39 | $confirmed = $this->confirm('Do you really wish to run command?'); |
| 38 | 40 | |
| 39 | - if (!$confirmed) { |
|
| 41 | + if (!$confirmed) |
|
| 42 | + { |
|
| 40 | 43 | $this->comment('Command Canceled!'); |
| 41 | 44 | |
| 42 | 45 | return false; |
@@ -21,18 +21,18 @@ discard block |
||
| 21 | 21 | private readonly AppEnvironment $appEnv, |
| 22 | 22 | InputInterface $input, |
| 23 | 23 | OutputInterface $output, |
| 24 | - ) { |
|
| 24 | + ){ |
|
| 25 | 25 | $this->input = $input; |
| 26 | 26 | $this->output = $output instanceof SymfonyStyle ? $output : new SymfonyStyle($input, $output); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function confirmToProceed(string $message = 'Application in production.'): bool |
| 30 | 30 | { |
| 31 | - if (!$this->appEnv->isProduction()) { |
|
| 31 | + if (!$this->appEnv->isProduction()){ |
|
| 32 | 32 | return true; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if ($this->hasOption('force') && $this->option('force')) { |
|
| 35 | + if ($this->hasOption('force') && $this->option('force')){ |
|
| 36 | 36 | return true; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $confirmed = $this->confirm('Do you really wish to run command?'); |
| 42 | 42 | |
| 43 | - if (!$confirmed) { |
|
| 43 | + if (!$confirmed){ |
|
| 44 | 44 | $this->comment('Command Canceled!'); |
| 45 | 45 | |
| 46 | 46 | return false; |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | use Spiral\Core\Container\Autowire; |
| 7 | 7 | use Spiral\Router\RouterInterface; |
| 8 | 8 | |
| 9 | -if (!\function_exists('bind')) { |
|
| 9 | +if (!\function_exists('bind')){ |
|
| 10 | 10 | /** |
| 11 | 11 | * Shortcut to container Autowire definition. |
| 12 | 12 | * |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | -if (!\function_exists('route')) { |
|
| 24 | +if (!\function_exists('route')){ |
|
| 25 | 25 | /** |
| 26 | 26 | * Generate the URL to a named route. |
| 27 | 27 | * |
@@ -6,7 +6,8 @@ discard block |
||
| 6 | 6 | use Spiral\Core\Container\Autowire; |
| 7 | 7 | use Spiral\Router\RouterInterface; |
| 8 | 8 | |
| 9 | -if (!\function_exists('bind')) { |
|
| 9 | +if (!\function_exists('bind')) |
|
| 10 | +{ |
|
| 10 | 11 | /** |
| 11 | 12 | * Shortcut to container Autowire definition. |
| 12 | 13 | * |
@@ -21,7 +22,8 @@ discard block |
||
| 21 | 22 | } |
| 22 | 23 | } |
| 23 | 24 | |
| 24 | -if (!\function_exists('route')) { |
|
| 25 | +if (!\function_exists('route')) |
|
| 26 | +{ |
|
| 25 | 27 | /** |
| 26 | 28 | * Generate the URL to a named route. |
| 27 | 29 | * |
@@ -23,7 +23,8 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | public function populate(StateInterface $state): void |
| 25 | 25 | { |
| 26 | - if ($this->request === null) { |
|
| 26 | + if ($this->request === null) |
|
| 27 | + { |
|
| 27 | 28 | return; |
| 28 | 29 | } |
| 29 | 30 | |
@@ -32,11 +33,13 @@ discard block |
||
| 32 | 33 | |
| 33 | 34 | $state->setVariable('headers', $this->request->getHeaders()); |
| 34 | 35 | |
| 35 | - if ($this->request->getQueryParams() !== []) { |
|
| 36 | + if ($this->request->getQueryParams() !== []) |
|
| 37 | + { |
|
| 36 | 38 | $state->setVariable('query', $this->request->getQueryParams()); |
| 37 | 39 | } |
| 38 | 40 | |
| 39 | - if ($this->request->getParsedBody() !== null) { |
|
| 41 | + if ($this->request->getParsedBody() !== null) |
|
| 42 | + { |
|
| 40 | 43 | $state->setVariable('data', $this->request->getParsedBody()); |
| 41 | 44 | } |
| 42 | 45 | } |
@@ -23,20 +23,20 @@ |
||
| 23 | 23 | |
| 24 | 24 | public function populate(StateInterface $state): void |
| 25 | 25 | { |
| 26 | - if ($this->request === null) { |
|
| 26 | + if ($this->request === null){ |
|
| 27 | 27 | return; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $state->setTag('method', $this->request->getMethod()); |
| 31 | - $state->setTag('url', (string) $this->request->getUri()); |
|
| 31 | + $state->setTag('url', (string)$this->request->getUri()); |
|
| 32 | 32 | |
| 33 | 33 | $state->setVariable('headers', $this->request->getHeaders()); |
| 34 | 34 | |
| 35 | - if ($this->request->getQueryParams() !== []) { |
|
| 35 | + if ($this->request->getQueryParams() !== []){ |
|
| 36 | 36 | $state->setVariable('query', $this->request->getQueryParams()); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if ($this->request->getParsedBody() !== null) { |
|
| 39 | + if ($this->request->getParsedBody() !== null){ |
|
| 40 | 40 | $state->setVariable('data', $this->request->getParsedBody()); |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -128,7 +128,7 @@ |
||
| 128 | 128 | private function getFileMode(): int |
| 129 | 129 | { |
| 130 | 130 | return match ($this->argument('mode')) { |
| 131 | - 'readonly' => FilesInterface::READONLY, |
|
| 131 | + 'readonly' => FilesInterface::readonly, |
|
| 132 | 132 | 'runtime' => FilesInterface::RUNTIME, |
| 133 | 133 | default => FilesInterface::RUNTIME, |
| 134 | 134 | }; |
@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | FilesInterface $files, |
| 47 | 47 | DirectoriesInterface $directories, |
| 48 | 48 | ): int { |
| 49 | - switch ($this->argument('type')) { |
|
| 49 | + switch ($this->argument('type')){ |
|
| 50 | 50 | case 'replace': |
| 51 | 51 | case 'follow': |
| 52 | - if ($this->isDirectory()) { |
|
| 52 | + if ($this->isDirectory()){ |
|
| 53 | 53 | $this->sprintf( |
| 54 | 54 | '<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>', |
| 55 | 55 | $this->getSource($files), |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $this->getMergeMode(), |
| 63 | 63 | $this->getFileMode(), |
| 64 | 64 | ); |
| 65 | - } else { |
|
| 65 | + }else{ |
|
| 66 | 66 | $this->sprintf( |
| 67 | 67 | '<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>', |
| 68 | 68 | $this->getSource($files), |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | private function getSource(FilesInterface $files): ?string |
| 101 | 101 | { |
| 102 | - if (!$this->isDirectory()) { |
|
| 102 | + if (!$this->isDirectory()){ |
|
| 103 | 103 | return $files->normalizePath($this->argument('source')); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string |
| 110 | 110 | { |
| 111 | 111 | $target = $this->argument('target'); |
| 112 | - foreach ($directories->getAll() as $alias => $value) { |
|
| 112 | + foreach ($directories->getAll() as $alias => $value){ |
|
| 113 | 113 | $target = \str_replace(\sprintf('@%s', $alias), $value, $target); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | return match (true) { |
| 122 | 122 | $this->argument('type') === 'ensure' => true, |
| 123 | - \str_contains((string) $this->argument('source'), '*') => true, |
|
| 123 | + \str_contains((string)$this->argument('source'), '*') => true, |
|
| 124 | 124 | default => \is_dir($this->argument('source')), |
| 125 | 125 | }; |
| 126 | 126 | } |
@@ -46,10 +46,12 @@ discard block |
||
| 46 | 46 | FilesInterface $files, |
| 47 | 47 | DirectoriesInterface $directories, |
| 48 | 48 | ): int { |
| 49 | - switch ($this->argument('type')) { |
|
| 49 | + switch ($this->argument('type')) |
|
| 50 | + { |
|
| 50 | 51 | case 'replace': |
| 51 | 52 | case 'follow': |
| 52 | - if ($this->isDirectory()) { |
|
| 53 | + if ($this->isDirectory()) |
|
| 54 | + { |
|
| 53 | 55 | $this->sprintf( |
| 54 | 56 | '<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>', |
| 55 | 57 | $this->getSource($files), |
@@ -62,7 +64,9 @@ discard block |
||
| 62 | 64 | $this->getMergeMode(), |
| 63 | 65 | $this->getFileMode(), |
| 64 | 66 | ); |
| 65 | - } else { |
|
| 67 | + } |
|
| 68 | + else |
|
| 69 | + { |
|
| 66 | 70 | $this->sprintf( |
| 67 | 71 | '<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>', |
| 68 | 72 | $this->getSource($files), |
@@ -99,7 +103,8 @@ discard block |
||
| 99 | 103 | |
| 100 | 104 | private function getSource(FilesInterface $files): ?string |
| 101 | 105 | { |
| 102 | - if (!$this->isDirectory()) { |
|
| 106 | + if (!$this->isDirectory()) |
|
| 107 | + { |
|
| 103 | 108 | return $files->normalizePath($this->argument('source')); |
| 104 | 109 | } |
| 105 | 110 | |
@@ -109,7 +114,8 @@ discard block |
||
| 109 | 114 | private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string |
| 110 | 115 | { |
| 111 | 116 | $target = $this->argument('target'); |
| 112 | - foreach ($directories->getAll() as $alias => $value) { |
|
| 117 | + foreach ($directories->getAll() as $alias => $value) |
|
| 118 | + { |
|
| 113 | 119 | $target = \str_replace(\sprintf('@%s', $alias), $value, $target); |
| 114 | 120 | } |
| 115 | 121 | |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | $this->sprintf("<info>New encryption key:</info> <fg=cyan>%s</fg=cyan>\n", $key); |
| 41 | 41 | |
| 42 | 42 | $file = $this->option('mount'); |
| 43 | - if ($file === null) { |
|
| 43 | + if ($file === null){ |
|
| 44 | 44 | return self::SUCCESS; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if (!$confirmation->confirmToProceed()) { |
|
| 47 | + if (!$confirmation->confirmToProceed()){ |
|
| 48 | 48 | return self::FAILURE; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if (!$files->exists($file)) { |
|
| 51 | + if (!$files->exists($file)){ |
|
| 52 | 52 | $this->error(\sprintf('Unable to find `%s`.', $file)); |
| 53 | 53 | |
| 54 | 54 | return self::FAILURE; |
@@ -56,10 +56,10 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $content = $files->read($file); |
| 58 | 58 | |
| 59 | - try { |
|
| 59 | + try{ |
|
| 60 | 60 | $content = \str_replace($this->option('placeholder'), $key, $content); |
| 61 | 61 | $content = \str_replace($enc->getKey(), $key, $content); |
| 62 | - } catch (\Throwable) { |
|
| 62 | + }catch (\Throwable){ |
|
| 63 | 63 | // current keys is not set |
| 64 | 64 | } |
| 65 | 65 | |
@@ -40,15 +40,18 @@ discard block |
||
| 40 | 40 | $this->sprintf("<info>New encryption key:</info> <fg=cyan>%s</fg=cyan>\n", $key); |
| 41 | 41 | |
| 42 | 42 | $file = $this->option('mount'); |
| 43 | - if ($file === null) { |
|
| 43 | + if ($file === null) |
|
| 44 | + { |
|
| 44 | 45 | return self::SUCCESS; |
| 45 | 46 | } |
| 46 | 47 | |
| 47 | - if (!$confirmation->confirmToProceed()) { |
|
| 48 | + if (!$confirmation->confirmToProceed()) |
|
| 49 | + { |
|
| 48 | 50 | return self::FAILURE; |
| 49 | 51 | } |
| 50 | 52 | |
| 51 | - if (!$files->exists($file)) { |
|
| 53 | + if (!$files->exists($file)) |
|
| 54 | + { |
|
| 52 | 55 | $this->error(\sprintf('Unable to find `%s`.', $file)); |
| 53 | 56 | |
| 54 | 57 | return self::FAILURE; |
@@ -56,10 +59,13 @@ discard block |
||
| 56 | 59 | |
| 57 | 60 | $content = $files->read($file); |
| 58 | 61 | |
| 59 | - try { |
|
| 62 | + try |
|
| 63 | + { |
|
| 60 | 64 | $content = \str_replace($this->option('placeholder'), $key, $content); |
| 61 | 65 | $content = \str_replace($enc->getKey(), $key, $content); |
| 62 | - } catch (\Throwable) { |
|
| 66 | + } |
|
| 67 | + catch (\Throwable) |
|
| 68 | + { |
|
| 63 | 69 | // current keys is not set |
| 64 | 70 | } |
| 65 | 71 | |
@@ -36,7 +36,8 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function appBooting(\Closure ...$callbacks): void |
| 38 | 38 | { |
| 39 | - foreach ($callbacks as $callback) { |
|
| 39 | + foreach ($callbacks as $callback) |
|
| 40 | + { |
|
| 40 | 41 | $this->bootingCallbacks[] = $callback; |
| 41 | 42 | } |
| 42 | 43 | } |
@@ -51,7 +52,8 @@ discard block |
||
| 51 | 52 | */ |
| 52 | 53 | public function appBooted(\Closure ...$callbacks): void |
| 53 | 54 | { |
| 54 | - foreach ($callbacks as $callback) { |
|
| 55 | + foreach ($callbacks as $callback) |
|
| 56 | + { |
|
| 55 | 57 | $this->bootedCallbacks[] = $callback; |
| 56 | 58 | } |
| 57 | 59 | } |
@@ -89,11 +91,13 @@ discard block |
||
| 89 | 91 | */ |
| 90 | 92 | protected function mapDirectories(array $directories): array |
| 91 | 93 | { |
| 92 | - if (!isset($directories['root'])) { |
|
| 94 | + if (!isset($directories['root'])) |
|
| 95 | + { |
|
| 93 | 96 | throw new BootException('Missing required directory `root`'); |
| 94 | 97 | } |
| 95 | 98 | |
| 96 | - if (!isset($directories['app'])) { |
|
| 99 | + if (!isset($directories['app'])) |
|
| 100 | + { |
|
| 97 | 101 | $directories['app'] = $directories['root'] . '/app/'; |
| 98 | 102 | } |
| 99 | 103 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function appBooting(\Closure ...$callbacks): void |
| 46 | 46 | { |
| 47 | - foreach ($callbacks as $callback) { |
|
| 47 | + foreach ($callbacks as $callback){ |
|
| 48 | 48 | $this->bootingCallbacks[] = $callback; |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function appBooted(\Closure ...$callbacks): void |
| 61 | 61 | { |
| 62 | - foreach ($callbacks as $callback) { |
|
| 62 | + foreach ($callbacks as $callback){ |
|
| 63 | 63 | $this->bootedCallbacks[] = $callback; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -99,29 +99,29 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | protected function mapDirectories(array $directories): array |
| 101 | 101 | { |
| 102 | - if (!isset($directories['root'])) { |
|
| 102 | + if (!isset($directories['root'])){ |
|
| 103 | 103 | throw new BootException('Missing required directory `root`'); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if (!isset($directories['app'])) { |
|
| 107 | - $directories['app'] = $directories['root'] . '/app/'; |
|
| 106 | + if (!isset($directories['app'])){ |
|
| 107 | + $directories['app'] = $directories['root'].'/app/'; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | return \array_merge( |
| 111 | 111 | [ |
| 112 | 112 | // public root |
| 113 | - 'public' => $directories['root'] . '/public/', |
|
| 113 | + 'public' => $directories['root'].'/public/', |
|
| 114 | 114 | |
| 115 | 115 | // vendor libraries |
| 116 | - 'vendor' => $directories['root'] . '/vendor/', |
|
| 116 | + 'vendor' => $directories['root'].'/vendor/', |
|
| 117 | 117 | |
| 118 | 118 | // data directories |
| 119 | - 'runtime' => $directories['root'] . '/runtime/', |
|
| 120 | - 'cache' => $directories['root'] . '/runtime/cache/', |
|
| 119 | + 'runtime' => $directories['root'].'/runtime/', |
|
| 120 | + 'cache' => $directories['root'].'/runtime/cache/', |
|
| 121 | 121 | |
| 122 | 122 | // application directories |
| 123 | - 'config' => $directories['app'] . '/config/', |
|
| 124 | - 'resources' => $directories['app'] . '/resources/', |
|
| 123 | + 'config' => $directories['app'].'/config/', |
|
| 124 | + 'resources' => $directories['app'].'/resources/', |
|
| 125 | 125 | ], |
| 126 | 126 | $directories, |
| 127 | 127 | ); |
@@ -23,11 +23,11 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | public function __construct(?int $code = null, string $message = '', ?\Throwable $previous = null) |
| 25 | 25 | { |
| 26 | - if (empty($code) && empty($this->code)) { |
|
| 26 | + if (empty($code) && empty($this->code)){ |
|
| 27 | 27 | $code = self::BAD_DATA; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - if (empty($message)) { |
|
| 30 | + if (empty($message)){ |
|
| 31 | 31 | $message = \sprintf('Http Error - %s', $code); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -23,11 +23,13 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | public function __construct(?int $code = null, string $message = '', ?\Throwable $previous = null) |
| 25 | 25 | { |
| 26 | - if (empty($code) && empty($this->code)) { |
|
| 26 | + if (empty($code) && empty($this->code)) |
|
| 27 | + { |
|
| 27 | 28 | $code = self::BAD_DATA; |
| 28 | 29 | } |
| 29 | 30 | |
| 30 | - if (empty($message)) { |
|
| 31 | + if (empty($message)) |
|
| 32 | + { |
|
| 31 | 33 | $message = \sprintf('Http Error - %s', $code); |
| 32 | 34 | } |
| 33 | 35 | |
@@ -16,11 +16,11 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | private function writeJson(ResponseInterface $response, mixed $payload, int $code = 200): ResponseInterface |
| 18 | 18 | { |
| 19 | - if ($payload instanceof \JsonSerializable) { |
|
| 19 | + if ($payload instanceof \JsonSerializable){ |
|
| 20 | 20 | $payload = $payload->jsonSerialize(); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])) { |
|
| 23 | + if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])){ |
|
| 24 | 24 | $code = $payload['status']; |
| 25 | 25 | } |
| 26 | 26 | |
@@ -16,11 +16,13 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | private function writeJson(ResponseInterface $response, mixed $payload, int $code = 200): ResponseInterface |
| 18 | 18 | { |
| 19 | - if ($payload instanceof \JsonSerializable) { |
|
| 19 | + if ($payload instanceof \JsonSerializable) |
|
| 20 | + { |
|
| 20 | 21 | $payload = $payload->jsonSerialize(); |
| 21 | 22 | } |
| 22 | 23 | |
| 23 | - if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])) { |
|
| 24 | + if (\is_array($payload) && isset($payload['status']) && \is_int($payload['status'])) |
|
| 25 | + { |
|
| 24 | 26 | $code = $payload['status']; |
| 25 | 27 | } |
| 26 | 28 | |