@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | public function boot(Container $container, FinalizerInterface $finalizer) |
| 40 | 40 | { |
| 41 | 41 | $finalizer->addFinalizer(function () use ($container) { |
| 42 | - if ($container->hasInstance(ORMInterface::class)) { |
|
| 42 | + if ($container->hasInstance(ORMInterface::class)){ |
|
| 43 | 43 | $container->get(ORMInterface::class)->getHeap()->clean(); |
| 44 | 44 | } |
| 45 | 45 | }); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | ): ORMInterface { |
| 81 | 81 | $orm = new ORM($factory, $schema); |
| 82 | 82 | |
| 83 | - if ($promiseFactory !== null) { |
|
| 83 | + if ($promiseFactory !== null){ |
|
| 84 | 84 | return $orm->withPromiseFactory($promiseFactory); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -38,8 +38,10 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function boot(Container $container, FinalizerInterface $finalizer) |
| 40 | 40 | { |
| 41 | - $finalizer->addFinalizer(function () use ($container) { |
|
| 42 | - if ($container->hasInstance(ORMInterface::class)) { |
|
| 41 | + $finalizer->addFinalizer(function () use ($container) |
|
| 42 | + { |
|
| 43 | + if ($container->hasInstance(ORMInterface::class)) |
|
| 44 | + { |
|
| 43 | 45 | $container->get(ORMInterface::class)->getHeap()->clean(); |
| 44 | 46 | } |
| 45 | 47 | }); |
@@ -80,7 +82,8 @@ discard block |
||
| 80 | 82 | ): ORMInterface { |
| 81 | 83 | $orm = new ORM($factory, $schema); |
| 82 | 84 | |
| 83 | - if ($promiseFactory !== null) { |
|
| 85 | + if ($promiseFactory !== null) |
|
| 86 | + { |
|
| 84 | 87 | return $orm->withPromiseFactory($promiseFactory); |
| 85 | 88 | } |
| 86 | 89 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function boot(SchemaInterface $schema = null) |
| 80 | 80 | { |
| 81 | - if (!is_null($schema)) { |
|
| 81 | + if (!is_null($schema)){ |
|
| 82 | 82 | $this->bootRepositories($schema); |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function bootRepositories(SchemaInterface $schema) |
| 90 | 90 | { |
| 91 | - foreach ($schema->getRoles() as $role) { |
|
| 91 | + foreach ($schema->getRoles() as $role){ |
|
| 92 | 92 | $repository = $schema->define($role, Schema::REPOSITORY); |
| 93 | - if ($repository === Repository::class || $repository === null) { |
|
| 93 | + if ($repository === Repository::class || $repository === null){ |
|
| 94 | 94 | // default repository can not be wired |
| 95 | 95 | continue; |
| 96 | 96 | } |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | public function getGenerators(): array |
| 129 | 129 | { |
| 130 | 130 | $result = []; |
| 131 | - foreach ($this->generators as $generator) { |
|
| 132 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
| 131 | + foreach ($this->generators as $generator){ |
|
| 132 | + if (is_object($generator) && !$generator instanceof Container\Autowire){ |
|
| 133 | 133 | $result[] = $generator; |
| 134 | - } else { |
|
| 134 | + }else{ |
|
| 135 | 135 | $result[] = $this->container->get($generator); |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | protected function schema(MemoryInterface $memory): ?SchemaInterface |
| 147 | 147 | { |
| 148 | 148 | $schema = $memory->loadData('cycle'); |
| 149 | - if (is_null($schema)) { |
|
| 149 | + if (is_null($schema)){ |
|
| 150 | 150 | return null; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -78,7 +78,8 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function boot(SchemaInterface $schema = null) |
| 80 | 80 | { |
| 81 | - if (!is_null($schema)) { |
|
| 81 | + if (!is_null($schema)) |
|
| 82 | + { |
|
| 82 | 83 | $this->bootRepositories($schema); |
| 83 | 84 | } |
| 84 | 85 | } |
@@ -88,9 +89,11 @@ discard block |
||
| 88 | 89 | */ |
| 89 | 90 | public function bootRepositories(SchemaInterface $schema) |
| 90 | 91 | { |
| 91 | - foreach ($schema->getRoles() as $role) { |
|
| 92 | + foreach ($schema->getRoles() as $role) |
|
| 93 | + { |
|
| 92 | 94 | $repository = $schema->define($role, Schema::REPOSITORY); |
| 93 | - if ($repository === Repository::class || $repository === null) { |
|
| 95 | + if ($repository === Repository::class || $repository === null) |
|
| 96 | + { |
|
| 94 | 97 | // default repository can not be wired |
| 95 | 98 | continue; |
| 96 | 99 | } |
@@ -128,10 +131,14 @@ discard block |
||
| 128 | 131 | public function getGenerators(): array |
| 129 | 132 | { |
| 130 | 133 | $result = []; |
| 131 | - foreach ($this->generators as $generator) { |
|
| 132 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
| 134 | + foreach ($this->generators as $generator) |
|
| 135 | + { |
|
| 136 | + if (is_object($generator) && !$generator instanceof Container\Autowire) |
|
| 137 | + { |
|
| 133 | 138 | $result[] = $generator; |
| 134 | - } else { |
|
| 139 | + } |
|
| 140 | + else |
|
| 141 | + { |
|
| 135 | 142 | $result[] = $this->container->get($generator); |
| 136 | 143 | } |
| 137 | 144 | } |
@@ -146,7 +153,8 @@ discard block |
||
| 146 | 153 | protected function schema(MemoryInterface $memory): ?SchemaInterface |
| 147 | 154 | { |
| 148 | 155 | $schema = $memory->loadData('cycle'); |
| 149 | - if (is_null($schema)) { |
|
| 156 | + if (is_null($schema)) |
|
| 157 | + { |
|
| 150 | 158 | return null; |
| 151 | 159 | } |
| 152 | 160 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | string $header, |
| 94 | 94 | string $footer = '', |
| 95 | 95 | array $options = [] |
| 96 | - ) { |
|
| 96 | + ){ |
|
| 97 | 97 | $this->config->modify( |
| 98 | 98 | 'console', |
| 99 | 99 | $this->sequence('configure', $sequence, $header, $footer, $options) |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | string $header, |
| 112 | 112 | string $footer = '', |
| 113 | 113 | array $options = [] |
| 114 | - ) { |
|
| 114 | + ){ |
|
| 115 | 115 | $this->config->modify( |
| 116 | 116 | 'console', |
| 117 | 117 | $this->sequence('update', $sequence, $header, $footer, $options) |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | string $footer, |
| 134 | 134 | array $options |
| 135 | 135 | ): Append { |
| 136 | - if (is_array($sequence) || $sequence instanceof \Closure) { |
|
| 136 | + if (is_array($sequence) || $sequence instanceof \Closure){ |
|
| 137 | 137 | return new Append( |
| 138 | 138 | $target, |
| 139 | 139 | null, |
@@ -133,7 +133,8 @@ |
||
| 133 | 133 | string $footer, |
| 134 | 134 | array $options |
| 135 | 135 | ): Append { |
| 136 | - if (is_array($sequence) || $sequence instanceof \Closure) { |
|
| 136 | + if (is_array($sequence) || $sequence instanceof \Closure) |
|
| 137 | + { |
|
| 137 | 138 | return new Append( |
| 138 | 139 | $target, |
| 139 | 140 | null, |
@@ -37,13 +37,13 @@ |
||
| 37 | 37 | ConfiguratorInterface $config, |
| 38 | 38 | HttpBootloader $http, |
| 39 | 39 | DirectoriesInterface $directories |
| 40 | - ) { |
|
| 40 | + ){ |
|
| 41 | 41 | $config->setDefaults('session', [ |
| 42 | 42 | 'lifetime' => 86400, |
| 43 | 43 | 'cookie' => 'sid', |
| 44 | 44 | 'secure' => false, |
| 45 | 45 | 'handler' => new Autowire(FileHandler::class, [ |
| 46 | - 'directory' => $directories->get('runtime') . 'session', |
|
| 46 | + 'directory' => $directories->get('runtime').'session', |
|
| 47 | 47 | 'lifetime' => 86400 |
| 48 | 48 | ] |
| 49 | 49 | ) |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | { |
| 70 | 70 | $kernel->addDispatcher($factory->make(SapiDispatcher::class)); |
| 71 | 71 | |
| 72 | - if (class_exists(PSR7Client::class)) { |
|
| 72 | + if (class_exists(PSR7Client::class)){ |
|
| 73 | 73 | $kernel->addDispatcher($factory->make(RrDispacher::class)); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -69,7 +69,8 @@ |
||
| 69 | 69 | { |
| 70 | 70 | $kernel->addDispatcher($factory->make(SapiDispatcher::class)); |
| 71 | 71 | |
| 72 | - if (class_exists(PSR7Client::class)) { |
|
| 72 | + if (class_exists(PSR7Client::class)) |
|
| 73 | + { |
|
| 73 | 74 | $kernel->addDispatcher($factory->make(RrDispacher::class)); |
| 74 | 75 | } |
| 75 | 76 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | PermissionsInterface $permissions, |
| 41 | 41 | ContainerInterface $actorScope, |
| 42 | 42 | array $roles = [] |
| 43 | - ) { |
|
| 43 | + ){ |
|
| 44 | 44 | $this->roles = $roles; |
| 45 | 45 | $this->container = $actorScope; |
| 46 | 46 | $this->permissions = $permissions; |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | public function allows(string $permission, array $context = []): bool |
| 53 | 53 | { |
| 54 | 54 | $allows = false; |
| 55 | - foreach ($this->getRoles() as $role) { |
|
| 56 | - if (!$this->permissions->hasRole($role)) { |
|
| 55 | + foreach ($this->getRoles() as $role){ |
|
| 56 | + if (!$this->permissions->hasRole($role)){ |
|
| 57 | 57 | continue; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function getActor(): ActorInterface |
| 101 | 101 | { |
| 102 | - if (!is_null($this->actor)) { |
|
| 102 | + if (!is_null($this->actor)){ |
|
| 103 | 103 | return $this->actor; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - try { |
|
| 106 | + try{ |
|
| 107 | 107 | return $this->container->get(ActorInterface::class); |
| 108 | - } catch (ContainerException $e) { |
|
| 108 | + }catch (ContainerException $e){ |
|
| 109 | 109 | throw new ScopeException("Unable to resolve Actor from the scope", $e->getCode(), $e); |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -52,8 +52,10 @@ discard block |
||
| 52 | 52 | public function allows(string $permission, array $context = []): bool |
| 53 | 53 | { |
| 54 | 54 | $allows = false; |
| 55 | - foreach ($this->getRoles() as $role) { |
|
| 56 | - if (!$this->permissions->hasRole($role)) { |
|
| 55 | + foreach ($this->getRoles() as $role) |
|
| 56 | + { |
|
| 57 | + if (!$this->permissions->hasRole($role)) |
|
| 58 | + { |
|
| 57 | 59 | continue; |
| 58 | 60 | } |
| 59 | 61 | |
@@ -99,13 +101,17 @@ discard block |
||
| 99 | 101 | */ |
| 100 | 102 | public function getActor(): ActorInterface |
| 101 | 103 | { |
| 102 | - if (!is_null($this->actor)) { |
|
| 104 | + if (!is_null($this->actor)) |
|
| 105 | + { |
|
| 103 | 106 | return $this->actor; |
| 104 | 107 | } |
| 105 | 108 | |
| 106 | - try { |
|
| 109 | + try |
|
| 110 | + { |
|
| 107 | 111 | return $this->container->get(ActorInterface::class); |
| 108 | - } catch (ContainerException $e) { |
|
| 112 | + } |
|
| 113 | + catch (ContainerException $e) |
|
| 114 | + { |
|
| 109 | 115 | throw new ScopeException("Unable to resolve Actor from the scope", $e->getCode(), $e); |
| 110 | 116 | } |
| 111 | 117 | } |
@@ -39,28 +39,28 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | protected function mapDirectories(array $directories): array |
| 41 | 41 | { |
| 42 | - if (!isset($directories['root'])) { |
|
| 42 | + if (!isset($directories['root'])){ |
|
| 43 | 43 | throw new BootException("Missing required directory `root`."); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if (!isset($directories['app'])) { |
|
| 47 | - $directories['app'] = $directories['root'] . '/app/'; |
|
| 46 | + if (!isset($directories['app'])){ |
|
| 47 | + $directories['app'] = $directories['root'].'/app/'; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | return array_merge([ |
| 51 | 51 | // public root |
| 52 | - 'public' => $directories['root'] . '/public/', |
|
| 52 | + 'public' => $directories['root'].'/public/', |
|
| 53 | 53 | |
| 54 | 54 | // vendor libraries |
| 55 | - 'vendor' => $directories['root'] . '/vendor/', |
|
| 55 | + 'vendor' => $directories['root'].'/vendor/', |
|
| 56 | 56 | |
| 57 | 57 | // data directories |
| 58 | - 'runtime' => $directories['root'] . '/runtime/', |
|
| 59 | - 'cache' => $directories['root'] . '/runtime/cache/', |
|
| 58 | + 'runtime' => $directories['root'].'/runtime/', |
|
| 59 | + 'cache' => $directories['root'].'/runtime/cache/', |
|
| 60 | 60 | |
| 61 | 61 | // application directories |
| 62 | - 'config' => $directories['app'] . '/config/', |
|
| 63 | - 'resources' => $directories['app'] . '/resources/', |
|
| 62 | + 'config' => $directories['app'].'/config/', |
|
| 63 | + 'resources' => $directories['app'].'/resources/', |
|
| 64 | 64 | ], $directories); |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | \ No newline at end of file |
@@ -39,11 +39,13 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | protected function mapDirectories(array $directories): array |
| 41 | 41 | { |
| 42 | - if (!isset($directories['root'])) { |
|
| 42 | + if (!isset($directories['root'])) |
|
| 43 | + { |
|
| 43 | 44 | throw new BootException("Missing required directory `root`."); |
| 44 | 45 | } |
| 45 | 46 | |
| 46 | - if (!isset($directories['app'])) { |
|
| 47 | + if (!isset($directories['app'])) |
|
| 48 | + { |
|
| 47 | 49 | $directories['app'] = $directories['root'] . '/app/'; |
| 48 | 50 | } |
| 49 | 51 | |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | public function createInjection(\ReflectionClass $class, string $context = null) |
| 36 | 36 | { |
| 37 | - if (!$this->orm->getSchema()->defines($context)) { |
|
| 37 | + if (!$this->orm->getSchema()->defines($context)){ |
|
| 38 | 38 | throw new ORMException("Cycle schema is not initiated or role missing, run `cycle`."); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -34,7 +34,8 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | public function createInjection(\ReflectionClass $class, string $context = null) |
| 36 | 36 | { |
| 37 | - if (!$this->orm->getSchema()->defines($context)) { |
|
| 37 | + if (!$this->orm->getSchema()->defines($context)) |
|
| 38 | + { |
|
| 38 | 39 | throw new ORMException("Cycle schema is not initiated or role missing, run `cycle`."); |
| 39 | 40 | } |
| 40 | 41 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | int $verbosity, |
| 49 | 49 | HandlerInterface $handler, |
| 50 | 50 | FilesInterface $files |
| 51 | - ) { |
|
| 51 | + ){ |
|
| 52 | 52 | $this->directory = $directory; |
| 53 | 53 | $this->maxFiles = $maxFiles; |
| 54 | 54 | $this->verbosity = $verbosity; |
@@ -92,17 +92,17 @@ discard block |
||
| 92 | 92 | protected function rotateSnapshots() |
| 93 | 93 | { |
| 94 | 94 | $finder = new Finder(); |
| 95 | - $finder->in($this->directory)->sort(function (SplFileInfo $a, SplFileInfo $b) { |
|
| 95 | + $finder->in($this->directory)->sort(function (SplFileInfo $a, SplFileInfo $b){ |
|
| 96 | 96 | return $b->getMTime() - $a->getMTime(); |
| 97 | 97 | }); |
| 98 | 98 | |
| 99 | 99 | $count = 0; |
| 100 | - foreach ($finder as $file) { |
|
| 100 | + foreach ($finder as $file){ |
|
| 101 | 101 | $count++; |
| 102 | - if ($count > $this->maxFiles) { |
|
| 103 | - try { |
|
| 102 | + if ($count > $this->maxFiles){ |
|
| 103 | + try{ |
|
| 104 | 104 | $this->files->delete($file->getRealPath()); |
| 105 | - } catch (FilesException $e) { |
|
| 105 | + }catch (FilesException $e){ |
|
| 106 | 106 | // ignore |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -92,17 +92,23 @@ |
||
| 92 | 92 | protected function rotateSnapshots() |
| 93 | 93 | { |
| 94 | 94 | $finder = new Finder(); |
| 95 | - $finder->in($this->directory)->sort(function (SplFileInfo $a, SplFileInfo $b) { |
|
| 95 | + $finder->in($this->directory)->sort(function (SplFileInfo $a, SplFileInfo $b) |
|
| 96 | + { |
|
| 96 | 97 | return $b->getMTime() - $a->getMTime(); |
| 97 | 98 | }); |
| 98 | 99 | |
| 99 | 100 | $count = 0; |
| 100 | - foreach ($finder as $file) { |
|
| 101 | + foreach ($finder as $file) |
|
| 102 | + { |
|
| 101 | 103 | $count++; |
| 102 | - if ($count > $this->maxFiles) { |
|
| 103 | - try { |
|
| 104 | + if ($count > $this->maxFiles) |
|
| 105 | + { |
|
| 106 | + try |
|
| 107 | + { |
|
| 104 | 108 | $this->files->delete($file->getRealPath()); |
| 105 | - } catch (FilesException $e) { |
|
| 109 | + } |
|
| 110 | + catch (FilesException $e) |
|
| 111 | + { |
|
| 106 | 112 | // ignore |
| 107 | 113 | } |
| 108 | 114 | } |