@@ -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(); |
| 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(); |
| 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 | |
@@ -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(); |
| 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(); |
| 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 | |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | CycleBootloader $cycleBootloader, |
| 36 | 36 | Registry $registry, |
| 37 | 37 | MemoryInterface $memory |
| 38 | - ) { |
|
| 38 | + ){ |
|
| 39 | 39 | $this->write("Updating ORM schema... "); |
| 40 | 40 | |
| 41 | 41 | $schema = (new Compiler())->compile($registry, $bootloader->getGenerators()); |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | public function getGenerators(): array |
| 90 | 90 | { |
| 91 | 91 | $result = []; |
| 92 | - foreach ($this->generators as $group) { |
|
| 93 | - foreach ($group as $generator) { |
|
| 94 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
| 92 | + foreach ($this->generators as $group){ |
|
| 93 | + foreach ($group as $generator){ |
|
| 94 | + if (is_object($generator) && !$generator instanceof Container\Autowire){ |
|
| 95 | 95 | $result[] = $generator; |
| 96 | - } else { |
|
| 96 | + }else{ |
|
| 97 | 97 | $result[] = $this->container->get($generator); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | protected function schema(MemoryInterface $memory): ?SchemaInterface |
| 110 | 110 | { |
| 111 | 111 | $schema = $memory->loadData('cycle'); |
| 112 | - if (is_null($schema)) { |
|
| 112 | + if (is_null($schema)){ |
|
| 113 | 113 | return null; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -89,11 +89,16 @@ discard block |
||
| 89 | 89 | public function getGenerators(): array |
| 90 | 90 | { |
| 91 | 91 | $result = []; |
| 92 | - foreach ($this->generators as $group) { |
|
| 93 | - foreach ($group as $generator) { |
|
| 94 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
| 92 | + foreach ($this->generators as $group) |
|
| 93 | + { |
|
| 94 | + foreach ($group as $generator) |
|
| 95 | + { |
|
| 96 | + if (is_object($generator) && !$generator instanceof Container\Autowire) |
|
| 97 | + { |
|
| 95 | 98 | $result[] = $generator; |
| 96 | - } else { |
|
| 99 | + } |
|
| 100 | + else |
|
| 101 | + { |
|
| 97 | 102 | $result[] = $this->container->get($generator); |
| 98 | 103 | } |
| 99 | 104 | } |
@@ -109,7 +114,8 @@ discard block |
||
| 109 | 114 | protected function schema(MemoryInterface $memory): ?SchemaInterface |
| 110 | 115 | { |
| 111 | 116 | $schema = $memory->loadData('cycle'); |
| 112 | - if (is_null($schema)) { |
|
| 117 | + if (is_null($schema)) |
|
| 118 | + { |
|
| 113 | 119 | return null; |
| 114 | 120 | } |
| 115 | 121 | |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | public function boot(Container $container, FinalizerInterface $finalizer, SchemaInterface $schema = null) |
| 47 | 47 | { |
| 48 | 48 | $finalizer->addFinalizer(function () use ($container) { |
| 49 | - if ($container->hasInstance(ORMInterface::class)) { |
|
| 49 | + if ($container->hasInstance(ORMInterface::class)){ |
|
| 50 | 50 | $container->get(ORMInterface::class)->getHeap()->clean(); |
| 51 | 51 | } |
| 52 | 52 | }); |
| 53 | 53 | |
| 54 | 54 | $container->bindInjector(Select::class, SelectInjector::class); |
| 55 | 55 | |
| 56 | - if ($schema !== null) { |
|
| 56 | + if ($schema !== null){ |
|
| 57 | 57 | $this->bindRepositories($container, $schema); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function bindRepositories(Container $container, SchemaInterface $schema) |
| 68 | 68 | { |
| 69 | - foreach ($schema->getRoles() as $role) { |
|
| 69 | + foreach ($schema->getRoles() as $role){ |
|
| 70 | 70 | $repository = $schema->define($role, SchemaInterface::REPOSITORY); |
| 71 | - if ($repository === Select\Repository::class || $repository === null) { |
|
| 71 | + if ($repository === Select\Repository::class || $repository === null){ |
|
| 72 | 72 | // default repository can not be wired |
| 73 | 73 | continue; |
| 74 | 74 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | ): ORMInterface { |
| 105 | 105 | $orm = new ORM($factory, $schema); |
| 106 | 106 | |
| 107 | - if ($promiseFactory !== null) { |
|
| 107 | + if ($promiseFactory !== null){ |
|
| 108 | 108 | return $orm->withPromiseFactory($promiseFactory); |
| 109 | 109 | } |
| 110 | 110 | |
@@ -45,15 +45,18 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function boot(Container $container, FinalizerInterface $finalizer, SchemaInterface $schema = null) |
| 47 | 47 | { |
| 48 | - $finalizer->addFinalizer(function () use ($container) { |
|
| 49 | - if ($container->hasInstance(ORMInterface::class)) { |
|
| 48 | + $finalizer->addFinalizer(function () use ($container) |
|
| 49 | + { |
|
| 50 | + if ($container->hasInstance(ORMInterface::class)) |
|
| 51 | + { |
|
| 50 | 52 | $container->get(ORMInterface::class)->getHeap()->clean(); |
| 51 | 53 | } |
| 52 | 54 | }); |
| 53 | 55 | |
| 54 | 56 | $container->bindInjector(Select::class, SelectInjector::class); |
| 55 | 57 | |
| 56 | - if ($schema !== null) { |
|
| 58 | + if ($schema !== null) |
|
| 59 | + { |
|
| 57 | 60 | $this->bindRepositories($container, $schema); |
| 58 | 61 | } |
| 59 | 62 | } |
@@ -66,15 +69,18 @@ discard block |
||
| 66 | 69 | */ |
| 67 | 70 | public function bindRepositories(Container $container, SchemaInterface $schema) |
| 68 | 71 | { |
| 69 | - foreach ($schema->getRoles() as $role) { |
|
| 72 | + foreach ($schema->getRoles() as $role) |
|
| 73 | + { |
|
| 70 | 74 | $repository = $schema->define($role, SchemaInterface::REPOSITORY); |
| 71 | - if ($repository === Select\Repository::class || $repository === null) { |
|
| 75 | + if ($repository === Select\Repository::class || $repository === null) |
|
| 76 | + { |
|
| 72 | 77 | // default repository can not be wired |
| 73 | 78 | continue; |
| 74 | 79 | } |
| 75 | 80 | |
| 76 | 81 | // initiate all repository dependencies using factory method forwarded to ORM |
| 77 | - $container->bindSingleton($repository, function (ORMInterface $orm) use ($role) { |
|
| 82 | + $container->bindSingleton($repository, function (ORMInterface $orm) use ($role) |
|
| 83 | + { |
|
| 78 | 84 | return $orm->getRepository($role); |
| 79 | 85 | }); |
| 80 | 86 | } |
@@ -104,7 +110,8 @@ discard block |
||
| 104 | 110 | ): ORMInterface { |
| 105 | 111 | $orm = new ORM($factory, $schema); |
| 106 | 112 | |
| 107 | - if ($promiseFactory !== null) { |
|
| 113 | + if ($promiseFactory !== null) |
|
| 114 | + { |
|
| 108 | 115 | return $orm->withPromiseFactory($promiseFactory); |
| 109 | 116 | } |
| 110 | 117 | |
@@ -41,9 +41,9 @@ |
||
| 41 | 41 | EnvironmentInterface $env, |
| 42 | 42 | DirectoriesInterface $dirs, |
| 43 | 43 | FilesInterface $files |
| 44 | - ) { |
|
| 44 | + ){ |
|
| 45 | 45 | return new FileSnapshotter( |
| 46 | - $dirs->get('runtime') . '/snapshots/', |
|
| 46 | + $dirs->get('runtime').'/snapshots/', |
|
| 47 | 47 | $env->get('SNAPSHOT_MAX_FILES', self::MAX_SNAPSHOTS), |
| 48 | 48 | $env->get('SNAPSHOT_VERBOSITY', HandlerInterface::VERBOSITY_VERBOSE), |
| 49 | 49 | new HtmlHandler(), |
@@ -50,7 +50,7 @@ discard block |
||
| 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', |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | 'handler' => new Autowire( |
| 59 | 59 | FileHandler::class, |
| 60 | 60 | [ |
| 61 | - 'directory' => $directories->get('runtime') . 'session', |
|
| 61 | + 'directory' => $directories->get('runtime').'session', |
|
| 62 | 62 | 'lifetime' => 86400 |
| 63 | 63 | ] |
| 64 | 64 | ) |
@@ -26,20 +26,20 @@ discard block |
||
| 26 | 26 | public function perform(FilesInterface $files, DirectoriesInterface $directories) |
| 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) |
| 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) |
@@ -27,20 +27,20 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function perform(ViewsConfig $config, FilesInterface $files) |
| 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) |
| 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()) |