@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | $http = $this->container->get(HttpCore::class); |
60 | 60 | $emitter = $emitter ?? $this->container->get(EmitterInterface::class); |
61 | 61 | |
62 | - try { |
|
62 | + try{ |
|
63 | 63 | $response = $http->handle($this->initRequest()); |
64 | 64 | $emitter->emit($response); |
65 | - } catch (\Throwable $e) { |
|
65 | + }catch (\Throwable $e){ |
|
66 | 66 | $this->handleException($emitter, $e); |
67 | - } finally { |
|
67 | + }finally{ |
|
68 | 68 | $this->finalizer->finalize(false); |
69 | 69 | } |
70 | 70 | } |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | { |
86 | 86 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
87 | 87 | |
88 | - try { |
|
88 | + try{ |
|
89 | 89 | /** @var SnapshotInterface $snapshot */ |
90 | 90 | $this->container->get(SnapshotterInterface::class)->register($e); |
91 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
91 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
92 | 92 | // nothing to report |
93 | 93 | } |
94 | 94 |
@@ -59,12 +59,17 @@ discard block |
||
59 | 59 | $http = $this->container->get(HttpCore::class); |
60 | 60 | $emitter = $emitter ?? $this->container->get(EmitterInterface::class); |
61 | 61 | |
62 | - try { |
|
62 | + try |
|
63 | + { |
|
63 | 64 | $response = $http->handle($this->initRequest()); |
64 | 65 | $emitter->emit($response); |
65 | - } catch (\Throwable $e) { |
|
66 | + } |
|
67 | + catch (\Throwable $e) |
|
68 | + { |
|
66 | 69 | $this->handleException($emitter, $e); |
67 | - } finally { |
|
70 | + } |
|
71 | + finally |
|
72 | + { |
|
68 | 73 | $this->finalizer->finalize(false); |
69 | 74 | } |
70 | 75 | } |
@@ -85,10 +90,13 @@ discard block |
||
85 | 90 | { |
86 | 91 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
87 | 92 | |
88 | - try { |
|
93 | + try |
|
94 | + { |
|
89 | 95 | /** @var SnapshotInterface $snapshot */ |
90 | 96 | $this->container->get(SnapshotterInterface::class)->register($e); |
91 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
97 | + } |
|
98 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
99 | + { |
|
92 | 100 | // nothing to report |
93 | 101 | } |
94 | 102 |
@@ -38,15 +38,15 @@ |
||
38 | 38 | public function getServices(): array |
39 | 39 | { |
40 | 40 | $result = []; |
41 | - foreach ($this->classes->getClasses(ServiceInterface::class) as $service) { |
|
42 | - if (!$service->isInstantiable()) { |
|
41 | + foreach ($this->classes->getClasses(ServiceInterface::class) as $service){ |
|
42 | + if (!$service->isInstantiable()){ |
|
43 | 43 | continue; |
44 | 44 | } |
45 | 45 | |
46 | 46 | $instance = $this->container->get($service->getName()); |
47 | 47 | |
48 | - foreach ($service->getInterfaces() as $interface) { |
|
49 | - if ($interface->isSubclassOf(ServiceInterface::class)) { |
|
48 | + foreach ($service->getInterfaces() as $interface){ |
|
49 | + if ($interface->isSubclassOf(ServiceInterface::class)){ |
|
50 | 50 | $result[$interface->getName()] = $instance; |
51 | 51 | } |
52 | 52 | } |
@@ -38,15 +38,19 @@ |
||
38 | 38 | public function getServices(): array |
39 | 39 | { |
40 | 40 | $result = []; |
41 | - foreach ($this->classes->getClasses(ServiceInterface::class) as $service) { |
|
42 | - if (!$service->isInstantiable()) { |
|
41 | + foreach ($this->classes->getClasses(ServiceInterface::class) as $service) |
|
42 | + { |
|
43 | + if (!$service->isInstantiable()) |
|
44 | + { |
|
43 | 45 | continue; |
44 | 46 | } |
45 | 47 | |
46 | 48 | $instance = $this->container->get($service->getName()); |
47 | 49 | |
48 | - foreach ($service->getInterfaces() as $interface) { |
|
49 | - if ($interface->isSubclassOf(ServiceInterface::class)) { |
|
50 | + foreach ($service->getInterfaces() as $interface) |
|
51 | + { |
|
52 | + if ($interface->isSubclassOf(ServiceInterface::class)) |
|
53 | + { |
|
50 | 54 | $result[$interface->getName()] = $instance; |
51 | 55 | } |
52 | 56 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | EnvironmentInterface $env, |
38 | 38 | FinalizerInterface $finalizer, |
39 | 39 | ContainerInterface $container |
40 | - ) { |
|
40 | + ){ |
|
41 | 41 | $this->env = $env; |
42 | 42 | $this->finalizer = $finalizer; |
43 | 43 | $this->container = $container; |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | $worker = $this->container->get(Worker::class); |
66 | 66 | $locator = $this->container->get(LocatorInterface::class); |
67 | 67 | |
68 | - foreach ($locator->getServices() as $interface => $service) { |
|
68 | + foreach ($locator->getServices() as $interface => $service){ |
|
69 | 69 | $server->registerService($interface, $service); |
70 | 70 | } |
71 | 71 | |
72 | - $server->serve($worker, function (\Throwable $e = null) { |
|
73 | - if ($e !== null) { |
|
72 | + $server->serve($worker, function (\Throwable $e = null){ |
|
73 | + if ($e !== null){ |
|
74 | 74 | $this->handleException($e); |
75 | 75 | } |
76 | 76 | |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | */ |
84 | 84 | protected function handleException(\Throwable $e) |
85 | 85 | { |
86 | - try { |
|
86 | + try{ |
|
87 | 87 | $this->container->get(SnapshotterInterface::class)->register($e); |
88 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
88 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
89 | 89 | // no need to notify when unable to register an exception |
90 | 90 | } |
91 | 91 | } |
@@ -65,12 +65,15 @@ discard block |
||
65 | 65 | $worker = $this->container->get(Worker::class); |
66 | 66 | $locator = $this->container->get(LocatorInterface::class); |
67 | 67 | |
68 | - foreach ($locator->getServices() as $interface => $service) { |
|
68 | + foreach ($locator->getServices() as $interface => $service) |
|
69 | + { |
|
69 | 70 | $server->registerService($interface, $service); |
70 | 71 | } |
71 | 72 | |
72 | - $server->serve($worker, function (\Throwable $e = null) { |
|
73 | - if ($e !== null) { |
|
73 | + $server->serve($worker, function (\Throwable $e = null) |
|
74 | + { |
|
75 | + if ($e !== null) |
|
76 | + { |
|
74 | 77 | $this->handleException($e); |
75 | 78 | } |
76 | 79 | |
@@ -83,9 +86,12 @@ discard block |
||
83 | 86 | */ |
84 | 87 | protected function handleException(\Throwable $e) |
85 | 88 | { |
86 | - try { |
|
89 | + try |
|
90 | + { |
|
87 | 91 | $this->container->get(SnapshotterInterface::class)->register($e); |
88 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
92 | + } |
|
93 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
94 | + { |
|
89 | 95 | // no need to notify when unable to register an exception |
90 | 96 | } |
91 | 97 | } |
@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | |
44 | 44 | $runtimeDirectory = $this->dirs->get('runtime'); |
45 | 45 | |
46 | - if (!$this->files->exists($runtimeDirectory)) { |
|
46 | + if (!$this->files->exists($runtimeDirectory)){ |
|
47 | 47 | $this->files->ensureDirectory($runtimeDirectory); |
48 | 48 | $output->writeln("<comment>created</comment>"); |
49 | 49 | return; |
50 | - } else { |
|
50 | + }else{ |
|
51 | 51 | $output->writeln("<info>exists</info>"); |
52 | 52 | } |
53 | 53 | |
54 | - foreach ($this->files->getFiles($runtimeDirectory) as $filename) { |
|
55 | - try { |
|
54 | + foreach ($this->files->getFiles($runtimeDirectory) as $filename){ |
|
55 | + try{ |
|
56 | 56 | $this->files->setPermissions($filename, FilesInterface::RUNTIME); |
57 | 57 | $this->files->setPermissions(dirname($filename), FilesInterface::RUNTIME); |
58 | - } catch (\Throwable $e) { |
|
58 | + }catch (\Throwable $e){ |
|
59 | 59 | // @codeCoverageIgnoreStart |
60 | 60 | $output->writeln(sprintf( |
61 | 61 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>", |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | // @codeCoverageIgnoreEnd |
67 | 67 | } |
68 | 68 | |
69 | - if ($output->isVerbose()) { |
|
69 | + if ($output->isVerbose()){ |
|
70 | 70 | $output->writeln(sprintf( |
71 | 71 | "<fg=green>[updated]</fg=green> `%s`", |
72 | 72 | $this->files->relativePath($filename, $runtimeDirectory) |
@@ -43,19 +43,26 @@ discard block |
||
43 | 43 | |
44 | 44 | $runtimeDirectory = $this->dirs->get('runtime'); |
45 | 45 | |
46 | - if (!$this->files->exists($runtimeDirectory)) { |
|
46 | + if (!$this->files->exists($runtimeDirectory)) |
|
47 | + { |
|
47 | 48 | $this->files->ensureDirectory($runtimeDirectory); |
48 | 49 | $output->writeln("<comment>created</comment>"); |
49 | 50 | return; |
50 | - } else { |
|
51 | + } |
|
52 | + else |
|
53 | + { |
|
51 | 54 | $output->writeln("<info>exists</info>"); |
52 | 55 | } |
53 | 56 | |
54 | - foreach ($this->files->getFiles($runtimeDirectory) as $filename) { |
|
55 | - try { |
|
57 | + foreach ($this->files->getFiles($runtimeDirectory) as $filename) |
|
58 | + { |
|
59 | + try |
|
60 | + { |
|
56 | 61 | $this->files->setPermissions($filename, FilesInterface::RUNTIME); |
57 | 62 | $this->files->setPermissions(dirname($filename), FilesInterface::RUNTIME); |
58 | - } catch (\Throwable $e) { |
|
63 | + } |
|
64 | + catch (\Throwable $e) |
|
65 | + { |
|
59 | 66 | // @codeCoverageIgnoreStart |
60 | 67 | $output->writeln(sprintf( |
61 | 68 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>", |
@@ -66,7 +73,8 @@ discard block |
||
66 | 73 | // @codeCoverageIgnoreEnd |
67 | 74 | } |
68 | 75 | |
69 | - if ($output->isVerbose()) { |
|
76 | + if ($output->isVerbose()) |
|
77 | + { |
|
70 | 78 | $output->writeln(sprintf( |
71 | 79 | "<fg=green>[updated]</fg=green> `%s`", |
72 | 80 | $this->files->relativePath($filename, $runtimeDirectory) |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | bool $suppressErrors, |
45 | 45 | RendererInterface $renderer, |
46 | 46 | SnapshotterInterface $snapshots = null |
47 | - ) { |
|
47 | + ){ |
|
48 | 48 | $this->suppressErrors = $suppressErrors; |
49 | 49 | $this->renderer = $renderer; |
50 | 50 | $this->snapshotter = $snapshots; |
@@ -57,20 +57,20 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function process(Request $request, Handler $handler): Response |
59 | 59 | { |
60 | - try { |
|
60 | + try{ |
|
61 | 61 | return $handler->handle($request); |
62 | - } catch (ClientException|RouterException $e) { |
|
63 | - if ($e instanceof ClientException) { |
|
62 | + }catch (ClientException | RouterException $e){ |
|
63 | + if ($e instanceof ClientException){ |
|
64 | 64 | $code = $e->getCode(); |
65 | - } else { |
|
65 | + }else{ |
|
66 | 66 | $code = 404; |
67 | 67 | } |
68 | - } catch (\Throwable $e) { |
|
69 | - if (!$this->suppressErrors) { |
|
68 | + }catch (\Throwable $e){ |
|
69 | + if (!$this->suppressErrors){ |
|
70 | 70 | throw $e; |
71 | 71 | } |
72 | 72 | |
73 | - if ($this->snapshotter !== null) { |
|
73 | + if ($this->snapshotter !== null){ |
|
74 | 74 | $this->snapshotter->register($e); |
75 | 75 | } |
76 | 76 |
@@ -57,20 +57,30 @@ |
||
57 | 57 | */ |
58 | 58 | public function process(Request $request, Handler $handler): Response |
59 | 59 | { |
60 | - try { |
|
60 | + try |
|
61 | + { |
|
61 | 62 | return $handler->handle($request); |
62 | - } catch (ClientException|RouterException $e) { |
|
63 | - if ($e instanceof ClientException) { |
|
63 | + } |
|
64 | + catch (ClientException|RouterException $e) |
|
65 | + { |
|
66 | + if ($e instanceof ClientException) |
|
67 | + { |
|
64 | 68 | $code = $e->getCode(); |
65 | - } else { |
|
69 | + } |
|
70 | + else |
|
71 | + { |
|
66 | 72 | $code = 404; |
67 | 73 | } |
68 | - } catch (\Throwable $e) { |
|
69 | - if (!$this->suppressErrors) { |
|
74 | + } |
|
75 | + catch (\Throwable $e) |
|
76 | + { |
|
77 | + if (!$this->suppressErrors) |
|
78 | + { |
|
70 | 79 | throw $e; |
71 | 80 | } |
72 | 81 | |
73 | - if ($this->snapshotter !== null) { |
|
82 | + if ($this->snapshotter !== null) |
|
83 | + { |
|
74 | 84 | $this->snapshotter->register($e); |
75 | 85 | } |
76 | 86 |
@@ -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 HttpCore $http */ |
72 | 72 | $http = $this->container->get(HttpCore::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 HttpCore $http */ |
72 | 72 | $http = $this->container->get(HttpCore::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 |
@@ -36,21 +36,21 @@ |
||
36 | 36 | { |
37 | 37 | $conn = $env->get('RR_RPC', static::RPC_DEFAULT); |
38 | 38 | |
39 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
39 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)){ |
|
40 | 40 | throw new BootException( |
41 | 41 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
42 | 42 | ); |
43 | 43 | } |
44 | 44 | |
45 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
45 | + if (!in_array($parts[1], ['tcp', 'unix'])){ |
|
46 | 46 | throw new BootException( |
47 | 47 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
48 | 48 | ); |
49 | 49 | } |
50 | 50 | |
51 | - if ($parts[1] == 'unix') { |
|
51 | + if ($parts[1] == 'unix'){ |
|
52 | 52 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
53 | - } else { |
|
53 | + }else{ |
|
54 | 54 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
55 | 55 | } |
56 | 56 |
@@ -36,21 +36,26 @@ |
||
36 | 36 | { |
37 | 37 | $conn = $env->get('RR_RPC', static::RPC_DEFAULT); |
38 | 38 | |
39 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
39 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) |
|
40 | + { |
|
40 | 41 | throw new BootException( |
41 | 42 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
42 | 43 | ); |
43 | 44 | } |
44 | 45 | |
45 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
46 | + if (!in_array($parts[1], ['tcp', 'unix'])) |
|
47 | + { |
|
46 | 48 | throw new BootException( |
47 | 49 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
48 | 50 | ); |
49 | 51 | } |
50 | 52 | |
51 | - if ($parts[1] == 'unix') { |
|
53 | + if ($parts[1] == 'unix') |
|
54 | + { |
|
52 | 55 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
53 | - } else { |
|
56 | + } |
|
57 | + else |
|
58 | + { |
|
54 | 59 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
55 | 60 | } |
56 | 61 |
@@ -35,11 +35,11 @@ |
||
35 | 35 | */ |
36 | 36 | public function createInjection(\ReflectionClass $class, string $context = null) |
37 | 37 | { |
38 | - if (!$this->orm->getSchema()->defines($context)) { |
|
38 | + if (!$this->orm->getSchema()->defines($context)){ |
|
39 | 39 | $context = Inflector::singularize($context); |
40 | 40 | } |
41 | 41 | |
42 | - if (!$this->orm->getSchema()->defines($context)) { |
|
42 | + if (!$this->orm->getSchema()->defines($context)){ |
|
43 | 43 | throw new ORMException("Cycle schema is not initiated or role missing, run `cycle`"); |
44 | 44 | } |
45 | 45 |
@@ -35,11 +35,13 @@ |
||
35 | 35 | */ |
36 | 36 | public function createInjection(\ReflectionClass $class, string $context = null) |
37 | 37 | { |
38 | - if (!$this->orm->getSchema()->defines($context)) { |
|
38 | + if (!$this->orm->getSchema()->defines($context)) |
|
39 | + { |
|
39 | 40 | $context = Inflector::singularize($context); |
40 | 41 | } |
41 | 42 | |
42 | - if (!$this->orm->getSchema()->defines($context)) { |
|
43 | + if (!$this->orm->getSchema()->defines($context)) |
|
44 | + { |
|
43 | 45 | throw new ORMException("Cycle schema is not initiated or role missing, run `cycle`"); |
44 | 46 | } |
45 | 47 |
@@ -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("<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>\n", |
45 | 45 | $files->relativePath($filename, $cacheDirectory), |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | // @codeCoverageIgnoreEnd |
51 | 51 | } |
52 | 52 | |
53 | - if ($this->isVerbose()) { |
|
53 | + if ($this->isVerbose()){ |
|
54 | 54 | $this->sprintf( |
55 | 55 | "<fg=green>[deleted]</fg=green> `%s`\n", |
56 | 56 | $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("<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>\n", |
45 | 51 | $files->relativePath($filename, $cacheDirectory), |
@@ -50,7 +56,8 @@ discard block |
||
50 | 56 | // @codeCoverageIgnoreEnd |
51 | 57 | } |
52 | 58 | |
53 | - if ($this->isVerbose()) { |
|
59 | + if ($this->isVerbose()) |
|
60 | + { |
|
54 | 61 | $this->sprintf( |
55 | 62 | "<fg=green>[deleted]</fg=green> `%s`\n", |
56 | 63 | $files->relativePath($filename, $cacheDirectory) |