@@ -40,21 +40,21 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $conn = $env->get('RR_RPC', static::RPC_DEFAULT); |
| 42 | 42 | |
| 43 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
| 43 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)){ |
|
| 44 | 44 | throw new BootException( |
| 45 | 45 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
| 46 | 46 | ); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
| 49 | + if (!in_array($parts[1], ['tcp', 'unix'])){ |
|
| 50 | 50 | throw new BootException( |
| 51 | 51 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
| 52 | 52 | ); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ($parts[1] == 'unix') { |
|
| 55 | + if ($parts[1] == 'unix'){ |
|
| 56 | 56 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
| 57 | - } else { |
|
| 57 | + }else{ |
|
| 58 | 58 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -69,25 +69,25 @@ discard block |
||
| 69 | 69 | { |
| 70 | 70 | $conn = $env->get('RR_RELAY', static::WORKER_DEFAULT); |
| 71 | 71 | |
| 72 | - if ($conn === 'pipes' || empty($conn)) { |
|
| 72 | + if ($conn === 'pipes' || empty($conn)){ |
|
| 73 | 73 | return new Worker(new StreamRelay(STDIN, STDOUT)); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
| 76 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)){ |
|
| 77 | 77 | throw new BootException( |
| 78 | 78 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
| 79 | 79 | ); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
| 82 | + if (!in_array($parts[1], ['tcp', 'unix'])){ |
|
| 83 | 83 | throw new BootException( |
| 84 | 84 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
| 85 | 85 | ); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if ($parts[1] == 'unix') { |
|
| 88 | + if ($parts[1] == 'unix'){ |
|
| 89 | 89 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
| 90 | - } else { |
|
| 90 | + }else{ |
|
| 91 | 91 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -40,21 +40,26 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $conn = $env->get('RR_RPC', static::RPC_DEFAULT); |
| 42 | 42 | |
| 43 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
| 43 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) |
|
| 44 | + { |
|
| 44 | 45 | throw new BootException( |
| 45 | 46 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
| 46 | 47 | ); |
| 47 | 48 | } |
| 48 | 49 | |
| 49 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
| 50 | + if (!in_array($parts[1], ['tcp', 'unix'])) |
|
| 51 | + { |
|
| 50 | 52 | throw new BootException( |
| 51 | 53 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
| 52 | 54 | ); |
| 53 | 55 | } |
| 54 | 56 | |
| 55 | - if ($parts[1] == 'unix') { |
|
| 57 | + if ($parts[1] == 'unix') |
|
| 58 | + { |
|
| 56 | 59 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
| 57 | - } else { |
|
| 60 | + } |
|
| 61 | + else |
|
| 62 | + { |
|
| 58 | 63 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
| 59 | 64 | } |
| 60 | 65 | |
@@ -69,25 +74,31 @@ discard block |
||
| 69 | 74 | { |
| 70 | 75 | $conn = $env->get('RR_RELAY', static::WORKER_DEFAULT); |
| 71 | 76 | |
| 72 | - if ($conn === 'pipes' || empty($conn)) { |
|
| 77 | + if ($conn === 'pipes' || empty($conn)) |
|
| 78 | + { |
|
| 73 | 79 | return new Worker(new StreamRelay(STDIN, STDOUT)); |
| 74 | 80 | } |
| 75 | 81 | |
| 76 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
| 82 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) |
|
| 83 | + { |
|
| 77 | 84 | throw new BootException( |
| 78 | 85 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
| 79 | 86 | ); |
| 80 | 87 | } |
| 81 | 88 | |
| 82 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
| 89 | + if (!in_array($parts[1], ['tcp', 'unix'])) |
|
| 90 | + { |
|
| 83 | 91 | throw new BootException( |
| 84 | 92 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
| 85 | 93 | ); |
| 86 | 94 | } |
| 87 | 95 | |
| 88 | - if ($parts[1] == 'unix') { |
|
| 96 | + if ($parts[1] == 'unix') |
|
| 97 | + { |
|
| 89 | 98 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
| 90 | - } else { |
|
| 99 | + } |
|
| 100 | + else |
|
| 101 | + { |
|
| 91 | 102 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
| 92 | 103 | } |
| 93 | 104 | |
@@ -78,35 +78,35 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | private function configureExtensions(ConsoleBootloader $console, Container $container): void |
| 80 | 80 | { |
| 81 | - if ($container->has(DatabaseProviderInterface::class)) { |
|
| 81 | + if ($container->has(DatabaseProviderInterface::class)){ |
|
| 82 | 82 | $this->configureDatabase($console); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if ($container->has(ORMInterface::class)) { |
|
| 85 | + if ($container->has(ORMInterface::class)){ |
|
| 86 | 86 | $this->configureCycle($console, $container); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if ($container->has(TranslatorInterface::class)) { |
|
| 89 | + if ($container->has(TranslatorInterface::class)){ |
|
| 90 | 90 | $this->configureTranslator($console); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if ($container->has(ViewsInterface::class)) { |
|
| 93 | + if ($container->has(ViewsInterface::class)){ |
|
| 94 | 94 | $this->configureViews($console); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if ($container->has(Migrator::class)) { |
|
| 97 | + if ($container->has(Migrator::class)){ |
|
| 98 | 98 | $this->configureMigrations($console); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if ($container->has(InvokerInterface::class)) { |
|
| 101 | + if ($container->has(InvokerInterface::class)){ |
|
| 102 | 102 | $this->configureGRPC($console); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ($container->has(EncryptionInterface::class)) { |
|
| 105 | + if ($container->has(EncryptionInterface::class)){ |
|
| 106 | 106 | $this->configureEncrypter($console); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if ($container->has(RouterInterface::class)) { |
|
| 109 | + if ($container->has(RouterInterface::class)){ |
|
| 110 | 110 | $console->addCommand(Router\ListCommand::class); |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | $console->addCommand(Cycle\SyncCommand::class); |
| 137 | 137 | |
| 138 | - if ($container->has(Migrator::class)) { |
|
| 138 | + if ($container->has(Migrator::class)){ |
|
| 139 | 139 | $console->addCommand(Cycle\MigrateCommand::class); |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -78,35 +78,43 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | private function configureExtensions(ConsoleBootloader $console, Container $container): void |
| 80 | 80 | { |
| 81 | - if ($container->has(DatabaseProviderInterface::class)) { |
|
| 81 | + if ($container->has(DatabaseProviderInterface::class)) |
|
| 82 | + { |
|
| 82 | 83 | $this->configureDatabase($console); |
| 83 | 84 | } |
| 84 | 85 | |
| 85 | - if ($container->has(ORMInterface::class)) { |
|
| 86 | + if ($container->has(ORMInterface::class)) |
|
| 87 | + { |
|
| 86 | 88 | $this->configureCycle($console, $container); |
| 87 | 89 | } |
| 88 | 90 | |
| 89 | - if ($container->has(TranslatorInterface::class)) { |
|
| 91 | + if ($container->has(TranslatorInterface::class)) |
|
| 92 | + { |
|
| 90 | 93 | $this->configureTranslator($console); |
| 91 | 94 | } |
| 92 | 95 | |
| 93 | - if ($container->has(ViewsInterface::class)) { |
|
| 96 | + if ($container->has(ViewsInterface::class)) |
|
| 97 | + { |
|
| 94 | 98 | $this->configureViews($console); |
| 95 | 99 | } |
| 96 | 100 | |
| 97 | - if ($container->has(Migrator::class)) { |
|
| 101 | + if ($container->has(Migrator::class)) |
|
| 102 | + { |
|
| 98 | 103 | $this->configureMigrations($console); |
| 99 | 104 | } |
| 100 | 105 | |
| 101 | - if ($container->has(InvokerInterface::class)) { |
|
| 106 | + if ($container->has(InvokerInterface::class)) |
|
| 107 | + { |
|
| 102 | 108 | $this->configureGRPC($console); |
| 103 | 109 | } |
| 104 | 110 | |
| 105 | - if ($container->has(EncryptionInterface::class)) { |
|
| 111 | + if ($container->has(EncryptionInterface::class)) |
|
| 112 | + { |
|
| 106 | 113 | $this->configureEncrypter($console); |
| 107 | 114 | } |
| 108 | 115 | |
| 109 | - if ($container->has(RouterInterface::class)) { |
|
| 116 | + if ($container->has(RouterInterface::class)) |
|
| 117 | + { |
|
| 110 | 118 | $console->addCommand(Router\ListCommand::class); |
| 111 | 119 | } |
| 112 | 120 | } |
@@ -135,7 +143,8 @@ discard block |
||
| 135 | 143 | |
| 136 | 144 | $console->addCommand(Cycle\SyncCommand::class); |
| 137 | 145 | |
| 138 | - if ($container->has(Migrator::class)) { |
|
| 146 | + if ($container->has(Migrator::class)) |
|
| 147 | + { |
|
| 139 | 148 | $console->addCommand(Cycle\MigrateCommand::class); |
| 140 | 149 | } |
| 141 | 150 | } |
@@ -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 | } |
@@ -42,8 +42,8 @@ |
||
| 42 | 42 | EnvironmentInterface $env, |
| 43 | 43 | DirectoriesInterface $dirs |
| 44 | 44 | ): void { |
| 45 | - if (!$dirs->has('migrations')) { |
|
| 46 | - $dirs->set('migrations', $dirs->get('app') . 'migrations'); |
|
| 45 | + if (!$dirs->has('migrations')){ |
|
| 46 | + $dirs->set('migrations', $dirs->get('app').'migrations'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $config->setDefaults( |
@@ -40,7 +40,8 @@ |
||
| 40 | 40 | EnvironmentInterface $env, |
| 41 | 41 | DirectoriesInterface $dirs |
| 42 | 42 | ): void { |
| 43 | - if (!$dirs->has('migrations')) { |
|
| 43 | + if (!$dirs->has('migrations')) |
|
| 44 | + { |
|
| 44 | 45 | $dirs->set('migrations', $dirs->get('app') . 'migrations'); |
| 45 | 46 | } |
| 46 | 47 | |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | public function getGenerators(): array |
| 86 | 86 | { |
| 87 | 87 | $result = []; |
| 88 | - foreach ($this->generators as $group) { |
|
| 89 | - foreach ($group as $generator) { |
|
| 90 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
| 88 | + foreach ($this->generators as $group){ |
|
| 89 | + foreach ($group as $generator){ |
|
| 90 | + if (is_object($generator) && !$generator instanceof Container\Autowire){ |
|
| 91 | 91 | $result[] = $generator; |
| 92 | - } else { |
|
| 92 | + }else{ |
|
| 93 | 93 | $result[] = $this->container->get($generator); |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | protected function schema(MemoryInterface $memory): SchemaInterface |
| 106 | 106 | { |
| 107 | 107 | $schema = $memory->loadData('cycle'); |
| 108 | - if (is_null($schema)) { |
|
| 108 | + if (is_null($schema)){ |
|
| 109 | 109 | $schema = (new Compiler())->compile( |
| 110 | 110 | $this->container->get(Registry::class), |
| 111 | 111 | $this->getGenerators() |
@@ -85,11 +85,16 @@ discard block |
||
| 85 | 85 | public function getGenerators(): array |
| 86 | 86 | { |
| 87 | 87 | $result = []; |
| 88 | - foreach ($this->generators as $group) { |
|
| 89 | - foreach ($group as $generator) { |
|
| 90 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
| 88 | + foreach ($this->generators as $group) |
|
| 89 | + { |
|
| 90 | + foreach ($group as $generator) |
|
| 91 | + { |
|
| 92 | + if (is_object($generator) && !$generator instanceof Container\Autowire) |
|
| 93 | + { |
|
| 91 | 94 | $result[] = $generator; |
| 92 | - } else { |
|
| 95 | + } |
|
| 96 | + else |
|
| 97 | + { |
|
| 93 | 98 | $result[] = $this->container->get($generator); |
| 94 | 99 | } |
| 95 | 100 | } |
@@ -105,7 +110,8 @@ discard block |
||
| 105 | 110 | protected function schema(MemoryInterface $memory): SchemaInterface |
| 106 | 111 | { |
| 107 | 112 | $schema = $memory->loadData('cycle'); |
| 108 | - if (is_null($schema)) { |
|
| 113 | + if (is_null($schema)) |
|
| 114 | + { |
|
| 109 | 115 | $schema = (new Compiler())->compile( |
| 110 | 116 | $this->container->get(Registry::class), |
| 111 | 117 | $this->getGenerators() |
@@ -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 | } |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | private function route(ServerRequestInterface $request): RouteInterface |
| 58 | 58 | { |
| 59 | 59 | $route = $request->getAttribute(Router::ROUTE_ATTRIBUTE, null); |
| 60 | - if ($route === null) { |
|
| 60 | + if ($route === null){ |
|
| 61 | 61 | throw new ScopeException('Unable to resolve Route, invalid request scope'); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -57,7 +57,8 @@ |
||
| 57 | 57 | private function route(ServerRequestInterface $request): RouteInterface |
| 58 | 58 | { |
| 59 | 59 | $route = $request->getAttribute(Router::ROUTE_ATTRIBUTE, null); |
| 60 | - if ($route === null) { |
|
| 60 | + if ($route === null) |
|
| 61 | + { |
|
| 61 | 62 | throw new ScopeException('Unable to resolve Route, invalid request scope'); |
| 62 | 63 | } |
| 63 | 64 | |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | |
| 75 | 75 | $kernel->addDispatcher($factory->make(SapiDispatcher::class)); |
| 76 | 76 | |
| 77 | - if (class_exists(PSR7Client::class)) { |
|
| 77 | + if (class_exists(PSR7Client::class)){ |
|
| 78 | 78 | $kernel->addDispatcher($factory->make(RrDispatcher::class)); |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -74,7 +74,8 @@ |
||
| 74 | 74 | |
| 75 | 75 | $kernel->addDispatcher($factory->make(SapiDispatcher::class)); |
| 76 | 76 | |
| 77 | - if (class_exists(PSR7Client::class)) { |
|
| 77 | + if (class_exists(PSR7Client::class)) |
|
| 78 | + { |
|
| 78 | 79 | $kernel->addDispatcher($factory->make(RrDispatcher::class)); |
| 79 | 80 | } |
| 80 | 81 | } |