@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | use Spiral\Debug\Dumper; |
| 11 | 11 | |
| 12 | -if (!function_exists('bind')) { |
|
| 12 | +if (!function_exists('bind')){ |
|
| 13 | 13 | /** |
| 14 | 14 | * Shortcut to container Autowire definition. |
| 15 | 15 | * |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | -if (!function_exists('dumprr')) { |
|
| 30 | +if (!function_exists('dumprr')){ |
|
| 31 | 31 | /** |
| 32 | 32 | * Dumprr is similar to Dump function but always redirect output to STDERR. |
| 33 | 33 | * |
@@ -9,7 +9,8 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | use Spiral\Debug\Dumper; |
| 11 | 11 | |
| 12 | -if (!function_exists('bind')) { |
|
| 12 | +if (!function_exists('bind')) |
|
| 13 | +{ |
|
| 13 | 14 | /** |
| 14 | 15 | * Shortcut to container Autowire definition. |
| 15 | 16 | * |
@@ -27,7 +28,8 @@ discard block |
||
| 27 | 28 | } |
| 28 | 29 | } |
| 29 | 30 | |
| 30 | -if (!function_exists('dumprr')) { |
|
| 31 | +if (!function_exists('dumprr')) |
|
| 32 | +{ |
|
| 31 | 33 | /** |
| 32 | 34 | * Dumprr is similar to Dump function but always redirect output to STDERR. |
| 33 | 35 | * |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | SchemaBootloader $bootloader, |
| 32 | 32 | Registry $registry, |
| 33 | 33 | MemoryInterface $memory |
| 34 | - ) { |
|
| 34 | + ){ |
|
| 35 | 35 | $show = new ShowChanges($this->output); |
| 36 | 36 | |
| 37 | 37 | $schema = (new Compiler())->compile( |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | $memory->saveData('cycle', $schema); |
| 43 | 43 | |
| 44 | - if ($show->hasChanges()) { |
|
| 44 | + if ($show->hasChanges()){ |
|
| 45 | 45 | $this->writeln("\n<info>ORM Schema has been synchronized</info>"); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -41,7 +41,8 @@ |
||
| 41 | 41 | |
| 42 | 42 | $memory->saveData('cycle', $schema); |
| 43 | 43 | |
| 44 | - if ($show->hasChanges()) { |
|
| 44 | + if ($show->hasChanges()) |
|
| 45 | + { |
|
| 45 | 46 | $this->writeln("\n<info>ORM Schema has been synchronized</info>"); |
| 46 | 47 | } |
| 47 | 48 | |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | string $clientFilename = null, |
| 27 | 27 | string $clientMediaType = null |
| 28 | 28 | ): UploadedFileInterface { |
| 29 | - if ($size === null) { |
|
| 29 | + if ($size === null){ |
|
| 30 | 30 | $size = $stream->getSize(); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -26,7 +26,8 @@ |
||
| 26 | 26 | string $clientFilename = null, |
| 27 | 27 | string $clientMediaType = null |
| 28 | 28 | ): UploadedFileInterface { |
| 29 | - if ($size === null) { |
|
| 29 | + if ($size === null) |
|
| 30 | + { |
|
| 30 | 31 | $size = $stream->getSize(); |
| 31 | 32 | } |
| 32 | 33 | |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | $http = $this->container->get(Http::class); |
| 58 | 58 | $emitter = $emitter ?? $this->container->get(EmitterInterface::class); |
| 59 | 59 | |
| 60 | - try { |
|
| 60 | + try{ |
|
| 61 | 61 | $response = $http->handle($this->initRequest()); |
| 62 | 62 | $emitter->emit($response); |
| 63 | - } catch (\Throwable $e) { |
|
| 63 | + }catch (\Throwable $e){ |
|
| 64 | 64 | $this->handleException($emitter, $e); |
| 65 | - } finally { |
|
| 65 | + }finally{ |
|
| 66 | 66 | $this->finalizer->finalize(false); |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -83,10 +83,10 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
| 85 | 85 | |
| 86 | - try { |
|
| 86 | + try{ |
|
| 87 | 87 | /** @var SnapshotInterface $snapshot */ |
| 88 | 88 | $this->container->get(SnapshotterInterface::class)->register($e); |
| 89 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 89 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
| 90 | 90 | // nothing to report |
| 91 | 91 | } |
| 92 | 92 | |
@@ -57,12 +57,17 @@ discard block |
||
| 57 | 57 | $http = $this->container->get(Http::class); |
| 58 | 58 | $emitter = $emitter ?? $this->container->get(EmitterInterface::class); |
| 59 | 59 | |
| 60 | - try { |
|
| 60 | + try |
|
| 61 | + { |
|
| 61 | 62 | $response = $http->handle($this->initRequest()); |
| 62 | 63 | $emitter->emit($response); |
| 63 | - } catch (\Throwable $e) { |
|
| 64 | + } |
|
| 65 | + catch (\Throwable $e) |
|
| 66 | + { |
|
| 64 | 67 | $this->handleException($emitter, $e); |
| 65 | - } finally { |
|
| 68 | + } |
|
| 69 | + finally |
|
| 70 | + { |
|
| 66 | 71 | $this->finalizer->finalize(false); |
| 67 | 72 | } |
| 68 | 73 | } |
@@ -83,10 +88,13 @@ discard block |
||
| 83 | 88 | { |
| 84 | 89 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
| 85 | 90 | |
| 86 | - try { |
|
| 91 | + try |
|
| 92 | + { |
|
| 87 | 93 | /** @var SnapshotInterface $snapshot */ |
| 88 | 94 | $this->container->get(SnapshotterInterface::class)->register($e); |
| 89 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 95 | + } |
|
| 96 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
| 97 | + { |
|
| 90 | 98 | // nothing to report |
| 91 | 99 | } |
| 92 | 100 | |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | $response = new Response('php://memory', $code, []); |
| 38 | 38 | $response = $response->withStatus($code, $reasonPhrase); |
| 39 | 39 | |
| 40 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 40 | + foreach ($this->config->getBaseHeaders() as $header => $value){ |
|
| 41 | 41 | $response = $response->withAddedHeader($header, $value); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -37,7 +37,8 @@ |
||
| 37 | 37 | $response = new Response('php://memory', $code, []); |
| 38 | 38 | $response = $response->withStatus($code, $reasonPhrase); |
| 39 | 39 | |
| 40 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 40 | + foreach ($this->config->getBaseHeaders() as $header => $value) |
|
| 41 | + { |
|
| 41 | 42 | $response = $response->withAddedHeader($header, $value); |
| 42 | 43 | } |
| 43 | 44 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | FinalizerInterface $finalizer, |
| 47 | 47 | ContainerInterface $container, |
| 48 | 48 | FactoryInterface $factory |
| 49 | - ) { |
|
| 49 | + ){ |
|
| 50 | 50 | $this->env = $env; |
| 51 | 51 | $this->finalizer = $finalizer; |
| 52 | 52 | $this->container = $container; |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | /** @var Http $http */ |
| 72 | 72 | $http = $this->container->get(Http::class); |
| 73 | - while ($request = $client->acceptRequest()) { |
|
| 74 | - try { |
|
| 73 | + while ($request = $client->acceptRequest()){ |
|
| 74 | + try{ |
|
| 75 | 75 | $client->respond($http->handle($request)); |
| 76 | - } catch (\Throwable $e) { |
|
| 76 | + }catch (\Throwable $e){ |
|
| 77 | 77 | $this->handleException($client, $e); |
| 78 | - } finally { |
|
| 78 | + }finally{ |
|
| 79 | 79 | $this->finalizer->finalize(false); |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | { |
| 90 | 90 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
| 91 | 91 | |
| 92 | - try { |
|
| 92 | + try{ |
|
| 93 | 93 | /** @var SnapshotInterface $snapshot */ |
| 94 | 94 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
| 95 | 95 | error_log($snapshot->getMessage()); |
| 96 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 96 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
| 97 | 97 | error_log((string)$e); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -70,12 +70,18 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | /** @var Http $http */ |
| 72 | 72 | $http = $this->container->get(Http::class); |
| 73 | - while ($request = $client->acceptRequest()) { |
|
| 74 | - try { |
|
| 73 | + while ($request = $client->acceptRequest()) |
|
| 74 | + { |
|
| 75 | + try |
|
| 76 | + { |
|
| 75 | 77 | $client->respond($http->handle($request)); |
| 76 | - } catch (\Throwable $e) { |
|
| 78 | + } |
|
| 79 | + catch (\Throwable $e) |
|
| 80 | + { |
|
| 77 | 81 | $this->handleException($client, $e); |
| 78 | - } finally { |
|
| 82 | + } |
|
| 83 | + finally |
|
| 84 | + { |
|
| 79 | 85 | $this->finalizer->finalize(false); |
| 80 | 86 | } |
| 81 | 87 | } |
@@ -89,11 +95,14 @@ discard block |
||
| 89 | 95 | { |
| 90 | 96 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
| 91 | 97 | |
| 92 | - try { |
|
| 98 | + try |
|
| 99 | + { |
|
| 93 | 100 | /** @var SnapshotInterface $snapshot */ |
| 94 | 101 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
| 95 | 102 | error_log($snapshot->getMessage()); |
| 96 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 103 | + } |
|
| 104 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
| 105 | + { |
|
| 97 | 106 | error_log((string)$e); |
| 98 | 107 | } |
| 99 | 108 | |
@@ -50,13 +50,13 @@ |
||
| 50 | 50 | CookiesBootloader $cookies, |
| 51 | 51 | HttpBootloader $http, |
| 52 | 52 | DirectoriesInterface $directories |
| 53 | - ) { |
|
| 53 | + ){ |
|
| 54 | 54 | $config->setDefaults('session', [ |
| 55 | 55 | 'lifetime' => 86400, |
| 56 | 56 | 'cookie' => 'sid', |
| 57 | 57 | 'secure' => false, |
| 58 | 58 | 'handler' => new Autowire(FileHandler::class, [ |
| 59 | - 'directory' => $directories->get('runtime') . 'session', |
|
| 59 | + 'directory' => $directories->get('runtime').'session', |
|
| 60 | 60 | 'lifetime' => 86400 |
| 61 | 61 | ] |
| 62 | 62 | ) |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | |
| 67 | 67 | $kernel->addDispatcher($factory->make(SapiDispatcher::class)); |
| 68 | 68 | |
| 69 | - if (class_exists(PSR7Client::class)) { |
|
| 69 | + if (class_exists(PSR7Client::class)){ |
|
| 70 | 70 | $kernel->addDispatcher($factory->make(RrDispacher::class)); |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -66,7 +66,8 @@ |
||
| 66 | 66 | |
| 67 | 67 | $kernel->addDispatcher($factory->make(SapiDispatcher::class)); |
| 68 | 68 | |
| 69 | - if (class_exists(PSR7Client::class)) { |
|
| 69 | + if (class_exists(PSR7Client::class)) |
|
| 70 | + { |
|
| 70 | 71 | $kernel->addDispatcher($factory->make(RrDispacher::class)); |
| 71 | 72 | } |
| 72 | 73 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function boot(SchemaInterface $schema = null) |
| 76 | 76 | { |
| 77 | - if (!is_null($schema)) { |
|
| 77 | + if (!is_null($schema)){ |
|
| 78 | 78 | $this->bootRepositories($schema); |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function bootRepositories(SchemaInterface $schema) |
| 86 | 86 | { |
| 87 | - foreach ($schema->getRoles() as $role) { |
|
| 87 | + foreach ($schema->getRoles() as $role){ |
|
| 88 | 88 | $repository = $schema->define($role, Schema::REPOSITORY); |
| 89 | - if ($repository === Repository::class || $repository === null) { |
|
| 89 | + if ($repository === Repository::class || $repository === null){ |
|
| 90 | 90 | // default repository can not be wired |
| 91 | 91 | continue; |
| 92 | 92 | } |
@@ -125,11 +125,11 @@ discard block |
||
| 125 | 125 | public function getGenerators(): array |
| 126 | 126 | { |
| 127 | 127 | $result = []; |
| 128 | - foreach ($this->generators as $group) { |
|
| 129 | - foreach ($group as $generator) { |
|
| 130 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
| 128 | + foreach ($this->generators as $group){ |
|
| 129 | + foreach ($group as $generator){ |
|
| 130 | + if (is_object($generator) && !$generator instanceof Container\Autowire){ |
|
| 131 | 131 | $result[] = $generator; |
| 132 | - } else { |
|
| 132 | + }else{ |
|
| 133 | 133 | $result[] = $this->container->get($generator); |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | protected function schema(MemoryInterface $memory): ?SchemaInterface |
| 146 | 146 | { |
| 147 | 147 | $schema = $memory->loadData('cycle'); |
| 148 | - if (is_null($schema)) { |
|
| 148 | + if (is_null($schema)){ |
|
| 149 | 149 | return null; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -74,7 +74,8 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function boot(SchemaInterface $schema = null) |
| 76 | 76 | { |
| 77 | - if (!is_null($schema)) { |
|
| 77 | + if (!is_null($schema)) |
|
| 78 | + { |
|
| 78 | 79 | $this->bootRepositories($schema); |
| 79 | 80 | } |
| 80 | 81 | } |
@@ -84,9 +85,11 @@ discard block |
||
| 84 | 85 | */ |
| 85 | 86 | public function bootRepositories(SchemaInterface $schema) |
| 86 | 87 | { |
| 87 | - foreach ($schema->getRoles() as $role) { |
|
| 88 | + foreach ($schema->getRoles() as $role) |
|
| 89 | + { |
|
| 88 | 90 | $repository = $schema->define($role, Schema::REPOSITORY); |
| 89 | - if ($repository === Repository::class || $repository === null) { |
|
| 91 | + if ($repository === Repository::class || $repository === null) |
|
| 92 | + { |
|
| 90 | 93 | // default repository can not be wired |
| 91 | 94 | continue; |
| 92 | 95 | } |
@@ -125,11 +128,16 @@ discard block |
||
| 125 | 128 | public function getGenerators(): array |
| 126 | 129 | { |
| 127 | 130 | $result = []; |
| 128 | - foreach ($this->generators as $group) { |
|
| 129 | - foreach ($group as $generator) { |
|
| 130 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
| 131 | + foreach ($this->generators as $group) |
|
| 132 | + { |
|
| 133 | + foreach ($group as $generator) |
|
| 134 | + { |
|
| 135 | + if (is_object($generator) && !$generator instanceof Container\Autowire) |
|
| 136 | + { |
|
| 131 | 137 | $result[] = $generator; |
| 132 | - } else { |
|
| 138 | + } |
|
| 139 | + else |
|
| 140 | + { |
|
| 133 | 141 | $result[] = $this->container->get($generator); |
| 134 | 142 | } |
| 135 | 143 | } |
@@ -145,7 +153,8 @@ discard block |
||
| 145 | 153 | protected function schema(MemoryInterface $memory): ?SchemaInterface |
| 146 | 154 | { |
| 147 | 155 | $schema = $memory->loadData('cycle'); |
| 148 | - if (is_null($schema)) { |
|
| 156 | + if (is_null($schema)) |
|
| 157 | + { |
|
| 149 | 158 | return null; |
| 150 | 159 | } |
| 151 | 160 | |