@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $runtimeDirectory = $this->dirs->get('runtime'); |
47 | 47 | |
48 | - if (!$this->files->exists($runtimeDirectory)) { |
|
48 | + if (!$this->files->exists($runtimeDirectory)){ |
|
49 | 49 | $this->files->ensureDirectory($runtimeDirectory); |
50 | 50 | $output->writeln('<comment>created</comment>'); |
51 | 51 | return; |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | $output->writeln('<info>exists</info>'); |
54 | 54 | |
55 | 55 | |
56 | - foreach ($this->files->getFiles($runtimeDirectory) as $filename) { |
|
57 | - try { |
|
56 | + foreach ($this->files->getFiles($runtimeDirectory) as $filename){ |
|
57 | + try{ |
|
58 | 58 | $this->files->setPermissions($filename, FilesInterface::RUNTIME); |
59 | 59 | $this->files->setPermissions(dirname($filename), FilesInterface::RUNTIME); |
60 | - } catch (\Throwable $e) { |
|
60 | + }catch (\Throwable $e){ |
|
61 | 61 | // @codeCoverageIgnoreStart |
62 | 62 | $output->writeln( |
63 | 63 | sprintf( |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | // @codeCoverageIgnoreEnd |
71 | 71 | } |
72 | 72 | |
73 | - if ($output->isVerbose()) { |
|
73 | + if ($output->isVerbose()){ |
|
74 | 74 | $output->writeln( |
75 | 75 | sprintf( |
76 | 76 | '<fg=green>[updated]</fg=green> `%s`', |
@@ -45,7 +45,8 @@ discard block |
||
45 | 45 | |
46 | 46 | $runtimeDirectory = $this->dirs->get('runtime'); |
47 | 47 | |
48 | - if (!$this->files->exists($runtimeDirectory)) { |
|
48 | + if (!$this->files->exists($runtimeDirectory)) |
|
49 | + { |
|
49 | 50 | $this->files->ensureDirectory($runtimeDirectory); |
50 | 51 | $output->writeln('<comment>created</comment>'); |
51 | 52 | return; |
@@ -53,11 +54,15 @@ discard block |
||
53 | 54 | $output->writeln('<info>exists</info>'); |
54 | 55 | |
55 | 56 | |
56 | - foreach ($this->files->getFiles($runtimeDirectory) as $filename) { |
|
57 | - try { |
|
57 | + foreach ($this->files->getFiles($runtimeDirectory) as $filename) |
|
58 | + { |
|
59 | + try |
|
60 | + { |
|
58 | 61 | $this->files->setPermissions($filename, FilesInterface::RUNTIME); |
59 | 62 | $this->files->setPermissions(dirname($filename), FilesInterface::RUNTIME); |
60 | - } catch (\Throwable $e) { |
|
63 | + } |
|
64 | + catch (\Throwable $e) |
|
65 | + { |
|
61 | 66 | // @codeCoverageIgnoreStart |
62 | 67 | $output->writeln( |
63 | 68 | sprintf( |
@@ -70,7 +75,8 @@ discard block |
||
70 | 75 | // @codeCoverageIgnoreEnd |
71 | 76 | } |
72 | 77 | |
73 | - if ($output->isVerbose()) { |
|
78 | + if ($output->isVerbose()) |
|
79 | + { |
|
74 | 80 | $output->writeln( |
75 | 81 | sprintf( |
76 | 82 | '<fg=green>[updated]</fg=green> `%s`', |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | HandlerInterface $handler, |
54 | 54 | FilesInterface $files, |
55 | 55 | LoggerInterface $logger = null |
56 | - ) { |
|
56 | + ){ |
|
57 | 57 | $this->directory = $directory; |
58 | 58 | $this->maxFiles = $maxFiles; |
59 | 59 | $this->verbosity = $verbosity; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | $snapshot = new Snapshot($this->getID($e), $e); |
71 | 71 | |
72 | - if ($this->logger !== null) { |
|
72 | + if ($this->logger !== null){ |
|
73 | 73 | $this->logger->error($snapshot->getMessage()); |
74 | 74 | } |
75 | 75 | |
@@ -102,18 +102,18 @@ discard block |
||
102 | 102 | { |
103 | 103 | $finder = new Finder(); |
104 | 104 | $finder->in($this->directory)->sort( |
105 | - function (SplFileInfo $a, SplFileInfo $b) { |
|
105 | + function (SplFileInfo $a, SplFileInfo $b){ |
|
106 | 106 | return $b->getMTime() - $a->getMTime(); |
107 | 107 | } |
108 | 108 | ); |
109 | 109 | |
110 | 110 | $count = 0; |
111 | - foreach ($finder as $file) { |
|
111 | + foreach ($finder as $file){ |
|
112 | 112 | $count++; |
113 | - if ($count > $this->maxFiles) { |
|
114 | - try { |
|
113 | + if ($count > $this->maxFiles){ |
|
114 | + try{ |
|
115 | 115 | $this->files->delete($file->getRealPath()); |
116 | - } catch (FilesException $e) { |
|
116 | + }catch (FilesException $e){ |
|
117 | 117 | // ignore |
118 | 118 | } |
119 | 119 | } |
@@ -69,7 +69,8 @@ discard block |
||
69 | 69 | { |
70 | 70 | $snapshot = new Snapshot($this->getID($e), $e); |
71 | 71 | |
72 | - if ($this->logger !== null) { |
|
72 | + if ($this->logger !== null) |
|
73 | + { |
|
73 | 74 | $this->logger->error($snapshot->getMessage()); |
74 | 75 | } |
75 | 76 | |
@@ -102,18 +103,24 @@ discard block |
||
102 | 103 | { |
103 | 104 | $finder = new Finder(); |
104 | 105 | $finder->in($this->directory)->sort( |
105 | - function (SplFileInfo $a, SplFileInfo $b) { |
|
106 | + function (SplFileInfo $a, SplFileInfo $b) |
|
107 | + { |
|
106 | 108 | return $b->getMTime() - $a->getMTime(); |
107 | 109 | } |
108 | 110 | ); |
109 | 111 | |
110 | 112 | $count = 0; |
111 | - foreach ($finder as $file) { |
|
113 | + foreach ($finder as $file) |
|
114 | + { |
|
112 | 115 | $count++; |
113 | - if ($count > $this->maxFiles) { |
|
114 | - try { |
|
116 | + if ($count > $this->maxFiles) |
|
117 | + { |
|
118 | + try |
|
119 | + { |
|
115 | 120 | $this->files->delete($file->getRealPath()); |
116 | - } catch (FilesException $e) { |
|
121 | + } |
|
122 | + catch (FilesException $e) |
|
123 | + { |
|
117 | 124 | // ignore |
118 | 125 | } |
119 | 126 | } |
@@ -112,7 +112,7 @@ |
||
112 | 112 | ] |
113 | 113 | ); |
114 | 114 | |
115 | - $tokenizer->addDirectory(directory('vendor') . 'spiral/validation/src/'); |
|
115 | + $tokenizer->addDirectory(directory('vendor').'spiral/validation/src/'); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -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 | } |
@@ -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 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | 'handler' => new Autowire( |
63 | 63 | FileHandler::class, |
64 | 64 | [ |
65 | - 'directory' => $directories->get('runtime') . 'session', |
|
65 | + 'directory' => $directories->get('runtime').'session', |
|
66 | 66 | 'lifetime' => 86400 |
67 | 67 | ] |
68 | 68 | ) |
@@ -70,16 +70,16 @@ |
||
70 | 70 | { |
71 | 71 | $state = new State(); |
72 | 72 | |
73 | - foreach ($this->collectors as $collector) { |
|
74 | - if (is_string($collector)) { |
|
73 | + foreach ($this->collectors as $collector){ |
|
74 | + if (is_string($collector)){ |
|
75 | 75 | $collector = $this->factory->make($collector); |
76 | 76 | } |
77 | 77 | |
78 | - if ($collector instanceof Autowire) { |
|
78 | + if ($collector instanceof Autowire){ |
|
79 | 79 | $collector = $collector->resolve($this->factory); |
80 | 80 | } |
81 | 81 | |
82 | - if (!$collector instanceof StateCollectorInterface) { |
|
82 | + if (!$collector instanceof StateCollectorInterface){ |
|
83 | 83 | throw new StateException( |
84 | 84 | sprintf( |
85 | 85 | 'Unable to populate state, invalid state collector %s', |
@@ -70,16 +70,20 @@ |
||
70 | 70 | { |
71 | 71 | $state = new State(); |
72 | 72 | |
73 | - foreach ($this->collectors as $collector) { |
|
74 | - if (is_string($collector)) { |
|
73 | + foreach ($this->collectors as $collector) |
|
74 | + { |
|
75 | + if (is_string($collector)) |
|
76 | + { |
|
75 | 77 | $collector = $this->factory->make($collector); |
76 | 78 | } |
77 | 79 | |
78 | - if ($collector instanceof Autowire) { |
|
80 | + if ($collector instanceof Autowire) |
|
81 | + { |
|
79 | 82 | $collector = $collector->resolve($this->factory); |
80 | 83 | } |
81 | 84 | |
82 | - if (!$collector instanceof StateCollectorInterface) { |
|
85 | + if (!$collector instanceof StateCollectorInterface) |
|
86 | + { |
|
83 | 87 | throw new StateException( |
84 | 88 | sprintf( |
85 | 89 | 'Unable to populate state, invalid state collector %s', |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function getActor(TokenInterface $token): ?object |
54 | 54 | { |
55 | - foreach ($this->getProviders() as $provider) { |
|
56 | - if (!$provider instanceof ActorProviderInterface) { |
|
55 | + foreach ($this->getProviders() as $provider){ |
|
56 | + if (!$provider instanceof ActorProviderInterface){ |
|
57 | 57 | throw new AuthException( |
58 | 58 | sprintf( |
59 | 59 | 'Expected `ActorProviderInterface`, got `%s`', |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | $actor = $provider->getActor($token); |
66 | - if ($actor !== null) { |
|
66 | + if ($actor !== null){ |
|
67 | 67 | return $actor; |
68 | 68 | } |
69 | 69 | } |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | */ |
87 | 87 | private function getProviders(): \Generator |
88 | 88 | { |
89 | - foreach ($this->actorProvider as $provider) { |
|
90 | - if ($provider instanceof Autowire) { |
|
89 | + foreach ($this->actorProvider as $provider){ |
|
90 | + if ($provider instanceof Autowire){ |
|
91 | 91 | yield $provider->resolve($this->factory); |
92 | 92 | continue; |
93 | 93 | } |
94 | 94 | |
95 | - if (is_object($provider)) { |
|
95 | + if (is_object($provider)){ |
|
96 | 96 | yield $provider; |
97 | 97 | continue; |
98 | 98 | } |
@@ -52,8 +52,10 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function getActor(TokenInterface $token): ?object |
54 | 54 | { |
55 | - foreach ($this->getProviders() as $provider) { |
|
56 | - if (!$provider instanceof ActorProviderInterface) { |
|
55 | + foreach ($this->getProviders() as $provider) |
|
56 | + { |
|
57 | + if (!$provider instanceof ActorProviderInterface) |
|
58 | + { |
|
57 | 59 | throw new AuthException( |
58 | 60 | sprintf( |
59 | 61 | 'Expected `ActorProviderInterface`, got `%s`', |
@@ -63,7 +65,8 @@ discard block |
||
63 | 65 | } |
64 | 66 | |
65 | 67 | $actor = $provider->getActor($token); |
66 | - if ($actor !== null) { |
|
68 | + if ($actor !== null) |
|
69 | + { |
|
67 | 70 | return $actor; |
68 | 71 | } |
69 | 72 | } |
@@ -86,13 +89,16 @@ discard block |
||
86 | 89 | */ |
87 | 90 | private function getProviders(): \Generator |
88 | 91 | { |
89 | - foreach ($this->actorProvider as $provider) { |
|
90 | - if ($provider instanceof Autowire) { |
|
92 | + foreach ($this->actorProvider as $provider) |
|
93 | + { |
|
94 | + if ($provider instanceof Autowire) |
|
95 | + { |
|
91 | 96 | yield $provider->resolve($this->factory); |
92 | 97 | continue; |
93 | 98 | } |
94 | 99 | |
95 | - if (is_object($provider)) { |
|
100 | + if (is_object($provider)) |
|
101 | + { |
|
96 | 102 | yield $provider; |
97 | 103 | continue; |
98 | 104 | } |